The Artima Developer Community
Sponsored Link

Java Buzz Forum
Scala: Still Uncomfortable After Five Years

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Weiqi Gao

Posts: 1808
Nickname: weiqigao
Registered: Jun, 2003

Weiqi Gao is a Java programmer.
Scala: Still Uncomfortable After Five Years Posted: Mar 24, 2008 12:33 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Weiqi Gao.
Original Post: Scala: Still Uncomfortable After Five Years
Feed Title: Weiqi Gao's Weblog
Feed URL: http://www.weiqigao.com/blog/rss.xml
Feed Description: Sharing My Experience...
Latest Java Buzz Posts
Latest Java Buzz Posts by Weiqi Gao
Latest Posts From Weiqi Gao's Weblog

Advertisement

I am a good pragmatic programmer. I follow the The Pragmatic Programmer recommendation of learning a new programming language a year. At least I try to.

But I'm having trouble with Scala.

Last Friday, at the OCI internal Java lunch, Tim Dalton gave a presentation on Scala. This one is very similar to the one Tim gave at the St. Louis JUG last year. As I did last time, I went to scala-lang.org and downloaded the latest version of the language and played with it this weekend. I got scala-2.7.0-final this time, replacing the scala-2.4.0 I downloaded last time.

As if the world is conspiring to push me into Scala-land, InfoQ also released a presentation on Scala by Lex Spoon from the Scala core team. I also found Ted Neward's "The busy Java developer's guide to Scala" series of articles at IBM developerWorks. And to round out the outside stimulus package, I can't say the blatant self-promotion of their own Scala book, in the form of online advertising at Artima, has gone unnoticed by me. I don't know if Bruce Tate is on board this time. But he should. Scala seems like a pretty powerful language to kayak or mountain biking with!

I other words, the three year hype cycle for Scala has started, at least in my books. It may very well have began a little while earlier, in December 2007, when Artima announced The Book. And I'll make a mental note to reexamine the adoption of Scala in December 2010.

Back to Scala the language.

First of all, let me explain the title of this post a little bit. I'm not sure of how long I have been in the mode of "learning Scala"—get a new version of the package, print out the tutorial and language reference, and start at page 1, only to give it up a few pages into the tutorial, either because the code int he tutorial doesn't compile, or another Slashdot discussion pulled my attention away from it—sort of like the way I tried to "learn Russian".

Secondly, notice that I used the word uncomfortable, which is different from other more objective descriptions like "Scala sucks," or "Scala is the next big thing." The latter description I've used in jest at the office where I know people will see through it right away. (This, by the way, will replace my earlier line: "Use Ruby on Rails! You don't even have to write a line of code. Just think about it, and it will be done!" Now that the Ruby on Rails hype has died, that line is no longer funny.)

Scala is uncomfortable for me, because it is too different from what I use on a daily basis, Java and C++. Here's my list:

Conceptual Hurdles

Pattern matching. I fully understand the power of pattern matching from Haskell's pattern matching and Scheme syntactic extensions. Pattern matching is purportedly a big innovation of Scala in that it mixes pattern matching into an OO language.

However, pattern matching in Scala is exactly the point at which I would spend time trying to understand it, trying to master it, trying to learn to use it. I understand the syntax. I understand the explanation that the speakers in presentations gave. I do get to the part where I say "This is cool." But I never get to the point where I would see a problem and say "This problem is best solved with pattern matching, let me fire up Scala and code the solution."

The same feeling I have with Common Lisp CLOS, Scheme hygienic macros, Perl globs, and the whole Tcl language.

Syntax Hurdles

The semi-colon. This should be an easy one to overcome, but it's not. I was doing a little bit of Scala and Java this weekend, in Vim, of course. And at one point my mind went completely blank as to whether I should type a semi-colon at the end of a line. I caught myself thinking "This is the end of a line. Should I type a semi-colon here? I don't know!!!" And I was editing a Java file.

Arbitrary Differences

At least from a Java developer's point of view. The syntax for the default constructor, the post-fix type declaration, the use of [] for type parameters and for List literals, the use of Unit for void, etc., are examples of where Scala deviates from Java. Either using a different notation for things that are available in Java, or using notations that are used for one thing in Java to mean a different thing in Scala.

I understand the origins of these differences. They are more similar to Haskell or ML or some other functional languages then Java. So, naturally, a question I have is why isn't Scala being pushed as heavily to the functional programmers as it is to the Java programmers?

Syntactic Sugary Trickery

There is a dizzying array of syntactic sugar in Scala, most of them geared toward making Scala a perfect language for constructing DSLs. The optional omission of the dot when calling a method on an object, the optional omission of the parentheses when calling a method on an object with no arguments, one argument or more arguments, the way an infix operator on a class is declared with the "unary_" keyword, the liberal use of the "_" (the underscore) character to mean different things in different contexts, the way a infix method could be declared to be not only right-associative, but right-applicable, making it possible to write Scala code right-to-left, etc., could only be classified as syntactic tricks in the tradition of Perl.

While each of these tricks is simple when viewed individually, their aggregate effect is code that needs non-trivial thinking on the part of the programmer.

Scala Is More Different

For a language that is hailed as the next big thing, at least on the JVM, my feeling is that Scala is more different from Java than, say, Groovy, BeanShell, and maybe even Jython. As a consequence, the jump from Java to Scala is not an easy one.

One refrain that I hear again and again in the Java closures debate is "Don't complicate Java even more with closures. If you want closures, just use Scala." With all the differences I outlined above, I believe "just use Scala" is not as easily doable in this context. (BTW, I was struck by the similarity between the syntax of Scala closures and the BGGA closures.)

Scala is to Java as C++ is to C?

One thing that is mentioned in the second Ted Neward article is the possibility of using Scala as a better Java the way Bjarne Stroustrup advocated C++ as a better C.

I think that is a viable way of driving Scala's adoption. And indeed, Scala contains enough goodies to allow the Java programmer to write more concise programs without losing type safety and performance. This is an advantage of Scala over Groovy. A better "better Java", maybe?

But really, to make Scala mainstream would require commitment and investment, just like anything else, from C++ to Java to .NET/C# to Groovy. One or more industrial strength, focused, well financed companies need to spring onto the scene to offer continued Scala productization and support for the long term.

Read: Scala: Still Uncomfortable After Five Years

Topic: Back in Brooklyn Previous Topic   Next Topic Topic: SXSW Nite 3 - Cloud Cult Twice, and more Indie from DrunkAndRetired.com

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use