Friday, December 15. 20065 Things a Java developer needs to know about ScalaTrackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
Cracking start! I would add a little on how constructors work - it's a bit a of a surprise to see that the master constructor is defined as part of the class definition!
Think of constructors in Scala the way you would arguments to a function. The code inside has access to those values.
I've been using Scala for some time now, and although the language has great ideas it also has quite annoying troubles. The double approach to parametric polymorphism (both OO-style and functional style) means that some type errors are very hard to understand. Views can be very confusing, mixins sometimes seemingly randomly are not allowed and compiler still has bugs in some border cases. The conceptual problems are known and are described in Martin's paper about Scala, while the buggy compiler comes from too small user base.
All in all it's considerably more complex than Java or even Ruby, so there definitely will be some troubles with adoption. You could easily cut down on language features without losing much expressiveness. Case classes and matching are genius, high order functions and closures are a must-have, but the rest of the stuff become increasingly redundant. Just my 2 cents
Jevgeni,
I've got a ton of respect for what you've done with Aranea http://araneaframework.org/ I want to disagree a bit with you. Scala's traits rule the universe for me. Traits allow me to compose a lot of complex functionality into classes. Scala's type inferencing works well for me and cuts down a lot of code clutter. Combined with the parametric polymorphism, I've been able to write a bunch of "duck-type-feeling" code that's actually type-safe. When I started with Ruby, I wrote Java-style code in Ruby and gradually worked Rubyisms into my code. I'm early to Scala, but I've been writing Ruby-style code and gradually working into Scala-style code. IMHO, A developer can write Java-style code in Scala pretty easily. Over time, the developer will become more Scalaish in their constructs. Thanks for your post! David
Hey, it's a big world and there is enough space for all kinds of approaches. I was just expressing my (personal and limited) experience with Scala. I played with functional languages for quite some time and became a bit bitter about the seemingly beautiful, but rigorous static type systems. At the moment I'm doing research on the soft typing, which is a mixture of dynamic and static typing. I think this is where the future lies -- a language that can be statically typed when possible, and dynamically when not.
Scala is definitely very cool, I loved it when I first have seen it, and I have great respect for its creator. I think that the ideas from Scala will gradually float into Java (e.g. Martin Odersky was one of the guys behind Generics), but I don't believe Scala itself will gain great acceptance. besides I still think that web is inherently Object-Oriented, and functional approach has much more point in the business layer. In any case it is definitely worth seeing what will come out from your effort. We are welcoming the competition, as our motto is to let programmers use any approach possible in any application Good luck!
"Scala code runs as fast as Java code"
"Scala code is more compact and more expressive" If you read the Scala programs on the computer language shootout you'll see that they drop-back to using while-loops instead of for-comprehensions - just to get the times down.
The Scala programs in the shoot-out were not written by me or other people on the Scala team. I think if they had been written in a tail-recursive style, the times would have been just the same as with while-loops. That said, I don't think shootout data are very significant in any case.
"The Scala programs in the shoot-out were not written by me or other people on the Scala team."
True enough, but why is that relevant? "a tail-recursive style ... just the same as with while-loops" Would that actually be "more compact" or "more expressive" or would it really be just the same as while-loops? "I don't think shootout data are very significant in any case" I whole-heartedly agree Does that take us further than "your application is the ultimate benchmark"?
Tail recursive functions are normally compiled into the same bytecodes as while-loops, so the times should be really just the same.
"Tail recursive functions ... the times should be really just the same"
The times of for-comprehensions are not.
Scala defines the characters eol and semicolon as statement separators. So while the Java code below is legal:
interface Foo { }class test { } the following Scala code is not: trait Foo { }object test { }
2 things a Java Developer should know:
You should try out Groovy. It is far more expressive and you do not need to compile the source code, but you can if you wish. Many advantages mentioned this article are also valid for Groovy!!! http://groovy.codehaus.org if you are still not convinced... check out: groovy on rails http://grails.codehaus.org
I tried Groovy and pretty much think it's the worst of all possible worlds. It's got all of Ruby's badness combined with all of Java's badness.
I find Scala to be significantly more expressive than Groovy, especially when dealing with XML and other sets of data. I like lift a whole lot better than Grails because lift abstracts away much more of the HTTP request/response cycle and is a lot more secure (then again... I'm biased
(I'm a Scala user)
Good Java developers will write: List foos = map( others, new Mapper() { public Foo map(Other other) { return new Foo(other); } } and reuse the Mapper. Cheers Stephan http://twitter.com/codemonkeyism |
David PollakCalendar
QuicksearchCategoriesBlog Administration |
|||||||||||||||||||||||||||||||||||||||||||||||||