10 ms·
Ask HN: Java 8 or Scala?
We are going to start on a new project. We will be 7-8 developers. 5-6 know Scala basics. We are deciding between choosing Play with Scala vs Play with Java. What do you think will help?
I personally like less verbose code and that's why prefer Scala. But considering team would be working and shipping the project, not sure whether Java 8 or Scala would help better.
- DandyDev 11y agoI work at a company that exclusively uses Scala for the backend of our applications/services, and I found that if developers are willing, it's almost never a problem to have them learn Scala within a reasonable amount of time, if they come from a Java background. We found that it's very hard to find Scala developers when hiring, so we basically dip into the Java pool and look for strong and talented developers there, that are eager to try and learn Scala. We then train them on the job, which almost never takes more than a couple of weeks before they really become productive. So I'd say, if you're confident in your team as far as their quality as developers goes, then go for Scala. The time lost in learning, will be made up in productivity once they get the hang of Scala and the start experiencing the productivity boost that a more functional approach can give you.
- ubertaco 11y agoScala is more flexible (for better or worse) and less verbose (for better or worse). Because of this, it's possible to be much more expressive in Scala and it's possible to be much more terse/obtuse. I like Scala's powerful type system -- I just have a hard time reading most other people's Scala. If you're sure you can get a consistency of style and approach in Scala among your team, sure, by all means. But if you believe that you're likely, at least in the short term, to have stylistic inconsistencies among your team, I'd lean a little more towards Java (just on "worse-is-better" principle).
- scala8 11y agoWhat do people mean when they say "powerful type system"? Does that mean it could potential be a downward spiral where everyone creates their own DSL? I use Ruby on Rails and Django - and in ruby and python, it's interpreted on the fly. How will a type system, let alone a "powerful type system", help improve ruby or python's web apps?
- ubertaco 11y agoBy "a powerful type system", I mean a type system that allows you to flexibly express more-complex constraints in a way that the platform (either compiler or runtime) will catch. For example, Javascript's type system (such as it is) is not, in my opinion, as powerful as Java's -- since there's no compile-checking and the runtime coerces stuff all over the place and does basically no checking at any point. Python's is somewhat better: there's runtime-checking, but it's duck-typed -- so you could call some array methods on an instance of, say, "FootballField" just because the FootballField has a "__len__" property and the runtime wouldn't catch it. Java's type system is a tiny bit more powerful -- the compiler does a lot of checking for you (so you can enforce that a method must take an array or a List<something>), but it's not as flexible (until JDK8, there was almost zero type inference, so you had to be super-explicit everywhere). Scala's type system is more powerful still; traits allow you to describe similar classes in a duck-typed-esque way (without the classes themselves having to opt-in), and there's really good type inference. I'm not an expert in Scala, so I could be wrong about some of its features in particular, but that's the sort of thing that I mean by "powerful type system".
- brianwawok 11y agoScala for sure. It is a more expressive language that leads to less bugs down the road. Encouraging lots of immutability is huge, as well as a bunch of other benefits. There will be a transition time for non-scala devs, but it should easily pay for itself down the road.
- brudgers 11y agoIf immutablity and functional style programming are priorities, then why Scala over Clojure? By which I mean that the decision is less about technical concerns, they all run on the JVM, than team dynamics and who is willing to learn what...or not learn what. If using Java/Scala contributes to the likelihood of the project team failing then Java/Scala is the wrong choice.
- scala8 11y agoIt is a more expressive language that leads to less bugs down the road. Encouraging lots of immutability is huge, as well as a bunch of other benefits. Deja vu. I use to talk just like you. My colleagues would too. I miss Java's verbose-ness. It's hell, but for large codebases and tooling - I wish I had a bottle of JDK 8 right now. I heard a lot of this "prescription"-like talk, it'll buy us a lot X down the road. I blame our "this or nothing" attitude toward scala. We would unconsciously, I think, immediately cast aside any contrary information. We thought ourselves as using this perfect tool and were condescending to anyone who used other things. We wrote everything in it. We fired 2 node/python coders. We're too invested and afraid to admit reality, it's a flawed language. Too complicated. Too many idioms for the lexer to handle. Frankly, the only scala engineer who ever admitted it (they outright ban scala detractors on the mailing list and freenode) was Brad Phillips. Don't take my word for it, I recommend looking him up.
- Psyonic 11y agoI assume you mean Paul Phillips, the co-founder of typesafe? It's true that he admits scala is too complicated; but it's also true he keeps working in it and himself admits he hasn't found a suitable replacement.
- M8 11y agoIn .NET as a similar choice, very subjectively, I would pick C# over F#, because: 1) succinct != readable 2) ReSharper and Roslyn IDE support makes a difference 3) there is no work opportunity to learn it 4) learning it in spare time would mean not implementing something else - I would prefer to solve domain problems rather than language AND domain problems
- Zergy 11y agoThis doesn't really make sense to me. C# is oriented towards imperative programming while F# is oriented to functional programming. The style of programming that best solves the problem and fits your teams' expertise should dictate the choice.
- M8 11y agoAre you sure you are replying to a correct post? Your statement is correct, but so are my points.
- brudgers 11y ago5-6 know Scala basics. Where will the team get Scala expertise? Where will it get Java expertise? What is the buy in to Scala from the team as a whole? What is the buy in for Java? What is the level of expertise with Play? What languages and frameworks has the team used previously on successful projects? What has it used on unsuccessful ones? What matters more in this decision are the human factors, not the technology. That's why you're not considering Clojure among alternatives. If the team is split over language, that's a team problem and the solution can only come via working to get buy in from those who feel they have something to lose if Scala or java is the way forward. Finally, if the long term goal is to transition from Java to Scala, Play with Java is a good first step. It gets Scala in the door, but keeps it out of the way as people are in the early stages of onboarding. Good luck.
- dudul 11y agoScala. The integration with play is much better since it is written in scala. The Java api is just an added layer that doesn't really deliver.
- weego 11y agoThe strange part of that question is you appear to have decided on the framework before the language. Strange because having used Play quite a bit, it's really not all that great in many ways, not good enough to be a default choice anyway. I might consider taking a step back and reconsider your decision making steps to this point. If for some reason you have to use Play then the only sensible choice is Scala.
- peteypao 11y agoWhat would you recommend instead?
- scala8 11y agoFor a website? Why scala? Because LinkedIn and Twitter use it? I have had great experience with Django in the past 8 years. Nice tooling. Nice template engine. Nice ORM. Mature. Scalable. Robust. The main detractor you'll hear about it is performance. You're just building a website. Even in situations where I'm recompiling LESS (bootstrap), with all debug tools on, and rendering images in the same pageload, it takes 200ms. Since python is interpreted, you just refresh the page. No 10 minute compiling just because you had a typo. One thing about django I don't like though is you never get the "snappy" feeling of just loading a page like lightning fast. Java / scala / golang gives the impression.
- justthistime_ 11y agoAccount-created-2-hours-ago, did you ever use Scala, or are you just trying to troll (badly)? :-) Edit: Oh, right. After reading your other comments, it's obvious that you haven't used Scala.
- gamechangr 11y agoJava is the right choice. Before I get into that, you may want to not focus on the framework so much, at least not before you choose the language! Scala is great for the right purpose, it's powerful and should make you productive much faster. Yes, Scala is much less verbose which seems like it would be much more efficient. Enter one Scala developer who has small stylistic inconsistencies and you have set everyone back quite far (especially when using other sources to answer a problem). Java is super easy to find answers if you need to and super, super easy for one developer to inherit the code of another. But then again, Scala might be the right choice if you HAVE to use Play, as Play was written in Scala.
- scala8 11y agoDoesn't Play have documentation / API for Java?
- alexgaribay 11y agoYes it does. But even after knowing some basic Scala, I find it significantly easier to work with Play on the Scala side. It feels more of a first-class citizen. However, this is just my personal opinion.
- scala8 11y agoCan any scala package be accessible via Java? What are the catches? Could you go into detail?
- gamechangr 11y agoIt's amusing that your user name includes the word "Scala". Sounds like you already picked a side...
- kimi 11y agoIf your devs are bright and want to learn something new, go for Clojure. If you already have strong Java skills and need to deliver fast, go for Java 8.
- deleted 11y ago[deleted]
- falcolas 11y agoHow well does the team know the domain in which the project rests? If it's a well trod domain, going to a new language (Scala) would do well to keep interest high, while not getting bogged down in the challenges of solving a known problem. If, however, the problem domain is relatively unknown, I would recommend Java8, so you and your team aren't fighting two unknowns at the same time.
- anithian 11y agoFrom my experience, Java while more verbose offers better tooling, standards, documentation and support. Scala certainly is more concise but there is a cost that you will incur later when trying to debug or maintain s large fast moving code base. Sbt blows, ide support for scala is spotty and good luck defining a code convention and standard that you can automatically lint and format. To me it's c++ for the jvm (not a good thing ☺). The next thing I'd advise is to not use play but to consider dropwizard or better yet spring boot. You may be thinking "ugh spring.. Isn't that so heavy?" Possibly but it's a lot simpler to use, extremely powerful and well documented and supported. Play just doesn't have that maturity and support going for it that a spring or dropwizard have.
- eip 11y agoI like Scala, Spring, and Maven. Sbt is definitely questionable and I always use Maven instead. IDE support for Scala is not great but it's pretty close to good enough. I don't really like Spring Boot but I like Spring in general and use it for pretty much all projects. After switching back and forth between Java and Scala a lot I find that I prefer Scala. I have never used it in teams of more than a few people though. I would recommend the same thing I recommend to all teams. Mandatory code reviews. Don't think of them as judgement. Think of them as async pair programming. If you want really bad IDE support you can always cross compile Java and Scala in same project with Maven.
- flippant 11y agoI tried ScalaIDE once and I hated it. I've also used the IntelliJ plugin for Scala and it was a pleasant experience. Would you explain what you're missing with the IntelliJ plugin?
- jghn 11y agoIt depends on when they used the IntelliJ plugin. I've been using it for a few years and it is much better now than it was when I started.
- alexgaribay 11y agoI agree. Intellij and Scala work very well together.
- mark_l_watson 11y agoMy preference is Java 8 because I find the Scala tooling to be so-so. I really don't like sbt. I find Java 8 to be "good enough." If you do like Scala, I recommend Martin Odersky's Coursera class. I took it a few years ago and it was great! Really fun and I learned a lot. He is a great lecturer. One way that Scala does win big is supporting a repl style of development. One great example of this is the Spark repl. If you live in the JVM world, Clojure (which I use more than any other programming language) and JRuby are also worth a good look.
- kod 11y agoScala. Checked exceptions make Java 8 lambdas basically worthless. Play is a Scala project first and foremost.
- runT1ME 11y agoIf your team is open to learning new things and comfortable with the occasional bout of feeling lost, then Scala is absolutely the better choice. The advantages of Scala is not it's lack of verbosity primarily, (Ceylon, Kotlin, F#, etc. are all similar in verbosity) but its support for functional programming. And I should add that 'lambdas' do not make a language functional, imho. Scala's focus on immutability (case classes, std lib), monadic comprehension (for expressions), type class support etc. all make it a joy to be productive in. But it also has proper lambdas that just work right (Java8s lambdas are done poorly for sake of backwards compatibility). You'll find less of a need to rely on frameworks (DI is trivial with just language features, you learn them once, you're good, no spring needed), you'll have less bugs, and it will be more fun! Reasons not to use Scala would be the lack of tooling (you're IDE will annoy you more than if you pick java), your team may get frustrated at times and need to ask the mailing list or IRC channel for help, and new developers who don't have scala experience will need a bit more handholding. We're finding for some cases we get a 100x LOC reduction coming from C#. This is not a joke, and it's not about us writing extra terse impossible to read scala and fitting too much on one line. The type system just allows us to reuse a few abstractions EVERYWHERE. We are getting insane code reuse, even between teams.
- goralph 11y agoI code Scala in IntelliJ and it's an absolute pleasure :-)
- wtf_is_up 11y agoAgreed. I'm using IntelliJ Community Edition with Scala plugin. It works really well. Only settings I've changed were setting the font to Source Code Pro and turning off spell checking. I'm absolutely loving Scala right now. I was writing a lot of stuff in Go until I started a new project that needed to leverage some Java libs. I had been wanting to try Scala, so I went with it instead of Java (or Clojure, etc). I liked Go for it's elegant concurrency, ease of deployment, and fast compiler, but Scala's type system and composition with for comprehensions is really nice. Java interop is pretty seamless so far. Scala has nice primitives for wrapping null and exceptions in safer ways and eliminates a lot of ugly x != null checks everywhere. Coming into it, I'd heard that Scala was hard to learn, but I didn't find that to be true. I was only vaguely familiar with pattern matching, monads, traits, ADTs, etc from playing with Rust, but I found plenty of good resources for learning Scala. I really found this series of blog posts to be helpful: http://danielwestheide.com/scala/neophytes.html http://danielwestheide.com/scala/neophytes.html
- serialpreneur 11y agoIn my personal experience, Java 8 is a safe bet. Yes, it is more verbose which I don't like either. If you avoid the over engineered frameworks in Java-land its not that bad. You mentioned Play, which as others have pointed out is a Scala first framework. I prefer modern Java frameworks like Dropwizard or Vertx. I tried to evaluate Scala after getting to know some basics & was thrilled at how concise code becomes in Scala vs Java. However, Scala does have a steep learning curve. I found that there were many different ways of implementing the same thing, which is time consuming in the beginning. There is opinion that it pays off later, I was not able to get to that stage because of initial impediments. As somebody else mentioned, using Spark API in Scala was a joy. Same code in Java becomes several times more verbose. At the end of the day you need to evaluate your team & develop a consensus. Your team might have some valuable opinions too.
- adamvega 11y agoBest Fails Compilation 2015 https://www.youtube.com/watch?v=iQ5gdqRNQgg&index=2&list=PLaf6keGWWV-C17ldlKLP5jQCCrioLZwz3 https://www.youtube.com/watch?v=iQ5gdqRNQgg&index=2&list=PLa... #bestfunnyvideos2015zen #bestpranksvideos2015zen