Over a million developers have joined DZone.

Why I Introduced Scala In Our Project

Why use Scala? what kind of advantages might it have over, say, regular Java? Read on to find out.

· Java Zone

Navigate the Maze of the End-User Experience and pick up this APM Essential guide, brought to you in partnership with CA Technologies

I don’t like Scala, and I think it has some bad and very ugly aspects that make it a poor choice for mainstream development.

But recently I still introduced it in our project. Not only that, but the team had no experience with Scala. I’ll try to explain why that is not a bad idea.

  • First and most important – I followed my own advice and introduced it only in a small, side module. We didn’t have acceptance tests and we desperately needed some, so the JBehave test module was a good candidate for a Scala project.
  • Test code is somewhat different from “regular” code – it is okay to be less consistent, more “sketchy”, and to have hacks. On the other hand it could benefit from the expressiveness and lesser verbosity of Scala, as tests are generally tough to read, especially in their setup phase. So Scala seems like a good choice – you can quickly write concise test code without worrying too much that you are shooting yourself in the foot in the long term, or that multiple team members do things in a different way (as Scala generously allows). Also, in tests you don’t have to face a whole stack of frameworks and therefore – all the language concepts at once (like implicits, partial functions, case objects, currying, etc.)
  • I didn’t choose a scripting language (or Groovy in particular), because I have a strong preference for statically typed languages (yeah, I know Groovy has had that option for a couple of years now). It should’ve been a JVM language, because we’d want to reuse some common libraries of ours.
  • It is good for people to learn new programming languages every now and then, as it widens their perspective even if that doesn’t change their language of choice.
  • Learning Scala I think can lead to a better understanding and use of Java 8 lambdas, as in Scala you can experience them “in their natural habitat”.

As a side-note – IntelliJ scala support is now better than last time I used it, unlike the Eclipse-based Scala IDE, which is still broken.

If writing acceptance test code with Scala turns out to be as easy as I imagine it, then it can mean we’ll have more and better acceptance tests, which is the actual goal, and it would mean we are using the right tool for the job, rather than a hammer.

Thrive in the application economy with an APM model that is strategic. Be E.P.I.C. with CA APM.  Brought to you in partnership with CA Technologies.

Topics:
scala ,acceptance testing

Published at DZone with permission of Bozhidar Bozhanov, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}