Live data from Hacker News

So you think you know C? (2016)

wordsandbuttons.online

201–210 of 344 posts

Re: So you think you know C? (2016)

#201

Earlier quoted context omitted.

Not lead designer :) But yes, Rust, or even in userspace, as newer and/or more microkernel-ish OS's allow for. Apple is doing work to allow drivers to be written in Swift...

I believe DriverKit is still C++.

...and of course pre-Apple, DriverKit was Objective-C.

Re: So you think you know C? (2016)

#202

Earlier quoted context omitted.

What would we write drivers in then if C was obsoleted?

pcwalton might have an opinion :). He is Rust lead designer.

C has a standard with multiple competing compilers.

Rust does not have these same features to date.

Re: So you think you know C? (2016)

#203
What a lot of people don’t get is that it’s not pointers or manual memory management or even lack of language level support for “modern features” like object oriented programming, exceptions etc. that make C a pain to use. No it is the undefined and implementation dependent behaviours. There are simply so many of them that even experienced C programmers may, at times, run into trouble.

C is essentially a portable assembler. It’s not enough to learn the language, you need to have deep understanding of the underlying hardware and compiler infrastructure.

Re: So you think you know C? (2016)

#204

Earlier quoted context omitted.

I couldn't agree more. After spending many years working with LLVM, which is at its heart a C compiler, and understanding why it has to do the sometimes-terrifying things it has to do to get C to run well, I've become very paranoid when writing C or C++. My C/C++ code is as boring as possible. (In fact I try to avoid writing C or C++ whenever possible these days; undefined behavior in the language is too pernicious a…

What would we write drivers in then if C was obsoleted?

Rust? I know a lot of people evangelise rust — to the point of annoyance of others — but as we move into an era where the entire world is run on computers, it is just not acceptable to have decades old infrastructure susceptible to bugs often caused by someone not understanding undefined or implementation dependent behaviour.

Re: So you think you know C? (2016)

#206

Having written a conforming C compiler, at one point I knew everything there was to know about C (I forget details now and then, or confusing them with C++ and D). But knowing every engineering detail is not the same thing as knowing how to program in C effectively. It's like being the engineer who designs a Grand Prix car. It does not mean you can drive it faster around the track than anyone else. Not even close. Fo…

And that's why people claiming that C++ is more complicated than C because it has an even bigger specification miss the point. What counts is how easy to use in practice. You can get along just fine in C++ without knowing the exact aliasing rules from C or or how to specialize a template. What matters is that the extra features of C++ makes actual programming simpler, not harder. (for example destructor (RAII), stand…

> You can get along just fine in C++ without knowing the exact aliasing rules from C

Nope, you can't. These are exactly the things that introduce undefined behavior (i.e. total breakage) if you aren't very careful about what you're doing at all times. Don't take my word for it, check out what the C++ designers themselves state about the issue in the C++ Core Guidelines. C/C++ is far from simple, and thinking that you can just make things up as you go along is a serious mistake.

Re: So you think you know C? (2016)

#208
post #11

At the end of the test, the author talks about automation programming for a nuclear power plant. I don’t think I could ever sleep the same at night after writing something like that.

> I don’t think I could ever sleep the same at night after writing something like that In these situations, you likely know your hardware and know your compiler, so you can actually provide an answer for 4 of the questions. The last one is a situation where someone should tell you not to get cute in the code review. I wrote C in telecom and finance and in both places we enforced a rule: when you define a structure, p…

Neat techniques. I had done similar stuff in some protocol code that i had a chance to write.

Re: So you think you know C? (2016)

#209

Earlier quoted context omitted.

I couldn't agree more. After spending many years working with LLVM, which is at its heart a C compiler, and understanding why it has to do the sometimes-terrifying things it has to do to get C to run well, I've become very paranoid when writing C or C++. My C/C++ code is as boring as possible. (In fact I try to avoid writing C or C++ whenever possible these days; undefined behavior in the language is too pernicious a…

> My C/C++ code is as boring as possible. One advantage to being an older programmer is I don't feel any need to show off any more. I try to make it so obvious that anyone would look at it and think that's so simple, anyone could do it. It's surprisingly hard to write simple code. Any idjit can come up with Rube Goldberg code.

Though different people consider different things simple. To one a loop is fine, to another a map is a better choice.

Re: So you think you know C? (2016)

#210
This quiz wasn't illuminating at all. You generally start with assuming and validating a "C Datatype Model" i.e. ILP32/LP64 etc. for your system. Once you know that, these questions are easily answered.

If you want to see some real tricky C code, see some of the articles here: https://locklessinc.com/articles/

Post reply on HN