4 ms·
It just occurred to me, Zig could be a great learning-language for CS When I was in college we mostly used C++, which exposed (and thereby taught) a lot of cor
by brundolf 4y ago
It just occurred to me, Zig could be a great learning-language for CS
When I was in college we mostly used C++, which exposed (and thereby taught) a lot of core concepts around how computers and low-level languages work. But it was also a bit of a nightmare for... unrelated, obvious reasons.
Rust is great for building software, but as a learning language I think it introduces too many additional concepts, has too many additional constraints, and has too many magical abstractions. Eg, doing manual deallocation helps you later appreciate what the borrow-checker does and why it exists
Zig is supposed to be C++ without all the pain and misery (esp around tooling). That could make it perfect for teaching people about pointers and heap allocations and working with bytes, with minimal extra pain and friction
- gautamdivgi 4y agoI think it’s supposed to be C without all the pain and misery. C++ without pain and misery is allegedly Rust :). But we were thrown into C and UNIX when I was at university. I think I’ll have Bus Error and Segmentation Fault core dump messages etched on my gravestone and may be request that the flower vases be labeled gdb (I forget the native debugger that came with the UNIX flavor I was using). Either way we did data structures and algorithms with Pascal. But I think c should be essential learning from a systems perspective. Maybe I’m too old though.
- skohan 4y agoZig might be a good alternative as it matures. As far as I understand, zig makes a lot of things explicit which are not in C, like explicitly passing the allocator when it’s needed. This might be even more edifying than C which has a little bit of magic going on.
- tialaramex 4y agoI still think the first language when I was an undergraduate (so, last century) was the correct choice: an ML in our case SML/NJ The stuff about how this actually works can come later, we're not teaching electronics students here (or are we? Zig as first language for electronics students makes some sense) I agree that (safe) Rust has too much stuff for a first language for Computer Scientists. Lifetimes! Polymorphism! Two entire Macro systems! although it's simpler than C++, surely nobody should teach that as first language. Zig has a compelling case as a second language if you learned something less practical like ML as first language. Apparently a colleague now teaches Haskell to the equivalent undergraduate classes as a second (or maybe third?) language, and I think Rust would also fit in there for the same purpose but given how practical the current first language is (now Java) he probably doesn't want more practicality. One thing I'd say for Rust is that we need to start teaching Safety and Correctness early. There's a reason the Medics don't wait until year four to do Ethics and Consent. If we want to stop writing software which is crap we need to start teaching the next generation of CS graduates that's not OK up front, not just in some Friday afternoon class about the Therac-25 which has maybe 40% attendance.
- bb88 4y ago> we're not teaching electronics students here (or are we? Zig as first language for electronics students makes some sense) From an educational viewpoint, I don't like that EE and SWE programs have very little overlap. A lot of EE tools could be improved if EE's learned more software (particularly parsing and compilers). A lot of SWE don't get into the dirty details of a CPU and what makes it tick and see it some sort of magical black box, and ergo don't understand digital logic. Datapoint: There are now thousands of programming languages. There are primarily two digital logic languages: VHDL and Verilog. If you ever cross over to the EE side, you'll understand how terrible some of the software is. > I still think the first language when I was an undergraduate (so, last century) was the correct choice: an ML in our case SML/NJ Again, I don't know. So much of Computer Science programs hinge on getting that first educational experience right. Not so much a problem for MIT, but the program I'm aware of that used Scheme for there CS100 course shrank over time. People just dropped and changed their degrees, when in reality if Scheme/ML were a junior level course, they probably would have more students, higher budget, etc -- and possibly most students would have an easier time after learning a little bit of imperative programming. Perhaps it's a fair point that CS100 should be a weed-out course. But on the other hand, we don't teach the theory of calculus before we teach students trigonometry.
- cassepipe 4y agoAs I understand you advocate a bottom - up approach rather than a top-down one. I personally prefer the former over the latter as it makes more sense to me to learn how to make basic programs work before I learn what incredible things I can do with them. I have over one year of C experience in my school doing things like rewriting functions of the C stdlib and reimplementin getline() before I learn about radix sort, implement a tree or make a basic ray tracer. Thats works for me but I know there are some theory/abstraction oriented people that like to learn about algorithms first and fill in the details late. In the end if you want programming to be interesting you need both practical and theoretical knowledge so I guess you should know yourself and take the approach that work for you. Having people who want to build stuff learn abstract concepts in Scheme may be as counter-productive than having people who want to learn about clever data structures learn how to make a basic text editor in C in the terminal.
- stjohnswarts 4y agoModern c++ needn't be "low level" particularly with c++20 and up, just sayin' . Back when I start school sure RAII was radical and "high level" and everything else was pretty low level. Modern C++ is a different creature. Anyway. I think small languages like c and zig are great for learning as a first language especially for computer engineering students. I still think that a lisp is the best first language for CS students however.
- pjmlp 4y agoRadical only for those entreched into the ways of C, our university was already teaching RAII to first year students in 1994. First semester was Pascal, followed by C++ on the second one.
- Tozen 4y agoI think many teachers would disagree about the usage of Zig for CS, and over the widely accepted and used C language or even over popular newer ones such as Go, D, or Rust. Not to mention the strong push that Embarcadero still makes to push Object Pascal (Delphi) into classrooms, and how well known Pascal/Object Pascal still is in countries outside of the U.S. 1) Zig lacks features where they could teach about OOP. There is no classes or inheritance. To include Zig doesn't lend itself so well to even the more general object-orientated concepts, which are in newer languages like Go or Vlang and others (structs that can be assigned methods and having interfaces). Like it or not (rightly or wrongly), class-based OOP still has many "hypnotized" and conditioned to its necessity. 2) There is the issue of having to address manual memory management. While that would be the same problem for C, many teachers choose to go the easier route, and select languages like Python or Java. Others like Go, Vlang, D, etc... would make things easier as well. And Pascal/Object Pascal (Delphi) is still around (a language made for being taught in CS), with a ton of books covering pointers, the heap, bytes, memory management, etc... 3) Zig is still a widely unknown and developing language. Zig is years away from reaching 1.0. Many teachers are conservative. They often will go with what is already widely known and will likely create the least amount of controversy. If more teachers can be convinced out of being so conservative, it would probably be because a language is being so strongly pushed by famous companies that are targeting schools or by demand in the job market. Google pushing Go, Oracle pushing Java, Microsoft pushing C#, etc...