language-design

OptionalInt vs Optional<Integer>

早过忘川 提交于 2019-12-03 00:59:38
When scrolling through the documentation for the java.util package, I was surpised to find that Optional<T> and OptionalInt have no relationship to each other. This seems very hard to belive, as it suggests that they are unrelated classes. Why don't they have a common interface, class, are sub-types, or something to reveal the relationship they have? (They're very similar classes when you look at their uses.) Also, why the need for an additional OptionalInt class? Why can't you just use Optional<Integer> ? I thought it was due to the fact that int is primitive, but there is no OptionalChar so

New language on top of PHP?

别来无恙 提交于 2019-12-03 00:45:55
问题 I'm a PHP developer. I like PHP! It is a really good language if you know how to use it, but I know it allows very bad design sometimes. It reminds me of JavaScript which has good parts and bad parts. One particular project, CoffeeScript, tries to focus only on the good parts, forcing you to write good code. I was thinking if something similar could be done with PHP... A new syntax that would be compiled only to good PHP code taking advatage of all the new and exciting stuff we can get with

Most interesting non-mainstream language? [closed]

梦想与她 提交于 2019-12-03 00:20:29
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not

What is F# lacking for OO or imperative? [closed]

╄→尐↘猪︶ㄣ 提交于 2019-12-02 23:02:22
Many times I hear that F# is not suited to particular tasks, such as UI. "Use the right tool" is a common phrase. Apart from missing tools such as a WinForms/WPF/ORM designer, I'm not sure what exactly is missing in F# -- honestly! Yet, particularly with UI, I'm told that C# just does it better. So, what are the actual differences and omissions in F# when using it imperatively? Here is a list I came up with: Lots of missing tool support F# is still beta Your developers don't know F# I'd like to not consider those points, as they aren't really intrinsic to F# Mutables need "mutable" or need to

Suggestions on syntax to express mathematical formula concisely

 ̄綄美尐妖づ 提交于 2019-12-02 21:56:24
I am developing functional domain specific embedded language within C++ to translate formulas into working code as concisely and accurately as possible. I posted a prototype in the comments, it is about two hundred lines long. Right now my language looks something like this (well, actually is going to look like): // implies two nested loops j=0:N, i=0,j (range(i) < j < N)[T(i,j) = (T(i,j) - T(j,i))/e(i+j)]; // implies summation over above expression sum(range(i) < j < N))[(T(i,j) - T(j,i))/e(i+j)]; I am looking for possible syntax improvements/extensions or just different ideas about

Datatype promotion for dependently challenged

会有一股神秘感。 提交于 2019-12-02 21:47:46
After reading through the ghc 7.4. pre-release notes and the Giving Haskell a Promotion paper, I'm still confused on what you actually do with promoted types. For example, the GHC manual gives the following examples on promoted datatypes: data Nat = Ze | Su Nat data List a = Nil | Cons a (List a) data Pair a b = Pair a b data Sum a b = L a | R b What kind of uses do these have as kinds? Can you give (code) examples? There are at least two examples in the paper itself: "1. Introduction" says: "for example, we might be able to ensure [at compile time] that an alleged red-black tree really has

Java static imports

不打扰是莪最后的温柔 提交于 2019-12-02 20:15:45
Just by experiment I discovered that Java non static methods overrides all same named methods in scope even at static context. Even without allowing parameter overloading. Like import java.util.Arrays; import static java.util.Arrays.toString; public class A { public static void bar(Object... args) { Arrays.toString(args); toString(args); //toString() in java.lang.Object cannot be applied to (java.lang.Object[]) } } I can't find anything about this in spec. Is this a bug? If it isn't, are there any reasons to implement language like that? UPD: Java 6 do not compile this example. The question is

What would we do without NULL?

被刻印的时光 ゝ 提交于 2019-12-02 19:08:17
I once read that having nullable types is an absolute evil. I believe it was in an article written by the very person who created them(in Ada?) I believe this is the article Anyway, so what if by default a language like C# used non-nullable types? How would you replace some of the common idioms in C# or Ruby or any other common language where null is an acceptable value? Instead of outright declaring that nullable types are evil, I would posit: most languages graft nullability onto entire kinds of types, when the two concepts should really be orthogonal . For example, all non-primitive Java

How come Go doesn't have stackoverflows

不羁的心 提交于 2019-12-02 19:06:43
I read in this presentation http://golang.org/doc/ExpressivenessOfGo.pdf page 42: Safe - no stack overflows How is this possible? and/or how does Go works to avoid this? It's a feature called "segmented stacks": every goroutine has its own stack, allocated on the heap . In the simplest case, programming language implementations use a single stack per process/address space, commonly managed with special processor instructions called push and pop (or something like that) and implemented as a dynamic array of stack frames starting at a fixed address (commonly, the top of virtual memory). That is

Scala's .type and Java's .class literal

旧时模样 提交于 2019-12-02 19:06:18
I wonder from a language design perspective why Scala has removed Java's class literal (e. g. String.class ) and replaced it with classOf[String] , but has then added a "type literal" with its Singletons like Singleton.type instead of something like typeOf[Singleton] ? Here is my rationalization: classOf[T] classOf is defined in Predef as a function with this signature: def classOf[T]: Class[T] Although it's implemented by the compiler, using the function syntax is possible without having to create any special treatment in terms of syntax . So that's one reason here to consider this option.