Live data from Hacker News

Scala Considered Harmful For Large Projects?

kirkwylie.blogspot.com

41–50 of 57 posts

Re: Scala Considered Harmful For Large Projects?

#41
The author is correct that, as a language "in the small", Scala offers many more ways for a programmer to create hard-to-understand complexity. Though many things have been conceptually simplified (the distinction between primitives and objects has been abstracted away so that most developers don't have to worry about, for example) there is a whole lot more stuff that make it easy to hang yourself with. (See implicit conversions and parameters, destructuring and pattern matching, and the power of the type system). Most of these things can be used to make code more readable, concise, and flexible, but can also be used to great ill effect.

When it comes to programming "in the large", like the author seems to be describing, I couldn't disagree more. Here it's Java--the culture and ecosystem--that tends towards over-abstraction, huge frameworks that obscure rather than illuminate intent, ridiculous class names that include "FactoryFactory", and so on.

I would argue that the second phenomenon--the hugely complex frameworks that have arisen in the Java world--is a direct consequence of the lack of power offered by Java, the language. Complex frameworks that do dependency injection through bytecode generation and XML configuration files really aren't necessary in the Scala world, where 90% of what you're actually trying to do can be done using compile-time mixins. The factory pattern can be replaced with anonymous first-class functions, with a net increase in clarity and conciseness. Most things that makes Scala more complicated in the small can be also be used to replace even more complicated, ad-hoc patterns and frameworks that make big Java projects such a pain to work on.

That said, it could be true that introducing Scala into existing codebases that already have thousands of lines of Spring XML config might simply introduce additional complexity, without offering a realistic path to removing all of the nonsense that supports the legacy Java code.

Re: Scala Considered Harmful For Large Projects?

#42
post #19

Earlier quoted context omitted.

Take a look at this sample ( http://static.springsource.org/spring/docs/2.5.x/api/org/spr... ) and see if you can figure out how to use these classes just by looking at them. That's the kind of abuse possible with languages such as Java. --- Seriously. Every new API that you intend to use has a learning curve, some more significant than others. Every new API is a new "language".

It's not really a fair objection. AOP isn't part of Java, it is an ugly hack that someone bolted onto the outsides of it. Seriously. You write your Java code, you compile it, and then in the night the evil AOP pixies sneak in and slip chunks of bytecode into your compiled classes.

The library tomh linked to is not a part of the Scala language or the standard library.

Re: Scala Considered Harmful For Large Projects?

#43

Earlier quoted context omitted.

I'm no fan of the language myself, but you're going overboard to try to dig a reason to trash Java out of this.

??? I'm not trashing Java. Did you read the article? I was making an analogy between the risk of having a language like Scala, which would mean there was stuff the Java-only people would not understand (which is what the article claims), with the black box auto-generated code produced by early J2EE (which is similarly a no-fly zone). Believe me, you'll know when I'm trashing Java, because I'll use the g word.

"...with the black box auto-generated code produced by early J2EE"

If this comparison were analogous, your point would make no sense, since it would boil down to in the bad old days, we got stuck with code we couldn't understand and lived with it, so now, code we can't understand isn't a problem.

And it's not analogous. We're not talking about black-box generated code nobody on the project understands, but instead people on the project making code that other people on the project don't understand. To harp on the one detail of incomprehensible code ignores huge differences in those situations. So, it's gratuitous to evoke that.

Re: Scala Considered Harmful For Large Projects?

#44
The author's argument is specious. You need design guidelines in place for any language feature. You can say the same thing about interfaces in Java - you see a call x.doFoo() and you have no idea what code gets called! Well yes, that's why you formalize your module interfaces and don't let people just randomly create interfaces between modules, etc, etc.

Even in assembly you can define a function _do_foo that actually does "bar."

You need to know how to architect code with meta-programming in mind, no doubt. But this isn't any harder than architecting code with any other language feature in mind. Just as you need to clearly specify the semantics of your interfaces, you need to clearly specify the semantics of DSLs.

Managed properly, DSL's can have a tremendous positive impact on the code-base.

I've been mucking around in compilers lately, and one thing that never ceases to amaze me is SBCL. The compiler is about 55K LOC + 15K LOC for each native back-end. That's about the same size as the C1 compiler in Hotspot, but does a whole lot more (ie: includes the front-end of the compiler, while C1 gets low-level bytecode as input, has to deal with type inferencing and lambda lifting and all sorts of other things to bring a high-level dynamic language down to machine code, etc, etc). And it does that with algorithms about 15 years older (it doesn't have the benefit of SSA form which would massively simplify many of the optimizations SBCL performs).

Macros are a huge part of how SBCL does it. There are 123 macro definitions in the compiler, and they do a tremendous job in cutting code by making DSLs for things like specifying code generators, etc. As for readability - because it's well designed and well-commented, it's surprisingly maintainable and readable for a code-base that's 25 years old and has been maintained by so many different people over the years.

Re: Scala Considered Harmful For Large Projects?

#45
post #9
post #2

"Ultimately, a programming language that's useful for large-scale programming projects needs to have clear, unambiguous grammar and syntax so that any developer familiar with the project and the language can instantly figure out what's going on." I have a hard time swallowing the necessity to rely on restricting the expressive power of the language to prevent people from creating code that is hard to understand. My c…

Python as a language does not lend itself to the same syntatic abuses as either Scala or C++ (or, for that matter, Perl). While you can certainly do some sketchy things, there's a pretty strong Python tradition of there being one standard way to do something, which is one of the language's strengths in my opinion, especially as you scale it up to larger projects. I'd also suggest that 100k is not a particularly large…

If you'd said you worked on a 1MM LOC C++, Scala, or Perl project where you didn't have to establish strict coding standards to avoid the code base descending into madness, I'd be pretty shocked.

If you've worked on a 1MM SLOC project in any language where you didn't have to establish coding standards, you were exceptionally fortunate to have such a disciplined, single-minded team.

Python as a language does not lend itself to the same syntatic abuses...

Syntactic abuses are the least of my maintainability worries--if they're truly a factor in your development environment, you need to have a friendly discussion with the antisocial sociopaths who write deliberately obfuscated code.

Python's good at enforcing a particular indentation style. That's never been interesting to me with regard to coding standards.

Re: Scala Considered Harmful For Large Projects?

#46

tl;dr: The author has a set of views about the benefits of hobbling programmers on large projects, which he takes as axiomatic. He espouses Java as a language suitable for performing said hobbling. He convincingly argues that permitting programmers to add Scala code to large Java projects undoes the hobbling provided by the Java language. I can't argue with his conclusions, but I'll fight his premises to the death.

You put it much better then I could.

I feel the entire article was just linkbait. Scala and Java could be replaced with .Net 3.5 and .Net 4.0. Or C++ and F#. Or any other language pair. And it would still be sorta right, maybe, if you assume your programmers are just average, not-overly talented developers, who don't know how to compartmentalize code.

Re: Scala Considered Harmful For Large Projects?

#47
post #19
post #5

Earlier quoted context omitted.

Well, take a look at this sample ( http://dispatch.databinder.net/Common_Tasks ) and see if you can figure out what all those operators do just by looking at them :) Thats the kind of abuse possible with languages such as Scala, Haskell or c++ templates.

Take a look at this sample ( http://static.springsource.org/spring/docs/2.5.x/api/org/spr... ) and see if you can figure out how to use these classes just by looking at them. That's the kind of abuse possible with languages such as Java. --- Seriously. Every new API that you intend to use has a learning curve, some more significant than others. Every new API is a new "language".

I think if you are familiar with the domain that API applies to (Aspect Oriented Programming) then you will instantly understand how to use them.

If every API is a new language then you are doing it wrong - the API should respect the conventions of both the computer language it is in, and the domain-specific terminology of the domain it serves.

Re: Scala Considered Harmful For Large Projects?

#48
post #15

I really disagree with the author in terms of metaprogramming. One thing in particular jumps out at me: > Ultimately, a programming language that's useful for large-scale programming projects needs to have clear, unambiguous grammar and syntax so that any developer familiar with the project and the language can instantly figure out what's going on. Wow. There are just so many things wrong with this statement. Let me…

Regarding 1, there are languages that do not have a clear, unambiguous (to my reading, formalized ) grammar yet possess compilers. Examples include classical FORTRAN, Forth and (if I'm feeling particularly trollish today) C++.

Fair enough. But in that case, the entire argument is moot. After all neither Java nor Scala (as far as I know) are formalized. :-)

Re: Scala Considered Harmful For Large Projects?

#49
post #48

Earlier quoted context omitted.

Regarding 1, there are languages that do not have a clear, unambiguous (to my reading, formalized ) grammar yet possess compilers. Examples include classical FORTRAN, Forth and (if I'm feeling particularly trollish today) C++.

Fair enough. But in that case, the entire argument is moot. After all neither Java nor Scala (as far as I know) are formalized. :-)

[deleted]

Re: Scala Considered Harmful For Large Projects?

#50
post #48

Earlier quoted context omitted.

Regarding 1, there are languages that do not have a clear, unambiguous (to my reading, formalized ) grammar yet possess compilers. Examples include classical FORTRAN, Forth and (if I'm feeling particularly trollish today) C++.

Fair enough. But in that case, the entire argument is moot. After all neither Java nor Scala (as far as I know) are formalized. :-)

I can't speak for Scala, but Java most definitely has a formal grammar: http://java.sun.com/docs/books/jls/second_edition/html/synta...
Post reply on HN