Sunday, November 18, 2012

Should You Learn Scala?

It depends on what you want to accomplish*, but the answer is probably yes.

By way of background, Scala is a programming language originally developed at the Swiss university EPFL in an attempt to apply recent innovations in programming languages research to a language that can gain mainstream traction.  Researchers keep coming up with clever ways to it easier for programmers to write correct code and to write less code, but much of the time only academic programmers benefit because these features are implemented in boutique languages (for instance, OCaml and Haskell) that are not in widespread use in industry or open source projects.

On its own, without considering features such a libraries and interoperability, Scala is a nice language.  It is "multi-paradigm," supporting object-oriented programming and functional programming idioms.  Scala allows you to define types associated with both data attributes (with classes behaving like C++/Java classes) and behavior attributes (with traits corresponding to Java interfaces).  In the way of functional programming idioms, Scala functions are first-class (which means you can pass them around as values) and Scala also supports anonymous functions and currying (partial application of multi-argument functions).  This combination of features make it possible to write Scala programs that are quite concise and elegant**.

Scala's libraries and interoperability make it a force to be reckoned with.  Scala runs on the Java Virtual Machine (JVM) and can interoperate nicely with Java code.  This means that you can use Java libraries directly from Scala code.  It is also possible to call Scala code from Java (see here).  There is a nice post about how you can take advantage of Scala parser combinators, which use higher-order functions to help you write concise parsers, to write parsers for systems otherwise written in Java.  Not only can you do all of the things in Scala, you can easily write part of your program in Scala and the rest in Java.  (This is huge for mainstream adoption potential because so much of the world's code is written in Java and so many developers are taught in school!)

Learning Scala will make you more marketable.  Many companies are using Scala these days, including LinkedIn, FourSquare, Twitter, and Quora.  The founders of Quora spent a couple of months building a Scala web framework in order to use Scala.  Martin Odersky, the man behind Scala, is now behind the startup Typesafe for supporting Scala development.  There are some nice Scala web frameworks out there, including Lift and Play.  Scala is also gaining traction in the research community.  Many more people cared about our research on the Jeeves programming language for automatically enforcing privacy policies once we implemented it as an embedded domain-specific language in Scala.

Scala is also relatively easy to learn, especially compared to other strongly statically typed languages (OCaml; Haskell).  I have previously said that Python is the most marketable language for beginners, but I am beginning to change my mind.  Like Python, Scala has clean syntax, nice libraries, good online documentation, and lots of people in industry using it.  Unlike Python, Scala also has a static type system that can prevent you from doing bad things (whereas in Python the bad things just happen when you run the program).

If you are teaching a course using Java, you may want to consider switching to Scala.  I have recently had positive experiences teaching Scala to MIT undergraduates during recitation in 6.005, the software construction course taught primarily in Java.  During three recitations I introduced how to use functional idioms, how to build an evaluator for a simple language by using data types and pattern matching, and how to build an incredibly concise parser for the tiny language using parser combinators.  You may find my notes here, along with the accompanying code examples.

If you are considering the merits of Scala over other languages, you may also be interested in reading my Quora responses to the questions "What makes a good programming language?" and What are the advantages of Scala over C++ and Haskell?.

* If you are building scientific applications, a language with more math support (Matlab; Mathematica; R) may be superior.  If you just want to do a weekend project writing a Craigslist scraper, Python may be better because it is easier to learn and has great web scraping libraries.
** Okay, Scala programs are not as beautiful as OCaml or Haskell (I have another post on ML vs. Haskell) but it's so much more practical in many ways.

46 comments:

Clement Levallois said...

2 questions:
- Would your recommend a book or textbook for somebody coming from Java?
- and a book / or any source that would focus on the advantages of Scala for server side programming (I use JSF, why should I be interested in Scala?)
Thx a lot!

Jean said...

Here are some useful links for learning Scala from Java:
- http://www.ibm.com/developerworks/java/library/j-scala01228/index.html
- https://blogs.oracle.com/sundararajan/entry/scala_for_java_programmers

You may be interested in learning about the Play MVC framework:
http://www.playframework.org/
There is a book with an early access edition about it:
http://www.manning.com/hilton/

Clement Levallois said...

thx!

christi parks said...

Hello, sir i would like to ask that what is the scope of java training, what all topics should be covered and it is kinda bothering me … and has anyone studies from this course http://www.wiziq.com/course/1779-core-and-advance-java-concepts of core and advance java online ?? or tell me any other guidance...
would really appreciate help… and Also i would like to thank for all the information you are providing on java concepts.

Mark Lewis said...

Great post. I love that you mention Scala as an option for introductory programming. I have been using it as the exclusive language of instruction for CS1 and CS2 at Trinity University since Fall of 2010 and I love how it works. Since there wasn't much material out there for that purpose I wound up writing a lot myself and it turned into this, http://www.amazon.com/Introduction-Programming-Chapman-Textbooks-Computing/dp/1439896666.

Nghia Huynh Trong said...

I do know that Scala is based on Java. So I would like to ask you whether I need to learn Java first, if not is there any diffculties?

Jean said...

You should not have to learn Scala first to learn Java. It may be useful to know some Java if you want to access Java libraries.

Randy said...

Hi Jean, really great article. I was just wondering what your thoughts are on how well scala stacks/compares against c#? Do you think scala will actually be a "successor" to java as some are claiming? And if it is a successor to java, which language do you think has a brighter future, c# or scala? also, which one do you think is more object oriented or has a better OOP model, c# or scala? thanks and sorry for all of these questions.

heena goyal said...

Hi,
Very informative information provided.
Is online training reliable?
I have never taken any but these days if you want to study from the best teachers online learning is best. So i have decided to do my online java training course from http://www.wiziq.com/course/12145-the-6-week-complete-java-primer-with-training-certificate as one of my friend recommended me this site. I don't know how is it going to work for me so if anybody have studied from this site please let me know .

sudheer said...

The information which you have provided is very good and easily understood.
It is very useful who is looking for java Online Training.

Anonymous said...

Indeed Java dev should now look to Scala. This article has covered some difference between Scala and Java and also shared few resources to learn Scala.

prabodh said...

I am from C++ background and do not know Java. DO you think I should go for Scala or learn Core Java first and then think of Scala?

Bala Murugan said...

This really useful this blogs i like it,CompTIA CASP Training VA
|CEH Training Fairfax VA

syed s said...

I was reading your blog this morning and noticed that you have a awesome
resource page. I actually have a similar blog that might be helpful or useful
to your audience.

Regards
sap sd and crm online training
sap online tutorials
sap sd tutorial
sap sd training in ameerpet

kits online said...

kits online trainings provides best online training for all it technologies

Ruby On Rails Training

SAP XI Training

OBIEE Training

Talend Training

PHP Training



Ravindra Reddy said...

Best kits online trainings,thanks for sharing

SAP Success Factors Online Training institute

SAP WebDynpro Online Training institute

SCCM 2012 Online Training institute

Selenium Online Training institute

Solaris Online Training institute

kits online said...

very nice article.Thanks for sharing the post..!
Oracle Golden Gate Online Training By Real Time Faculties

Ruby Online Training By Real Time Faculties

SAP XI Online Training By Real Time Faculties

OBIEE Online Training By Real Time Faculties

Talend Online Training By Real Time Faculties

PHP Online Training By Real Time Faculties

Coy Currin said...

Thanks for nice topic. I like it. We are Providing Online Training Classes. SAPMMonlinetraining

Anonymous said...

kits online trainings provides best online training for all it technologies
SCOM 2012 Online Training Institute

SAP Bw Hana Online Training institute

Oracle SOA Online Training institute

for IT the said...

Online Java Training | Online Java Training India | Online Java EE Training | Online Java EE Training India | Online Java Training Institutes

for IT the said...

Online Java Training | Online Java Training India | Online Java EE Training | Online Java EE Training India | | Online Java Training Institutes

Karthika Shree said...

It's interesting that many of the bloggers to helped clarify a few things for me as well as giving.Most of ideas can be nice content.The people to give them a good shake to get your point and across the command.
Java Training in Chennai

KarlDeville said...

Thank you for taking the time and sharing this information with us. It was indeed very helpful and insightful while being straight forward and to the point.
http://www.mcdonaldsgutscheine.net/ | http://www.startlr.com/ | http://www.saludlimpia.com/

suresh H said...

AngularJS Training Institute in Chennai
AngularJS Cetification Training in Chennai
AWS Training in Chennai
AWS Devops Training in Chennai
Best AngularJS Training in Chennai
AngularJS Training in Chennai

Praveen said...

Nice article
artificial intelligence online training
python online training
talend online training

Upender said...

Nice blog this informations is unique information i haven't seen ever by seeing this blog i came know lots of new things
those are very useful tom me i will suggest the peopele who are looking this type of information
python training in hyderabad the best career

upender anagandula said...

nice blog thank you for sharing wonderful information
python training in Hyderabad the best career

Roja Priya said...

Great efforts put it to find the list of articles. thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic.
Angular JS Training in Chennai | Angular JS Training in Velachery

Alister cook said...

I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.

aws training in chennai

advanced aws training in chennai

Prasad Gowtham said...

Great post! Thanks for sharing with us, Its really gives lot of useful information. Regards,

Angularjs Training in Chennai

samala swathi said...

This concept is a good way to enhance the knowledge.thanks for sharing. please keep it up
core Java online training Hyderabad

SRI said...

Thanks for the informative article. This is one of the best resources I have found in quite some time. Nicely written and great info. I really cannot thank you enough for sharing.

rpa training in marathahalli

rpa training in btm

rpa training in kalyan nagar

rpa training in electronic city

rpa training in chennai

rpa training in pune

rpa online training

Ram priya said...

The knowledge of technology you have been sharing thorough this post is very much helpful to develop new idea. here by i also want to share this.
Data Science training in chennai
Data science training in velachery
Data science training in tambaram
Data Science training in OMR
Data Science training in anna nagar
Data Science training in chennai
Data science training in Bangalore
Data Science training in marathahalli

Deepika Analy said...

Great Article...Thanks for sharing the best information.It was so good to read and useful to improve my knowledge as updated one.

Mobile Apps Training
Mobile Apps Training in Chennai

sai said...

This is beyond doubt a blog significant to follow. You’ve dig up a great deal to say about this topic, and so much awareness. I believe that you recognize how to construct people pay attention to what you have to pronounce, particularly with a concern that’s so vital. I am pleased to suggest this blog.
python training in velachery
python training institute in chennai

shethal said...

Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
Devops Training in pune
Devops Training in Chennai
Devops training in sholinganallur
Devops training in velachery

pavithra dass said...

Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article.thank you for sharing such a great blog with us. expecting for your.
AWS Course in Chennai
Aws Certification in Bangalore
AWS Certification Training in Anna nagar
AWS Courses in T nagar

akhilapriya404 said...

Thanks for sharing this blog post,Nice written skill core Java Online Training Bangalore

Anonymous said...

Selenium is one of the most popular automated testing tool used to automate various types of applications. Selenium is a package of several testing tools designed in a way for to support and encourage automation testing of functional aspects of web-based applications and a wide range of browsers and platforms and for the same reason, it is referred to as a Suite.

Selenium Interview Questions and Answers
Javascript Interview Questions
Human Resource (HR) Interview Questions

Priya Rajesh said...

Interesting blog, it gives lots of information to me. Thanks for sharing such a nice blog.
DevOps Training in Chennai
DevOps Training near me
Angularjs Training in Chennai
AWS Training in Chennai
RPA Training in Chennai
Blue Prism Training in Chennai

Meera Kumar said...

I think things like this are really interesting. I absolutely love to find unique places like this. It really looks super creepy though!! R Programming institutes in Chennai | R Programming Training in Chennai | R Programming Course Fees | R Language training in Chennai

sumant kumar said...

nice blog.thank you for sharing informative post.
web prograaming tutorial
welookups

IT Tutorials said...

Great efforts put it to find the list of articles which is very useful to know, Definitely will share the same to other forums. hadoop training in chennai velachery | hadoop training course fees in chennai | Hadoop Training in Chennai Omr

LindaJasmine said...

Interesting Post. Looking for this information for a while. Thanks for Posting.

Node JS Training in Chennai
Node JS Course in Chennai
Node JS Advanced Training
Tableau Training in Chennai
Tableau Course in Chennai
Primavera Training in Chennai
Primavera Course in Chennai
Pega training in chennai
Pega course in chennai

Aruna ram said...

Really thank you!!!This is one marvelous blog article. I appreciate your sharing this post.
Learn Ethical Hacking in Bangalore
Best Etical Hacking Training in Bangalore
Ethical Hacking Training in Chennai Adyar
Hacking Training in Adyar
Ethical Hacking Training in Velachery
Ethical Hacking Training in Chennai Velachery

Vicky Ram said...

Thanks for your sharing such a useful information. this was really helpful to me

Guest posting sites
Education