6 ms·
> C won the competition because it just gives programmers the bare minimum functionality to put an operating system and a compiler in place! Not really. C won
by jcranmer 6y ago
> C won the competition because it just gives programmers the bare minimum functionality to put an operating system and a compiler in place!
Not really. C won because it was the standard compiler for Unix, and was a free compiler for a free operating system in a time when both were highly unusual.
But in the past few decades, C has lost a lot of its market share to other programming languages. In the realm of desktop (and mobile) applications, C is basically unused for new projects--its standard library is truly anemic here, and major support libraries (e.g., GUI toolkits) are often in C++ and not C. Where C is still the dominant language is the land of embedded applications, and it's not had a lot of competition here since most languages don't bother trying to define a freestanding implementation.
Rust is really the first language to try to contend this space. And there are signs that it may supplant C: Intel is apparently looking to move its firmware to Rust; Linux is allowing Rust for device drivers and kernel modules. Hell, even some OS programming courses (e.g., Stanford, Georgia Tech) have moved their curriculum to use Rust instead of C.
- coldpie 6y ago> Linux is allowing Rust for device drivers and kernel modules. Oh, did this happen? I remember some discussion some months ago, has it actually been merged?
- jcranmer 6y agoNothing has merged yet, but the basic plan to start allowing Rust has been approved at a high level.
- witherk 6y agoI'm enrolled for a masters at Georiga Tech right now and last I checked the OS course is in C, I would kinda prefer to learn rust anyway so I hope you are right.
- steveklabnik 6y agohttps://tc.gts3.org/cs3210/2020/spring/info.html https://tc.gts3.org/cs3210/2020/spring/info.html Dunno how often this class runs, and if it was just for one semester or more than that.
- jcranmer 6y agoGT just switched over in the spring semester, I believe.
- bluecalm 6y agoWhy would you prefer to learn Rust at this point, especially during OS course when all relevant OS code you will encounter is in C and understanding C is crucial to understand low level programming concepts. You can always learn Rust later when/if it becomes more relevant. Without C a lot of programming areas will be a closed door forever.
- jcranmer 6y ago> understanding C is crucial to understand low level programming concepts That is a patently false statement. To understand low-level programming concepts, you need to understand fundamental notions about how machines represent state in registers and memory, how memory is organized (including primarily the concept of function calls and the stack), and the indirect referencing of memory via pointers. Note that nowhere in that list did I describe a concept that is unique to C. In fact, one of the more common approaches to introducing developers to low-level programming is to introduce them to these concepts via assembly (say, Nand2tetris). In my own experience TA'ing such a course, I am more than willing to translate code into whatever language the student is most comfortable with to express the concepts as necessary. You can absolutely learn these concepts in other languages, and my own suspicion is that unsafe Rust does a slightly better job of it than regular C does. C does not have a monopoly on understanding the low-level organization of code, and quite frankly, C's lack of coverage here can be frustrating. C has no concept of multiple return values, functions with multiple entry points, unwinding the stack, computed goto, SIMD vector types, nested functions, discontinuous structures, or tail calls, and these are all concepts that are present in other languages that cannot be expressed in standard C or often even in vendor-extended C.
- ghostwriter 6y ago> You can absolutely learn these concepts in other languages, and my own suspicion is that unsafe Rust does a slightly better job of it than regular C does. > C has no concept of multiple return values, functions with multiple entry points, unwinding the stack, computed goto, SIMD vector types, nested functions, discontinuous structures, or tail calls, and these are all concepts that are present in other languages that cannot be expressed in standard C or often even in vendor-extended C. ATS does a better job than safe Rust and you can think of it as a vendor-extended C (http://ats-lang.sourceforge.net/DOCUMENT/INT2PROGINATS/HTML/c2016.html http://ats-lang.sourceforge.net/DOCUMENT/INT2PROGINATS/HTML/...).
- Cloudef 6y agoRust doesn't compete with C, rust competes with C++. Rust doesn't get why C programmers still use C at all.
- jjgreen 6y agoC says "Rust? Who?"
- jnwatson 6y agoIt does indeed compete with C in a lot of places. Device drivers and embedded are a couple of places where Rust will replace a lot of C.
- Cloudef 6y agoIt may replace some software, but it won't really lure many of the C / embedded developers. The problem is that rust developers miss the point of C. People who program with C want the bare minimum, they don't care about classes or other OOP features. If there was something that sort of grogs what C programmers want, it's probably zig-lang. To put it in short, C programmers hate needless abstraction and work with raw memory and hand-crafted data structures whenever possible. More data, less code.
- adwn 6y ago> C / embedded developers Embedded developers use C because they have to, not typically because they want to. And they have to use C because of proprietary toolchains and existing libraries, among other similar reasons. Good reasons, sure, but not because C the language is so great. > hand-crafted data structures [...] More data, less code You're paying lip service to the principle of datastructures-over-algorithms, yet you're advocating for a language which has neither algebraic data types nor tuples? Come on. That's like praising functional programming but using Fortran.
- jolux 6y agoRust doesn’t have classes or indeed many traditional OOP features, and it has an extremely strong focus on data.
- jamil7 6y agoOne area I still see it pop up frequently is audio related code on mobile.
- WalterBright 6y agoC won because it was the only low level language that was competently implemented for DOS for years. DOS was were 90% of the programming action was in the 80's, and C was a perfect fit for DOS. C also was easily extended to handle segmented memory.
- int_19h 6y ago(Turbo/Borland) Pascal was comparable to C in terms of closeness to hardware on DOS - I mean, it even had language facilities specifically for interrupt handlers! A lot of DOS software was written in that. In some countries, it was the case for most DOS software made in them. So I'd amend this to: C won because it was the only cross-platform low level language that was competently implemented for DOS.