Scala in the Enterprise

9 views
Skip to first unread message

vpaz...@gmail.com

unread,
Apr 6, 2015, 2:58:56 AM4/6/15
to san-diego-sca...@googlegroups.com
Hey All,

I've started reading a book on Scala. Interesting stuff. But now I'm wondering, what do you use Scala for?

Do you work for a company which uses it? Do you mainly write your own personal projects with it? Is it just a fun technology to play with on the side?

I like learning new languages and technologies, but I'm also trying to be wise on where to invest my time. I didn't see many jobs in San Diego for Scala developers, but maybe I didn't search for the right terms, or I'm not familiar with the underground Scala job board... :)

S. Kai Chen

unread,
Apr 6, 2015, 8:42:48 PM4/6/15
to san-diego-sca...@googlegroups.com
The short answer is, better Java.  Let me qualify that further: better as in more concise, more expressive, code, more flexible architecture, and more scalable performance.

The advantages are obvious if you come from a Java background.  Even if you use just 1) case classes with pattern matching, 2) non-strict collections, 3) for comprehension, and 4) methods in traits (whose benefit shows up more if you start using mixin inheritance) -- even if you don't use the more advanced stuff and stick just to these 4 basic things that vanilla Scala offers, you immediately gain a tremendous amount of productivity.

And yes, I'm comparing it to Java 8.  Without the syntax of for-comprehension, collection transformation is just a nightmare to read -- it is literally incomprehensible.  No amount of daisy chaining and indentation can help with that. :)

From my personal experience, I chose Scala to develop my product mainly out of necessity.  There's not enough time for me to write both the code and the tests in Java.  There's also not enough money yet for me to hire a big enough team.  While there certainly is the risk of not being able to find people to keep with the development effort as we go to market, I consider it still better than having no product at all.  In the worst case, we can hire Java devs to slug it out and be still operational.  And fortunately there doesn't seem to be a shortage of front-end developers with Javascript.

And I have to say it's blind luck so far that the choice has paid off quite well.  About 4 months into development, I came into the part where I have to write a query language parser and a syntax tree transformer to translate it into Cypher, a graph query language used by Neo4j.  It took me 1 week to finish the parser and the query generator and 2 weeks to finish writing unit tests.  Took me 2 more weeks to generate enough test data to do an end-to-end testing of that component.  I don't think it's possible to meet that kind of time constraint in Java.  Just for the parsing part, it'd have taken me probably 3 weeks to define a grammar and write the AST code using Antlr (note that Antlr is not the bottleneck here ... it's me :) )  Then add 2x of testing time on top of that -- hope that makes the picture clear.

Recently I had to write a Java library for building Cypher queries, kinda like JPA for graph based persistence.  Even though this is the second time I'm solving the problem, it still took me close to 2 months to finish it, part-time.  The total time is probably close to 1 month.  So this actually makes me want to add a 5th element of Scala: inline template, or string interpolation, which is really helpful in text processing.  In fact, that was the primary reason why Perl was so popular in the early days of the Internet.

For hobby languages, there are probably better choices than Scala -- that's dependent on perspective and, to a large degree, personality.  But still, one benefits a lot from learning Scala well, because it has a lot of awesome features from other languages.  Scala is like a melting pot, having taken some of the best ideas from Haskell, Erlang, and Lisp.  So learning the features and the idioms also prepares you for digging deeper into the other languages as well.  I have to make a disclaimer here that, out of the 3, I'm only reasonably familiar with Lisp, and have a very thin exposure to Haskell.  I've heard about Erlang only because of the Actor model but don't know anybody that's worked in it.

Lastly I just want to comment that, though I understand it's better to be able to learn and also profit from it, the profit part is far from certain.  In other words, abundant and high-paying jobs is probably not good enough of a reason to learn a language, unless it's your first language, or first job :)  In the first place, there are better, or easier ways to make money.  And secondly, if one were to follow the jobs only, then in the 1970s one should learn COBOL and IBM assembler instead of C and SQL, and in the 1990s, one should learn C++ instead of Java.  Not that those choices would be huge mistakes; but if you treat programming like a regular job, you are burning up a Rembrandt for the heat it would generate.

It's also very hard to predict what the future language would be.  Java was not even a contender in the late 1980s.  It was C++ v Smalltalk, with a possible resurgence of Lisp.  So even though Scala is getting more and more hype, which I happen to believe is a lot more legit than all the other kind of hypes that go around, it's a hard sell right now that it *will* become dominant.  In fact, if we just go by the odds, it probably won't.  Go probably have a better chance.  The tie-in to the JVM is almost like the tie-in of the Chinese Yuan to the Dollar: a blessing and a curse at the same time.  it certainly helps Scala to thrive and become adopted, but it also limits its innovation because interop is a hard and dirty job.  If Oracle acquires TypeSafe, then it'd be a different story.

So the tldr is: learn Scala for its intrinsic values, which I listed above.  The jobs come and go (take the demand for iOS devs 10 years ago, for example).  What you learn stays with you always.  And to paraphrase Alan Kay, a language that doesn't change your mind is not worth learning.  Scala has certainly changed my thinking in a lot of ways, and I continue to discover more, even around something basic like foldRight.

I guess I must have a spew|lecture button somewhere that you happened to press :)  Sorry for the length of it.  Hope it's not utterly useless, and if it is, hope there would at least some entertainment value in it for redeeming.

Cheers,
Kai

--
You received this message because you are subscribed to the Google Groups "San Diego Scala Enthusiasts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to san-diego-scala-ent...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Arne Claassen

unread,
Apr 7, 2015, 12:07:28 AM4/7/15
to san-diego-sca...@googlegroups.com
I used to be a C# developer and got into Scala for the more concise syntax, rich functional constructs and easy immutability while still retaining access to the entire JVM ecosystem. Having been using it every day for for work for about 9 months now, I have to say I really love it.

As for jobs, I don't know of any underground Scala job board either. At Emotient, we needed data processing and scala fit the bill, especially since pretty much all emerging tech in Big Data is moving to Scala right now. San Diego usually lags in tech trends, so i don't expect the market to take off here for another couple of years.

arne
Reply all
Reply to author
Forward
0 new messages