9 ms·
Why Scala seems difficult but really isn’t
- darklajid 15y agoDown for me, cached link here: https://webcache.googleusercontent.com/search?q=cache:q2kp8RKQ5h8J:markusjais.com/why-scala-seems-difficult-but-reallyisnt/+&cd=1&hl=en&ct=clnk https://webcache.googleusercontent.com/search?q=cache:q2kp8R...
- speckledjim 15y agoEither you care about shipping products, and making things of value, or you care about what the latest fashionable language to do it in is.
- rauljara 15y agoIf you care about shipping products, it is worth it to care about the tools you use to ship the products with. Some languages are fashionable because they are neat. Some languages are fashionable because they have allowed people to ship products better and faster. Some languages are fashionable because of both.
- PaulHoule 15y agoThere are a handful of commercial success stories with Scala, like the messaging engine behind Twitter, but not a lot. I can definitely see how an individual or small team could build something fiendishly clever in Scala that's maybe 2,000 lines of code that does the work of 20,000 lines of code in some other language. On the other hand, I'm not sure that systems 10x that size developed by bigger teams would succeed in Scala, and I fear for what happens when that 2,000 line Scala system falls into the hands of maintenance programmers.
- rauljara 15y agoHe made his statement in the general sense, and I responded in the general sense. I don't know scala and can't speak to it. But I've heard that exact same sentiment applied to ruby (rails, specifically). But ruby has enabled huge increases in productivity for me over php. So I can safely say that the sentiment that if one is doing something fashionable one must not care about shipping, is full of shit.
- bad_user 15y agosmall team could build something fiendishly clever in Scala that's maybe 2,000 lines of code that does the work of 20,000 lines of code I actually provoke you to pick a language, any language other than assembler, and write a piece of software with both languages, of reasonable complexity (no micro-benchmarks shit), as concise as you can. If the source-code in Scala is at least 3 times smaller, I'll buy you a drink.
- TylerE 15y agoCOBOL?
- jeswin 15y agoI work as a consultant in Bangalore; most of my daytime job involves reviewing projects (for code quality). I see about 8-10 projects a month (Java/.Net). There are projects which are just bad, let's ignore those. Those which can be classified as maintainable, are well structured and object-oriented, they abstract implementations behind interfaces etc. But, they are verbose. I could probably accomplish the same thing in about 3x less code using FP/declarative constructs. Reminds me of Yegge's Kingdom of Nouns; it is a funny read if you haven't read it yet.
- melling 15y agoYesterday on HN, someone from FourSquare said they have 150k lines of Scala. http://news.ycombinator.com/item?id=2679041 http://news.ycombinator.com/item?id=2679041 Is it safe to assume that would be 300k-450k if written in Java?
- fogus 15y agoThere are a handful of commercial success stories with Scala Correction: There are a handful of commercial success stories with Scala made public. There are companies trying to solve hard problems with Scala that are not necessarily interested in language advocacy.
- PaulHoule 15y agoThat brings us to point (1) of his article. He asks us to make a large investment in learning a language that might pay off in the future... might. My understanding of Scala is quite imperfect but the more I've learned the more it seems that it's got pretty facades built over weak wood. Rather than being a 'scalable language' it comes across like a fake town that was built as a set for a Western. Look at any beautiful concise code sample that they try to seduce you with and you find that any small change requires tripling the code size. Look at the chapter in the book on DSLs and the take-away is "don't try to build internal DSLs". Be it looking at the profiler running on on a Scala program that uses actors or finding that I never quite seem to get away with not having to declare types explicitly, I have a facepalm event every hour or so working with Scala. In my case, (2) has nothing to do with it. I'm quite familiar with functional programming, both in languages that support it well and languages that don't. These days even my PHP looks like LISP. (3) is certainly true, and I think it has something to do with the cultural difference that @speckledjim points out. Anyone who's got to work with Scala will definitely confront (4); if you're working in Java or PHP or some other commercially viable language you can probably solve a high fraction of problems by using Google and Stack Overflow. If you're programming in Scala you'll have a lot more success understanding the fundamentals of the language. If, for instance, you need to access Scala objects from Java (particularly the super-prevalent ones like Option and List) you'll find that cookbook-style documentation is 100% AWOL. Go look at the scaladocs for Option and List, however, and you'll be calling methods on them in no time from Java. If you insist on working with Scala, get a book and read it all the way through from the beginning, skipping forward when you don't understand something.
- fogus 15y agoLook at the chapter in the book on DSLs and the take-away is "don't try to build internal DSLs". Which book do you mean? Also, do you mind elaborating on why one should avoid building DSLs with Scala? In my own experience [1] I've found it extremely nice for internal DSLs. [1]: https://github.com/fogus/baysick https://github.com/fogus/baysick
- troutwine 15y ago
- elmomalmo 15y agoIf you're shipping products and making things of value using great tools (however fashionable they are) it means you spend more time shipping and adding value and less time dealing with the limitations of your tools.
- jinushaun 15y agoI have the same problem with learning Ruby. The official tutorial basically runs you through "regular" style imperative programming. But when you see real-world Ruby in the wild, it's always so cryptic, and uses popular language features that don't really get touched on in the tutorials.
- bad_user 15y agoIf you're talking about the Picaxe book, Ruby is all about meta-programming, so that's only a book to get you started. I also think it's a highly overrated book and personally I haven't had the patience to read it. Ruby code gets really clear when you understand "self", eigenclasses and closures. Required reading: http://pragprog.com/titles/ppmetr/metaprogramming-ruby http://pragprog.com/titles/ppmetr/metaprogramming-ruby Also, Ruby is not a functional language; but IMHO is much better and more elegant than many languages that claim to be functional.
- jamesbritt 15y agoThe pickaxe always struck me as Ruby from a Java programmer's perspective. At one point it was one of very few options in English but nowadays the choices are better. Ruby Best Practices and The Complete Rubyist are key reading.
- nvarsj 15y agoPickaxe is pretty awful for learning Ruby. I also did not have a great experience with it. My favorite Ruby book is http://www.amazon.com/Ruby-Programming-Language-David-Flanagan/dp/0596516177/ref=sr_1_3?ie=UTF8&qid=1308760667&sr=8-3 http://www.amazon.com/Ruby-Programming-Language-David-Flanag....
- joe_the_user 15y agoI have to agree. I remember reading early Rails code and - bang - everything is obscure notation for class member of private class using the '@' symbol or something (along with eval expression that would clearly slow down everything and ... did).
- leftnode 15y agoI've given up PHP for Scala recently, and it doesn't seem too difficult yet. Do yourself a favor, pick up a copy of "Programming In Scala" by the languages author, and read it starting from page one, even if you think you're an expert programming. I can't learn a new language quickly, so to learn I'm blogging about my experiences at http://leftnode.com http://leftnode.com and trying to write as many small programs as possible, moving into larger ones when I'm ready. I'm trying to ignore many of the larger projects and in-depth Scala projects for the time being so I don't overwhelm myself and give up on learning the language.
- jshen 15y agoI used scala for a few projects, and overall I like it much more than java. Let's just get that out of the way upfront :) I loved scala when I was writing and reading my own code, but it started to feel like perl when I had to use and dig through other peoples code. This is a fairly superficial feeling, and I could be off mark, so take it with a grain of salt. I definitely plan to use scala again when I need the performance over jruby/clojure, in place of java of course.
- kaffiene 15y agoI don't think that's superficial. That's the same reason that I used to love programming in C++ but began to see its foibles when I started working with large groups of C++ programmers. People tend to work in a stylistic cul-de-sac which doesn't play nicely with others. Criticising Java seems to be a favourite passtime of IT snobs, but theres a lot of real world payoff to having a language which is simple and tends to have one (idiomatic) way of doing things. Not that its perfect - not by a long shot. Writing languages is easy (I've written a couple) but writing one which people actually want to use is a hell of a lot harder. That said, I like quite a few of Scala's ideas. I'd love closures, type inference and traits in Java.
- Meai 15y agoI think this is just a case of different viewpoints. The author clearly states himself in the last paragraph that learning Scala in under 3 weeks should not be expected. Personally, I consider any language that I can't learn to a reasonable level in 2 days difficult.
- nuriaion 15y agoAny language which uses concepts which you haven't used before (Like Functional Programming or in the other direction OOP etc.) will need more than 2 days. You will need the time to learn the new concepts and not the language. So the language per se isn't difficult but the new concepts...
- Ubersoldat 15y agoI've been an OO programmer for a long time and I really, really like the way functional programming works. It takes some time to re-think your previous assumptions, but even when in pure Java, a more functional approach provides a much better code. And, maybe it's because I've used another languages that I find Scala pretty straight forward.
- devinfoley 15y agoHe actually states becoming an expert in Scala in 3 weeks should not be expected, not learning Scala.
- bad_user 15y agoAs a replacement for Java, Scala is a failure. It is a language too complex that doesn't provide enough benefits for people that just want something better than Java. The perfect Java replacement would have - local type inference, less verbosity (e.g. public by default), full closures, anonymous blocks, no generics, special syntax for arrays and hashes, operator overloading and the ability of a variable to behave as if dynamic (e.g. leveraging the future InvokeDynamic). I would also completely purge checked exceptions and also get rid of the general syntax for anonymous classes - basically get rid of anything not useful. People actually liked earlier versions of Java. It was a simple language, while still a lot more productive than C++. They fucked up its evolution and IMHO it's pretty sad that people like Scala so much; it just shows how low are the standards.
- phillco 15y ago> The perfect Java replacement would have - local type inference, less verbosity (e.g. public by default), full closures, anonymous blocks, no generics, special syntax for arrays and hashes, operator overloading and the ability of a variable to behave as if dynamic (e.g. leveraging the future InvokeDynamic). I would also completely purge checked exceptions and also get rid of the general syntax for anonymous classes - basically get rid of anything not useful. Ahem. http://groovy.codehaus.org/ http://groovy.codehaus.org/ The #1 feature of Groovy in my mind is that there is almost no learning curve whatsoever. All Java code is already Groovy code - you can learn all the dynamic tricks as you go.
- Lewisham 15y agoAll Java is also a valid subset of Scala, IIRC.
- devinfoley 15y agoScala introduces new versions of collections like Map and List that aren't compatible with Java's versions. The syntactic sugar only works with the Scala Maps. Meanwhile, Groovy uses Java collections.
- deleted 15y ago[deleted]
- davidw 15y agoAs someone who is curious about Scala, what's the current "state of the art" in terms of a web framework? Can you point to some example code?
- michaels0620 15y agoLift (http://liftweb.net/ http://liftweb.net/) is the most widely adopted Scala web framework. Scalatra (https://github.com/scalatra/scalatra https://github.com/scalatra/scalatra) is another that is based on Ruby's Sinatra.
- deleted 15y ago[deleted]
- mrspeaker 15y agoThe Play! framework is awesome... http://scala.playframework.org/ http://scala.playframework.org/
- ww520 15y agoPlay Framework for Java itself is already awesome. The Scala support is wonderful, too.
- Lewisham 15y agoCan someone please explain to me why Scala has been getting such vitriol on HN comments lately? I've never found Scala "difficult"; you can use Java and take in new bits as you go. Why do people keep saying its too complex? It's no more or less complex than Ruby, and certainly less of a learning curve than Haskell, more familiar syntax than Lisp (for more programmers), yet the comments here indicate that "Oh, Scala is so complicated, how could anyone learn it?" This article seemed on the money for me. I know things like type erasure and other programming language bits and bobs upset the PLs gurus, but I really don't care about that. I can write concise code that looks like a dynamic language, but get full static type-checking. That's a huge win. I really just don't understand it.
- nuriaion 15y agoI know several (good) java programmers which thought they should without learning be able to understand/write idiomatic scala code. But idiomatic scala has also a lot of concepts (functional programming etc.) which they just don't knew.
- Elrac 15y agoIt so happens I've been trying to write my first "real" Scala application these past few days. It's been a harrowing experience. Just a few highlights off the top of my head: * Eclipse support is spotty. Apparently legal programs suddenly develop lots of errors. Sometimes restarting Eclipse will allow the program to run anyway. * Types are constantly getting in my way. Sometimes types are correctly inferred, sometimes I need to add types to hint the compiler about what I'm doing. * Writing anonymous functions remains hit and miss. I just throw in underscores at random until something works. * I don't understand where the round or squiggly parentheses go in for comprehensions; i.e. what goes in the parens and what stays outside. * Hashmaps have a cool "+=" operator to add a key-value pair. So why does "put" work but "+=" doesn't? Another mystery. * Sometimes the parentheses after function invocations are optional if there are no parameters. Sometimes not. Why? It's not Scala's fault that the Eclipse plugin is less than perfect, it's already very powerful. As for my little struggles with the language, none of this is witchcraft; I'm sure there are well-defined rules and sensible answers to all these questions and many more. But I must say I'm annoyed with the huge number of rules behind Scala. The amount of stuff I need to learn to really use Scala effectively is daunting. Contrast this with my Ruby experience. This is a language that places great value on orthogonality: wherever possible, every operation works the same in every situation. So you have a smallish number of versatile functions, not too much stuff to absorb and things generally Just Work (TM). I taught myself Ruby and Rails and wrote my first useful Web app in a couple of weeks' worth of evenings, and it was a very pleasant experience. Clojure, similarly. All the parentheses took some getting used to, but the language's syntax is wonderfully simple and consistent, so getting stuff done is mostly just a matter of looking up the most appropriate function in the cheat sheet. I managed to be productive (for small programs) with Clojure in a couple of days. Scala is no doubt a fantastic language. But thanks to its kitchen sink attitude, it's not an easy language to come to grips with for someone with an aging memory and a less than full-time commitment.
- currywurst 15y agoCoincidentally, today is the first day I'm seriously looking into Scala, and I think his points serve well to temper one's approach to language. I think Scala is an admirable and ambitious effort to allow oo + func programming on the JVM. I also got the impression that the type system is "good enough" for most DRY efforts. But then, my background in this area is virtually non-existent. Depending on what sources you learn from, you don't need to learn all the intimidating language features in the beginning itself. I am currently working through [1] - well written, but slightly outdated. [2] is where I got oriented initially. It's also great that they do well to come within striking distance of Java in performance (this is not my impression of Clojure). Another super cool approach seems to be that of Mirah (no special runtime, Ruby-like syntax). [1]: http://www.codecommit.com/blog/scala/roundup-scala-for-java-refugees http://www.codecommit.com/blog/scala/roundup-scala-for-java-... [2]: http://grahamhackingscala.blogspot.com/2010/12/guide-to-learning-scala-by-graham.html http://grahamhackingscala.blogspot.com/2010/12/guide-to-lear...
- numbsafari 15y agoScala runs on the JVM, which is owned and encumbered by Oracle. So... why should we care?
- dstein 15y agoThere are many JVM implementations: http://en.wikipedia.org/wiki/List_of_Java_virtual_machines http://en.wikipedia.org/wiki/List_of_Java_virtual_machines
- numbsafari 15y agoAnd how many people running Scala are actually using those other JVMs? How many of them even compare to the Sun/Oracle JVM? I mean, honestly? And given Oracle's new penchant for suing people and their spat with Google/Apache, do you really want to keep your eggs in that basket? People keep trying to sell new languages to Java developers using the JVM. The problem isn't the language, though, it's the JVM itself and the licensing problems, too.
- perfunctory 15y agoA bit off topic rant on the Eckel's article linked in the post. 1. I wish people stopped saying "static language that feels like dynamic". This is just a marketing slogan. Type inference is not a substitute to dynamic typing. 2. I know that coming up with a good, plausible code examples is difficult but it's not an excuse to give bad examples. House has-a Bedroom; House not is-a Bedroom. 3. > Scala has the best of both worlds: true multiprocessor parallelism and a powerful functional programming model This sounds as if usually multiprocessor parallelism and functional programming are mutually exclusive and Scala finally managed to have the best of both worlds. 4. > v.foreach(println) ... eh, isn't this just passing a named function as a parameter?
- riffraff 15y agoas someone pointed out on HN before "dynamic" seems to be an increasingly common way of saying "doesn't annoy me much" or something like that.
- code_duck 15y agoI've found Scala to be more intimidating to approach than the average non-functional language because the people who tend to use and write about it are of a relatively high level of expertise. I'm rather sold on it, though. I've been warily learning it in dribs and drabs for about a year, and one of these days will actually write something that accomplishes a task.