Hacker News new | past | comments | ask | show | jobs | submit login

How does it compare to Python or Ruby?



I have done a lot of Ruby work and a lot more JavaScript work (not one of the languages you mentioned, but I consider it a similar language to ruby/python). I find Scala to be a lot more enjoyable to use compared to them. It's probably my favorite language so far.

I never thought I would like statically typed languages, but now I don't know how I can live without them.

Scala is also more functional than Ruby or Python. I use it in a hybrid OO/Functional style. I probably lean 80-90% functional though.

As for people complaining it being hard to read, I disagree. Sure, some people try to be clever and play the, "how much can I reduce this code down to as few lines as possible" game. But if you break things out and not chain too many combinators or use too many symbolic operators, it can be readable. I don't find it any more difficult or easy compared to any other languages out there. It's just how you write it.

I think the biggest hurdle is to find a good mentor to give you the ah ha! moment when learning Scala (or any other functional language). I don't think many people can learn it by themselves. But once someone shows you how you can write your app in a more functional way, you begin too see some of the benefits of FP.


Very similar-looking when used with taste (unfortunately some libraries have a culture of using unreadable symbols and poor documentation, but that's changing), so you get the conciseness and readability of Python or Ruby (indeed better - I wish Python would adopt the "_" syntax for lambdas), but with greatly improved safety (and performance), or equivalently with the same level of safety for less testing.


I assume you know this, but it warrants saying explicitly: Scala is statically typed, while Python and Ruby aren't. This has immediate practical implications which for many people (on both sides of the divide) are A Big Deal.

In terms of elegance and succinctness, Scala is somewhere in the middle between Java's bureaucratic verbosity and Python's terseness.


Scala code will generally have a slightly lower LoC than Ruby IMO. Maybe 20% overall typically. And the lines will be longer.

Ruby forces new lines for many expressions that Scala doesn't. (Think class with accessors vs a typical case class.) as things get more advanced, Scala allows you to express things that can be very difficult or awkward in Ruby. Like function composition, currying, pattern matching.

There's not really a case where a Ruby program will typically be shorter than a Scala program (well, excluding imports since there's no shared global namespace in Scala), even if you're avoiding typelevel style programming.


Yes, I used to mainly work with Java, but now mainly Python. I was wondering if "best language going" had considered these two languages.


Yes - I have substantial experience with both. The differences from those are wider (and the advantages - or what others may see as disadvantages - clearer) - I felt it was more useful to compare against more similar languages where people would be more likely to be choosing between them.


https://www.python.org/doc/essays/comparisons/

"Java Python programs are generally expected to run slower than Java programs, but they also take much less time to develop. Python programs are typically 3-5 times shorter than equivalent Java programs."

I think Python performance wise a less attractive options than Java or Scala. At least according to the authors. Development time is a different question.


DEv/debug time is expensive, and there are options for python - http://quant-econ.net/py/need_for_speed.html


Absolutely - if I could reliably write correct code first time then Python might well be a better option. Reduced debugging time is my biggest reason for preferring Scala. In particular the ability to refactor with confidence is exponentially helpful (you can keep your APIs clean and clear, which feeds back in and helps prevent mistakes). Having the safety of a typed language without having to sacrifice any of the clarity of Python was a real revelation.


Idiomatic Scala is very similar to Python written in a comprehension-heavy style with better destructuring.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: