Live data from Hacker News

The Development of the C Language (1993)

bell-labs.com

281–290 of 536 posts

Re: The Development of the C Language (1993)

#281
post #220

Earlier quoted context omitted.

I'm an embedded Linux engineer and I love C and Linux in particular. However, I'm considering dipping my toes in non-embedded stuff for a while, particularly full-stack development and wondering if the grass is greener on the other side from me, haha!

I did that... Then committed myself back to embedded a couple of years later.

why is that? I am an embedded linux guy but I'm learning full stack all the time, plan to be able to do both, though, it's really hard.

embedded linux pay is fine but not great, not sure how it compares to full stack jobs.

full stack at least is more remote friendly as it does not need deal with hardware hands on which is not remote friendly, and, things made by full stack is potentially more scalable.

Re: The Development of the C Language (1993)

#282
post #119

"Although the first edition of K&R described most of the rules that brought C's type structure to its present form, many programs written in the older, more relaxed style persisted, and so did compilers that tolerated it. To encourage people to pay more attention to the official language rules, to detect legal but suspicious constructions, and to help find interface mismatches undetectable with simple mechanisms for…

they should simply use c++, like k&r did to compile their example code in their 2nd ed - see preface to book if you don't believe. i will never understand why C programmers get so upset about C++. of course, the latest revisions of C introduce some new features not in C++, but nothing really major. if you want good type checking, compile your C code with C++, and fix all the type errors you will get.

I dreamed about a simplified c++, that is better/safer than c but much simpler than existing c++, call it c+, a subset c++ that enhances c but not bringing in all those c++ complexities that I 99% do not need in daily coding.

Re: The Development of the C Language (1993)

#283
post #207

My career is in full stack web development but I program in C in my master's degree coursework and as a hobby. Every time I have to peel back a decade's worth of CSS to move a button on a webapp I daydream of moving to a career in C. Is the grass actually greener on the other side?

Doing embedded in almost exclusively C since 15 years. Never had a dull day.

Re: The Development of the C Language (1993)

#284

Earlier quoted context omitted.

That’s the only caveat. With operator overloading, the scope for what happens on a given line of code expands dramatically. Now your entire dependency graph is part of the search space. Heck, the operator might not even terminate at all!

> That’s the only caveat. a = b + c; Is the addition done by itself, so it costs 1 clock cycle? Is it merged into some complex operation so the net cost is less than 1 cycle? Is it completely optimized away at compile time, so it's infinitely faster? Does the addition trigger some trap, that will run some distant code? Is the addition by itself? Or are there store and load instructions that can stall for way more tha…

> Is the addition done by itself, so it costs 1 clock cycle? Is it merged into some complex operation so the net cost is less than 1 cycle? Is it completely optimized away at compile time, so it's infinitely faster?

Those are generic instruction selection/optimization questions, which are always gonna be *additional* complexity to any and all operations everywhere. So there's still benefit in cutting down the complexity elsewhere.

> Is the addition by itself? Or are there store and load instructions that can stall for way more than 1000 cycles?

..those are questions about the loads & stores, not addition. On embedded, afaik loads & stores will be significantly closer in latency to arith too.

> At the same time, every single person that is good at micro-optimizations look at the compiled binary as a first step, because C is a high-level language that has little relation to the code the compiler actually creates.

Yes, but being able to have good intuition is still quite important, because one can think & read code much faster than compile & read assembly.

> the people repeating that execution time is well known didn't actually practice micro-optimizations based on that fact.

The question of operator overloading is mostly about reading code, not writing it. And it doesn't have to be micro-optimization either, any level of optimization will be affected by a call happening where you don't expect one (probably most importantly the kind where you scan over a piece of code to figure out if it does anything suspiciously bad (i.e. O(n^2) or excessive allocations or whatever thing may be expensive in the codebase in question) but it isn't worth the effort diving into assembly or figuring out how to get representative data for profiling the specific thing).

Or you could just be exploring a new codebase and wanting to track down where something happens, where it'd be beneficial to have to just scan through function calls and not operators.

Re: The Development of the C Language (1993)

#285

Earlier quoted context omitted.

That’s the only caveat. With operator overloading, the scope for what happens on a given line of code expands dramatically. Now your entire dependency graph is part of the search space. Heck, the operator might not even terminate at all!

> That’s the only caveat. a = b + c; Is the addition done by itself, so it costs 1 clock cycle? Is it merged into some complex operation so the net cost is less than 1 cycle? Is it completely optimized away at compile time, so it's infinitely faster? Does the addition trigger some trap, that will run some distant code? Is the addition by itself? Or are there store and load instructions that can stall for way more tha…

Your argument boils down to this: because we cannot look at an operator and have a 100% iron-clad guarantee of the exact sequence of instructions the compiler will ultimately emit, we should throw it all away and just settle for every operator in the language potentially being a function call that might be O(1) or O(n) or even O(2^n). That's called throwing out the baby with the bathwater.

every single person that is good at micro-optimizations look at the compiled binary as a first step

That isn't an option when you're writing portable code that runs on many different platforms, some of which may not even exist at the time you're writing it. Furthermore, micro-optimization isn't the only reason operator overloading is bad. The implicit flow control dramatically inflates the search space for what every single operation can do, making all code much more complicated to inspect at a glance. This carries over to debugging, where stepping through code is much more cumbersome when each operation can involve large amounts of indirection.

Re: The Development of the C Language (1993)

#286
post #6

People who still write C, honest question: Why? C is full of quirks. From cryptic "undefined behaviors" to a type system that isn't really a type system (more like "size hints for the compiler"), the language doesn't feel easy to use/debug. Add to this CPP macros, a universally recognized bad idea, a clunky import system, and lack of a single reference implementation of the compiler/libC, and you have a language that…

Because I don't like "magic". I can understand the appeal of one-liners that do the work of 100 (or more) lines of C but that's just not what I like to do. I like to be in control. I don't like side effects. "Undefined behaviors" is a propaganda. In my 15 years of programming in C, I never had an issue with "undefined behaviors". Things I created a decade ago still run like a champ on a damn coin cell.

Re: The Development of the C Language (1993)

#287
post #277

Earlier quoted context omitted.

I’m also a “full-stack” web developer and would love to transfer to a career in C (or Rust also?). There’s such a wide variety of interesting problems to be solved over many applications. I’m not sure how I would begin making a career transfer. Would anyone happen to have any advice / experience on this? I would be really grateful! (based in UK if that helps)

The best way to do it (if you can) is to get paid for making the change. First, study C and/or Rust on your own. Maybe do a personal project or two. Second, find something at work where Rust or C would bring some benefits. Tell your boss that you think this would work better in a language like Rust or C, and explain why. Volunteer to try to do it. (Note: Appearing too eager at this point might be a mistake.) Do the s…

Thanks so much for your advice! I agree, having the opportunity to use the language as part of your daily-work helps massively, and is one of the best but most difficult options to realize. I'm aware this will come with some sacrifices (pay reduction, longer hours to catch-up) which I'm willing to make while I become more competent.

As for the second point, that is a great suggestion. However, I'm very limited by my current working environment (regulation, corp. restrictions, etc.) so it becomes a little more difficult.

I believe I will just have to push very hard for option one and continue to study areas of interest in my spare time. I'm reading xv6: a simple, Unix-like teaching operating system which is helping me grasp some practical applications using C.

Re: The Development of the C Language (1993)

#288
post #277

Earlier quoted context omitted.

I’m also a “full-stack” web developer and would love to transfer to a career in C (or Rust also?). There’s such a wide variety of interesting problems to be solved over many applications. I’m not sure how I would begin making a career transfer. Would anyone happen to have any advice / experience on this? I would be really grateful! (based in UK if that helps)

The best way to do it (if you can) is to get paid for making the change. First, study C and/or Rust on your own. Maybe do a personal project or two. Second, find something at work where Rust or C would bring some benefits. Tell your boss that you think this would work better in a language like Rust or C, and explain why. Volunteer to try to do it. (Note: Appearing too eager at this point might be a mistake.) Do the s…

Also know your boss. I know I cannot suggest such a thing to my boss. Generally, the more "serious" your company is with an established stack the less likely you're going to get a green light to do anything not blessed by management.

If OP plays it wrong they can also look like a tonedeaf dunce. Definitely try to read the room.

Re: The Development of the C Language (1993)

#289
everyone should learn c/c++.

you need it when exploring the performance ceiling of a workload. without an understanding of performance ceiling, you can’t design a system well.

if you want to approach that ceiling[1], you need to implement c/c++. if not, it’s better to have chosen not than been forced not.

between ccls, clangd, and clion, tooling is fantastic now. it’s a great time to start.

1. https://github.com/nathants/bsv

Re: The Development of the C Language (1993)

#290

Earlier quoted context omitted.

I did that... Then committed myself back to embedded a couple of years later.

why is that? I am an embedded linux guy but I'm learning full stack all the time, plan to be able to do both, though, it's really hard. embedded linux pay is fine but not great, not sure how it compares to full stack jobs. full stack at least is more remote friendly as it does not need deal with hardware hands on which is not remote friendly, and, things made by full stack is potentially more scalable.

I am going sort of the embedded full stack way. Like include microcontrollers and fpgas along with Linux embedded. Most of my hobby projects are heavy on electronics and ham radio. I'd rather spend more time getting a better understanding in RF than getting better at react, typescript etc. Don't get me wrong, if you need a good UI it seems way more versatile to have a web server and a rest api than a qt GUI, but getting better at that just doesn't feel nearly as fulfilling as learning one more corner case in antena design.. to each his own
Post reply on HN