8 ms·
Like the author, I've been using Scala more and more as of late (mostly after finding it to be a viable alternative to Java on Android). Perhaps the biggest thi
by yareally 13y ago
Like the author, I've been using Scala more and more as of late (mostly after finding it to be a viable alternative to Java on Android). Perhaps the biggest thing that I've had to get over is the "feature freedom" of the language after being walled in by Java on Android. I know I'm not too far off in saying it, but it's like Martin Odersky created it in direct response to the nanny-like restrictiveness that Java has, but perhaps went too far in some areas (as the article describes a bit). He did write the current java compiler, so he's well familiar with how Java is. I just sometimes get the feeling someone pressed accept to every feature enhancement to the language at some point as just about any feature you can think of in a modern language has found its way into Scala. Generally, I find that to be a good thing, but I can see how it would be off-putting to some and makes Scala somewhat of a controversial language for both imperative and functional language advocates.
If one is not careful and adhering to a formal style guide, it would easy to end up with an unreadable mess of inconsistent code. Anyone with some grounding in programming already at a professional level shouldn't have a problem, but someone that's relatively new to development might want to look into another language. For example, all of these are valid ways to create a class with some parameters/properties:
https://gist.github.com/yareally/5811498 https://gist.github.com/yareally/5811498
After having to use Java on Android for the past three years, such freedom is both liberating and shocking at the same time. I use C#, JavaScript and Python pretty frequent as well, but it's just I'd say Scala is even more liberal than any of those feature wise. It's more like Perl (not quite, but close), but not quite in the area of a Lisp variant. Scala is definitely written from the viewpoint of the developer and not the intended users though. It's also nice to have access to features that are standard in languages like Python, Ruby, C# and functional languages. Seeing 13 lines of Java become 1 line of Scala[1] is a great feeling.
I'd say if you have experience with Java, C#, Python, Ruby or any functional language you'll pick up on Scala pretty quick. If Java is your only language experience, it might be a bit rough at first, because of the expressiveness and freedom of the language, but don't let it detour you. If needed, you can mostly stick to the imperative side of Scala and slowly work in more functional features as well as some of the useful syntactical sugar stuff (like operator overloading) that Scala provides.
[1] https://gist.github.com/yareally/5810767 https://gist.github.com/yareally/5810767
- mooreds 13y agoDo you have any links to suggested style guides? Google returns this: http://docs.scala-lang.org/style/ http://docs.scala-lang.org/style/ or this: http://davetron5000.github.io/scala-style/index.html http://davetron5000.github.io/scala-style/index.html but do you have any that you'd recommend?
- saryant 13y agoTwitter has one: http://twitter.github.io/effectivescala/ http://twitter.github.io/effectivescala/
- yareally 13y agoI mostly follow the official one on Scala. I deviate from it a little to help me stay sane when switching between languages like 4 spaces tabbing and sticking to K&R style[1] for indentation/braces. Using an IDE like Intellij or Eclipse can also help reinforce consistency as well since you can set the way it formats for you (and also have it auto-format before you commit to git). Most important thing is to just stay consistent with whatever you decide upon more than which formal style you choose. If I were working in a team with Scala, then I would stick with a formal spec (or just let the IDE auto-format for me to adhere to the team's style when committing). [1] http://en.wikipedia.org/wiki/Indent_style#K.26R_style http://en.wikipedia.org/wiki/Indent_style#K.26R_style
- deleted 13y ago[deleted]
- _pmf_ 13y ago> I just sometimes get the feeling someone pressed accept to every feature enhancement to the language at some point as just about any feature you can think of in a modern language has found its way into Scala. That was also my impression. Clojure is sometimes painfully restrictive (I need forward declarations for functions if I use them before they are defined? In a compiled language in 2013? Really?), but at least it is curated.
- yareally 13y ago