News for hackers. Stuff that matters.
Re:The Mirah Language: bringing modern features to the JVM w... by amadiver on Friday March 25, 2011 @11:23PM (#2371248)
Pretty neat. Mirah is to Java as CoffeeScript is to JavaScript?

Looks very similar to ActionScript 2, with shades of Scala. Really neat looking language.

Anyone know where the `param: Type` (i.e., parameter name colon type) convention came from? I've seen it more frequently lately, and I wonder if it's easier to parse than Java's `Type param` (or my favorite: `param Type`)?

Re:The Mirah Language: bringing modern features to the JVM w... by headius on Friday March 25, 2011 @11:26PM (#2371256)
I actually officially asked Jeremy Askenas if I can use the phrase "Mirah is the Coffeescript of Java". He gave me his blessing.

The param:type notation I largely just stole from Scala, but it seems (in my novice opinion) easier to parse as well. It also fits better with optional type declarations, which we have in the case of interface impl or class extension (easier to omit syntax on the RHS than on the LHS for a typical parser).

Re:The Mirah Language: bringing modern features to the JVM w... by headius on Saturday March 26, 2011 @05:01PM (#2373173)
And oops...that's Ashkenas. Sorry, Jeremy :)
Re:The Mirah Language: bringing modern features to the JVM w... by samdk on Saturday March 26, 2011 @02:18AM (#2371502)
I'm not sure if it's where the 'param: Type' idiom is where it came from originally, but its use in Mirah almost certainly descended from its use in Haskell and ML. Scala also uses it, and its use there is definitely ML/Haskell-inspired. (Haskell technically is 'param :: Type', since ':' is the cons operator, but it's basically the same thing.)

Since languages like Haskell and ML (and Scala, to a lesser extent) do type inference, type annotations are often unnecessary, and so having the type listed after the name probably makes more sense in that context: what's important is the name, and variable-specific type hints are usually there for the compiler, not the human reader. The exception is functions, which very often get type definitions just because it's very helpful to have that information as a human. Since ML/Haskell-like languages have multiple function definitions and rely on pattern matching, the postfix type notation fits in very well:

    func :: type1 -> type2
    func a = ...
    func b = ...
Re:The Mirah Language: bringing modern features to the JVM w... by headius on Saturday March 26, 2011 @02:29PM (#2372770)
Interesting...and the point about "the name" being the most important thing is really insightful. That's exactly true.
Re:The Mirah Language: bringing modern features to the JVM w... by chancho on Saturday March 26, 2011 @04:04AM (#2371621)
Pascal uses the "param : type" syntax, although I'm not sure it's the first language to do so. I believe it's older than ML. It's funny to "see this more frequently lately" as it's a really old convention. What's old is new again, I guess...

http://en.wikipedia.org/wiki/Pascal_(programming_language)#P...

Re:The Mirah Language: bringing modern features to the JVM w... by munificent on Saturday March 26, 2011 @01:23AM (#2371432)
ML type annotations use that syntax, so it's probably the grandaddy of them all.

It's easier to parse if your type syntax uses juxtaposition. "Some int" is a valid type, so it would make "<type> <var>" harder to parse. It's hard to tell when the type ends and the variable name starts without backtracking.

Re:The Mirah Language: bringing modern features to the JVM w... by Dn_Ab on Saturday March 26, 2011 @09:59AM (#2372083)
It's common in statically typed functional languages and an old notation. I believe a key motivation is the analogy between a Set and a Type. Then saying x : Int is like similar to saying x ∈ Z, x is an element of the integers.
Re:The Mirah Language: bringing modern features to the JVM w... by nivertech on Saturday March 26, 2011 @12:42PM (#2372516)
`param: Type` is from Pascal
Re:The Mirah Language: bringing modern features to the JVM w... by Roboprog on Saturday March 26, 2011 @01:52PM (#2372685)
That would be my bet, especially since Java, especially since 1.1, reminded me so much of [Turbo] Pascal in C++ clothing, so it only seems natural to borrow another Pascal-ism.

But Pascal stole from Algol. Nothing new under the sun...