Live data from Hacker News

Modern C and What We Can Learn from It [video]

youtube.com

111–120 of 132 posts

Re: Modern C and What We Can Learn from It [video]

#111

Earlier quoted context omitted.

While this is mostly true, there are some (very limited) circumstances where modern language constructs are legitimately the best approach. Generic libraries are probably the most obvious case where you may need some fancy metaprogramming. Move semantics and other similar tricks for avoiding copies are often used for saving much more than a 24-byte copy. Unfortunately, a lot of C++ enthusiasts who write this kind of…

The C answer to generics is void pointers, careful programmers, and CVEs. CVEs are the most important C language construct.

https://insights.dice.com/2019/11/27/programming-language-vu...

I think this has reasonable explanation:

“The high number of open source vulnerabilities in C can be explained by several factors,” the organization added in a blog posting. “For starters, C has been in use for longer than any of the other languages we researched and has the highest volume of written code. It is also one of the languages behind major infrastructure like Open SSL and the Linux kernel. This winning combination of volume and centrality explains the high number of known open source vulnerabilities in C.”

So... C++ is there. That it isn't the top of the list is a reflection on the fact that it is rarely used for important stuff.

Nobody registers CVEs for computer games, yet they are predominantly written in C++ and full to the brim with security holes. If what you said was true, these should fare better than C code, and yet they do not.

Re: Modern C and What We Can Learn from It [video]

#112

What I really want, is a C++ book that lists the absolutely must-have features for a beginner-intermediate programmer, I don't want to be overloaded(no pun intended) with all those 2000 advanced features, I can read an advanced level book when I'm ready. Basic types, smart-pointers(how to use them and when to use them), basic OOD and template(but no advanced tricks), essential algorithms and containers, that's about…

I also wish such book could exist. Seems we have to rely in our instincts to realize when an author is getting a bit too "enthusiastic" with C++.

Re: Modern C and What We Can Learn from It [video]

#113
post #53
post #45

Earlier quoted context omitted.

No upvote can tell how much I relate to this. The only way to get a good maintainable C++ code is to hire very mediocre programmers whose “C++” really means “Qt with some shared ptrs”. The reason (I believe) is that complex things are like hard drugs for smart people. Instead of solving business tasks, which honestly are often just boring, they long for an art in programming. In C++ this inevitably leads to solving n…

> The reason (I believe) is that complex things are like hard drugs for smart people. That is the golden explanation I kind of understood internally but never formulated consciously. Yes, that's exactly it. It takes willpower to be able to refrain from all those shiny toys. You see one and you are immediately imagining what you could use it for. Writing C is like using typewriter or distraction-free editor, putting a…

>The reason (I believe) is that complex things are like hard drugs for smart people.

>That is the golden explanation I kind of understood internally but never formulated consciously.

I am thinking would it be fair to say C++ are for the wicked smart but C are for ones with age old wisdom.

Re: Modern C and What We Can Learn from It [video]

#114
post #56

Earlier quoted context omitted.

What I miss most when working in C instead of C++ is that although lint was created in 1979, most projects still avoid any kind of static analysis. Then there are the discussions on: - what warnings to turn on as errors - what ISO C says and what compiler XYZ does, with many not even aware to the differences - not clear understanding of the 200+ UB cases documented on the standard - in-house libraries for safer handl…

Almost all above applies to C++ too.

It does indeed, with the big difference that C++ community cares to reduce the amount of UB on the standard, and pushes for language features that improve safety.

Now if people choose to ignore the tools available to them, just like they enjoy ignoring lint since 1979, well there is little the doctor can do to save patients that refuse help.

Re: Modern C and What We Can Learn from It [video]

#115
post #113
post #53

Earlier quoted context omitted.

> The reason (I believe) is that complex things are like hard drugs for smart people. That is the golden explanation I kind of understood internally but never formulated consciously. Yes, that's exactly it. It takes willpower to be able to refrain from all those shiny toys. You see one and you are immediately imagining what you could use it for. Writing C is like using typewriter or distraction-free editor, putting a…

>The reason (I believe) is that complex things are like hard drugs for smart people. >That is the golden explanation I kind of understood internally but never formulated consciously. I am thinking would it be fair to say C++ are for the wicked smart but C are for ones with age old wisdom.

Some more:

Any problem has many possible solutions, but only one (well... few) are simplest.

It doesn't take much intelligence to write complicated code, this is just finding "a" solution.

Finding simple solution requires understanding of range of all possible solutions or at least a lot of them, understanding what makes them simple, and selecting the one that is simplest.

If you are smart and want to show it, why not show your smarts by finding simple solution to the problem?

Re: Modern C and What We Can Learn from It [video]

#116

Earlier quoted context omitted.

> allows for out parameters Out parameters are mostly a legacy feature from the time when C compilers didn't allow struct return values though, or implemented this inefficiently (besides, out parameters via pointers works too). > memory addresses without the unsafety of dealing with pointers I never understood the "increased safety" argument. C++ references can become dangling just as easily as pointers, and arguable…

> Out parameters are mostly a legacy feature from the time when C compilers didn't allow struct return values though, or implemented this inefficiently (besides, out parameters via pointers works too). ah yes, that legacy, age-old GCC 11 compiler https://gcc.godbolt.org/z/rYsxxTxqd

Wow. The function produces identical code when inlined, so why does the C version require that memcpy when it's not inlined?

Re: Modern C and What We Can Learn from It [video]

#117
post #44
post #42

Earlier quoted context omitted.

It is a culture problem, something that only will change with mentality reboot. "CppCon 2016: Dan Saks “extern c: Talking to C Programmers about C++”" https://www.youtube.com/watch?v=D7Sd8A6_fYU "Writing better embedded Software - Dan Saks - Keynote Meeting Embedded 2018" https://www.youtube.com/watch?v=3VtGCPIoBfs "Embedded & C++ - Meeting 2017 Keynote" https://www.youtube.com/watch?v=mNPfsUZb3vs In a way, the same…

I think the basic issue is that C++ want to spend a lot of time focusing on C++ The Language, while C developers mostly want to focus on developing the logic of whatever they are doing. When I worked on C++ projects half of the discussion was on just the use of language or various consequences of it. On C projects that never happens. There is nothing to talk about so everybody focuses on making the project better. Th…

> I think the basic issue is that C++ want to spend a lot of time focusing on C++ The Language, while C developers mostly want to focus on developing the logic of whatever they are doing.

This is just libel, really. There are meta-nerds in C and C++, but there is also a great majority of programmers just interested in delivering good software.

Re: Modern C and What We Can Learn from It [video]

#118

What I really want, is a C++ book that lists the absolutely must-have features for a beginner-intermediate programmer, I don't want to be overloaded(no pun intended) with all those 2000 advanced features, I can read an advanced level book when I'm ready. Basic types, smart-pointers(how to use them and when to use them), basic OOD and template(but no advanced tricks), essential algorithms and containers, that's about…

"A Tour of C++" is only 256 pages and the 1st edition is what I used to get into modern C++ in the workplace years after a strange mix of C/C++ labs in college.

true, a great book that I'm reading now, but it's more of a 'tour guide' indeed. It's probably the closest I can find however.

Re: Modern C and What We Can Learn from It [video]

#119
post #55
post #2

Association of C and C++ Users (ACCU) They should really just call themselves the ACU, they are wildly pro C++. It's progress that there is even a C talk at all at their conference but even looking at the title it's pitching itself at "No really, C isn't completely worthless" One day such language wars might seem quaint. While everyone has their livelihoods tied to their chosen technologies it probably won't. C++ is…

Not trying to start a language war, but what exactly would you use C for? C++ is just as good at embedded, and you can use it as basically a slightly less foot-gunny C. And there is also Rust and Zig, if that’s not really what you want. I just can’t really use C with that amount of namespace pollution, at least namespaces should be added. And purely text-based macros are the worst thing ever.

Rust is very, very complicated and Zig is not stable.

Re: Modern C and What We Can Learn from It [video]

#120

Earlier quoted context omitted.

The C answer to generics is void pointers, careful programmers, and CVEs. CVEs are the most important C language construct.

https://insights.dice.com/2019/11/27/programming-language-vu... I think this has reasonable explanation: “The high number of open source vulnerabilities in C can be explained by several factors,” the organization added in a blog posting. “For starters, C has been in use for longer than any of the other languages we researched and has the highest volume of written code. It is also one of the languages behind major inf…

That's kind of a useless chart for the reason you point out, which is that it doesn't divide by language use.

I think computer games are a bad example because game developers don't care about code quality for their release-once-and-done games.

Post reply on HN