4 ms·
To be honest with you, I use Scala as a better Java. Which means I still code imperatively (and use null instead of None) but with less noise (semi colons etc).
by wiradikusuma 13y ago
To be honest with you, I use Scala as a better Java. Which means I still code imperatively (and use null instead of None) but with less noise (semi colons etc).
But, esp when working with collections, I take advantage of Scala's features. It's not perfect, but it works wonderfully. I can always revisit/refactor my code again later.
- solomatov 13y agoNone vs null has nothing to do with imperative/declarative programming.
- svachalek 13y agoI believe that is implied by the conjunction 'and'.
- ffk 13y agoUsing null instead of None means you are more at risk of hitting a NPE. Here are a couple examples: myVar match { case Some(val) => doSomething(val) case None => handleNone() } myVar.getOrElse("else") In both of these cases, we eliminated the possibility of a NPE through the use of a language feature. :) (edited for formatting)
- gclaramunt 13y agoor myVar.map({ val => doSomething(val) }).getOrElse(handleNone())
- EdwardDiego 13y ago> Using null instead of None means you are more at risk of hitting a NPE. I think he's aware of that - he said he's using Scala as a better Java, what would Java be without the odd NPE?
- fizx 13y agoYou might be better off using a pre-release snapshot of Java 8 as a better Java. You'll get closures, functional collections, and better type inference. I bet Eclipse and Intellij support it better too.
- eranation 13y agoJava 8 for me is still far from making me move from Scala. Lambda expressions is only a small part of what I like about Scala. For me Scala is a statically typed Ruby / Python / JavaScript that runs on the JVM, and is very Java like. I would change some things in it, but a language doesn't have to be revolutionary to make me want to use it. Things I have in Scala that I like and Java 8 won't provide (many are syntactic sugars and non critical stuff, I know, but I like it, I'm spoiled) - implicit conversions. some hate it, I love it. It allows much better "pimp my library" mechanism than Ruby's and it's very easy to write extensions to your or 3rd party extensions in a safe and easy manner - duck typing, e.g. allows to write a "try with resource" without native support for anything that implements "close" - automatic tuples - better type inference - semicolons, hate them - automatic equals and hashcode for case classes - case classes - futures and promises - by name parameter passing (passing a block of code without running it) - partial functions, multiple parameter lists - for comprehensions - pattern matching - nested functions - lazy vals - everything is an expression - String interpolation - multiline string - default parameters - named parameters - pattern matching - everything is immutable by default - very string type system I think that's it. Yes, Scala is infamous as the language that took many many features from other languages and piled it all together, well, fine with me! you say more features that are great in other languages and make people productive? (and are kind of expected, like default parameters etc) I say bring them on and the more the merrier. I can choose which features I want to use out of the way too many features the languages, much better than waiting years for features to be added. Hater's gonna hate, I'm still going to write Scala until something better comes around. (Nimrod? Kotlin? Ceylon? TypeScript? Dart? perhaps even Go? Don't know... time will tell)
- pkolaczk 13y agoThere's even more: - implicit objects & type classes - path dependent types - abstract types - generic variance control - trait linearization - awesome collections library