On 2009-12-18 18:02:28 +0100, retard <[email protected]> said:
I've only seen how Scala solves problems elegantly. These are from some
biased blog posts etc. Can you show one example that looks uglier in
Scala, but looks decent in D or some other language?

I can not paste any of this particular code ($WORK). From the top of my head, some random things that I found annoying:

- Types of both worlds get mixed. For instance, Scala has 'functional lists', but much of the Java world uses mutable lists (following the List interface). If you use the vast amounts of Java class libraries around (since the Scala library is still fairly minimal), you either have to fall back to Java lists (which do not work with a functional style of programming) or convert list back and forth all the time.

- You can do functional programming, but it will end up being slow, because of the lack of proper tail-call recursion optimization.

- Documentation for much of the Scala library is non-existant. There's a lot of second-guessing which traits you are expected to use, or which self-calling functions are tail-recursive. Since method signatures are pretty unreadable as well, you are pretty much on your own.

- Classes are ugly. Constructor parameters are part of the class definition:

class Something(someString: String)

While this looks like a somewhat typically functional type declaration in this simple case, once you start building real classes they pollute class declarations, since you have to do non-trivial initialization somewhere. Of course, you could do this in functional style, but most libraries are not written in this manner.

- Pattern matching with match...case is not particularly elegant compared to Haskell (where you just have multiple function definitions).

- Currying is not trivial: either you have to define multiple parameter lists, or construct a new function that allows for currying (Function.curried). And at the call site, you also need two parameter lists if you call a 'curryable' function without currying.

- There's a lot of operator overloading abuse. I like the freeness of overloading for DSLs. But using method names such as /: and \: (which are just folds) sometimes makes things quite unreadable.

- Generics are still implemented via type erasure.

Scala is to Java what C++ is to C, an old language with new constructs forcefully bolted on top. It is powerful, and people will continuously find fantastic things you can do with it. But it is also overly complex, verbose, and unreadable, and inherits some legacy from Java. If it really catches on, most users will probably restrict themself to a subset of the language.

Personally, I like simple languages better: Haskell/ML for functional programming, Prolog for logics programming, and C/Python/D for imperative programming. Now, if it can be stitched together with LLVM, that would be nice ;).

Take care,
Daniel

Reply via email to