4 ms·
Ever since I watched a Java developer at a client give a rabid "Why Scala is OMFG AMAZING!!!!!" talk to a bunch of bemused Perl programmers ("and it has this th
by peteretep 15y ago
Ever since I watched a Java developer at a client give a rabid "Why Scala is OMFG AMAZING!!!!!" talk to a bunch of bemused Perl programmers ("and it has this thing called a map and it has this thing where you can execute some code for each element of a list inline and..."), I've been carrying around the following prejudice, which I'd like to be freed from, so help me out:
There are only two types of people who find Scala even vaguely interesting:
- Java programmers who have never used another reasonably powerful high-level programming language
- Programmers familiar with high-level programming languages who have a need (or want) to target the JVM
What am I missing here?
- joshhart 15y agoIt's a hybrid OO-FP language that is statically typed with decent type inference. This has never been done before. Perl is not statically typed. You might think that's a good thing, but I don't because I routinely refactor in a large code base. I can make one change and start propagating it around until everything compiles and unless I've made a mistake it will all work. I don't make very many mistakes so I can improve a code base at rapid speed.
- peteretep 15y agoOK, interesting. The research I'm doing as I wait for comments suggests that it's the power of Perl with some of the good parts of Java, and without having to lean on Moose to get decent OO...
- spacemanaki 15y ago> This has never been done before. What about OCaml? I've never used it, but I was under the impression it is sort of OO combined with ISWIM FP. I've been poking about and reading about Standard ML and the module system seems like it supports some quite powerful OO stuff, but I also haven't really wrapped my head around it. I'm a Lisper and I basically don't know what I'm talking about here when it comes to ML and Scala. I do find Scala interesting though.
- chc 15y agoI'm not an expert in either language, but from my expose to the two, it seems to me OCaml is much heavier on the FP than the OO. If you asked me to imagine a FP-OO hybrid language, it would be closer to Scala than OCaml. Scala is both pervasively object-oriented and pervasively functional. Scala's static type system also seems to be quite a bit more sophisticated than OCaml (though its type inference is crippled as a compromise).
- gaius 15y agoAhem, once you have used OCaml, which is a hybrid etc etc, you would never say Scala has decent type inference. I have to annotate my Scala a hell of a lot more than my OCaml to get it to compile. All function arguments for example, whereas OCaml just deals with it with no fuss. I understand this is because Scala can't use Hindley-Milner due to some OO reason or other but still.
- fogus 15y agodue to some OO reason or other Overloading would be that reason.
- mietek 15y agoNemerle is also a hybrid OO-FP, statically typed language, with subtyping-savvy type inference, targeting the CLI. Moreover, it allows metaprogramming using Lisp-style macros. Nemerle has been available at least since 2005, but I can't blame you for not being aware of it. I probably wouldn't have heard about it, had I not attended the university where it was invented. Check it out: http://en.wikipedia.org/wiki/Nemerle http://en.wikipedia.org/wiki/Nemerle
- deleted 15y ago[deleted]
- harryh 15y agoTo your 2nd point it's not just targeting the JVM. It's really targeting the whole Java infrastructure: JVM/tools/libraries and (critically) a syntax that will be very familiar to the legions of Java developers out there in the world. To me at least this is a very powerful and important thing. PS: http://foursquare.jobs http://foursquare.jobs for anyone interested in working at a startup that does most of its work in Scala!
- lightcatcher 15y agoAs an outsider to the Java world, I don't really distinguish between JVM and the Java infrastructure. Also, I didn't know that .jobs was a top level domain.
- gaius 15y ago#2 is perfectly true, Scala for me is a basically acceptable ML that can interoperate with everything else JVM, given the choice I would be using OCaml or Haskell. Integrating these with C/C++ is straightforward but I have no experience of calling Java from OCaml. Hmm, I ought to write a blog post about that. On .NET they have it much better, F# is much more MLy.
- dgreensp 15y agoHa. Well, Scala was designed by hardcore JVM people after all. You could count me in the second camp. It's possible that some fondness for the JVM is required to have much interest in Scala. It is a unique language, though. Functional, yet lets you program in nouns, unlike verb-obsessed lisps. Powerful type system, but less stodgy than Haskell. Terse, but fancier than Python. Plus access to rich and well-documented libraries by virtue of the JVM.
- jheriko 15y agoI broadly agree - lots of hype and a bewildering array of features, but no reason to use it unless you are some kind of academic or lucky enough to be in the right kind of job for playing with general purpose high level languages. In my world (job) you either have to squeeze every possible cycle out of the innermost loops or get new hardware land on your desk which has an assembler and C compiler, maybe even a buggy, unfinished C++ compiler if you are super lucky. This probably sways me heavily against having an especially deep interest in all of these newer languages... I guess there might be some appeal if you are stuck with having to write code which targets JVM. Real programmers write Fortran anyway, right? (j/k obviously they write C++ [j/k]) :)
- cachemoney 15y ago"It's as expressive as Ruby, but runs much faster and is easier to refactor."
- kingkilr 15y agoThat first claim, that it's as expressive as Ruby, just doesn't hold up to scrutiny. (I've never used Ruby much, but I know my Python, and I'm going to assume they're approximately equally expressive). In no sane Python codebase would you see copy-paste that looks like: https://github.com/foursquare/rogue/blob/master/src/main/scala/com/foursquare/rogue/Query.scala#L95 https://github.com/foursquare/rogue/blob/master/src/main/sca... or the function/tuple/product classes found here: https://github.com/scala/scala/tree/master/src/library/scala https://github.com/scala/scala/tree/master/src/library/scala
- to3m 15y agoBeing able to tell the computer basic things about your program definitely makes the language MORE expressive, not less. I don't disagree that letting people express themselves isn't always very useful...
- zohebv 15y agoWell, all these tuples can be represented as a List[Any] object in Scala with no problems and it would be just like any other dynamically typed language. However, if you want static type checking of your code, then yes - it is useful to tell the compiler the constraint on the range of values that are valid for your object. This is generally not possible in dynamic languages and should not be surprising.
- DannoHung 15y agoDon't doubt the power of 2. Java is so friggin' entrenched that having a pretty nice half-type-inferencing functional language that's at least a little competent is a breath of fresh air. Sure I'd rather be using Haskell, but the available integration tools between Haskell and Java are not widely used and a bit immature or otherwise nasty. Maybe, one day, when the JVM finally keels over and dies and we're freed from the yoke of bad enterprise decisions, we'll all be able to use functional languages that were designed largely without compromise.
- chc 15y agoScala has a very interesting confluence of features. It's statically typed, which some people think is very desirable. It supports functional programming very well. It has strong concurrency support. It has an amazing breadth of libraries from the JVM. It has a lot of niceties that make your code shorter. Overall, it's a pleasantly practical language, aside from the fact that the type system makes Haskell's look benign and conservative.