Newbie Topic Regarding Scala Build Tools


#1

coming from a enterprise java background, my initial approach to learning scala was to do exactly what I do in the java environment:
I followed these steps:

  1. First down load scala librarites
  2. setup environment variables
  3. figure out how to load scala into Eclipse
  4. figure out how to set up a Maven Job withnin Eclipse to compile and run scala
  5. Use eclipse to learn Scala , in addition use the REPL

And thats it. That is what I have used thus far with success so far.
BUT:
I always hear about SBT and other approaches to learning , building and running scala from people that were not ex java developers.
So I guess my question is:
What are the pros and cons of the various build tools. Is it best to use SBT instead of the way I am currently doing it, i.e. using MAVEN.
Or is it better or easier to use a Gradle as a build tool?
Is Eclipse a good IDE for learning Scala. So far I have used it. It seems ok ?


#2

I would strongly recommend getting used to sbt. While other tools can be used, it’s the 800-pound gorilla – by far the most common build tool, and the best-supported. (Maven is actually quite important, but most folks use it under the hood – it’s essentially built into sbt for dependency resolution. sbt has a specific syntax for resolving libraries by Maven coordinates.) While it’s not strictly necessary, sbt gets increasingly essential as your application gets complex.

There is a counter-argument that sbt is over-complex, and there’s a lot of ferment in this space, with folks coming up with newer build systems such as cbt and Mill. Those are fun to explore, but not yet something I’d recommend to a beginner.

There are some folks who use Gradle, but most of the ones I’ve spoken with who have used both came out preferring sbt.

So pretty much regardless of what IDE you use, I strongly recommend using sbt on the command line for doing your actual builds.

I’m fond of it – it’s what I use day-to-day – but you should be aware that it’s a bit under-maintained at this point, and tends to be a little glitchy. It’s actually not very common among Scala engineers.

(There’s also a project named ENSIME, for folks who like Emacs, vim, Sublime and other editors. But it’s complex, not really aimed at beginners to the ecosystem.)

By far the most commonly-used IDE is IntelliJ IDEA plus the Scala plugin. While no firm numbers exist, I believe it’s used by a comfortable majority of the community. It has its own issues, mainly when you get into the more sophisticated ends of the language, but there seems a pretty good consensus that it’s the best IDE for beginners. (Note that, while the Ultimate Edition costs money, the Community Edition can be downloaded and used for free, and includes most of the really important features.)

Note also that there’s a bunch of recent movement in this area; it looks likely that there will be more good IDE options available in a year’s time. But for now, I’d recommend IDEA to start out with.


#3

thanks …
But …
Unfotunately, I do not know IDEA yet. I guess I could try and devote some time to learning. I actually have a copy of it ( got a free one from a relative that happens to be a professor at a university ) but never seem to have time to learn a new IDE. I just use eclipse so far. Strangely enough, Eclipse seems to work perfectly for me and using Maven. I haven’t ran into any real issues yet. And the debugger works pretty good … not as good as the java debugger … but still pretty good.
On the other hand, I think looking into SBT will be beneficial.


#4

That’s fine – like I said, I use Eclipse every day myself, and I like it. Just be aware that it’s not unusual for it to get a little confused, especially as an application gets large and complex.


#5

Search back a bit, a few weeks?, in this forum about a hellloworld example. That advice is to get sbt and import into IntelliJ. Or just stay with sbt for awhile.

The approach your taking with Eclipse is the “I have a hammer and everything is a nail” approach. Or for another metaphor, you’re a salmon swimming upstream trying to make Eclipse work for Scala, you know the salmon is so tired they die at the end right? sbt is more like swimming downstream for Scala work.


#6

That’s rather over-dramatic. Like I said, I’m using Eclipse routinely, building a substantial and very complex pure-end-to-end-Scala application, and have been doing so for over five years. I would recommend using Eclipse with sbt, using the sbt-eclipse plugin to generate the Eclipse project files. And it’s probably true that IntelliJ is the better choice for most folks at this point. But Eclipse does work reasonably well…


#7

Ah okay well no personal experience trying with Eclipse. Just as far as well worn beginner paths I can count many more in the direction I indicated doing a Google search on Scala and IDE. Perhaps the salmon analogy is overwrought but taking a path less taken when you are new at many elements of a new ecosystem does often lead beginners to burnout faster.


#8

That’s rather over-dramatic.

I agree completely. I’ve used Eclipse on large, complex Scala apps
every day since at least 2010. It works fairly well; I’ve never felt
like I was “swimming upstream”. Refactoring is iffy sometimes, but
mostly ok, but I never get spurious red squiggles like my colleagues
using IntelliJ do.

To the OP, use whatever you’re comfortable with. If you’ve been using
Eclipse for Java work for a while, you’ll be at home doing Scala work in
Eclipse with ScalaIDE installed.

Like I said, I’m using Eclipse routinely,


#9

From a java point of view, the issue immediately becomes this:
All the current java applications are unit tested via some IDE, usually Eclipse; sometimes IntelliJ. In fact, Eclipse and Maven along with Git and JFrog aritfactory are used together via Maven Build files. And when it comes to deployment, Jenkins is of course used and Jenkins has some type of pipeline set up to automatically deploy the jars/wars to artifactory and sometimes directly to the server ( usually linux servers ).
SO … most java people, including developers, managers, project leaders … etc etc are going the BALK at the idea to suddenly introduce some new build mechanism … that is a BIG issue.


#10

Doesn’t java almost always use JUnit?

The same tends to go for scala.

At the moment, I don’t really know what your question is anymore. You’re asking whether the development and build environments you use work with scala. The answer is yes, but they’re not the most common build and development tools for use with scala.

You say that for you, using sbt is out of the question, because it’s not Maven, and your environment is used to use maven to build integration pipelines in.

And that’s cool too, feel free.


#11

Keep in mind, it isn’t as if this is a sudden change or anything – I started using Scala 10 years ago, and it wasn’t brand-new then. Scala interoperates with Java, but that doesn’t mean its ecosystem is identical; it would be quite limiting if it were. Nor is this something that’s odd about Scala. For the most part, different languages favor different tools.

As Martijn says, if you want to keep using your existing tools, you largely can; that makes Scala more Java-compatible than most languages right there. But there are other tools that are better for Scala, because they were designed for it; that shouldn’t be surprising…


#12

Yes … Junit , mokito, selinium , etc etc , but from within Eclipse/Maven and various plugins for Jenkins … ( sometimes Gradle is used also for deploying the applications via Jenkins pipeline … groovy language used to create jenkins pipeline )

I guess maybe I will investigate using SBT from within jenkins,eclipse,maven … there are probably plugins available for that