6 ms·
Using Scala has been a breath of fresh air after 10+ years of (mostly) Java. Mountains of boilerplate (I'm looking at you getter/setter/constructor auto-generat
by tkw8 13y ago
Using Scala has been a breath of fresh air after 10+ years of (mostly) Java. Mountains of boilerplate (I'm looking at you getter/setter/constructor auto-generated code) become 2 or 3 lines, in some cases a 1 line class definition:
class Foo(var x: Int, var y: Int, var name: String)
(Thats equivalent to 6 method definitions and a constructor in Java. Also, the possibility that you forget to initialize one of the fields in your constructor [which happens from time to time in most Java code] is removed)
It's not just about having to write less boilerplate, it's also about having to read less code and expressing ideas using functional concepts where it makes sense.
Critics like to complain that having many features makes the language complex. In practice Scala code is fairly straightforward, the extra features just mean that library designers have to power to implement some pretty amazing interfaces for you using these features. Most Scala code is pretty sensible, and it's nice to know that the extra expressive power is there when you need it.
This may sound like heresy but I find myself being more productive in Scala than in Ruby. Part of that comes for the self-documenting nature of static typing and clear interfaces (No more "what methods and fields does this Foo object that is being passed in to this obscure method have?"). This is a very useful property to have when reading other peoples' code. The tooling is surprisingly mature (IntelliJ).
In hindsight picking Scala as a better Java should have been a no-brainer.
- habosa 13y agoScala = scalable language. This is for all the reasons you said. Because the language allows so much, library designers can really extend the language itself and create whole new paradigms or do other powerful things you just can't do in any other language that's this stable and portable.
- lucian1900 13y agoThere are much less complex but precisely as powerful languages out there (like Haskell). Scala's crazy amount of syntax is what makes me avoid it, not unlike C++.
- trailfox 13y agoDoes Haskell let me use the many Java libs that are used extensively internally in many organizations (including mine)?
- lucian1900 13y agoNo, but that still doesn't excuse Scala's syntax.
- trailfox 13y agoWe haven't had issues with Scala's syntax. Point is that Haskell isn't a viable option for most use cases.
- deleted 13y ago[deleted]
- virmundi 13y agoTerrible, terrible answer if you are mostly doing functional Scala. I've got a blog post that deals with this. Tl;dr: Java libs are good along as they are thread-safe or immutable; if they're not, you're looking at horrible side-effects where there shouldn't be any. http://talesfromannoyance.blogspot.com/2012/05/why-im-looking-at-erlang-over-scala.html http://talesfromannoyance.blogspot.com/2012/05/why-im-lookin... If you want reuse, you need to look at taking those parts and wrapping them up in SOA.
- trailfox 13y agoFor many use cases OO Scala works just fine, functional code used where it makes sense. Our goal is to integrate with existing systems, not to seek purely functional code as a goal in and of itself.
- virmundi 13y agoI agree with the concept. My concern is what happens as your team grows to include others whose Scala background is more functional. There is a sense that they should be aware of the old way your code base is put together. Unfortunately things could go awry when they code new functional based code expecting functional based input. Don't get me wrong, I like Scala. You just really have to watch its dual paradigm behavior when dealing with Java code