Collaborating on scala for newbies guide?

I’ve heard frequently that scala is not a beginners language. When looking at the online coursework and classes for scala I frequently see them marked as requiring intermediate or advanced programming skills.

I would like to write an introductory scala text for people who haven’t programmed before. I think that while scala has a great deal of depth, it is very possible for programming newbies to start with the language.

Would anyone want to contribute to such a thing, or help proofread? I’d be grateful if so.

2 Likes

These things do exist, but they might not be in the places you are looking. The reason is that a true novice, who has never programmed before, isn’t just learning Scala, they are learning to program. The learning to program is actually the primary goal. The fact that they are doing it with Scala is secondary. This means that they have to learn how to break problems down and think algorithmically. Those things have to be learned no matter what language is used.

So what you are really looking for is an introduction to programming using Scala. There aren’t a lot of options for this either, but there are some. For example, here are my own materials for CS1 and CS2, which assume no previous programming experience.

Note that the books are textbooks that include exercises and a lot of descriptions of things that would be significant for any programming language. I’m currently working on a 3rd edition of the books using Scala 3, but progress on that has been slow.

One key thing that I have to point out about my materials is that they aren’t purely functional. I think that it would be really good to have an introductory textbook that uses Scala and uses a more purely functional approach.

5 Likes

Daniela Sfregola’s recent book “Get Programming with Scala” (Get Programming with Scala) assumes less programming experience than some other books, but perhaps you have in mind to assume even less.

And have you looked at “Atomic Scala” by Dianne Marsh and Bruce Eckel? It’s not mentioned much these days since it hasn’t been kept to up-to-date (no new edition since 2015), but it would definitely be worth looking at for inspiration.

2 Likes

There’s also Creative Scala, which expects a little programming experience, but not much, and can be used with none if there is a little tutoring help. (We use it for ScalaBridge with reasonably good success.)

3 Likes

basically what I want to achieve is what people have with python. it’s easily recommended as a language for newbies because it has a wealth of tutorials and guides geared towards people who’ve never programmed before in their lives.

2 Likes

I think that would be wonderful, but it is a really heavy lift. Python has so many resources because a huge number of people have been making them for years. I wrote the first edition of my textbook and started posting videos about 10 years ago, but the vast majority of the work that has gone into Scala has been aimed at more experienced developers. As far as I know, no other textbook has been written using Scala for introductory courses.

When I think of things that are doable, it might be helpful to have a “beginner programmer” section on the Scala website (Documentation | Scala Documentation). The “First Steps” section has links for online materials and books, but none of those include the materials that have been mentioned in this thread. Just giving them more visibility would be an easy first step.

I should also point out that Kojo Home stands out in my mind as a Scala programming effort aimed at novices.

2 Likes

I agree that the misconception that Scala is not good for beginners seems frequently held. I have created open source beginner teaching material for Scala at university level and also contributed to material for kids for the Kojo project.

I’m currently teaching 200+ beginner students at our computer science and information technology programs each year for first-year university students at the engineering faculty of Lund University. The teaching material is in Swedish but from the code and using google translate I guess you can get an idea of the progression that has been tested and adjusted over 6 years now and this year updated and given for Scala 3. The course comprises one semester (14 study weeks, 2 exam weeks) with a theory module, exercises and labs for each week. Here are some links:

Compendium: https://cs.lth.se/pgk/compendium
Experiences reported at Scala Days: https://youtu.be/ii_sC1TfpZY
Youtube channel: https://www.youtube.com/playlist?list=PLEV42dlCGAJ-A-F15fVPcTNhHgO3VU7mc
Course home page: https://cs.lth.se/pgk
Github repo open course material: https://github.com/lunduniversity/introprog
Github repo simple-to-use libray for beginners used in weekly labs: https://github.com/lunduniversity/introprog-scalalib

I really think a beginner programmer section would be great, both for young learners in primary and secondary school, as well as adult persons. And if I can steal some off hours from my teaching day job I’d be happy to contribute.

3 Likes

Hi! Nice topic!

Mark makes an important point about how teaching a language to complete beginners means that the teaching of basic programming comes first and the language is mostly just a tool to that end.

I completely agree that Scala can be wonderful first language under the right circumstances. I also agree that the perception that Scala is too complex is harming adoption. I do think it’s true, though, that an introduction to programming in Scala needs to be particularly carefully designed, compared to, say, Python (not that doing a good job of it is trivial in any language).

If there is an effort to create or curate materials for beginners, I would be happy to read and comment, at least, although free time is always scarce.

And if we’re listing existing beginner-oriented materials in this thread, perhaps I can bang on my own drum. I’ve taught the basics of programming in Scala at university for close to a decade now, with intake of 1000+ students a year currently. Roughly half of the students are beginners. Most of them are our own university students, but about a quarter are external students who take the open-access offering of the course. I use my own materials, which aren’t in the form of a traditional textbook but an ebook/website (free to access by anyone). Some of its features are:

  • It’s designed with beginners in mind and influenced by research on computing education as well as detailed feedback from thousands of students.
  • Its main purpose is to support a semester-long programming course, but there are some students from Finland and elsewhere in the world using it for self-study at their own pace.
  • The material is meant to be self-contained: students don’t need external materials to do the course. It’s hundreds of thousands of words long, so corresponds to a big book. (Well, two big books, since it’s available in both Finnish and English.)
  • The chapters contain various interactive components, such as autograded assignments and stepwise visualizations of program execution. Still haven’t gotten around to Scastie integration though :slightly_frowning_face:.
  • In addition to a bunch of IntelliJ modules that the students work with, supporting software includes a plugin that lets students submit directly from the IDE and a custom library with tools for 2D graphics and animation, MIDI sound, and other things.
  • We’re not even close to being purely functional, but the functional goodies of, say, the collection framework are very much present, and themes such as mutability vs. immutability do come up many times.
  • The ebook’s in Scala 2 for now, but next year’s edition will be in Scala 3, which is something I’m currently busy with — loads of work ahead still!

(At some point in the future, it would be nice to create a version that doesn’t explicitly link to our specific course arrangements anywhere; maybe something like a still improved version of what Runestone Interactive has for Python and some other languages.)

In case anyone is interested in looking at our stuff in more detail, here are some links to different parts:

3 Likes

@MarkCLewis @juha Nice that we are at least 3 university lecturers in this thread :slight_smile:
I agree @juha, @MarkCLewis that one of the most critical choices is how to design the progression based on a beginner-viable subset of the Scala language.

This is the progression that we have currently in our first course, after adjusting it over several years in the context of our second and third course progressions (translation of themes to English in the following table):

There are links to the slides of each week in the table below. All slides in one file here (in Swedish, but there is code and some terms in English):

In the Function-week we show recursion and explain what happens with the call stack when a function calls itself, but being able to effectively use recursion is not part of neither the learning goals nor the exam in the first course, as the second course focuses on recursive data structures and recursive algorithms among other things. The first course focuses on understanding how to use standard data structures rather than implementing them. It is my conclusive experience that recursion can be challenging for a large part of the human population and I prefer to wait with that until imperative iteration using while and functional iteration using for comprehensions and map is understood in-depth by the student. But in official course material on the Scala-lang web, recursion must ofcourse be included, but for the no-pre-knowldege-assuming version I think its should come as a second more advanced part.

Also the API design part (W11 above) is to explain the rationale behind a “good” api, rather than focusing on advanced design concepts, as our third course includes design pattern – but I think it is important for a beginner to understand that there is a trade-off among quality goals such as flexibility, readability, performance and other aspects of api usability.

An important point to be aware of is that the week themes above do not exclude iteration of the same concepts before and after that week, and this kind of iterative approach has been made significantly easier with the “lean and mean” Scala3! For instance, we introduce simple enum types already in W02. I’m surprised how top-level defs and optional indentation has impacted the learning speed, esp. in the beginning, but also throughout the course as conciseness and syntax simplicity balanced with just the right explicitness seems key to learning and self-efficacy.

@markehammons Do you think the progression above would be a good foundation for a series of markdown beginner pages? Note that the headings are general computer science and software engineering concepts, not very specific to Scala and I think a beginner series should have some ambition to teach programming not just the language constructs – a pure language constucts enumeration will not help the learner to apply the concepts in the context of system development…

@SethTisue Were is the best place to start building a structure of markdown things – in the official :scala: docs repo somewhere (where?) or in a separate repo? Should we use Scal3doc with sbt-compiled snippets or how best to integrate with existing docs while using “future-proof” tech for this?

3 Likes

Also, here is our Quickref for Scala 3 that I’d be happy to contribute to the :scala: web: link to source.

1 Like

We have deliberately through our course used the pedagogical approach of contrasting (learning through explicit awareness of similarities and differences) where e.g. functional and imperative solutions are compared and contrasted, as well as immutable and mutable approaches. I think the paradigmatic pragmatism of Scala and the power of understanding a concept through contrasting would be an interesting path to follow also for an official “newbie guide”, esp. since the knowledge that the learner gains provides increased conceptual understanding that can be more generally applied when learning and inter-operating with other languages. So “pure” might be too limiting IMHO.

2 Likes

That is similar to how I teach CS1, pointing out the differences between imperative and functional approaches. Not everyone who teaches the course does that though and not everyone in the department is happy with it. Some feel that it adds complexity that is hard for the novice to understand. I’m not convinced of that myself as I’ve been doing it for longer than anyone else and I don’t feel that I’ve really run into a lot of problems with it.

2 Likes

I also teach programming at the college level (software engineering), and I do use Scala in my classes, although so far only at the more advanced levels after the students have already had a lot of Java experience. One problem I’ve had with getting students to use Scala in a functional way is that it looks too much like Java (Scala 2 anyway). It is very, very easy for them to think like a Java programmer and lean heavily on the imperative style they are used to using. I’ve often thought that teaching Scala up front and presenting a more functional style as “normal” might produce better programmers in the long run. However, the culture here, and I think at many other schools, is heavily biased against such an approach. Java and Python rule supreme as first languages in introductory courses.

I have always thought that if you put down some fairly simple rules for Scala to enforce students writing functional code: no var, no collection.mutable, no while/do-while. However, I’ve never done this and it seems that you have. Can you tell me what I’m missing? I’ve considered using Scala for a purely functional class and I’d appreciate your experience with that.

While the dominance of Java in CS1 is something that annoys me a bit, it is the rise of Python that I find truly disappointing. The sirens call of Python for many is that it is a “simple” language, but I truly don’t believe that is true for the novice and Python is lacking for many of the concepts that I want to teach in CS1 (types, scope, mutable/immutable) that I see it as a horrible introductory language. I’ve written a bit about my thoughts on this. None of it is that original, but if you have any interest in arguments to present to your colleagues, it might include something that you can use.

We are in the middle of a curricular review and I’m very fearful that the sirens song of Python as a “simpler” language is holding sway on many of my colleagues. I also know that some of them question the value of teaching imperative and functional at the same time and I think there might be a push to a purely imperative approach. Of course, every language out there other than C includes lambdas, filter, map, etc. So I’m not certain there are many “purely” imperative options out there in reality.

2 Likes

I’ll note that this is how I always teach Scala in my working-programmer environments. (That is, I don’t teach college classes per se, but I wrote some training courses during my consulting days, and I do a lot of tutoring of new Scala engineers at work, which has been largely pure-FP environments for the past couple of years.)

Really, just breaking people of the var habit tends to go a long ways towards reorienting their thinking – it forces them to ask the right “but then how can I do this?” questions.

Thanks for these resources. They look great. I have tried to do the “no var, etc.” route. In a fair number of cases, the students ignore it and use vars anyway. I take off points, but it doesn’t dissuade them. This doesn’t apply to everyone, of course, but it does to a surprisingly large number. I suppose I could be harsher and just refuse to accept their work. I haven’t gone that far as yet.

I have a colleague who teaches functional programming using Haskell and there it is the functional way or the highway. The students start off hating it with the heat of the burning sun, but some of them do eventually come out the other side with a good understand of the benefits of functional programming.

I think the progression sounds good. I’ve been reading through the posts here and thinking about what I want to do and how. I think a beginners section on the scala website that is geared towards people that are completely new to programming is a good idea, and I think some youtube videos on how to install VSCode, Metals, and instantiate a template project is a good step forward.

Another thing that would probably help is jupyter worksheets in repos that are set up in vscode. I tried almond and it worked very well for scala 2 and seems like it would be a good alternative to reliance on scastie (especially for homework/worksheets)

regarding progression, I think pushing to have an immutable only course path would be helpful. I think starting with mutability starts people off on a style of programming that is really better suited for high-performance optimization rather than the standard logic of your program.

1 Like

Interesting. I wonder if this is actually easier in the work environment, where a var will usually just get your PR bounced – no grading, just a flat rejection. (That’s not quite true – I will occasionally allow function-local vars if it makes life easier – but in general I don’t allow var members, period, in business logic.)

It seems to me that if it is a course on functional programming then using var or other non-functional approaches should result in losing pretty much all points. Granted, I’d do that with the option to resubmit. That only works if the process is automated or you have small courses. I am fortunate to fall into the second category.