Why Scala is the ultimate teaching language

It is not ideal foundation at all. But it is a life. There are many reasons and it is separate theme.
I can say that many of our employees do not have good CS education, but they are good workers.
I can hire a junior if he is good in advanced mathematics and can manipulate pointers.
So the only think he should do it is to spend one day on reading Introduction to Algorithms,it is very easy if someone has suitable brains.
Of course he will have low salary and he will be able to become expert only in 5-10 years it is not cool, I can say it is sad.
Good CS education can save at least three years.

But there are really many people who did not have luck to get good CS when they were young, and It is not necessary that situation will change at least in my country.

Java’s collections contain all kinds of magical operations, like get on HashMap. This obscures all sorts of critical algorithmic details. We’re talking about beginners here. They should be forced to think about a more basic way of organizing data so it can be efficiently accessed. Furthermore, Java blithely obscures critical and difficult resource management issues, like making sure you have adequate memory. Beginners should be forced to think about the basics like resource utilization and recovery. Clearly, Java is a poor choice for a teaching language. We should use C.

C’s standard library contains all kinds of magical operations like malloc and fopen and printf. Surely beginners should be forced to think about how hardware is structured and how device subsystems are controlled at a fundmental level by microprocessors, and the challenges of maintaining a “heap”, and the overhead of complex formatting. Management of stack frames is critical for properly functioning code, yet C prevents the student from learning how this works. Clearly, C is a poor choice for a teaching language. We should use assembly.

So, why is your argument true, but my two are not? (If you think they are not.)

(That assembly–without macros, mind you–is a cheat on machine code is not the same kind of argument; a low-level assembler gives you complete access to everything machine code can do, and basically nothing else save readability.)

If you mean understand in exhaustive detail, that’s true. But neither is get on java.util.HashMap easy to understand.

It’s really easy to understand otherwise.

  • takeWhile produces a new collection by going in order, testing each element until the condition fails.

  • You can call the element being tested _ if it’s in a simple expression.

  • != is the simple way to write “is not equal to”.

That’s all you need to know to fully understand the semantics of the operation. You won’t understand the implementation details, the runtime performance, the memory allocation, how the result is stored in temporary registers, the way in which _ != "stop" is syntactic sugar for new Function1[String, Boolean] { def apply(s: String) = s != "stop" }, nor will you understand anonymous classes of which this is an instance, etc. etc…

But you’re definitely learning to program.

I don’t think so. I’d level the same charge against you. If you understand that sqrt(x) is a new number that has a property that it times itself is x, you’re most of the way towards understanding what map does, for instance.

The whole idea of mutability–you need a place to store something, and you’re going to reuse it by applying a function to it and then writing the new value in place of the old–is more complicated than, and built upon, functions.

You don’t get complicated until you start caring a lot about purity etc…

4 Likes

+1, you are right.
especially if you were happy enough to meet with such wonderful book as

All examples in the books use a language called “MIX assembly language”.

It is really great book. :wink:

I love The Art of Computer Programming, but these days starting out learning from that is kind of like teaching a three year old about set theory and trying to teach them two is isomorphic to the von Neumann ordinals 0 = {}, 1 = {0} = {{}}, 2 = {0, 1} = {{}, {{}}}, 3 = {0, 1, 2} = {{}, {{}}, {{}, {{}}}}, ....

Just learn to count, first! Worry about the deep structure and relationships with more fundamental-seeming types of mathematics later.

Or it’s like starting your cooking classes with metallurgy, where you learn how to mix various compositions of steel to get knives and other implements with different properties. You can make really tasty stuff without having to worry overly much about the difference between 420 and 1095 steel.

Again, I think learning to think deeply about algorithms is very valuable and should form a core requirement of a computer scientist’s education. It just doesn’t need to come first.

5 Likes

Functional programming, which is a form of declarative programming, is an additional abstraction layer on top of imperative programming. The basics of computation and the “problem solving” that programming is all about are imperative. Sure, there are some applications where a declarative language is easier to grasp at first – and actually databases might be an example with SQL – but I’d argue that this is not the general rule for computation as a whole.

I highly recommend watching this introduction to CS and programming from MIT, 2008. I would say it’s worth watching from the beginning, but the relevant part starts at about 17:50.


My argument is when you teach about collections you need to explain what is a collection, what are the most basics of operations it has, and start growing from there. This might seem like an “arbitrary” level of abstraction to start teaching from, but it seems to be very easy to grasp for most (without going into why).

Note that even in your example, the monadic operation (takeWhile) cannot be explained unless you first understand the more basic ideas of what is a collection, how to get a value from it, iterate over it, and construct new collections. It requires more steps than just getting or setting a value. It is an additional layer of complexity beyond the basic operations. It might be easy for some to grasp, but in my experience even the basic concept of a loop is troublesome for beginners at times.

I really don’t see the relevance of sqrt to understanding a monadic operation such as map. Are you implying that recursion is the connection between them? Because a monadic operation doesn’t have to be recursive – that’s an implementation detail – where’s it is the definition of sqrt is recursive, not the implementation.

I also don’t see how mutability is more complicated than functions (and these aren’t exactly on the same abstraction level). It may be true in a mathematical setting, but not in a programming one, where one is expected to implement an imperative “solution” to a declarative “problem”. I’d recommend you watch that section from the MIT lecture I linked earlier in this comment.


Well, not quite. You have to choose a certain point on the “abstraction spectrum” to start from. Collections seem like a fairly good start to me as we still mostly keep the idea of collections of data when we solve most of our programming tasks and problems.

Perhaps I’m not quite concerned with this, as I frankly believe this is not the best way to go about learning how to program. I believe a much more focused and dedicated program is better. I am of course very “biased” as I never participated in any academic program, and my best learning experiences where always the ones where I was focused and constantly being engaged.

I agree with you that teaching multiple paradigms is crucial for beginners, but it doesn’t mean that there is a magical way to condense all of these concepts into a program with the same time and resources. I also think that FP might very well be on par with OOP – or even simpler – but is definitely more advanced than basic imperative programming.

I might even prefer teaching FP over OOP if I needed to make the choice. But then I’m not so sure if Scala is the best fit as it’s not purely FP and does have a lot of OOP influence that can’t just be ignored. I’m not too familiar with other FP languages, but aren’t there ones where FP can really be focused on without all the OOP mess?

P.S. you sound like a really good teacher :slight_smile:

1 Like

Having cut my teeth on Hypercard when my age was in the low double digits, then having gone back after a decade-long gap and started re-learning in C in college, I’m skeptical about there being any particular importance to where on the ladder of abstractions a student starts.

What I know is the most important things are the ability to make the computer do something visible, quickly, and the ability to feel like you’ve mastered the corner of programming you’ve been exposed to. The students who felt they had some control over what the computer was doing kept at it. The ones who felt like they were muttering gibberish incantations into the void dropped out quickly. Even if, at their level, it’s an illusion, cultivating a feeling of mastery is key.

Can you do that in C? Yes.
Can you do that in Basic? Yes.
Can you do that in assembly? Quite a bit harder, but possible.
Can you do that in Java? Not quite as hard as assembly, but not trivial either (there’s a lot of boilerplate, and it’s mystifying until far too late in the semester).
Can you do that in Scala? Yes, and with the possible exception of Basic on DOS, probably easier than any of the preceding languages.
Can you do that in Logo? Yes, and as it’s most prominent feature (turtle) is about the best tool I’ve ever seen to provide this feeling, it’s position as a favorite for teaching kids is entirely unsurprising.

Ultimately, in an introductory CS context, the standard collections library doesn’t matter that much because students can (and should) hack together a simple linked list in a an afternoon and use that, and they’ll learn much more from it. Then, when the standard collections are introduced later, they’ll have a framework for understanding what they offer.

1 Like

It’s definitely one of the most important things, but it’s hard to say it is the single most important one. Some students need more encouragement than others. Some programs are more engaging by other means (university courses are probably the least engaging by nature).

I would also argue that this is probably true only for the very beginning, but that there are topics which are important to learn and it’s a little hard to visualize them. I don’t think there is a specific language that is better at visualization of these concepts – it’s all a matter of which libraries you choose and how much setup you put into your exercises.

Some of the “educational languages” are just exactly that; a well thought out platform for visualizing these concepts with exercises. There are even some products that tailor the technology to the learning material (one such example is CodeMonkey).

1 Like

I could be wrong, but that sounds to me like: “it’s harder for some people to get that feeling of mastery than others” - which I absolutely agree with, it’s much easier if you have a background that lets you skip some steps. Other things are definitely important, but stuff like bad habits a student picks up along the way are sort of a non-issue if they don’t have the motivation to stick around long enough to pick up habits of any kind.

At both of the colleges I studied CS at, there was at least a 50% drop off after the first and second CS courses. After that, it was pretty stable - though we still lost one or two each year or so. If that’s because the feeling of mastery is less important as you get further in, or that by that point only the people who find CS intrinsically rewarding were left is debatable.

1 Like

Scala is the ultimate learning language.

3 Likes

This reminds me of a quote I heard once. “There is no real teaching if there isn’t learning.”

2 Likes

I think you’re missing my point: we are teaching Scala to that third group. That’s a substantial part of what ScalaBridge is about – we are teaching Scala, specifically FP-flavored Scala, to absolute beginners outside of a school environment. It works, rather well, and it’s not especially hard. If anything, it’s easier in some ways than teaching that to existing OO programmers, who are sometimes resistant to the FP approach.

This is why I find this whole “Scala is bad for beginners” argument hard to understand. We are using it to introduce beginners to programming, in many places, run by many different branches. So to my eyes, it seems empirically incorrect to say that this is a problem…

3 Likes

I have never said it. Is it a question?
I think it would be a bad question.
I have never seen people from the third group which have chosen scala as the first language. So I have feelings that the most people don’t choose scala for that. Am I wrong?
The right question is why do not they choose scala.

I have not met any problem with such languages as java and plsql either. What does it prove?

I’m curious how you introduce interactions with files or users in an FP-flavored class.

1 Like

Quite coincidentally, a very similar discussion started two weeks ago on the “Technion Confessions” Facebook group; same idea as with the “MIT Confessions” group, but for Technion students (top ranked university in Israel, oriented towards technology). The discussion was in Hebrew, so I took the liberty of translating some of it.

An anonymous “confession” reads as follows:

Studying Computer Science Semester A. I don’t understand anything in the introduction to CS. Why they teach C language in the introductory course and not Python? C is a terrible language! Why should someone who has never encountered programming get traumatized at the beginning? Which programming language do you think is best for the introductory course?


Shahar Zivan replies (197 reactions):

A bit more serious answer -
Nobody cares if someone who never encountered programming will be traumatized at the beginning. The purpose of an introduction to CS is not to sell the profession to you. If you are there, it’s assumed that you already want to learn it (moreover, many first-year courses try to do just the opposite of selling the profession to you - filtering out people who are not fit or those who the profession is not suitable for them).
The purpose of Introduction to computer science is to teach you the basics of computer science, and C is an excellent language for it because it’s low enough enough to understand how things work behind the scenes and high level enough to allow algorithms to be conveniently written in it.

Guy Tamir replies (34 reactions):

In my opinion, C or Java are better to understand the principles in depth.
In Python there are many shortcuts (which hide the principles), that are very convenient for work - such as the fact that variables don’t need to be defined.
But it is far easier to switch from any language to an python while the opposite is harder I think.

Yoav Haleva replies (32 reactions):

Because you are studying computer science.
Not programming.

Yam Mesicka replies (26 reactions):

Hello. I’ve been teaching Python for about a decade, and some of the industry for quite some time now. This question is one of the most difficult and common questions in programming teaching. Contrary to some of the comments, in my opinion a language’s distribution in the industry, how well its performance is or how well it is built architecturally are near negligible considerations from the pedagogical aspect.
The benefits of Python over C are quite eye-catching. It’s designed for fast everyday writing, it is comfortable and helps to achieve results easily. The reasons to use it over C in this learning context is that students get a quick sense of working code (this positive feedback is important), enjoy the building in small steps of their logic (no significant barriers to learning, the basics can be learned pretty quickly and all the weight of learning falls on building the student’s logic of coherent assembly of units, code organization and programming terms), and the handling and wrestling with small errors is significantly lower than C, so things that are relatively frustrating are left behind. Some would argue that Python is better for algorithmic studies, for example, because it simplifies a lot of non-essential CS principles for writing an algorithm.
In contrast, C is a bit tougher language. While not blessed with the abstraction that Python provides, it has many important computer science concepts that in Python one has to dig a lot to reach. It is much more convenient to understand the idea of pointers, for example, or the idea of organizing memory. Another argument is that once you know C it is relatively comfortable to switch to any other language, but that is certainly not a convincing enough pedagogical argument. An argument I have recently heard from many university students - wanting to make those who do not fit it drop out quickly, and for this purpose deliberately hardening the learning experience.
In any case, I’m convinced they thought about it a lot and that the Technion Faculty of CS did not make this decision by rolling a dice. Personally understand the venting out, but there is a chance that for the Technion students this is the right pedagogical choice. Good luck in the degree!

Uri Dekel replies (3 reactions):

OK. A serious reply from a (very) former teaching assistant supervisor.

  1. The Technion teaches computer science from electrical engineering viewpoint rather than math, so the whole curriculum is built towards the direction of hardware / computer engineering. It means C language and ASM instead of a high level language like Java or Python.
  2. All the material at the Technion is and has been prepared since the early 1990s. It is rare to change a Technion course only because there are other languages.
  3. Most of the companies that hire students from the Technion for a student job (and later on full time) wanted students with a background in C and C++. What do you use today in Intel / Verilog / similar?
  4. A language with memory management is also important afterwards for teaching of data structures and such courses. I’ve taught similar courses in Java and I can say that students have no basic idea how to implement the data structures only how to use existing ones

Lior Alafi replies (27 reactions):

It is a fatal mistake to teach Python at the beginning, Python is not type safe, it has no affinity to memory (pointers) and it hides from the user a lot of real world problems, Python is excellent at what it does, it’s an easy language and the development speed in it is great but usually people who are formerly learning a language like Python have less understanding of things like stack, heap, etc and only when they come to some C / C ++ shit course they don’t really understand (again in my opinion), a person who studies C and Assembly first understands how things work and later can enjoy the many shortcuts that Python provides and most importantly - when needing to go to low level. In my opinion learning also Assembly is equally important (and I even got to solve problems in my work using a combination of C and Assembly), another thing is that learning a language like C makes you more careful programmer. These are good enough reasons (I think) that those who are not being taught C as “a first language” should actually start with it.

Waseem Makhoul replies (8 reactions):

Because the Linux operating system (which you will learn in operating systems in the future) is programmed in C, so this is why this is one of the most important reasons to learn C language from the beginning.

Anton Zaslavski replies (8 reactions):

Because Python is a language of slackers.
You do not declare variables and which types should return from functions because everything will fine and who wants to bother with that.
There is nothing to talk about efficiency, a language that encourages slow and inefficient code all that’s important is that it works.
And the cherry on top comes when you write multi threaded code and finds that Python has one huge mutex over the entire interpreter that needs to be grabbed as long as the thread runs code that does anything with Python variables, which basically means that all of your threads run sequentially instead of concurrently.

3 Likes

I (hopefully) will undertaking this experiment.
I will have about 10 high school students for 2 weeks.
I plan to show them what I am calling “Advanced Mathematical Concepts and Functional Programming.”
The idea is that we’ll discuss mathematical problems such as Taylor series computation, and computing area under the curve using the trapezoid rule.

This is best modelled (in my opinion) in a functional language, because integrals and derivatives are indeed functions which take functions as arguments and return back functions.

My special restriction is that I need to use an all web-based development environment. I don’t yet know whether that is possible, as the IT department is hesitant about installing development tools for the students. I’m still investigating the best web-based solution.

I’m happy to report back my experience, whether it was successful or a failure.

3 Likes