Why Scala?

Job hunting as of late. I’ve talked to an endless stream of recruiters, HR managers, tech managers, engineers over the last couple of weeks. They always want to know what kind of work I’m interested in — and for me that’s an easy answer: Scala. I am prioritizing Scala work above all other factors (salary, location, free soda, massages, etc). Everyone always wants to know why I am putting such a heavy emphasis on finding Scala work. Honestly, it’s just that awesome. For the most part, I think I’ve made a good argument for Scala, but I’m always struck with that post-conversation moment of clarity that usually goes something like, “Oh man! I forgot to mention that Scala also does X and Y *and* Z!”. Over the next week, I’m going to make a series of posts that iterate every reason I can think of that someone might find value in learning and adopting Scala. Hopefully, doing this will etch these reasons into my mind for easy recall the next time somebody asks. As a bonus, I’ll end the series with a post to explore the issues, limitations and “why-not”‘s of Scala that I’ve encountered so far.

Post Series:

  1. Code preemptively and eliminate entire classes of errors at compile-time
    1. Use Option to eliminate null
    2. Use immutable variables and immutable collections to eliminate syncronized
    3. Use actors to achieve race and deadlock free concurrency
    4. Leverage static-type checking to encode type-state at compile-time to eliminate issues such as taint or locking
  2. Leverage new language features that improve on Java:
    1. Get easy concurrency using Scala collection libraries’ parallel collections and methods
    2. Type less and grok faster with type-inferencing
    3. Imagine interfaces but with default method implementations
    4. Get a value from all statements, including if and try
    5. Auto-generate bean-style objects using case classes
    6. “Switch” on anything — not just int
    7. Restrict the allowed types of a generic class
    8. Reduce complexity with type-aliases
    9. Put more than one class in a file
    10. Import packages where it makes sense
    11. Easily refer to classes with the same name without typing the entire package name
    12. Type XML literals straight into your code
  3. Build on the best of Java’s features:
    1. Don’t give up static-typing and auto-completing IDEs
    2. Keep all the benefits of the JVM – portability, JIT, garbage collection
    3. Call any existing Java library from Scala with no extra work
    4. Call new Scala code from Java with only a little of bit of work
  4. Learn functional programming AND be productive at the same time:
    1. Code functionally as you learn
    2. Code immutably by default but be mutable when you need it
    3. Use functions as first-class objects
    4. Program with functional idioms to embed semantics into your code
    5. Use currying and compose partial functions
    6. Delay computations until when you need them
    7. Create type-classes using implicit class
    8. Use for-comprehensions and monads to do things you never imagined possible
    9. Fuse functional-programming and object-oriented programming
  5. Extend Scala with your own DSL:
    1. Override operators
    2. Use implicits to automatically convert types
    3. Stop using parentheses and periods
  6. Discover the Scala community
    1. Open-source libraries
    2. Frameworks
  7. Why not Scala?
    1. Binary incompatibility
    2. Optimization, tools and support are still maturing
    3. Production may suffer while learning
    4. Functional code has a learning curve
    5. Functional code can be cryptic
    6. Functional code has performance penalties
    7. Hard to find good Scala developers
    8. Real-time computing

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">