Live data from Hacker News

Switching to C over 'Modern' Programming Languages

devtails.xyz

71–80 of 170 posts

Re: Switching to C over 'Modern' Programming Languages

#71
post #30
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…

While I agree, I also have to say that Rust does a lot more than just solve some specific C and C++ issues. It doesnt solve all of them (e.g. logic errors, so if thats 90% of your issues you wont benefit too much), it repeats some design issues of C++ (massive complexity from the start, many ways to do the same thing), and implements a C-like unsafe{} language anyways. If Rust was just C but with strong typing, a bor…

> If Rust was just C but with strong typing, a borrow checker and what would basically be super strong static analysis of pairing malloc() and free(), people would likely switch immediately.

This is in a nutshell why I haven't switched to Rust. All I actually want is a small language like C, Go or Zig, but with compile time memory safety guarantees. Even if it means that a lot of 'dangerous' flexibility is removed or in an unsafe{} block (essentially a Rust--).

IMHO one problem with Rust is that it is moving too quickly into too many different directions, and as a result becoming a 'kitchen-sink language' in the tradition of C++.

Re: Switching to C over 'Modern' Programming Languages

#72

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. C gives you enough rope to shoot yourself in the foot. And rightfully so. It came out in a time when everyone was coding assembly. It's meant not to hold you back from doing voodoo with low-level stuff, therefore it won't hold your hand. Not very practical in the world of today when we've been spoiled by…

> when everyone was coding assembly.. This was before my time, but I think it's a common misconception (only true for operating system development). When C was created, there was already Lisp, Cobol, Fortran, Algol, Simula, BASIC... and SmallTalk and Prolog were just around the corner - and most of those are much higher level than C).

I think parent knows. A more accurate description would be everyone of the intended audience was writing assembly. Yes there are other languages of higher levels, but C was not invented to help their users. And since they are also not really what Rust targets either, IMO it’s reasonable to shorten it to drop the qualifier in this context.

Re: Switching to C over 'Modern' Programming Languages

#73
post #36
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…

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 abstracting all this by now? Either your own or one of the dozens available, including pascal-style strings?

Re: Switching to C over 'Modern' Programming Languages

#74

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. C gives you enough rope to shoot yourself in the foot. And rightfully so. It came out in a time when everyone was coding assembly. It's meant not to hold you back from doing voodoo with low-level stuff, therefore it won't hold your hand. Not very practical in the world of today when we've been spoiled by…

> when everyone was coding assembly.. This was before my time, but I think it's a common misconception (only true for operating system development). When C was created, there was already Lisp, Cobol, Fortran, Algol, Simula, BASIC... and SmallTalk and Prolog were just around the corner - and most of those are much higher level than C).

Sure, but none of those were for systems programming which is squarely the domain that C was aimed at, case in point: the first thing that C was used to write was UNIX (before then it was BCPL and this was iirc before C even had structs which made that a very tricky job, once structs were in place it got a lot easier). Probably Don Hopkins has more knowledge about this.

Re: Switching to C over 'Modern' Programming Languages

#75
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…

>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. C gives you enough rope to shoot yourself in the foot. And rightfully so. It came out in a time when everyone was coding assembly. It's meant not to hold you back from doing voodoo with low-level stuff, therefore it won't hold your hand. Not very practical in the world of today when we've been spoiled by…

> C gives you enough rope to shoot yourself in the foot.

If this was intended to illustrate the unexpected consequences of undefined behavior it succeeded remarkably well!

Re: Switching to C over 'Modern' Programming Languages

#76
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…

I have something like this that serves me well: struct strbuf { size_t cap, len; char *str; }; void sb_setf(struct allocator *a, struct strbuf *sb, const char *fmt, ...); void sb_appendf(struct allocator *a, struct strbuf *sb, const char *fmt, ...); // have other convenience functions for formatting fixed point values like "prefix AAA.BBB suffix" ("voltage: 7.23 V") // special helpers for dates, times, etc. Just keep…

Could even use something like Gnome's GLib

Re: Switching to C over 'Modern' Programming Languages

#78
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…

> Rust exists for a reason, and it solves specific problems.

But if say the foundation that supports it's development were to try asserting draconian control over it, many may reasonably be turned off.

I'll stick to C/C++ personally, rust does seem less flavor of the month but I can't get behind it if it's clear there are nutjobs at the helm.

Re: Switching to C over 'Modern' Programming Languages

#79
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…

>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. C gives you enough rope to shoot yourself in the foot. And rightfully so. It came out in a time when everyone was coding assembly. It's meant not to hold you back from doing voodoo with low-level stuff, therefore it won't hold your hand. Not very practical in the world of today when we've been spoiled by…

>It came out in a time when everyone was coding assembly

Expect to hear from @pjmlp on this!

Re: Switching to C over 'Modern' Programming Languages

#80
post #34
post #28

Earlier quoted context omitted.

> 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? It sounds to me like they keep learning languages with the same illusions and failing to take any lessons between their language exploration escapades. All programming languages suck. It's just about finding the one that sucks the least for you (or your project/business). They m…

Disagree on c++. Even if you forego the significant improvements in the last decade then: RAII and templates make it worth not using C anymore. Having to use shoddy macros for a resizeable array is just unreasonable.

I've written C++ for a long time, and I do agree that the language brings certain improvements over C. I think most people will agree with that. However, C++ can be incredibly frustrating to work with depending on the codebase.

Overall, C++ can be great choice, but it often times results in not being due to lack of rigorous discipline by everyone involved on the project.

It's a bit philosophical whether that's a problem of the tool or the craftsman, but I think it's usually a bit of both.

Post reply on HN