Live data from Hacker News

Switching to C over 'Modern' Programming Languages

devtails.xyz

131–140 of 170 posts

Re: Switching to C over 'Modern' Programming Languages

#132
post #51

I used to love C for its simplicity. There was just no surprises, and the limited feature set enforced a certain programming style that also happens to run very well on modern CPUs. But the C standard library is just awful. It's so inconsistent and full of quirks you just have to know. Like how some string functions allow you to specify a size, while others don't. And how strtok keeps track of an internal state and b…

> But the C standard library is just awful. This is very painfully true, but one 'killer feature' of C is that it is useful without ever using stdlib functions (except basics like memset, memcpy, ... which can be considered compiler builtins anyway). In more recent languages (even C++) there is no such clear distinction between the language and stdlib any more, which IMHO is a real problem (e.g. most of C++'s problem…

Because it was designed with UNIX API surface in mind, and also the reason why outside embedded and Windows everyone with a C compiler does POSIX, even crufty mainframes that are still being sold.

Re: Switching to C over 'Modern' Programming Languages

#133
post #73
post #36

Earlier quoted context omitted.

I'm a C programmer by day and I disagree with them, C is only simple if you're trying to do simple tasks with it. The very common thing I want to use in C is some sort of variable size string object. But no, I have to dynamically allocate a buffer that I know will be at least the right size for any text I ever put into it, or do I create a buffer that's the correct size for that string but re-alloc if I ever change i…

> The very common thing I want to use in C is some sort of variable size string object. But no, I have to dynamically allocate a buffer that I know will be at least the right size for any text I ever put into it, or do I create a buffer that's the correct size for that string but re-alloc if I ever change it to a longer string. But then how do I store the buffer size? As a C programmer shouldn't you have a library ab…

Okay, so you write your own string library. Now you'd like to do the same thing for resizable arrays, so you write a resizable array li… oops, you can't, because C doesn't have parametric types.

Re: Switching to C over 'Modern' Programming Languages

#134
post #16

Is this becoming a thing now (or maybe it was always a thing), where a language, like Rust, has become popular enough that instead of everyone talking about learning it, they now want to talk about how “simple” and “beautiful” C is for no other reason than signaling how different you are from the zeitgeist? Rust exists for a reason, and it solves specific problems. That’s the “magic”, just like any abstraction in any…

Only when a certain language community tries to promote itself as a “better” C and thinking all C code should be converted and then some people actually tried and do not agree with it.

Just write programs with your favorite language, if it is actually a “better “ one it will win, and you don’t annoy yourself and others by over promoting it. C did not start by building a evangelical strike force but bunch of programmers that actually wrote software that people have to use.

Re: Switching to C over 'Modern' Programming Languages

#135

Earlier quoted context omitted.

The other side of the medal (especially for game development), is that in the higher level parts of game code you need quick turnaround times for experimentation and tweaking, and most of that code won't even make it into the final product (so all the upfront time you spent thinking about proper architecture and ownership details is wasted up there). The traditional solution is to have different languages for differe…

I wish there was a language that is to JavaScript/TypeScript/Python/Lua what Rust is to C++/C/Java.

Do you mean like a scripting language that is brand new and doesn’t have a ton of historical warts?

Re: Switching to C over 'Modern' Programming Languages

#136

Earlier quoted context omitted.

Yeah, Rust may be a good choice for a game engine, but at the same time not a good choice for the actual game code.

To counter myself, I could also easily imagine that game engines are also full of dirty hacks to get things that the front end people want done, now, by hook or by crook. Ie, if a nice sane interface doesn't exist, and woukd take more than 11 minutes to add the right way, then just butcher in any kind of tight coupling and to hell with worrying about it breaking for the next game.

Oh no, I think you made a good point. I was definitely thinking about game code per se, rather than engines. The extra rigour around an engine (any library code, really) is definitely a good thing

Re: Switching to C over 'Modern' Programming Languages

#137
post #128
post #112

Earlier quoted context omitted.

It is quite difficult to write idiomatic C++ without memory allocation, for one, which is often a requirement for embedded code or any high-availability code that is not allowed to have memory fragmentation. Sure, it's possible (you can write C in C++, for the most part, and to its credit, C++ has placement new). But many of C++'s niceties require memory allocation, making much of its value-add over C questionable.

It super easy, we did it all the time back in the MS-DOS days.

right, but that was pre C++ niceties like the STL :).

Re: Switching to C over 'Modern' Programming Languages

#138

Earlier quoted context omitted.

Small typo correction for anyone trying to search or learn more about the term: it's "provenance", not "providence".

Ha woops. My mind is in Rhode Island :)

^_^

Although I am tickled by the idea of pointer providence – that pointers are handed to us from on high, from the C gods.

Re: Switching to C over 'Modern' Programming Languages

#139

Earlier quoted context omitted.

Ha woops. My mind is in Rhode Island :)

^_^ Although I am tickled by the idea of pointer providence – that pointers are handed to us from on high, from the C gods.

That's how it works in Python

Re: Switching to C over 'Modern' Programming Languages

#140
post #9

Don’t expect to see immediate benefit from Rust by writing a small Pong application. Rust gives you confidence at scale: the ability to depend on many 3rd party blocks without compromising stability or performance, the ability to grow and maintain the code, collaborate on it, etc. Nothing of this is easily seen on a small self-contained program you can write in C.

> Don’t expect to see immediate benefit from Rust by writing a small Pong application.

This is easily solved by writing a large Pong application in Rust.

Post reply on HN