5 ms·
C is the best abstraction for many problem domains and that isn't going to change. I understand why folks coming from higher-level languages would dislike it, b
by hgs3 4y ago
C is the best abstraction for many problem domains and that isn't going to change. I understand why folks coming from higher-level languages would dislike it, but for anyone coming from assembly it's a godsend.
The speaker discourages C for new projects, but that says more about the problem domains they work in than C itself. C is what it is because the hardware and assembly language are what they are. Folks who want a safer C should design a new hardware architecture with a "safe" assembly language and a new low-level language that targets it.
- sirsinsalot 4y agoAnyone discouraging a particular tool without actual context of the problem being solved gets zero respect from me. It's a massive red flag that they don't know enough to be useful. C is great for the things C is great for, however small that range may or may not be now and in the future. Any other stance is reductive and misleading.
- KerrAvon 4y agoExactly what, in the year 2023 C.E., is C great for? I’ve been writing C since 1991 and I can’t think of anything where I wouldn’t start a new project in some other language. There are many interesting choices of varying maturity in the low-level systems programming space: Zig, Rust, Crystal, D, Swift (if the standard library ever gains support for system-level programming). Even the “better C” subset of C++ will allow you to avoid certain classes of security bugs completely. I don’t think C is even merely adequate for anything at this point; defaulting to memory safety is table stakes in any domain where C was once dominant.
- Koshkin 4y ago> C.E. There.
- fncslothouber 4y agoMemory safety / security is important for a subset of all possible applications. It is not important for _all_ applications. If I use a micro controller to control a string of leds I do not care about security/memory safety. But I do care about being as close to the metal as possible, and being able to understand the compiled code.
- bonzini 4y agoTo control a string of LEDs, something like Forth (or some other p-code virtual machine) is going to be just as good as C. PIC microcontrollers have always had BASIC as an option for example. But many microcontrollers these days will likely have a TCP/IP stack, perhaps even crypto, even if it is to control a string of LEDs via MQTT or Modbus TCP.
- fncslothouber 4y agoForth would also be a nice choice. Give you another example. A watch, not an apple watch, but a simple Casio watch. One that does time, alarm and a stopwatch. Not connected to anything. What is important here is the battery life, so the less code the better. C would be a fine choice here. All additional code to prevent security breaches would be a complete waste here. Give another example. As my day-job I develop embedded software for the railways. Current system I work on operates the brakes when the train goes too fast. Not connected to the internet, and no connection would even be allowed. Written in C. One because it is simple to understand and the developer can focus on getting the functionality correct. Secondly because there is a wide choice of additional tooling and standards that is required to get the application certified.
- ptx 4y agoIf people rely on the LEDs working correctly or if the controller has any kind of connection to another system (which could be leveraged by an attacker to penetrate deeper into the network) it seems to me that security and memory safety would still be important.
- fncslothouber 4y agoNot everything is or needs to be connected to the Internet. There are plenty of things that are controlled by a micro controllers that do not have a network connection.
- estebank 4y ago
- matheusmoreira 4y ago> Exactly what, in the year 2023 C.E., is C great for? Writing readable code. I'm a huge fan of Zig and Rust too but at the end of the day they just aren't C.
- jeff-davis 4y agoThe consequences of C in long-lived software are somewhat known. Granted, the track record of C is mixed, but many important projects have been successful with it. Rust is exciting and proving itself about as rapidly as such a language could be expected to do. But there are big questions around how all of this plays out in a long-lived project. There's a good argument that C's simplicity is an asset here. I like Rust a lot and have done some cool stuff with it. I believe the challenges of long-lived projects will be solved. But at the same time, I admit that there are a lot of other factors (including non-trchnical ones). If you pick a language that doesn't last for whatever reason, and you have a couple decades worth of code, the options are grim.
- addaon 4y ago> Exactly what, in the year 2023 C.E., is C great for? Implementing low-level code that is important enough to prove correct, without going through the additional effort of de novo proving your entire toolchain is correct.
- tmtvl 4y agoYeah, Ada is pretty great, it takes the best things from Pascal and combines it with unparalleled reliability.
- doodlesdev 4y agoC is a great language to program a PDP-11 in the 1980s. And that's it. There are SO MANY alternatives for so many different use cases nowadays, it's just hard to justify using C anywhere whatsoever.
- erik_seaberg 4y agoIt was practical for self-hosted PDP-11 development, which was tough. They could have cross-compiled a few other languages on a bigger machine, if only they had one.
- pjmlp 4y agoLanguages like PL/I, NEWP, BLISS, Modula-2 did it much better, but they didn't come with a free beer OS.
- Koshkin 4y ago> C is the best abstraction for many problem domains It's really not, though. What C is an abstraction of is computer architecture as it existed by the late 1960s.
- hgs3 4y ago> It's really not, though. What C is an abstraction of is computer architecture as it existed by the late 1960s. I don't follow. Barring micro-code, hardware is designed for executing either RISC or CISC instructions. If anything, the industry has matured and we see less esoteric ISA's today than in the 1960s.
- estebank 4y agoA modern low level labguage would expose you to the concepts of cache lines and homogeneous and eterogeneous cores directly, with locality awareness to recognize false sharing. It would be something suitable to program the Cell architecture from PS2.
- addaon 4y agoWhat about those of us working on microcontrollers that use TCM rather than cache, and that don't have multiple cores? C sure seems like a good fit…
- hgs3 4y agoThose are fair points, but they're probably too specific to the architecture to incorporate in C's general execution model. They're better exposed through platform specific programming interfaces like OpenMP or CUDA. Even a domain specific language, like GLSL, may be more appropriate.
- turndown 4y agoI think that the general point being made here is that C’s general execution model, as you call it, really is just a PDP-like computer because that is what they had when making C.
- w10-1 4y ago> Folks who want a safer C should design a new hardware architecture with a "safe" assembly language and a new low-level language that targets it Would that be LLVM's IR or MLIR (https://mlir.llvm.org https://mlir.llvm.org)?