10 ms·
Scala 2.10 now available
- benmccann 14y agoThey still haven't fixed the compilation speed unfortunately. All these other features are useless when anything written in the language compiles so slowly that it's barely usable.
- michaelochurch 14y agoI like this "problem" because it encourages small programs. Also, Scala's type system is just very complex. If you have a 2000-file program with cyclical dependencies you are screwed. If you use Scala-IDE (which has an embedded sbt doing incremental compiles, which become non-incremental if your dependency structure is fail and you have a huge SCC) on such a project you are doubly screwed. That's not a problem with Scala. Bigass programs aren't a good idea in any language. The programmer-to-program relationship should be one-to-many (for engagement, productivity, modularity, code quality) and not the "enterprise" reverse.
- untog 14y agoUsing slow compilation speed to encourage small programs is a terrible "solution".
- michaelochurch 14y agoIt's slow because it's doing a lot. If you don't want a cutting-edge, powerful static type system there's an awesome JVM Lisp (Clojure) that I recommend highly.
- mietek 14y agoOn the other hand, if you do want a cutting-edge language with a powerful static type system, and a compiler an order of magnitude faster than Scala's, you could try Haskell.
- calpaterson 14y agoGHC does a lot of the same things (arguably more stuff) and it's extremely fast, especially if you don't use -O*. Anyway, type-checking is probably the fastest part of compilation so there's no reason to give up Hindley-Milner for speed reasons. (One of the best features of GHC is that you can use GHCi to typecheck)
- Flow 14y agoI wonder if those implicits in Scala makes the compilation non-linear in time.
- yummyfajitas 14y agoGHC doesn't do subtyping. I suspect that is the main reason why Scala is slow - it's certainly the reason why the code is more complex.
- mietek 14y agoOCaml does objects and subtyping, while still managing to remain quite fast. http://caml.inria.fr/pub/docs/u3-ocaml/ocaml-objects.html http://caml.inria.fr/pub/docs/u3-ocaml/ocaml-objects.html
- bad_user 14y agoOCaml doesn't have Haskell's type-classes or Scala's implicits. Scala's subtyping is also nominative (versus structural) and it's basically impossible to do type-inference for nominative subtyping. Whether this is good or bad, the fact remains that Scala runs on top of the JVM while Ocaml doesn't. If you ever work with Ocaml you'll notice that the type-inference system breaks down when you're working with OOP and in Ocaml you're really dealing with 2 type-systems shoved in the same language. What Ocaml does really well, compared to both Haskell and Scala is type-inference, but it's kind of a weak language IMHO as far as functional programming is concerned. I also don't get all this complaining, because in practice Scala compilation speed is not a problem. After working with Scala in production for a couple of months now, I'm beginning to suspect that all this is just hyperbole perpetuated by people that never worked with Scala a single day in their lives.
- ryanpers 14y agoI'm sorry but this is possibly one of the worst comments I've seen... There is a conservation of complexity that you just can't get rid of in an application. To suggest that Scala encourages small programs, you are also suggesting that Scala is only appropriate for small problems, and thus it isn't a scalable language. See: http://c2.com/cgi/wiki?ConservationOfComplexity http://c2.com/cgi/wiki?ConservationOfComplexity Ultimately, the baseline requirements drive the minimal complexity of code. Sure a poor programmer can drive up the complexity with unnecessary constructs, but the converse is not true: a great programmer can drive to simplicity. For example, a flight control system for a 777 can never be reduced to a single file of 700 lines of code. It will likely always be 2000+ files, and have lots of inter-dependencies. So I guess (run time safety issues of Scala aside) Scala is not an appropriate language for complex problems by your own words?
- michaelochurch 14y agoScala's compile speed (with incremental compiles) is generally acceptable if you have reasonable dependency patterns. If you have cyclic dependencies, it's a problem. However, cyclic dependencies are signs of things that are wrong in development practices that can't be blamed on the language. You mentioned flight control systems: those are unlikely to be written in Scala, being real-time systems, but if one were, it would not need to be compiled and recompiled on the fly. Scala's a great language but it's not the right language for every problem. No language is.
- ryanpers 14y agoGood non-answer. For many large, non-trivial systems have several requirements: - tends to have complex dependencies - needs fast builds This was a classic: http://www.amazon.com/Large-Scale-Software-Design-John-Lakos/dp/0201633620 http://www.amazon.com/Large-Scale-Software-Design-John-Lakos... Essentially how to design C++ systems so that incremental compiles don't sink you. Developer productivity is important. Scala is badly failing on this front IMO, it reminds me of the old bad days of C++ in a major way.
- bretthoerner 14y agosbt's incremental compiler is a huge improvement over restarting the compile from scratch each time. Use "sbt ~compile" or "sbt ~test". IntelliJ 12 + Scala plugin even an external running sbt incremental compiler to do compilation for the IDE.
- ffk 14y agoJust make sure you don't ever use incremental compiling to build production jars. There are some edge conditions that exist in both scala and java that cause wrong behaviour to occur. It has to do with information lost when the compile occurs. A full clean and compile produces correct results.
- fedesilva 14y agoCan you provide more info? I have 2 scala programs in production, one of which also has one java file (merssenetwister inlined) and I deploy incrementally built jars without any problems so far. What scala+sbt versions (or whatever) do you use? (editted formatting)
- ffk 14y agoHere's one example, in order, w/incremental compiling enabled in Java: Class A contains public static final String x = "x" Class B contains public static final String y = A.x Class A modified, A.x = B.y Result: A.x and B.y = "x" clean and compile, no code changes Result: A.x and B.y = null The reason this occurs is because information is lost during compile. The compiler optimizes the references away and doesn't fix them w/incremental an compile. This occurs in both sbt referencing javac and the eclipse incremental compiler in Eclipse IDE. While this is contrived, the main point is that more complex interactions occur where these references may not be updated properly and you may end up with behavior you were not expecting due to these optimizations. Interestingly, I think the problem can be solved if the compiler were to keep incremental metadata explicitly stating where these dependencies exist. This certainly is the case with eclipse, where the IDE knows about the link, but still produces behavior that is dependent on compile order and not on the code change itself.
- sreque 14y agoThat is certainly false hyperbole. There a lot of very useful new features in 2.10, and many people are currently successfully developing in Scala, even with its relatively slow compilation speed. The Scala team knows compilation speed is important; they have dedicated people working on it full time. This release they made progress by creating an incremental compilation system called Zinc that is shared by Eclipse, maven, and most recently, IntelliJ. They have also said that there is no easy fix on the horizon. Improvements will take time and likely continue to be incremental in the near future.
- LiveTheDream 14y agoActually, the IntelliJ team does not use Zinc. Their compilation subsystem is basically an equivalent re-implementation of Zinc. The reason they built their own is because they need more data about the compilation process than Zinc provides.
- sreque 14y agoThat is partially correct. Intellij doesn't use zinc, but it uses the same compilation system that is at the heart of zinc. From http://blog.jetbrains.com/scala/ http://blog.jetbrains.com/scala/, there is a section showing how their new system relates to zinc. It would have been more accurate for me to say that this release the Scala team developed an SBT incremental compiler that is used by Eclipse, Maven, and, most recently, IntelliJ.
- PommeDeTerre 14y agoPerformance problems like these early on in a product's adoption (yes, I know Scala isn't exactly new, but it still isn't widely used) can really give it a bad reputation that is extremely hard to shake. I hope that they don't fall into the trap that the Mozilla folk have with Firefox. Although Firefox is still slow, it isn't as bad as it once was. Even after substantial effort and some moderate improvements, it still has a very bad reputation. I don't think it'll ever overcome this. The same could easily happen to Scala, if they aren't careful.
- gilbertw1 14y agoSBT provides incremental compilation, so it's not really all that painful provided your using SBT to build your project. Additionally, your getting a hell of a lot of work out of that compiler.
- felipehummel 14y agoJust use sbt ~compile. It will compile every time a file changes (only what is needed) . I've been using Scala full time for a year now, and I've never been bothered by compiling time.
- virtualwhys 14y agoBullshit ;-) In theory that's how we'd like it to work, but just based on the SBT author's winding explanation of the under-the-hood mechanics (http://www.scala-sbt.org/release/docs/Detailed-Topics/Understanding-incremental-recompilation.html http://www.scala-sbt.org/release/docs/Detailed-Topics/Unders...), needless to say it's a very complex process, one that is far from exact in terms of user expectation (read: surprising). Also, If you use a framework, you're at its mercy. Take Play's routing, for example. Add a single route and EVERY route is recompiled, which means your controllers and, god forbid, their dependencies get thrown into the mix. If you're careful you can minimize the damage, but let's be honest, barring simplistic apps, you're in for ride, a few seconds here and there add up over the lifetime of a project.
- felipehummel 14y agoIt hasn't been a real problem for me. But I cant say the same for every kind of program developed in Scala. I'm not saying that it is not a problem and I dont recognize it. Its just that, for me, the problem is much smaller than some people here seem to think. Maybe I've waited too long too many times for gcc to compile C/C++ that when I went to Scala I thought waiting some seconds to compile is okay =P
- taeric 14y agoThis argument seems strange. When people complain that tests take a long time to perform, the argument usually falls back to "if your tests are useful, the time spent running them is well spent." Seems the same applies here. Scala takes a long time to compile if you lean heavily on the type system. This makes sense, since the type system can be seen as a type of test system. So, if you are making useless types, the speed concern is likely best addressed by moving stuff out of the type system. If the extra time is preventing bugs, then few would argue it is wasted. Or am I completely off in my view?
- calpaterson 14y agoTypechecking shouldn't take much of the time. I'd wager (having never even looked at the Scala source code) that the time consuming part is compiling everything into JVM bytecode.
- taeric 14y agoSince the type system in Scala is popularly touted as Turing complete, I think you are mistaken in this wager. I remember in one of the exercises for the course, I did something where compilation never terminated. Changed the type of a single function, and compilation took less than a second.
- calpaterson 14y ago> Since the type system in Scala is popularly touted as Turing complete So is GHC's. Turing-Completeness says nothing about speed, only about termination prediction. GHCi can type check most codebases in much less than a second. The puzzling thing about the apologism for Scala's slow speed is that some people seem to think that no FP language has ever had a fast compiler before...
- taeric 14y agoMeh, the puzzling thing about many acolytes of anything in programming is the belief that all things have been solved. Usually best in what they care for most. Clearly, since my point was easily shown as a non-sequitor, I'm not an expert. Following the folks involved with Scala, on the other hand, I don't have any reason to feel that they are the rank amateurs that they would have to be to be to produce such a slow compiler with no need. My hunch, the support of nominative subtyping is the culprit. My backing for this? Pretty much nothing other than snippets of posts others have made.
- noelwelsh 14y agoAnd yet people -- thousands of them -- do manage to get useful work done in Scala on a daily basis! It's almost as if Scala's compilation speed is fast enough for most people. :shakes head:
- aleyan 14y agoAnd yet people -- hundreds of thousands of them -- do manage to get useful work done in Java on a daily basis! I do not want to be one of those people however because I do not like suffering.
- virtualwhys 14y agoEverybody privately bitches, and some publicly, about scala compile times -- it's slow! Even incremental builds can be painfully slow when you change a file that then triggers the recompilation of a host of other dependent files. Scala is both completely & utterly awesome and not at the same time, impressive, I realize this truth daily ;-)
- Flow 14y agoI remember various Pascal compilers bragging about 30k lines/s back in the 80's/early 90's.
- mark_l_watson 14y agoI am not sure if that is correct. When I took Odersky's Functional Programming with Scala class last year, it was recommended that we use the Eclipse based Scala IDE that had live worksheets: save the file and everything on the worksheet gets executed (quickly). I am an old Lisp programmer and the Scala IDE worksheets had the goodness of working in a repl. Compiling homework assignments seemed fast also, but that was only a few hundred lines of code. BTW, off topic but I would really recommend Odersky's class if it is offered again. I mostly use Clojure now, but the material in the class was generally useful for doing functional programming.
- lgieron 14y agoI write production code in Scala on a daily basis and compilation time is a non-issue for me - the project is compiled in the background (by Scala Eclipse plugin) so fast that I rarely have to wait for it at all.
- JustinJ70s 14y agoI've used Scala on several (largish) projects using Eclipse and, thanks to incremental compilation, I've barely noticed compile times never mind had it become an issue.
- wheaties 14y agoWe only run into big compilation speed problems when we have the following: 1) Code that is lumped into one gigantic JAR instead of being broken down into several different libraries that can be compiled faster. 2) Code that forces the compiler to "solve" many problems in the type system, such as recursion and many other powerful type level constraints. The first isn't a problem with the compiler, it's a problem with how you're laying out your code. Luckily we don't have this problem. The second is a problem if you've decided to use a lot of type level programming all over the place. I can't say if this is really a "problem" or not because it depends on your use case.
- seunosewa 14y agoScala's "customers" (coders) don't really care about why compilation speed is slow. They just want it to be fast. Compiling Scala is definitely slower than compiling Java. If it can be fixed, it should be fixed. If not, that may be one more reason why Scala won't be the next Java.
- jakubholynet 14y agoSorry but to me this hears similarly too "coders do not care about why runtime speed is slow, they just want it fast". You cannot get gut runtime performance without understanding the performance constraints of data structures and algorithms you use, Similarly, when using Scala, you must be aware of the performance cost - in compilation time - of the various features and act accordingly. So yes, what can be fixed should be fixed - but I am happy with having the possibility to trade ocassionally a powerful feature that will make my coding simpler for some unavoidable compilation delay. (Though I would of course prefer the compilation to be instantanous.)
- LiveTheDream 14y agoHere are some pointers about writing code that works well with SBT incremental compiler: http://www.scala-sbt.org/release/docs/Detailed-Topics/Understanding-incremental-recompilation.html http://www.scala-sbt.org/release/docs/Detailed-Topics/Unders... Following that advice will drastically speed up your compile time while working (obviously, a clean compile will take as long as ever).
- fedesilva 14y agoNot likely to be fixed any time soon. Does incremental compile not help?
- Ygg2 14y agoHow slow is it (for a moderate sized programm - simple text editor for example)? Minute? Five minutes? Seven? More?
- nicothieb 14y agoI fell I should link to Martin Odersky's answer to that remark: http://stackoverflow.com/questions/3606591/why-does-intellij-idea-compile-scala-so-slowly/3612212#3612212 http://stackoverflow.com/questions/3606591/why-does-intellij...
- thebluesky 14y agoScalac 500-1000 lines per second according to the link, with a startup time of about 4-8 seconds. Startup time can be worked around with zinc/fsc/nailgun
- jahitr 14y agoI wonder when they are going to add a fully async SQL query kit.
- anthonyskipper 14y agoAnyone have a working Brew update URL?
- dkhenry 14y agoThe inclusion of Akka Actors and Futures is _huge_. It really puts Scala in a great place to do massively concurrent programs. I still think I will be pulling in Akka to use their clustering, but of programs that don't require some of the remoting capabilities I can scratch a few lines of my SBT config.
- fedesilva 14y agoI think that you will have to keep that sbt line there because akka-actor comes with the distribution but is a separate jar. So you will have to pull that dependency yourself in sbt. "For Akka users this change does not have visible effects (you will continue to depend on the same artifacts)" http://letitcrash.com/post/37716546018/2-1-spotlight-akka-actors-enter-scala-distribution http://letitcrash.com/post/37716546018/2-1-spotlight-akka-ac...
- necubi 14y agoSince the main thread here is a gripe about compilation speed, here's something more constructive. I've been working with 2.10 for a few months now, and there's a lot that's really exciting. The biggest addition is macro support, which allows compile-time metaprogramming and code generation. This brings the ability to write very dynamic-looking code that is in fact completely type-safe. These capabilities have been used to great effect by Slick (a new database library based on ScalaQuery), ScalaMock, and others. Right now the tooling support for writing macros is a bit weak, but I expect it to improve now that 2.10 has been released. There's a lot else to like here, with built-in futures and promises from Akka, string interpolation, reflection, and a bunch of speed improvements and bug fixes. It's great work by the Scala team, and an exciting start to a new year!
- bad_user 14y agoYou forgot the link to Slick [0]. It's worth mentioning that Slick is a lot like .NET's LINQ to SQL. [0] http://slick.typesafe.com/ http://slick.typesafe.com/
- CookWithMe 14y agoI recently used Slick a bit in combination with Play. On one hand I was really impressed by its capabilities, on the other hand the documentation is unfortunately lacking... I think Slick has great potential and hope that typesafe brings the documentation onto a quality level similar to Play. If you want to try it out today and get stuck, after some time I found it quicker to look at their test cases first before googling, much more info there than in the docu and example projects.
- bad_user 14y agoThe project is new, being at RC1 for the first stable release and relies heavily on Scala 2.10, so it is understandable that it lacks documentation. On the other hand, Slick is the only alternative to LINQ that I know of. All in all, exciting times ahead.