I wanted share this blog post by Jason Lee Hodges on why he thinks Scala is the ultimate teaching language.
I wrote a longer post about why CS1 should be taught using Scala earlier this year. In particular, I think that the move to Python is horrible for introductory computing. Scala has all of the advantages of a scripting language and none of the drawbacks.
As I’ve never taught CS-101, I’m really interested to know whether this is true or not. I’m open to the idea, but I have some healthy skepticism as well. There are quite a few things in Scala that make life difficult for the beginner. No doubt, there are many powerful features. I can imagine it would be pretty hard to put oneself back in the place of a student taking CS-101 for the first time.
In the meantime, I’ve ordered Mark Lewis’s book, and I’m looking forward to reading through it.
See a related talk at Scala Days 2019, “Scala First: Lessons from 3 student generations” by Björn Regnell
Yeah, I read your post a few months ago Mark and I thought it was really good.
I cannot agree less with this article.
First, it presumably addresses people who wish to learn programming on their own, in which case I believe it’s most important to keep yourself engaged and not get lost. Having a good and comprehensive guide to work with along with an easy-to-operate-overhead-free technology is at a top priority. I don’t think that’s the case with Scala at all.
As for a guided learning program, I think that it’s better to learn more than one language. It’s much easier to learn different aspects of programming using specialized and focused languages rather than trying to learn it all in one mish-mash of a language. Scala has too many options, too many styles. It would be confusing for a beginner.
The other disadvantages the article points out about dynamic languages (performance, refactoring) are completely irrelevant for beginners. Also, the job market for Scala looks even less promising for beginners, as your competition for that junior Scala position is probably with non-junior programmers who simply have no experience in Scala. The most peculiar point that was brought up is the overhead of the Java ecosystem – it’s exactly the same or even worse with Scala!
No, I think Scala is a worse alternative than others to learning programming. Start with something simple and easy to grasp; Python, JS, Logo, what have you. Teach OOP with a language focused on that paradigm; Java, C#, etc. Teach functional again with a language focused on it; Scheme? (that was my experience). Lower-level aspects can be taught with languages such as C++ or even ASM; they are optional in my opinion, but are definitely worth it if there’s time.
In the presentation, I didn’t understand why they use Scala just for the first course, but switch to Java for the second. Is it because the simply have not converted the second course yet?
Trying to learn Scala without understanding the Java ecosystem is indeed difficult. There are many things that can go wrong. So if someone, on top of that, does not even know programming, I wonder how he will cope.
I would rename it:
- What Programming Language Should You always learn
I think that first language very depends on practical aims which you want to achive.
Python is very good for implementing daily automation for example.
But scala is the best static language for productive high level development.
So you can learn it first, you can learn it second, but you should just learn it.
The problem I often see in these discussions is that people really don’t remember what a true beginner programmer is like. Learning a language is secondary. A true beginner is learning conditionals, iterations, problem decomposition, and the general act of logical problem solving. I have seen nothing that indicates that learning how to use an
if or a
for in Python or JS is simpler than in Scala when writing Scala scripts. Java has an overhead problem because of all the extra stuff that goes along with creating a class with a main, but when you are writing Scala scripts, the Hello World program is one line with
println("Hello World"). It is no more complex than Python.
The other thing that rarely comes up is that after that student has a grasp on the logical program solving, what matters most after that is topic coverage. Personally, I think that the concept of types is critical in programming and I want to stress it early. I love that in the Scala REPL when you enter
4+5 you get back something like
res0: Int = 9 instead of just
9. Indeed, one of the things that students struggle with early on is the difference between printing a value and giving it back as a result. The fact that the Python REPL gives the same feedback for
print(4+5) is something that I see as very problematic. Note that I’m not even addressing JS because I think the implication that JS is “simple and easy to grasp” makes no sense at all.
The observation that people need to learn multiple languages is a good one, but it ignores the fact that learning some language B after learning a language A can be easier or harder, depending on those two languages and how related they are. My daughter was a TA are Rice where they start with Python and then go to Java in the third semester. She commented on how students had problems both with type and the concept of scope when making that move and it slowed them down. Python, and most other scripting languages, allow sloppy programming and if you get used to things working when they are sloppy you will struggle when you move to a language that is more strict. I would also argue that someone learning to code should learn languages in different paradigms so that they have a broader view of programming. Learning Java then C# then several other imperative-OO languages is mostly a waste of time. One thing the first language can do is to set people up to be successful in learning multiple other languages later by giving them a nice point to take off from to get to the other languages.
The last thing I will note is that for a beginner language you shouldn’t judge complexity based on the full language that you, as a professional developer, see. Instead, you need to judge it based on what language features force themselves into the introductory curriculum. Languages like Java and C++ are horrible here. My standard example of Java is that I want to do examples where the student reads a String and we need an int. I also inevitably run into places where we have a double and we want an int. Why is one
Integer.parseInt(s) while the other is
(int)x? That’s very hard to explain to the novice. Similarly, I’m going to go beyond arrays to collections in CS1 and them I’m forced to explain why they can’t make an
ArrayList<int>. Those things are forced on me even for solving simple problems. Yes, Scala is a complex language, but my experience in teaching it is that the complexity doesn’t force itself into the CS1 or CS2 curricula. There are a few exceptions, like
ClassTag, but I very rarely get questions from students where I have to say it is because of some language feature they don’t know. I also don’t feel that I have to modify my assignments to fit the constraints of the language or to avoid certain things because students aren’t ready for them. So while the #1 complaint everyone seems to have about teaching introductory programming using Scala is the complexity of the language, I can tell you from actually doing it for 10 years that it really isn’t an issue. It is very easy to stick to cover the material in those courses without bumping into most of the higher-level features.
I’ll conclude by saying that I’m hoping this will still be true in Scala 3. I’m not yet convinced and that worries me a bit.
Strong to what Mark says here. This isn’t all hypothetical – note that ScalaBridge specifically teaches Scala to absolute-beginner programmers, and an observation that I’ve heard a number of times is that the raw beginners sometimes find it easier to pick up Scala than programmers who are experienced in other paradigms.
It’s all in how you teach it. Besides Mark’s book, I also recommend taking a look at Creative Scala, which is a lightweight introduction (that we use in ScalaBridge), aimed at teaching simple FP to people with no programming background at all. It actually illustrates the strengths and weaknesses quite clearly – the only hard part is setting up your environment. Once you’ve done that, most folks seem to find it a fine way to get their first taste of programming…
I totally agree, but I believe Scala just has too much overhead for that task. Not only that it suffers from the more cumbersome ecosystem of Java, but it requires a project setup using a build tool. I don’t expect students to use the REPL all day. Python for instance is much more straightforward.
The “hello world” scenario for Java is insignificant, and I’ve never seen anyone who struggles with it; you just accept it as a boilerplate for every program (at least when you start programming). If anything, I’ve seen students struggle with types – be it in variable declaration or function return type – when they are still trying to grasp the concept of commands that are executed in a certain order (program), a conditional, a loop, a function, scope, etc.
I agree, but again, there are better candidates than Scala I’m afraid – say, Java. Scala is complex, rich with features and syntax sugar (companion objects, clojures, pattern match, implicit, etc). It’s not just third-party libraries, but also the SDK code which is quite complex. Collections for instance are a big wart in the language. They are too verbose, with so many traits of inheritance. I would much rather beginners to learn the usage of collections with Java rather than Scala (but then again Python is preferable for that as well).
Definitely, and this is once again a point against Scala, which is multi-paradigm; It doesn’t have a focus on one paradigm or one style. It’s easy to get lost with it. I’d rather students learn more designated OOP and functional languages.
Scala is simpler than Java on some aspects but more complex on others (especially collections), where’s it’s almost always more complex than dynamically typed languages (like Python). From a beginner perspective, that is.
Just a little comparison:
- Introduction to the art of programming using scala, mark c. lewis
Someone should read 887 pages of theory which I am sure quite boring for true beginners
- automate the boring stuff with python
Someone should read 123 pages of theory, the other 320 pages are about interesting practical tasks
I totally agree, but I believe Scala just has too much overhead for that task. Not only that it suffers from the more cumbersome ecosystem of Java, but it requires a project setup using a build tool.
That would indeed be a problem if it was true. But is it?
Question 1: What does Java use for 1st year teaching nowadays? Manual recompile or also build tools?
Question 2 to @MarkCLewis: What do your students use once they have grown out of the REPL?
Question 3: How can we make the beginners experience simpler, not forcing students to use a build tool? Scala Center’s mission is work on tools for the beginner’s experience. So there’s scope to change things if we know where we want to go!
One is a textbook for students in Computer Science, the other for people who want to “automate the boring stuff”. I’m not sure how this comparison is relevant.
I’ve been a TA in a CS1 course that used Python. When I was the student it was Java. I agree with basically everything Mark said.
Students in their first programming course don’t come into contact with the SDK code, or with every complex feature of the language, or with the entire Java and Scala library ecosystem. That you can let them touch on multiple paradigms with one language seems like a strength to me. Imagine having to learn Java and Scheme in your very first programming course.
My experience is 100% different. Both in my MOOCs and in my life classes people take to Scala’s collections immediately, I never had a problem teaching them in class, and we almost never see people confused about them in the MOOC forums. Given that we had about a million subscriptions to the MOOCs so far, that’s a lot of counter arguments. I believe as always the question is what to teach. I typically teach bottom up. Do just lists first, then sets and maps, then arrays and array buffers (in a separate course). Students find it convenient that they can use the same methods everywhere without having to worry about the overarching collections architecture which makes that possible.
By comparison, I would find Java’s collections a lot harder to teach, and they are not immutable.
It is not relevant in context of computer science. The topic title does not says that it is all about CS. I am sure there are many beginners in the world which cannot overcome a textbook for students in Computer Science at first, I just have given the book which was loved by some beginners which I know.
I wonder how many programmers have good CS education in the world.
May I answer this question from my experience? I was already a programmer with 30+ years experience. I had used C, Python, Perl, shell, and OCaml, but primarily Lisp and Scheme. I had also read two or three books about programming Scala, and had worked many Scala exercises (on codilty.com) where the dev environment was already given and I just had to fill in the missing function content.
The first time I wanted to write a Scala program to do something real, I had a huge body of code in Common Lisp, and I wanted to experiment with Scala with some of the algorithms already implemented in Lisp to see if they were faster or slower to develop and the run. I expected I could just create a
file.scala in the same directory beside the lisp file.
I tried to create it with emacs (being a 30 year emacs user) using emacs scala mode, but this was a disaster. The emacs Scala mode is for expert-expert-expert Scala programmers, not beginners who don’t yet know the Scala language. To use emacs-scala mode you have to install Ensime which depends on swank, but the Ensime version of swank is not compatible with the version of swank I was already using for other things.
So I decided to bite the bullet and use IntelliJ. It forced me to create a huge directory structure that I didn’t understand, and use
sbt (I didn’t know what sbt was). There was something vague called a project which I didn’t find any definition of. There happens to be a directory named
project which turns out NOT TO BE the project directory. And I had to import the project directory into sbt. This was really confusing. IntelliJ (or maybe sbt) also created lots of hidden directories and xml files which showed in my version control manager. I didn’t know whether to add them to my
.gitignore file, or whether they were files I needed to version control.
It took me about a week or 2 before I could finally convince IntellJ to show me the play button, because the Scala file was always in the wrong directory or because I needed to re-import into sbt, and there wasn’t a function called main with the correct type signature in the correct Object definition. It took several months before I could convince IntelliJ to play the scratch file.
Once it finally worked, IntelliJ was great as it showed me lots of things I was doing wrong. It was worth the fight, but it was indeed frustrating and there were a huge set of obstacles before .
The thing that was EXTREMELY helpful was all the knowledgable and helpful people on users.scala-lang.org, who kindly and patiently answered 100s of questions, without calling me an idiot even once, which would never have happened on other internet forums.
Thanks for sharing this! I wholeheartedly agree that we need to do better. We cannot change all of the tools immediately, but we can change some of them and hopefully these will cause other tools to follow. The importance is to put yourself in the beginner’s shoes and take nothing for granted.
I had relatively big problems to accustom scala collection. The scala collection blew my brain until I had read its source code. It was not easy task for beginner
I think the main problem is the bad java collection architecture. When I saw scala code I did not believe it could work effectively until I had navigated to source code.
I think it will be very useful for java developers to have the uml diagram of scala collection architecture. Class hierarchy does not give such picture at all.