4 ms·
I believe that an ML should be the First Language for Computer Scientists. It's much less clear which language we should teach people for whom it will likely be
by tialaramex 2mo ago
I believe that an ML should be the First Language for Computer Scientists. It's much less clear which language we should teach people for whom it will likely be their Only Language, today Python is common, and for fields which care about stats often R is used, I've also seen Java used in this role. But for a First Language specifically I am in no doubt that an ML should be chosen, and this is despite the fact that the University where I work has taught Java for decades and Python most recently as First Language.
I'm an old man, I learned the Standard ML of New Jersey when I was an undergraduate many years ago, but I'm pretty sure that experience though it isn't irrelevant, did not overly colour my belief in what we [speaking broadly of humanity] ought to teach.
- MeetingsBrowser 2mo agoAn ML is great for the theory or abstraction side of programming, but C is also hands down the best language to get a sense of how the computer is running your program. It’s still an abstraction, but at least being aware of memory management, copying vs referencing, etc are hugely important concepts that ML languages can hide.
- xiaoyu2006 2mo ago> It’s still an abstraction C is still heavily abstracted. Modern OS evolved in conjunction with C s.t. it behaves like a C runtime simulating a PDP11 (I remember reading a nice article on that). To learn system, what you need is an OS course, not C. I'd say the current C-based stack is in a quite embarrassing state.
- siev 2mo agoProbably thinking of this article: "C Is Not a Low-level Language: Your computer is not a fast PDP-11." https://queue.acm.org/doi/10.1145/3212477.3212479 https://queue.acm.org/doi/10.1145/3212477.3212479
- hnfong 2mo agoSure, you need an OS course, but that's when students should learn C as well.
- uecker 2mo agoI think this PDP-11 meme is quite misleading. There is nothing really in the C programming model specific to the PDP-11 and C was used on systems much weirder than a PDP-11. C is also very successfully the basis of many parallel programs running on multi-processor systems with a memory model in the standard that was created much later than the PDP-11. Also somehow the implied argument that computing hardware and operating systems simulate a PDP-11 for the sake of C is completely backwards. Historically, there were other approaches, e.g. processors designed for object-oriented programming or actors etc.. All those were not very successful.
- nivertech 2mo agoIt's clear that the authors were either inspired by the PDP-11 ISA and/or designed the language to make porting UNIX from PDP-11 Assm to it easier. UNIX for PDP-7 in Assm -> UNIX for PDP-11 in Assm -> UNIX for PDP-11 in C https://news.ycombinator.com/item?id=42644851 https://news.ycombinator.com/item?id=42644851 and https://news.ycombinator.com/item?id=43245166 https://news.ycombinator.com/item?id=43245166
- uecker 2mo agoI do not think that pre- and postincrement operator being inspired by PDP-11 has anything to with fundamental system design questions.
- nivertech 2mo ago> Q. How do you port an OS from one language to a new one, pre-LLM? A. you reduce impedance mismatch, but making the new language using similar concepts and mechanisms -- You're right, this table is just a coincidence, probably derived from the standard math notation, and used in many PLs like FORTRAN and Python ;) PDP-11 C INC R ++i DEC R --i ADD src, dst dst += src SUB src, dst dst -= src (R)+ *p++ -(R) *--p X(R) p[x] @(R)+ **pp++ @X(R) *p[x] BR label goto label ; near jump JMP label goto label ; far jump
- oldsecondhand 2mo agoFor someone just starting to learn CS, it should not matter whether they're on PDP-11 or x64 or ARM. You can't start teaching with pipelining and speculative branch execution. So C is good choice because there is a simple CPU architecture that it maps to well.
- MeetingsBrowser 2mo agoFully agree. C sits in an almost perfect level of abstraction for students to get a vague sense of how the computer runs code. Those that don’t need low level details can spend their professional career in languages like python and JavaScript while still have a sense of what lies beneath the abstraction. For those that do want or need to go deeper, C is an excellent jumping off point into ASM and arch specifics.
- krapp 2mo agoC hasn't presented an accurate model of how computers actually work for decades. It's a high level language LARPing as a low level language.
- ahefner 2mo agoComputers haven't presented an accurate model of how computers actually work for decades. Compare the surface ISA of anything mainstream since the mid 90s versus all of the superscalar and out-of-order execution happening under the hood. Deliberate efforts to surface this deeper layer back to the programmer-facing ISA (VLIW, notably Itanium) failed spectacularly outside of niche applications. C and its contenders can't simply hop over the CPU abstraction presented to them without having to map backward from some lower-level model to the surface ISA it's forced to target then having the rug pulled every few years due to microarchitectural changes. It has managed to evolve surprisingly gracefully over decades from tiny 16 and 18-bit machines, sometimes segmented, to 32 and 64 bit machines, and even accommodating SIMD reasonably gracefully via intrinsics (which is about the best we can do at present, as CPUs continue to diverge wildly in this area, though I'm begrudgingly impressed by what modern compilers can do via autovectorization to optimize simple loops).
- slacknatcher12 2mo ago> but C is also hands down the best language to get a sense of how the computer is running your program. C is in an odd position right now to argue it is how the machine is really working. Computers are more complicated since bigger caches entered the picture. Hell I do not think even ASM is a good approximation on how machine really work given the data dependencies will make stuff being processed in parallel instead of sequentially. What you could argue is that C is the archetype for an imperative language procedural language with a clean mapping to ASM. That is different than how the machine works. Simpler architecture have less distance between their ASM and what is really hapenning.
- tialaramex 2mo ago> an imperative language procedural language with a clean mapping to ASM C really isn't as great for this as is often suggested either, not for decades at least K&R's original compiler on an actual Digital machine from that era makes the case best, but remember this is the era when if you hot loop over modifying a variable your compiler is going to emit memory stores for each iteration - because that's what you wrote, isn't it? No modern C compiler would do this because it's awfully slow. Likewise that iteration of C doesn't have what you'd recognise as function prototypes, it doesn't care whether your function takes six arguments, here are six arguments the first two are integers, good luck with that. In assembler that makes sense, but you don't do that in modern C either. C is still a close-to-the-metal language, but it is programming an abstract machine and it is important that the programmer knows that's not really how the machine works, if you want to learn about the machine you will need to write at least assembler and possibly just go learn electronics. Good luck.
- jech 2mo ago> C really isn't as great for this as is often suggested either, not for decades at least It's good enough for undergraduate teaching. In C, you can easily explain the relation between a struct definition and its layout in memory. It's much more difficult in Caml (what's the relation between an algebraic datatype and its layout in memory?) or Java (which introduces pointers that you never asked for). We (University of Paris-Cité) are teaching Java in first year, then C and Caml in second year, with seemingly good results.
- cardanome 2mo ago> C Well some procedural language would do the trick. The main issue is see is people jumping straight into OO or functional programming and developing a habit of over-abstracting everything. I think something like Odin which is purely procedural but has less historical cruft and offers modern affordances would be a great choice. C is absolutely worth learning but students will spent a lot of time learning to cope with its sharp corners and subpar standard library. Some might give up before they discover the joys for programming.
- giovannibonetti 2mo agoMaybe learn Rust as a middle ground between ML and C, then? It has sum types like ML and teaches you memory management like C.
- MeetingsBrowser 2mo agoThe allure of Rust is that you don’t have to manually manage memory. Lifetimes are a compiler safety abstraction and mostly unrelated with how the computer runs your program. Learning a language like C helps to understand why lifetime annotations are needed and how the compiler uses them.
- pjmlp 2mo agoC doesn't provide anything that C++, D, Object Pascal, Ada, Modula-2, Zig, Swift and many others won't do as well.
- MeetingsBrowser 2mo agoAll great options as well, with the caveat that it’s possible to “ignore” the parts that make C useful as a teaching tool. Most modern languages have ways to automate parts of memory management, and rightfully so. But you should at least be somewhat aware of what is going on under the hood.
- pjmlp 2mo agoSome of the suggested languages are as old as C, with better ergonomics if you mean ignorig is doing string concatenation instead of manually handling char buffers with pointer arithmetic, or proper reference parameters instead of being forced to pass the address of output variables manually, which is nonetheless possible in the suggested languages. What low level thing do you think C can do, but Modula-2, Ada or Object Pascal are unable to provide the comparable feature? Also taking into account possible C extensions not covered by ISO.
- MeetingsBrowser 2mo agoC lacks just enough “modern language features”, by design, that students are forced to be vaguely aware of memory layout, memory management, ref vs copy, shallow copy vs deep copy, maybe even calling convention, etc. It’s also popular enough that there is an abundance of high quality learning resources for beginners. No other language threads that needle as well as C.
- pjmlp 2mo agoProvided examples from 1978 and 1983 languages do that just as well, unless you mean by 1978, C design was too primitive, or even when compared with languages like PL/I and NEWP from 1966 and 1961 respectively, which then I fully agree with.
- astrobe_ 2mo agoMaybe we were led into a false dichotomy by the title. If someone wants to learn programming for other reasons than as a mean to a goal - which will become more and more rare because LLMs do that already - this person must not learn just one language but one per major paradigm : C (imperative/procedural), Smalltalk (OOP), Prolog (logic), SQL (declarative, although maybe there are better representatives), OCaml (functional, although one can go for Haskell or Lisp/Scheme), and Forth (concatenative, but also to take a look under the hood of interpreters/compilers/VMs).
- deleted 2mo ago[deleted]
- adrian_b 2mo agoTo get a sense of how the computer runs your program you need to learn some modern assembly language, i.e. either Intel/AMD x86-64 or Arm Aarch64, or for something simpler one could start with IBM POWER. The hardware machine model used by the C programming language is completely obsolete and very different from how modern CPUs work. Even for abstracting PDP-11 it had defects and omissions. The fact that C is indeed more transparent than many other more abstract programming languages does not make it good enough for understanding how the CPU runs your program. Believing that the CPU works within the straitjacket of the C language is dangerous, because much more than half of the instructions of a modern CPU cannot be directly expressed in C (though a good optimizing compiler can sometimes infer when such instructions can be used), and the C language does not even have the data types that are used by many hardware instructions. The relationship between the C language and how a computer runs a program is exactly the opposite of what the previous comment says. For someone who knows how a CPU runs a program, it will be easier to understand how a C program is run than how a program in another language is run, because for the latter there may be very different runtime library implementations, whose behavior cannot be guessed by looking at a source program, without having supplementary documentation about the compiler or interpreter that is used. On the other hand if someone knows only the C programming language, their mental image about how the program is executed is likely to be very wrong for any non-trivial program. For learning an assembly language, the prior knowledge of C is more a handicap than something helpful, by creating bad habits, like using incorrect implicit conversions, inappropriate integer data types, not caring about interactions with the cache memory or memory access ordering, choosing between alternative expressions those that are more inefficient in hardware (e.g. in many modern CPUs accessing data through indices is more efficient than through pointers, but a lot of legacy C programs use pointers to access arrays, under the wrong assumption that this is more efficient), etc. I agree with the top poster that languages from the ML family are a very good choice for a first-learned programming language. For a programming language to be known before any assembly language, I believe that even Fortran is much more appropriate than C, because it is much less misleading about how a modern CPU works, and I say this despite the fact that for decades I have been writing programs in the C language, for embedded computers (but before learning the first assembly languages I had experience mostly in Fortran, and to a lesser extent in LISP and COBOL). For a few years starting with 1990, I liked C very much, because with the Microsoft and Borland C compilers for IBM PC it was a great improvement over the Pascal, Fortran or Basic to which I had access previously, but today, 36 years later, I do not think that there exists any application for which learning or using C makes sense, despite the fact that we will remain stuck with it in many places for many more decades in the future. Even the ancient Fortran remains more useful than C today, because for many computational applications most modern programming languages are crippled in comparison with it, by poor support for array operations, while C does not have any intrinsic advantage over alternative programming languages. A "C" done in the right way is "D", so it would be better for learning, though it still inherits from C some questionable features, which would not exist in a clean design.
- iLemming 2mo agoYou really need to grok C and understand Lisp. Learning just these two well, will give you most of the foundation you're ever gonna need. Nearly every other PL is a bunch of accretions on top of one of these; sometimes those accretions are great improvements, and more often than you'd think - they are downgrades. Lisp can teach you everything about what logically a program is, how computation itself can be expressed - code as data, recursion, and abstraction built from almost nothing, and C can teach you what a program physically is - memory, pointers, and how the machine actually runs it. I have gone through over a dozen of different PLs, each time thinking that my skillset was improving but I still sucked at it, and just needed to learn yet another language to truly get better at programming. Turns out, I just needed to grok Lisp. Don't be like me, don't waste your lives wandering around, following a map everyone's holding. Majority not only can be wrong, but as history teaches us - it is wrong most of the time. Instead, follow those few that are looking for shortcuts. They may not have most popular opinions, but they might be on the right path after all.
- optbuild 2mo ago[dead]
- deleted 2mo ago[deleted]
- penteract 2mo ago> I believe that an ML should be the First Language for Computer Scientists. I'm not sure how much influence a First Language has - the biggest impact might be whether someone decides to continue learning to program. I'd also worry that we might lose something if all computer scientists are too similar. There are lisp believers, and there are those who swear by C; and I think the field of CS would be less rich if either were missing. Given that, it's a good thing that there are a variety of languages taught as first languages, and I'd like to see the variety widen (I don't know of any CS degree which begins by teaching Forth).
- WillAdams 2mo agoThe best programming course I had in college was one on comparative programming languages (and not just 'cause I was the only student who was able to do all of the Lisp exercises solo) --- it was quite striking getting an overview of the history of computer science and to see the myriad approaches which had been used.