Live data from Hacker News

Deconstructing K&R C Is Dead (2015)

c.learncodethehardway.org

81–90 of 190 posts

Re: Deconstructing K&R C Is Dead (2015)

#81
post #48

Earlier quoted context omitted.

Ironic, but the one think they are missing is an easy convenient way to call C libraries. Rust is very promising language, but unless you plan to write everything from scratch, you have to depend on 3rd party driver implementations for most stuff. Databases for example. There isn't a single database vendor that has Rust drivers.

Calling C from Rust is very convenient. All you have to do is declare the structs and function signatures and then it's like calling any other unsafe function.

IMHO it is OK if you are only going to call a few simple one, but for calling a few hundred complex ones (callbacks with variable argument list, etc..), it becomes a bit cumbersome.

BTW I am not implying that is Rust's fault, actually I can't think a syntax that would make it less verbose, and I am a huge Rust fan.

Re: Deconstructing K&R C Is Dead (2015)

#82
post #8

This 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…

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…

When I've mentioned what you propose to other programmer I always get baleful looks and a statement that, 'that's not how C is supposed to work'. Mention bounds checking, same thing.

I used to think it was hopeless, especially as each new language that came out required garbage collection or worse targeted the JVM. Perhaps cloud services will motivate people to fix this stuff since now computing costs are a hard line item on the books.

Re: Deconstructing K&R C Is Dead (2015)

#83
post #70

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.

Out of curiosity, do you have an example? Maybe I live in a C reality distortion field. :)

There are so many to choose from. Here is one I just thought up:

    void free_circularly_linked_list(struct node *head) {
      struct node *tmp = head;
      do {
        struct node *next = tmp->next;
        free(tmp);
        tmp = next;
      } while (tmp != head);
    }
Can you spot the undefined behavior?

Re: Deconstructing K&R C Is Dead (2015)

#84
post #78
post #37

Earlier 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…

Only, it isn't knob and tube or asbestos. It's much more like comparing crawling (machine code), walking (assembly), C (bi-cycling), and higher level languages (faster to write, more built in safety features, etc). Each is a good fit for a given role, and sometimes you need to get through tight spaces where using one of the lower impact methods is more effective; or maybe you just can't afford something 'nicer'. Use…

My C programs have crashed much more often than my bicycle...

Re: Deconstructing K&R C Is Dead (2015)

#85
K&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 a poor style.

Re: Deconstructing K&R C Is Dead (2015)

#86
post #54
post #6

Low level languages are tough. Gaining a mastery of C does require knowing quite a few strange rules and quirks and it's certainly a bit harder than learning Python. The C FAQ does a good job of illustrating some of the more confusing parts. Sure, I wish I could write Go instead, but that isn't going to happen on the many embedded systems I work on. This is a rather strange and insulting article. I'm not sure why Zed…

> Low level languages are tough I disagree. Low level languages, especially C, are the easiest to master. 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. C++ on the other hand is extremely difficult to master. Just have a look at the rules for Rvalue references and you will see what I mean. It may be easier for a complet…

This is not true because K&R does not address multithreaded programming at all.

Re: Deconstructing K&R C Is Dead (2015)

#87
post #37

Earlier 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.

Things look different from the outside than they do on the inside. The old saw of "science advances one funeral at a time" is true in lots of fields, you just probably see a lot more examples in programming because you spend more of your time there.

Re: Deconstructing K&R C Is Dead (2015)

#88
post #70

Earlier quoted context omitted.

Out of curiosity, do you have an example? Maybe I live in a C reality distortion field. :)

There are so many to choose from. Here is one I just thought up: void free_circularly_linked_list(struct node *head) { struct node *tmp = head; do { struct node *next = tmp->next; free(tmp); tmp = next; } while (tmp != head); } Can you spot the undefined behavior?

The `tmp != head` comparion is UB because `head` is a dangling pointer after the first loop iteration, right?

Re: Deconstructing K&R C Is Dead (2015)

#89

Maybe this made Zed feel better, but communicates almost nothing to any outside reader. Not a single actual quote from any of his detractors, for the reader to judge for him or her self if their criticisms have any validity. The categorical declaration of "I cannot help old programmers," without providing the evidence he has for this claim. Lots of name calling, though. No link to the original content, to determine f…

> I suppose Zed just meant this to be personally cathartic, and didn't realize he posted it on a public web site where other people can read it?

He's done these kinds of rants repeatedly. It's his counter-productive style. I can't judge his arguments on a technical level, (I do think his introduction to various language guides are excellent.) but these kinds of rants surely just alienate more people than they persuade?

Re: Deconstructing K&R C Is Dead (2015)

#90
post #22

Earlier 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.

Stop using MCU from the 1980 and you can at least use C++.
Post reply on HN