Live data from Hacker News

Scala: The Static Language that Feels Dynamic (Bruce Eckel)

artima.com

61–65 of 65 posts

Re: Scala: The Static Language that Feels Dynamic (Bruce Eckel)

#61

Earlier quoted context omitted.

Perhaps by "feels like a dynamic language" he means "is succinct".

Reminds me of this classic comment by Frank Atanassow on Lambda the Ultimate: http://lambda-the-ultimate.org/node/1562#comment-18623 > "Dynamic" is technical jargon used by programmers, meaning "good". It derives from the Latin dyno mite, meaning "I am extremely pleased", and is first recorded in the historical work Bona Aetas of noted Roman sage and pundit J.J. Walker. Its meaning evolved in the 4th century after mo…

Thank you sir. That is hilarious.

Re: Scala: The Static Language that Feels Dynamic (Bruce Eckel)

#62
post #57

Earlier quoted context omitted.

It was a mistake. A better effort would have been to implement a first-class Macro system a-la Lisp. You can see here that Nemerle supports macros and makes dealing with XML like relatively painless as if it were built in: http://nemerle.org/About/#ID0E6G Macros for the win.

I'm curious how much you've actually used Haskell's templating system. It is my understanding that a good macro system in a statically typed langauge is still an open research problem. I remember hearing that the Racket research group was still working on it for their typed Racket system, and that it was, at least as of a year ago, not possible to directly port macros from the standard language over to the typed lang…

Re: Template-Haskell - sadly not enough. I have used it to generate N-tuple-generalizations of functions in toys. I simply don't get enough time to hack around in Haskell. As far as being primitive, I guess you would have to compare that to the drudgery of emitting all the automatically generated code produced by macro expansions by hand. Yes, in Haskell TH is relatively infrequently used.

In no way am I trivializing the complexity of what would be involved in bringing a useful macro system to Scala, but compiler plugins for Scala are filling this role today, a good macro system could make meta programming more accessible. Already there are plugins for SBT to invoke FreeMarker on Scala-program templates to generate code, clearly a poor-man's solution, but it simply is more evidence that a macro-system would and would be put to good use were one available.

Taking Racket as an example, a good macro system would enable many kinds of experimentation in the Scala language without having to extend the core directly. In Typed Racket Hindley-Milner type-inference was added on-top of a dynamically typed-core, and Typed Racket targets Haskell-level (or better) typing infrastructure. All this enabled essentially due to support of Macros.

RE: Cutting edge - And Haskell isn't? While there are a number of language features where Scala may in fact outshine Haskell, I would hardly place Haskell in the old and well-trodden place on the programming language landscape. It is still evolving rapidly, and without the need to conform to any particular run-time-system (e.g. the JVM) the researchers working on Haskell are able to practically make the language warp space-time.

Re: Scala: The Static Language that Feels Dynamic (Bruce Eckel)

#63
post #60
post #57

Earlier quoted context omitted.

I'm curious how much you've actually used Haskell's templating system. It is my understanding that a good macro system in a statically typed langauge is still an open research problem. I remember hearing that the Racket research group was still working on it for their typed Racket system, and that it was, at least as of a year ago, not possible to directly port macros from the standard language over to the typed lang…

This comment on Typed Racket isn't correct. Lots of macros work just fine in Typed Racket, and XML literals would certainly be among them [1]. The macros that don't work yet are the most complex ones, like the one implementing an entire class system with Java and Beta style inheritance (both!). [1] In Racket, we typically use s-expressions rather than XML literals.

Typed Racket is a marvelous wonder. Sadly, it is simply not appreciated enough for what it is: an utter triumph of Lisp over all challengers. ;-)

Re: Scala: The Static Language that Feels Dynamic (Bruce Eckel)

#64

Earlier quoted context omitted.

Agreed. Macros and reader macros ;-)

Let me know when you figure out how to statically type check those. You could publish a paper or two, I'm sure.

To reiterate a point implied by other commenters: macro-expansion is a compile-time operation. If the language utilizes a typing system to help promote sound programming then the results of the expansion will be compiled in the context of type constraints - the expansion is either sound or unsound w.r.t. such constraints.

To some extent there is a continuing popular schism with the idea that "strongly typed" must be synonymous with the lack of "eval", which, at least in principle, cannot be true. In fact, StandardML does have the ability to extend the environment of a program at run-time (as well as Typed Racket). All the necessary typing and meta-data is retained at run-time so that newly evaluated code is checked for type-consistency just like when the "main code" was compiled. So, not only can one expand macros at compile time and verify that the expansions are sound, one can also do the same at run-time.

Re: Scala: The Static Language that Feels Dynamic (Bruce Eckel)

#65

Gosu has the same dynamic feel in a statically typed JVM language, with much less complexity. (I should mention Fantom too, although I'm much less familiar with it.) Artima appears to have gone all-scala-all-the-time at some point in 2010. Weird.

Followed up your suggestion of Gosu, which I hadn't heard about before. Looks interesting but this feature comparison chart is hilarious: http://gosu-lang.org/comparison.shtml It's the first time I've seen "not lisp" as a checkbox feature. :)

;)
Post reply on HN