What programming language and algorithms should be taught in a first year undergraduate course in electrical engineering

I am a professor at a German university in the Department of Electrical Engineering. Currently, our students take a mandatory course on the C programming language in their first term. Beyond that, there are no required programming courses. In other classes, various instructors make use of languages such as Python, MATLAB, Julia, or C++ (especially in the context of SystemC).

When I was a student, I also had a course on C, as well as one on algorithms and data structures. We covered topics such as memory management, linked lists, sorting algorithms like quicksort, and performed some basic complexity analysis. I appreciated C for its closeness to the hardware, which I felt was well suited to students of electrical engineering or electrical and computer engineering.

However, I should mention that I already had a fairly solid background in C, C++, and even some assembly programming when I entered university. What we observe now is that when students are required to program—often during their bachelor’s thesis—they have forgotten most of what they previously learned. Moreover, if students were not already enthusiastic about programming, being introduced to it through C is unlikely to inspire them. C does not appear to many as a practical tool for quickly solving problems.

I have noticed that at many U.S.-based universities, Python is now commonly taught as the first language. I certainly see the advantages: students can quickly tackle complex problems by using existing libraries. Although Python avoids the infamous “dependency hell” associated with C and C++, students still need to learn about environment management and dependency tracking. However, the time not spent teaching makefiles, pointer arithmetic, or manual memory management might instead be used to introduce version control systems like Git or concepts like CI/CD workflows.

This brings me to a pedagogical question: if one were to use Python as an introductory language, what kinds of algorithms and data structures should be taught? Given how high-level the language is, does it still make sense to teach “classical” concepts such as linked lists?

As a heavy user of Julia, I’ve also considered advocating for its adoption. Julia is a language designed for scientists; it offers modern high-level features while still allowing one to write code that interacts closely with the hardware when needed.

So there are a couple of questions, I am not sure I see the answer:

  • What are the long-term goals of our programming curriculum? Are we aiming to train software-literate engineers or to support algorithmic thinking for hardware specialists?
  • If we choose a high-level language like Python or Julia, how do we ensure students later understand lower-level concepts such as memory layout, registers, or instruction sets? Do we need a second mandatory programming class?

I am curious about the experiences at other universities/departments.

13 Likes

I’m not a professor but I work at a technology institute. I am a mechanical engineer working on fluid dynamics by the way. When I studied, my university did the same as yours. A course in C. I think it was terrible! A few students into computers enjoyed it but the rest hated it and avoided programming like the devil avoids the cross…

We’ve always had trainees from this same university. Again, a few who enjoyed computers turned out to be very good, but for most, Excel was their tool of choice and it was very difficult to get them to use anything else. Once they got the hang of it, they usually started using Excel less and less.

Around 2010, the university moved over from C to Python. I felt the difference right away. Any trainee was certainly more comfortable with a computer. They knew how to use Jupyter notebooks and used it to do their tasks. They definitely became more productive in the computer.

I really think that teaching C/java/etc as the basic course is terrible a waste of time. Yeah, a couple will enjoy it, but the rest will avoid programming (not only C) like the plague. The way I see it, if you know some (very little C), you can not plot a graph, input data, etc. And a single one semester course is far from sufficient for a beginner. An environment that helps the students do everyday work in most other classes is much better.

If I could choose I certainly would choose Julia, but Python is a much easier sell and it is half way there. Once they get comfortable with programming, the rest is much easier.

8 Likes

There’s a long related thread here: Julia as first language

2 Likes

What you write largely confirms our general experience—and why we are considering moving away from C. Thanks a lot!

My follow-up question concerns the skill set expected of electrical and electronics engineers: Is it sufficient for them to have mastered a programming language that allows them to complete typical tasks encountered in professional practice—ranging from power engineering to communications or information theory—without understanding how the language works at a lower level?

If a deep understanding of how a programming language interacts with the CPU and hardware is not required, this would support the case for Python. (In that scenario, Julia becomes a harder sell.)

However, if we want students to understand how, for example, a sorting algorithm or a dictionary is implemented, I would lean toward Julia, as it offers a clearer view into the inner workings.

1 Like

My feeling is that the first language matters much less than the second language. It’s actively bad for students to be exposed to only one language—they should be exposed to a second language (and more) as soon as possible, as I commented here: Can i start out with Julia as my 1st coding language - #5 by stevengj

10 Likes

For most schoolchildren and students, today, it is best to learn Python. Because it is in demand by most companies and corporations in the world. Moreover, literally billions are invested in Python, which means that it will never retire.

For schoolchildren and students who have planned for themselves a scientific field of development and activity for many years to come, it is worth studying Julia, since it provides much more productivity without the hassle of writing HPC libraries in C|C++, as for Python.

2 Likes

I don’t think that this is the right way to think about things. You don’t normally go straight from learning your first programming language to a programming job.

If I see on a resumé that someone only knows one programming language, my assumption is that they are a beginner, not a skilled programmer.

Learning your first programming language is mostly about learning concepts, not just syntax or specific libraries. I have nothing against Python for this purpose. But if you aren’t comfortable learning multiple languages then you aren’t ready to be a software engineer. Once you have learned how to program, and have chosen a particular field of interest (e.g. scientific computing, or systems administration, or web development, or machine learning), then you should learn the languages and libraries/toolkits that are popular in that field.

10 Likes

Based on this, I assume that learning C as the first language will introduce more concepts compared to Python.
My question is where can we draw the boundary of “enough concepts”?

Another question: can we use Julia in a second programming class to cover the concepts not covered in a Python-based first programming class?

I think people have been trying to draw that boundary for a while and never reached any consensus. If manual memory management and pointer arithmetic are part of the curriculum, then Python isn’t the way to go and unsafe Julia is probably overkill. If the users have no intention of being dedicated programmers and at most need to learn how to call functions and read the documentation of major practical libraries, then interactive languages are recommended and the choice of language largely depends on how good the ecosystem is for the context. There isn’t really a wrong answer for a first language because there’s always the opportunity to switch languages given enough time and basic knowledge will mostly transfer, but it’s probably good to consider the students’ needs because people paying for a 4 year degree don’t have much time to spare.

1 Like

To give a taste of programming. Some students will like it and want to learn more, others will not,and that is fine. A university education is not vocational training, it is assumed that you will only use a fraction of the stuff you are exposed to, but it is important to be exposed to a variety of things so you can figure out what you find interesting.

Possibly later, but not in a first year course.

Perhaps ask on a Python forum.

We don’t. You can be an excellent programmer these days without understanding registers or instruction sets, even if you are working on performance-focused software. The EE students who specialize in CPU design will pick that stuff up when needed, in another course.

Generally, a first programming course should be fun, task-oriented, and avoid frustrating students with irrelevant stuff. The extra 20% of knowledge you can shoehorn into such a course about low-level CPU specifics is really not worth it.

20 Likes

The context of the original post (and mine) was first course for engineering students. For many or most students this is/was their only programming course. Is this enough? I don’t think so but it is the reality in many universities.

With this in mind, the question is not how can we make better programmers but what is more useful for the students in the future - during course work or career. In this case, something like python or julia is much better. I really felt the improvement with interns and trainees.

For computer science courses, the logic can be different. But even if the engineering curriculum had more programming courses, I still think Python/Julia would be a better match. It is useful from day one, even as a simple calculator! And the students can, more easily, grow into enjoying programming.

I can not emphasize this enough: by far the most used and important computational tool for engineers everywhere is Excel, and without VBA. The things they do with Excel are amazing but often (almost always?) it could be done with a few lines of Julia (or Python).

4 Likes

I’ll say one thing: C is a horrid choice as an “intro to programming” language. C needs to be a dedicated course, it’s foolish to try to teach someone C while they’re still new to programming, because C is full of subtleties, and getting those wrong often leads to a silently wrong program. While it’s often considered a “simple” language or “close to the metal”, these are merely common misconceptions. For that matter, the strong tradition around C is another strong reason not to teach C as a first language: that tradition is chock-full of misconceptions by people who never bothered to read the standard or even cppreference, instead building upon those same traditions.

C++ is also the wrong choice, inheriting most or all semantics that make C the wrong choice, however C++ is more complicated than even C.

Contributing to the above issues is the fact that there is no manual, or even official guide or tutorial for either C or C++. The C++ specification is becoming more readable year-by-year, for what that’s worth, but hardly anyone reads the spec anyway.

10 Likes

I wouldn’t assume that first-year undergrad EE students will become software engineers. I’d teach what they will most commonly encounter in their field which is 1.) Programmable Logic Controllers and 2.) Python. Then maybe introduce C syntax enough for them to read it. They will more likely need to read and edit someone else’s code than to write their own from scratch. The details of Git and Pointers are far less important than just getting them comfortable writing simple loops and functions to solve problems.

3 Likes

I do like to add, that I had been misunderstood in this thread, and I felt gaslit through out the thread.

To sum it all up:

I think Julia can be a great language in the context of this thread here, specifically as first language for engineers and within an university setting, if you have teachers around in person, who ease you in.

In fact, it’s probably (one of) the best languages to do so.

Potentially be contested (and ideally combined with) the likes of Racket and Rhombus.

After this, people will have an easy time, to get to the good parts about Python, and how to write it.

In case they want to later work on a Python project, they are well prepared for it.

And still in the context of my thread, that has been linked, it can absolutely not be seen as a language for a newbie that has no-one to talk to in person, and also not to a newbie who wants to do anything not related to science with it.

It’s not a beginner language per se.

And the people in the thread were adamant, that Julia is already at the point, where it can be used as such.

And even worse there is an actively maintained idea, that the established part of the community, which inherently lacks the insight that is needed for such a view, is indeed capable for such judgement.

And that real experiences, by real people, who actively want to learn the language as a first instrument, do not count as valuable insight.

It was a huge reason, why I left the community
I felt gaslit and misunderstood, on purpose.

The goal seems to be, to establish Julia as a science only language, to the degree that it is purposefully rejecting other areas.

Which would be fine, if it would be stated like that.
Succeed, as nothing has happened. :slight_smile:

1 Like

Although there’s certainly some truth to this, these kind of over-generalizations do certainly not paint an accurate picture.
For one, the “established part of the community” is neither a clearly defined, nor homogeneous group of people.
And - presumably at least - also people in this nebulous group were beginners once, both to programming as well as to JuliaLang, no?

Without re-reading the linked thread, many people in this community just don’t appreciate blanket statements like these all that much…

2 Likes

I think you may right about the direction of travel - Julia is more and more becoming a science focused language and the focus on “general purpose computing” is seems to be diminishing, at least on this forum.

I’m not sure I agree with you on the motivation, though. My sense is more that this is a result of Julia’s amazing suitability for and success in scientific computing. This has become the centre of gravity on this Discourse and attracts more and more discussions, questions, proposals etc. I don’t necessarily see this as a bad thing, much less a conspiracy, but more as a natural reflection of Julia’s strengths. It is great for Julia to have a compelling USP!

I don’t fit in the group of users that are doing scientific computing. In the division of Julia users into “users” and “developers”, I am definitely a user. Among my colleagues …

by far the most used and important computational tool […] is Excel, and without VBA.

I use Julia because I find it effective and it has the tools I need. When I need help, I come here and, despite being outside the mainstream of scientific computing, I usually get helpful advice. Where I can make small contributions, they are in areas outside the technical scientific computing packages. I wish to make the on-ramps to using Julia for other people like me as easy as possible, to help counterbalance the preponderance of scientific computing users. But this is in no way to disparage Julia’s strengths or the users and developers that create and use them.

I picked up Julia from scratch two years ago with limited prior coding experience and no local peer support. Although I found it a steep learning curve, it was productive for me from day 1 (DataFrames and CSV got me going, working with a dataset too large to be comfortable in Excel). From my very limited experience of C, I cannot imagine this being true in that language.

8 Likes