5 ms·
> Scala is for those that want to get shit done without dealing with Java's endless boilerplate I've always wondered about this argument. Haven't modern Java I
by abalone 13y ago
> Scala is for those that want to get shit done without dealing with Java's endless boilerplate
I've always wondered about this argument. Haven't modern Java IDEs more or less automated away the boilerplate?
Using a tool like IntelliJ IDEA or even Eclipse for that matter, I'm really hard pressed to find something that could be autocompleted or generated that hasn't been. They even have views that collapse or otherwise hide away unnecessary verbosity.
Sure, you have a little more code to look at. But frankly, sometimes this can improve readability vis-a-vis excessively concise and overloaded syntax. It can make it easier to grok someone else's code.
I'm not saying there's no difference, just that it's a little odd that this is the NUMBER ONE advantage always cited for Scala vs. Java. Am I crazy?
- auggierose 13y agoYou are either crazy or maybe just not a very good programmer, if you think that tons of boilerplate is no problem because sometimes your IDE can generate / hide some of it for / from you.
- threeseed 13y agoBoilerplate code isn't just a problem for the person creating it. It's for the 20 people afterward who are going to be browsing, maintaining and adding new features on top of it. It is also lines of code that serve no purpose. And even the best IDEs can't help with much of what I've seen in large Java apps.
- eranation 13y agoYou are not, but subjectively I move more of my code to Scala, maybe java8 will change it, probably not. It's very much a personal choice. The easiest way is simply to write some code in Scala and get a feel for it. I prefer Scala because it's working for me, but everyone has different criteria and personal preferences. Go, clojure, Haskell might have more hype, but I tried them in the ultimate test of my productivity, and stayed with Scala. Because of my experience, not because someone convinced me in a comment or post. It's too subjective.
- saryant 13y agoI think the conciseness can improve readability. Consider these examples: List<String> list = getListofStrings(); List<String> capitalized = new ArrayList<String>(); for(String st : list) if(Character.isUpperCase(st.charAt(0))) capitalized.add(st); Or... val list = getListOfStrings val capitalized = list.filter(_.head.isUpper) Grokking two lines will take less time than grokking six lines.
- VladRussian2 13y ago>Grokking two lines will take less time than grokking six lines. when your mental/visual pattern machinery have been trained for 15+ years on the latter case? :)
- dragonwriter 13y agoSure, if you are excessively habituated to reading Language X and have some kind of barrier to learning new things, Language X will be better for you for most uses. That's not really a feature of Language X, though.
- saryant 13y agoIMO, the latter example is more readably because you're describing the result of the function rather than the outlining the operation itself.
- Dewie 13y agoAn IDE that could take the first example, then hide it, and then infer what that would look like with more higher order functions (the latter example), and then display that, that would be a truly magical IDE...
- BSousa 13y agoWelcome to Visual Studio with Resharper :) It can transform for loops into linq statements (and vice versa) quite easily
- dragonwriter 13y ago> I've always wondered about this argument. Haven't modern Java IDEs more or less automated away the boilerplate? They may automate some of the typing of boilerplate, but that just means the language you are entering isn't the same language you are reading, which is another problem. The boilerplate is still there, and its still in the way. > Sure, you have a little more code to look at. But frankly, sometimes this can improve readability vis-a-vis excessively concise and overloaded syntax. IME, its more often the case that the boilerplate that Java requires makes code hard to read than that the conciseness that Scala permits (but generally does not require) makes it hard to read. And, since the concise options in Scala are generally options, a programmer who is aware of a case where being maximally concise impedes clarity can opt for a more explicit expression, whereas the Java-required boilerplate isn't optional, so even if the programmer is aware of it getting in the way of readability, they can't eliminate it.
- abalone 13y ago> that just means the language you are entering isn't the same language you are reading I don't think that's true. Your phone has an autocomplete function for text input. You're still typing and reading the same language. > a programmer who is aware of a case where being maximally concise impedes clarity can opt for a more explicit expression By the same token, readers are held hostage by the poor decisions of overly concise Scala programmers. This is not theory, it really happens a nontrivial amount of time. You can blame the programmer if you want, but it's a point for Java readability.
- dragonwriter 13y agoA bad programmer can write code with poor readability in any language. That's no excuse for a language that makes clear, concise code impossible.
- abalone 13y ago> a language that makes clear, concise code impossible Now you're simply overstating the case. Why? This is a perfect example of my claim. There is this emotional component to the "Java boilerplate" argument that belies rationality. There is some other unstated reason advocates want Scala and are fitting the argument to that conclusion. Because it's cool? Big fish small pond syndrome?
- Dewie 13y agoUnless an IDE can hide 5 consecutive for-loops and then translate it into the equivalent composition of higher-order functions (with intermediate assignments for readability... but how will a code generator know what's readable) and then display that instead, I don't think that more functionally leaning programmers will think that IDE-generated code and code-hiding accomplishes the same thing, vis-a-vis what they might mean by "boilerplate".