3 ms·
I agree that, when you're learning, the "_" can be annoying since it's basically overloaded (its meaning depends on the context). Scala is very rich in feature
by lgieron 14y ago
I agree that, when you're learning, the "_" can be annoying since it's basically overloaded (its meaning depends on the context).
Scala is very rich in features (how many other languages need a 800+ pages book to explain just the syntax + core features like collections?). Once I got to know them though, I would very much miss most of them (and frankly I'm a bit afraid of what would be my reaction if one day I'd need to come back to Java). But, it's certainly not a language you will be fluent in within just a couple of days. As I didn't have previous functional programming experience, I'd say it took me a 3-4 months till I have gotten a feel of how/when to use most of the core features.
Hint I wish someone told me: write custom recursive functions only when you're certain the problem can't be handled with a simple reduce/fold. Basically, try to use lots of maps (the 'map' function, not the data structure) and folds, as they can solve tons of problems in an elegant (-> readable) and easily parallelizable way. It's also harder to make bugs when programming this way.
- lucian1900 14y agoI think needing a 800+ pages book to explain just the syntax is precisely the problem! Can it even be parsed reasonably? C++ sure can't be, and Scala appears to have the same silly feature creep.
- lgieron 14y agoWhat do you mean by "Can it even be parsed reasonably"? The size of the language seems to come in large part from the fact that it wants to be an OOP and a functional language at the same time, with providing rich and sometimes bleeding edge feature-set in both domains (plus, you've got built-in tools for common problems like XML/XPath handling being a part of syntax). When you combine those, the resulting size is enormous. IMO, it's definitely not a language for everyone and probably won't replace Java in its core domain (JEE enterprisey apps) - but, for many harder problems, the rich feature set can be a blessing.
- lucian1900 14y agoC++ famously needs parsers with about 7 passes. Most other languages have sane single-pass parsers, like recursive descent.
- cageface 14y agoYou could design a similarly powerful language without such a difficult syntax. C++ is notoriously difficult to parse.
- soc88 14y agoI would love to see an example of that.
- cageface 14y agoI would too. Unfortunately C++ is so entrenched it its domain now that any possible replacement is going to have to be more than just incrementally better. Languages like D and Rust and even Go could replace C++ in many of its applications but none so far seem to have gained much traction.
- seanmcdirmid 14y agoWhen I was working on Scala (5+ years ago), the syntax was still pretty rich but the parser was fairly concise. Martin is very good about designing consistent and fairly compact syntax; you get the richness from just a few rules that are easily expressed via recursive descent; there is a little bit of lexer madness for semicolon inference, but this isn't that big of a deal. Its definitely nowhere near C++ in terms of unparsability; one could probably write their own parser for Scala over a weekend or so (depending on their compiler skillz).
- davidf18 14y agoThere is a new book that is very good and to the point (the first 9 chapters are available free from Typesafe, the company that distributes the Scala/Akka/Play stack). Scala for the Impatient: http://www.amazon.com/dp/0321774094/ http://www.amazon.com/dp/0321774094/