Is Scala-lang good for beginners?

Hello,
For a newbie user that just familiar with programming languages like C\C++, is Scala-lang useful and understandable? Is it hard to learn?

Any advice welcomed.

Thank you.

1 Like

Useful? Yes.

Hard? Depends on the learner. Itā€™s different in some important ways, so it tends not to be a simple transition. The thing is, while you can program Scala in rather C-ish ways, you usually shouldnā€™t. There is an emphasis on principles like immutability and functional programming that is pretty alien to standard C/C++ style.

So itā€™s likely to be a serious learning experience. Donā€™t expect to pick it up overnight. That said, if you have the time, you may well find it worthwhile: learning Scala well teaches you a lot of concepts that will stand you in good stead in many modern programming languages.

3 Likes

Iā€™ve been teaching Scala to newbies for ten years now. I think it works well. I believe it sets them up nicely for learning other languages and also gives them a good foundation in general concepts related to programming. The challenge is finding good materials aimed at beginners. Most of the Scala resources out there assume that you have coded before. The main materials I know of that donā€™t assume previous knowledge are Atomic Scala (https://www.amazon.com/Atomic-Scala-programming-language-future/dp/0981872514) and my materials (textbook - https://www.amazon.com/Introduction-Programming-Problem-Solving-Textbooks-Computing/dp/1498730957 and YouTube videos - https://www.youtube.com/playlist?list=PLLMXbkbDbVt9MIJ9DV4ps-_trOzWtphYO). There is also a curriculum used by https://scalabridge.org/ to teach people Scala.

One word of caution is that I think it is best to have a teacher or mentor who you can go to, especially as there isnā€™t as much material freely available for Scala as there is for other languages.

6 Likes

I guess you should have some proficiency with Java programming.Otherwise not easy.

Thanksā€™
Sandesh Gitte

I donā€™t think Java knowledge is required at all. Most of the books for Scala do assume it, but it really isnā€™t needed to learn Scala from scratch. If anything, I would argue that knowing Java probably holds a lot of people back when they start to learn Scala. They struggle with the functional nature of Scala precisely because they learned Java first. From that view, you are probably better off learning Scala before Java.

1 Like

My humble opinion is that it is a good language for beginners.
But, as @MarkCLewis said, Scala requires you to have a mentor or follow a good resource.
It is not a language that you can learn just by learning the syntax, this is mainly due to its multi-paradigm nature as @jducoeur explained.

My advice.
Pick some book, course, tutorial, yotutuber, etc, that you find it easier to understand and stick to that until you get comfortable with the language. Then try to solve exercises.
Also, a good thing is that we have a very welcoming community, so feel free to ask questions here or in the gitter channel.

IMO, Scala is a scalable language because we can choose the extent of its usage, in the following sense:

  • Scala can be used in a mutable and imperative way, similar to other popular languages. This could be a useful vehicle to get familiar with basic syntax, tooling, ecosystem, learning resources, and community.
  • Then one can progress to a more idiomatic functional style by avoiding var and imperative loops, which does require a non-trivial shift in thinking about programs.
  • Then one can progress to an even higher level of functional style, by favouring functional abstractions over perhaps more object-oriented abstractions. This level likely requires familiarity with ad-hoc polymorphism and type constructor polymorphism. scala-cats would be an example of a library that encourages these techniques.
  • Then one can shift thinking even further towards type-level side by employing techniques of dependent typing which allow the compiler to verify things at compile-time that were previously possible only at runtime. shapeless would be an example of library that encourages these techniques.

Hence we can choose at what level to work with Scala, and when ready start exploring ā€œhigherā€ levels. Note that the breadth Scala provides is rather unique among industrial languages, which makes, IMO, learning Scala useful and exciting. Useful because you can earn a living by writing programs at lower levels of scale, and exciting because it helps drive industrial adoption of techniques at higher levels of scale, which were previously perhaps mostly within domain of academia.

Regarding things being hard, ask yourself what is your end game? If the end game is to have a career as a programmer, then hardness is an irrelevant concern, because the decades of effort in front of you will chip away at that stone until your understanding is sufficient to address most problems. Even if in the end there is still no understanding, at the very least there will be familiarity and experience to know which pattern to apply when, because we can all see shapes in clouds.

Good luck.

3 Likes

Thank you so much for all reply.
Why a user must select Scala over Java? I think Scala using JVM.

Why a user must select Scala over Java?

For the same reasons you would pick Scala over any other language.
Running on the JVM is not exactly a feature (it may be, it may not), and you actually are not tied to it. With projects like ScalaJS, ScalaNative and GraalVM you can run Scala programs in other environments.

Now, why would someone use Scala at all?
There may be many reasons, including:

  • Its strong and expressive type system.
  • Its mix between functional programming and object-oriented programming.
  • Its ecosystem of libraries / frameworks.
  • Its language features like: pattern matching, extension methods, variance control, etc.
  • It having a REPL.

For me, I summarize it all in a single phrase: ā€œBecause is powerful yet easy to use language which lets me write reliable and scalable software. Scala shines in proving you with the ability to prove most of the correctness of your code at compile timeā€.

4 Likes

I would already choose Scala over Java just because its syntax is much more pleasant, or because its standard library is nicer to work with. Or because it has some basic features that are lacking from Java such as case classes and pattern matching.

1 Like

Can Scala useful for system programming like C++?
On the cover of ā€œAtomic Scalaā€ book written ā€œThe language of the futureā€ , what does it mean?
Rust-Lang is not!!!

Yes, see https://www.amazon.com/Modern-Systems-Programming-Scala-Native/dp/1680506226

3 Likes

Consider these two fascinating talks by Danielle Ashley on Scala being used for Game Boy emulator, MP3 decoder, and signal processing:

ā€˜Inappropriateā€™ applications for Scala

Cobind and Chill

3 Likes

Iā€™m really thankful for all useful helps and great community.
I know with any programming languages you can do anything but in easy and hard way. You can write a GUI App with assembly but write this kind of App with the Vistual Studio is more easy.
With Scala can I write a Twitter or Instagram Bot as easy as Python?
With Scala can I write a program foe connect to a hypervisor like Xen Project?

This is actually a really good question, especially since any general-purpose programming language can be used for almost any purpose. Let me put it this wayā€¦

If you need something simple, and it is only going to have a few programmers, and it isnā€™t going to be long-lived, and it isnā€™t going to need much maintenance, you probably want a language like Python, because it is usually easier to whip something together quickly.

On the other hand, if you need to build something complex, or something that is going to have more programmers, or which needs to live for years and be maintained over that time, you probably want a compiled, strongly-typed language like Scala, which is much less prone to introducing dumb bugs constantly.

Thatā€™s the primary tradeoff, and most problems fall along that spectrum. The more quick-and-dirty the problem, the better a language like Python is; the more complex and long-lived, the better a language like Scala. Python is typically better for easily writing code; Scala is better for maintaining code.

This is why Python is very seductive: it is often easier to whip something up and feel productive, especially if youā€™re new. But writing small programs is the easy part ā€“ keeping it running and growing and improving for years, and building complex systems, is the hard part that people tend to ignore.

2 Likes

Thank you for your opinion.
I agree. Python is easy to learn and write a tool with just some lines of code but it is not stable.
I guess one if the Scala-lang problem is a lack of libraries. For example, most of programming languages have some libraries about Xen and other hypervisors but Scala-langā€¦
Any part of this forum dedicated to feature requests?

While I donā€™t know about Xen per se, in general thatā€™s not correct ā€“ there are a colossal number of libraries available for Scala.

Keep in mind, Scala runs primarily on the JVM, and most libraries on the JVM are compatible with most languages that runs on it. So while the number of libraries for Scala per se is moderate (more than many languages, not as many as some others), it also works with most Java libraries ā€“ and there are more libraries for Java than for almost any other language on Earth, since it is one of the older languages.

(Similarly, Scala.js runs in the browser, and is compatible with most JavaScript libraries ā€“ that is to say, nearly all browser libraries.)

That said ā€“ the JVM is not used much for embedded systems and the like. (Which I suspect is basically the hypervisor world.) For that youā€™re talking about Scala-Native, which is a relatively new project that is still in process. That compiles to LLVM, so I think that there is still an enormous number of libraries you can use, but I donā€™t know that subject as well.

The key point is that libraries are often focused on an environment, not a language. Language-specific libraries are a bit more limited in their scope ā€“ environment-based ones usually work with most languages that work in that environment, and are much broader in their applicability.

Not specifically, but if you have thoughts, itā€™s entirely reasonable to post them here. That happens, and they tend to get some discussion, but keep in mind that most feature requests made before you really understand the language will turn out to be inappropriate for one reason or another. Scala is a pretty carefully-designed language, and adding new pieces without breaking other pieces is harder than it looks. (Also, there is a strong preference to keep the language as slim as possible, so new features generally have to look really valuable in order to get traction.)

1 Like

Scala has yet to prove itself for systems programming. With scala-native, thereā€™s some hopeā€¦but itā€™s a much less obvious choice than C++ or Rust.

Not the language of the future? Rust ought to have a very bright future because it provides something sorely needed (in some contexts) that no other language really providesā€“a good account of ownership.

Scala also ought to have a very bright future, even if it doesnā€™t differentiate itself quite as much as Rust does, because of its immensely powerful abstraction capabilities and flexible approach.

The future has room for lots of languages! But if youā€™re going to pick one language to do everything, itā€™s hard to beat Scala. Except for lacking ownership management (and before Rust, nobody expected that), itā€™s unlikely that the language will ever badly let you down. And for creating powerful, flexible, easy-to-use libraries (like Scala collections), itā€™s better than anything.

2 Likes

Scala has a BOAT LOAD of libraries!! There are a whole slew of libraries that come with the Scala JDK and then you have a vast gold mine of Java applications and systems libraries that can be invoked from Scala code. There are more libraries than youā€™ll know what to do with.

Barring access to the actual hardware artifacts (like registers, physical memory addresses, etc.) what makes Scala so ill-suited for systems programming? With Futures, isnā€™t Scala virtually made for implicit parallel programming on multi-core machines? And with the vast collection of Java libraries, Scala etc., etc. etc.