Live data from Hacker News

Scala Considered Harmful For Large Projects?

kirkwylie.blogspot.com

21–30 of 57 posts

Re: Scala Considered Harmful For Large Projects?

#21
post #17

I'm learning Scala now and am impressed by its difficulty. Not since I learned C++ in college have I needed to spend the same amount of time and effort learning a language, and the arguments given here against Scala are exactly the arguments you hear against C++. That's heartening to me. C++ is a great language for people who 1) know the language, and 2) use it sensibly (which often means humbly.) There's all kinds o…

One of my CS professors made the remark that C++ seemed like it had been designed by people who thought that there was a tax on keyboard symbols. So rather than using new symbols that were on a standard keyboard but not part of the language already, they just reused the old symbols either as is or in strange new combinations.

When I look at Scala it gives me that same feeling. Additionally, they seem to come from the 'god kills a kitten every time I press a key' school of thought so everything looks really compressed and cramped. Granted it's not as bad as Perl or something you might see in an obfuscated C contest, but it seems a step away from Java in terms of readability. Which seems a shame to me. It is as though they said to themselves, "we will increase the utility, but something must be sacrificed". I just kind of wish they had added the extra power, but not at the expense of making it harder to read.

Re: Scala Considered Harmful For Large Projects?

#22
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…

I would disagree with your point 3. Sufficiently well written code (by which I mean deliberately written in a clear style with good comments) is readable right off the bat. What you want to avoid is invisible side-effects. Aspects for instance have their place, but if someone has tried to be too clever for their own good the program may be breaking in a way that is completely invisible when you look at the code.

No code is readable right off the bat. I mean you need to see it (meaning look at it in your editor), piece it together in your brain, and then place it in the context of the rest of the code. Of course, that doesn't sound like a big deal, but it adds up.

Some code might be readable more quickly but again, it's about tradeoffs. To take an extreme example, suppose the "instantly" readable method results in 10000 lines of code while the metaprogramming approach takes 10 lines. Clearly, even with extra levels of indirection the metaprogramming approach is more easily understandable by sheer virtue of there being less code.

Again, that's an extreme (and unlikely if not impossible) case, but it illustrates my point: it's all about tradeoffs.

Re: Scala Considered Harmful For Large Projects?

#23

Earlier quoted context omitted.

The obvious comeback being large Java projects considered harmful.

Obvious but not worthwhile, as the issue isn't Java, it's multiple languages on a project.

But I think this argument with respect to Java is flawed anyway, or was for a long time. EJB 3 and JPA is enormously much better, but back in the bad old days of J2EE you had these 'no go areas' anyway. You kind of slapped a couple of interfaces down, and then hoped that the magic code generator of the App Server would do the right thing (if configured properly).

How is that any different from having a "if you don't know what you're doing, don't mess with these bits" area for the Scala stuff to sit in?

J2EE isn't the only example of this. Plenty of frameworks had their 'here be dragons' sections, the fiddling with which was considered a dark art.

Re: Scala Considered Harmful For Large Projects?

#24
post #22

Earlier quoted context omitted.

I would disagree with your point 3. Sufficiently well written code (by which I mean deliberately written in a clear style with good comments) is readable right off the bat. What you want to avoid is invisible side-effects. Aspects for instance have their place, but if someone has tried to be too clever for their own good the program may be breaking in a way that is completely invisible when you look at the code.

No code is readable right off the bat. I mean you need to see it (meaning look at it in your editor), piece it together in your brain, and then place it in the context of the rest of the code. Of course, that doesn't sound like a big deal, but it adds up. Some code might be readable more quickly but again, it's about tradeoffs. To take an extreme example, suppose the "instantly" readable method results in 10000 lines…

If your code isn't readable right off the bat, you're doing it wrong.

At one place I worked I had a BA who was nosey and came and tried looking over my shoulder at one point at some file manipulation code I'd written. Now I used to put a lot of time and effort into writing nice neat code, but this was something for me alone, so I hadn't bothered putting in the comments that I normally would.

Anyway, because I wanted him to take a hike, I thought, "right, let's call his bluff". So I asked him whether he understood what the code was doing. And he said yes. Frankly, I didn't believe him, so I asked him to say what it was that the code was doing, and you could have knocked me over with a feather when he was able to run down the page of code and say pretty much what everything there did.

Another example: I often hear people say that they can't read the code they wrote 6 weeks ago let alone 6 months ago. I can.

Now, I'm not suggesting that everyone has to go out and start writing code that even non-programmers can read, but there are a couple of guidelines:

(a) pick good variable names

(b) pick good method names

(c) pick good class names

(d) whitespace is more important than you think (as is indentation)

(e) only do one thing per line if you can help it

(f) the one line of super-cunning code that replaces two lines of boring mundane code that does exactly the same thing may actually run slower after the JIT and other optimisations

(g) the easier it is to read, the easier it is to debug

(h) debugging is expensive, really expensive, much more expensive than writing the code in the first place, hence any investment in readability will almost immediately pay dividends

(i) code unto others as you would have them code unto you

Re: Scala Considered Harmful For Large Projects?

#25
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…

Turning that around, you think that in the presence of a powerful and expressive language it is nevertheless somehow easy or straight-forward to force people to create code that's easy to understand? I'd be interested to read more of your thinking in this matter.

No, it is neither easy nor straightforward. And if you think of it as "forcing", then you have already lost.

The key factor is good people (this itself makes it not easy, sorry to disappoint.) If you have a competent team you don't need a dumbed down language to keep them in check.

If you have incompetent people, then you may use a restrictive language as a crutch. But don't expect good results.

Re: Scala Considered Harmful For Large Projects?

#26

No matter what the language is, I think it is important to understand that readability of the code should be part of the design. Scala does make it easy to write hard to read code.

Presumably it gets easier with practice. But I think you have to write it, and there are some idioms and shortcuts that people use, and if you're unfamiliar with the shortcut then it can be hard to figure out.

I had a similar problem with Objective-C. Everyone was saying how easy it would be for someone who knew Java to pick up, but for the first couple of years I found the message passing syntax to be incredibly jarring. Note that I'm not stupid, of course I understand what messages are etc. It wasn't that I didn't understand the concepts, it was that the syntax of the language kept tripping my "that looks wrong" buttons.

I think that with programming languages there can be an 'uncanny valley' effect. Something that looks too close to something else but isn't quite the same. Java and JavaFX were an example of that for me. I thought they made the JavaFX too close to Java. Someone who knew Java would keep getting tripped up on the subtle (and not so subtle differences) - but because it was too close to Java you couldn't easily tell where the Java ended and the JavaFX started. You might have a class where halfway down your page of code the rules of syntax and grammar shift slightly, and then a little bit further on they shift back...

When I'm mixing two languages I find it easier if they are distinctly different, it makes the cognitive burden easier. Nobody complains about having to mix Java and SQL on the back end with HTML and Javascript on the front end for instance. There's four languages right there, and the wuss that wrote the original article thinks two is too scary for most programmers? I know most programmers are like insects to the giant intellects of those of us at HN, but even so I think he doesn't give them enough credit.

Re: Scala Considered Harmful For Large Projects?

#27
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++.

Re: Scala Considered Harmful For Large Projects?

#28
post #17

I'm learning Scala now and am impressed by its difficulty. Not since I learned C++ in college have I needed to spend the same amount of time and effort learning a language, and the arguments given here against Scala are exactly the arguments you hear against C++. That's heartening to me. C++ is a great language for people who 1) know the language, and 2) use it sensibly (which often means humbly.) There's all kinds o…

I used Boost Spirit in my dissertation project for the parsing: https://github.com/scotts/cellgen/blob/master/src/cellgen_gr...

I would not choose it again. With what I wanted to do, the performance was poor. Spirit just had to deep-copy the parse tree it was generating way too much. I liked having all of my source in C++, which meant not having to embed C++ in ANTLR or yacc. But I'm not sure that was worth it. Perhaps the newer version fixes that problem, but I doubt I'll ever test it out for sure.

Luckily for me, the performance of the compiler itself was not really a priority. And it was a research project, so it didn't really matter.

Anyway, I know your point was broader than Spirit specifically, but I thought you may be interested in my experiences.

Re: Scala Considered Harmful For Large Projects?

#29
I know everyone loves their high powered languages, but I'm afraid the author is right. The more developers, the more conformity you need. I'm doing a personal project in OCaml, and I absolutely love it. I like to think it keeps my medium size code base from ever turning into a large code base.

But Ocaml has so many features that two programmers can write in such different styles that it might as well be a different language. A team of maybe 5 people with a good attitude could probably work on the same code base. The same is true for lots of new languages like scala and clojure and even ruby.

Knowing what I know now, if there's a project that's going to have more than 10 people working on it, I'd hesitate to use anything except Java or C#.

Re: Scala Considered Harmful For Large Projects?

#30

Earlier quoted context omitted.

Obvious but not worthwhile, as the issue isn't Java, it's multiple languages on a project.

But I think this argument with respect to Java is flawed anyway, or was for a long time. EJB 3 and JPA is enormously much better, but back in the bad old days of J2EE you had these 'no go areas' anyway. You kind of slapped a couple of interfaces down, and then hoped that the magic code generator of the App Server would do the right thing (if configured properly). How is that any different from having a "if you don't…

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.
Post reply on HN