Earlier quoted context omitted.
> K&R book is the only book you need to read to know everything about C. All you need after you understand the fundamentals is a bit of discipline. I am a huge C fan but this is not true at all. C has tons of pitfalls, especially with modern UB-aggressive optimizing compilers. There are a lot of rules you need to be aware of that are not naturally-occurring results of the fundamentals.
For someone who wants to learn C from the ground up, do you have some kind of learning path or books you'd recommend?
Deconstructing K&R C Is Dead (2015)
121–130 of 190 posts
Re: Deconstructing K&R C Is Dead (2015)
#122Earlier quoted context omitted.
For someone who wants to learn C from the ground up, do you have some kind of learning path or books you'd recommend?
I was a big fan of this post from a few days ago. Has a great list of resources and different areas to cover: http://blog.regehr.org/archives/1393
Re: Deconstructing K&R C Is Dead (2015)
#123This is obviously a bitter rant, and devolves into uncomfortably ageist territory about halfway through. I do agree that we should be moving away from C and C++, though. It's pretty simple, really: C was a pretty good language in 1978. We didn't know a lot of things in 1978 that we do now in 2016. It now makes sense to revisit those decisions in light of nearly 40 years of practice. The so-called "PL Renaissance" has…
> C was a pretty good language in 1978. We didn't know a lot of things in 1978 that we do now in 2016. It now makes sense to revisit those decisions in light of nearly 40 years of practice. We surely did know that Burroughs was selling an operating system written in ESPOL, later NEWP in 1961. Nowadays Unisys still sells them as MCP. We did know that the Flex machine was written in ALGOL 68RS in 1980. We did know that…
Re: Deconstructing K&R C Is Dead (2015)
#124Earlier quoted context omitted.
"The block structure of ALGOL 60 induced a stack allocation discipline. It had limited dynamic arrays, but no general heap allocation. The substantially redesigned ALGOL 68 had both heap and stack allocation. It also had something like the modern pointer type, and required garbage collection for the heap. The new language was complex and difficult to implement, and it was never as successful as its predecessor." -- h…
> There's a reason languages like Rust and Go rely heavily on static linking and stack allocation This is untrue: Rust certainly does not do any optimisations linking statically by default, nor is there a difference between putting an array on the stack or on the heap. While it is true that code can benefit from whole-program optimisation, it isn't the default in either language, just like it isn't the default in C.
LTO notwithstanding, once you add those more sophisticated constructs, iterating the language becomes more difficult. You don't hit upon the best method for implementing various types the first time, or the second time, or even the third time. glibc is backwards compatible for programs compiled over 15 years ago (GCC's fixinclude hacks notwithstanding). You'll never see that with Rust's or Go's standard library, just like you never saw that with C++.
My point wasn't that static linking was necessary. My point was that static linking is indicative of other tradeoffs that most people don't understand. Static linking isn't just about making packaging easier. It's also about making it easier to write and implement the compiler and standard environment.
My more abstract point is that people who think C is on its last legs don't understand the whole picture. There's nothing intrinsic to C that makes it unsafe. Febrice's compiler was perfectly capable of implementing the C standard to the letter. What makes C unsafe are the requirements found in the niches where C exists, and those requirements don't magically disappear because the name of the language changes.
Rust supports unsafe code, but implementing code in Rust which is rigorously robust in the face of OOM situations, or where you need to implement use-case memory management strategies requires relying almost exclusively on unsafe code. (Try using Rust without boxing, for example, as is necessary if you want to catch OOM.) If you don't need those things, you probably don't need a low-level language, either. I love C, but I also love language like Lua with lexical closures and stackless coroutines. To me, languages like Rust and even C++ exist at a middle ground that is very unappealing to me.
C isn't standing still, either. Strategies like SafeStack (see http://dslab.epfl.ch/proj/cpi/) can provide substantially the same safety guarantees as Rust in terms of real-world attack vectors, without having to modify any existing C software, and without giving up performance.
None of this is to say languages like Rust are useless. Just that the harms and inevitable demise of C per se are, IMHO, greatly exaggerated. And if and when a language like Rust grows in usage, I doubt it will supplant C so much as open and populate virgin territory.
Re: Deconstructing K&R C Is Dead (2015)
#125K&R taught fundamentals and a good style. It is timeless classic, because the principles doesn't change within successions of mass hysteria. Plan9 dialect of C is another example. There is portable mk package, with includes core libs (libbio, libutf, etc. which also served as core libs for earlier versions of Golang) to appreciate what C supposed to be. I would paraphrase - attention seeking by attacking classics is…
Re: Deconstructing K&R C Is Dead (2015)
#126Earlier quoted context omitted.
I agree with where you're coming from. Another analogy that comes to mind is knob-and-tube wiring ( https://en.wikipedia.org/wiki/Knob-and-tube_wiring ). It's an older home wiring technology that works fine for years if undisturbed, is still present and working OK in homes all over, was invented in the early days of electrified homes, requires considerable skill to install properly, tends to be unsafe if not handled…
Yeah. The weird thing is that in other industries, people have no trouble admitting that the old stuff is often problematic and needs to be replaced. In the supposedly forward-looking tech industry, though, we stick with our tools from 1978 and stubbornly resist admitting that we have learned anything since then. It's strange.
- A base ten number system
- Lack of useful structure in the symbols and names for numerals, and lots of weird inconsistencies in number names
- Inconsistent, confusing, and arbitrary names/notation for basic mathematical operators and functions
- Use of inferior Gibbs/Heaviside vector algebra instead of Clifford/geometric algebra
- Very poor notational conventions in many advanced math/physics fields
- A highly irregular calendar
- Poorly designed measurement systems
- English spelling
- Very distorted dominant world map projections
- Most nutrition “science”, including federal dietary guidelines
- Bogus forensic “science” used to imprison innocent people
- The methodology and writing style used in political science
- Many essentially debunked economic models which continue to be taught
- A legal system chock full of incidental complexity and inconsistencies
- Inadequate species taxonomies
- Poor color models used in art/design
- Even worse, specification of colors using proprietary, arbitrary Pantone chips
- Lots of poor/obsolete metrics used for evaluating lighting
- Audio mastering with heavy-handed dynamic range compression
- Lectures as primary pedagogy in high school/college
- Grammar drills as a method for teaching foreign languages
- Modern zoning requirements in many countries
- Many unsafe and inefficient street design requirements
- The rigid design of modern shoes (let’s not even start on heels)
- Terrible user interfaces for most household appliances
- Mediocre user interfaces for many musical instruments
- An inefficient and dangerous typewriter / computer keyboard (which persists on tiny phone screens!?)
- Unhealthy design of office furniture, car/airplane seats, child strollers, etc.
- .....
Some of this stuff is decades old. Some is thousands of years old.Re: Deconstructing K&R C Is Dead (2015)
#127Earlier quoted context omitted.
I'm ready for the hate, so here we go... C was not a well-designed language in 1978. The fact that C arrays decay to pointers without any bounds is single-handedly responsible for a huge chunk, possibly even the majority, of all RCEs, worms, malware, and exploits. Ever. In the history of computing. It was a bad design. It was a bad design in 1978. It was known to be a bad design in 1978. Other languages knew that che…
I suspect this has a -lot- to do with performance. When C was designed, and even today, there are systems without pipelining, where it is expensive (in time) to de-reference a memory address and follow that pointer. I do not argue that the design you suggest would be safer, and even have advantages for slicing; but that's really not the kind of program that C was intended to service writing. Also, C is supposed to sc…
This is C snake oil, sold by the C community that usually omits the fact that computers build a decade before the PDP-11 like the Burroughs, already had much better systems programming languages like ESPOL and NEWP, two Algol derivatives.
Algol 68 already had slices and modules (Algol68 RS) among many other nice features, running in early 70's hardware.
There are a few other examples.
Re: Deconstructing K&R C Is Dead (2015)
#128This is obviously a bitter rant, and devolves into uncomfortably ageist territory about halfway through. I do agree that we should be moving away from C and C++, though. It's pretty simple, really: C was a pretty good language in 1978. We didn't know a lot of things in 1978 that we do now in 2016. It now makes sense to revisit those decisions in light of nearly 40 years of practice. The so-called "PL Renaissance" has…
C can be replaced with a reasonable amount of effort with C++. But C++ won't be easy to replace, and I'm not sure it needs to be, since rewrites are highly risky, time consuming and disruptive. With some luck and depending on how the language evolves we might be moving from C++ to a safer C++.
But using the C++ features that make it safer than C is only an option in small security motivated teams.
Sadly the majority of C++ teams, at least in the enterprise space, tends to use it as "C with classes" thus voiding most improvements the language has to offer over plain C.
Re: Deconstructing K&R C Is Dead (2015)
#129Earlier quoted context omitted.
It's remarkable, though, that it's taken 40 years to make much head way in replacing C. There's still a lot of C code out there, and a lot of new C code still being written.
Lots more will be written until there is a viable replacement for C in embedded systems.
Oberon for ARM Cortex-M4, Cortex-M3 Microcontrollers and Xilinx FPGA Systems
http://www.astrobe.com/default.htm
Pascal and Basic for lots of micro and pico-processors
http://www.mikroe.com/compilers/
Ada,
http://www.ghs.com/products/ada_optimizing_compilers.html
http://www.ptc.com/developer-tools/apexada
Java for MCUs
Re: Deconstructing K&R C Is Dead (2015)
#130Earlier quoted context omitted.
> It's remarkable, though, that it's taken 40 years to make much head way in replacing C. I don't agree: it's been a long process, but the trend is unmistakable. It's hard to remember now, but in the early '90s C and C++ were completely dominant. Nowadays they're much more specialized: you're as likely to build your company on Java or even Python/Ruby as you are to build it on C++. People talk about how it's hard to…
That's quite normal, because the market today is much larger and diverse. e.g: It doesn't make any sense to build web apps in C or C++ and this type of software is very spread nowadays but was virtually non-existing back then. The interesting question is what will mobile devices, the IoT and embedded devices in general be programmed in? C and C++ are popular choices today, so the trend is not really "unmistakable".
Everything else usually has other languages available as well, one just needs to search for what is out there.