Live data from Hacker News

GNU Coding Standards: Writing Robust Programs

gnu.org

41–50 of 111 posts

Re: GNU Coding Standards: Writing Robust Programs

#41
post #21

Earlier quoted context omitted.

I can't speak for the parent, but I've been using RAII and smart pointers in the 00s and it provided a lot of the benefits that got standardised with C++11.

None of that was a thing in 90s and early 00s.

Sure it was, Borland and Microsoft compilers already had smart pointers for COM libraries.

Besides even on MS-DOS with frameworks like Turbo Vision, RAII was a common pattern.

Re: GNU Coding Standards: Writing Robust Programs

#42
> In error checks that detect “impossible” conditions, just abort. There is usually no point in printing any message. These checks indicate the existence of bugs. Whoever wants to fix the bugs will have to read the source code and run a debugger. So explain the problem with comments in the source.

But then the person RUNNING the program will only see this:

    Abort trap: 6
And that's all the info you'll get from their bug report.

So please ignore this directive and print a descriptive message always, complete with file and line, and the values that led to the impossible situation. Then you can get helpful bug reports like:

    BUG: flush.c:51: buff_offset (65535) must not be greater than 20!
    Abort trap: 6

Re: GNU Coding Standards: Writing Robust Programs

#43
post #19
post #3

> When you want to use a language that gets compiled and runs at high speed, the best language to use is C. C++ is ok too, but please don’t make heavy use of templates. So is Java, if you compile it. Back in the early days, this sentence was more like "When you want to use a language that gets compiled and runs at high speed, the best language to use is C." . So we switched from a path where all major desktop environ…

C++ up to and including '98 spec was terrible from security perspective, not a iota better than plain C.

On the contrary,

- proper string and vector types (most compilers allow to enable bounds checking anyway)

- stronger rules for type conversions

- reference types for parameters

- better tooling for immutable data structures

- memory allocation primitives instead of getting sizeof wrong to malloc()

- collection library instead of reinventing the wheel in each project

- RAII

- smart pointers

- templates instead of error prone macros

- namespacing (usefull in large scale projects with prefix tricks)

Re: GNU Coding Standards: Writing Robust Programs

#44
post #3

> When you want to use a language that gets compiled and runs at high speed, the best language to use is C. C++ is ok too, but please don’t make heavy use of templates. So is Java, if you compile it. Back in the early days, this sentence was more like "When you want to use a language that gets compiled and runs at high speed, the best language to use is C." . So we switched from a path where all major desktop environ…

I don't think there is a justification for the idea that 90s "C++" was going to be substantially different from C. You can call the C files C++ and be pretty much correct. Speculatively ... the OSS community would have converged on the C part of C++. That is the well understood part.

Re: GNU Coding Standards: Writing Robust Programs

#45
post #21

Earlier quoted context omitted.

None of that was a thing in 90s and early 00s.

auto_ptr (precursor to unique_ptr) was first proposed for standardisation in 1994 [0], and there was probably non standard versions of it before 94. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/1994/N055...

ok then, nobody was using auto_ptr in the 90s.

Re: GNU Coding Standards: Writing Robust Programs

#46
post #12

Earlier quoted context omitted.

> So we switched from a path where all major desktop environments ... were adopting C++ to a surge in C programming, as FOSS adoption started to gain steam. So you say FLOSS is responsible that the late 90s/early 2000s C++ hype slowly died off? > trying to fix the security inconveniences caused by this manifesto. And you believe those projects chose C, solely because some random GNU document suggested they do? If tha…

In part yes. Had GNU/Linux not taken off, in the alternative universe from Windows, BeOS, Mac OS, OS/2, commercial UNIX (remember Motif++ and CORBA?) would kept writing the software in C++, instead of caring about creating FOSS stuff in C. GNOME vs KDE is a good example of that schism and language wars.

I remember CORBA. Oh, god, do I remember CORBA. I wish I could forget CORBA.

Re: GNU Coding Standards: Writing Robust Programs

#47
post #43
post #19

Earlier quoted context omitted.

C++ up to and including '98 spec was terrible from security perspective, not a iota better than plain C.

On the contrary, - proper string and vector types (most compilers allow to enable bounds checking anyway) - stronger rules for type conversions - reference types for parameters - better tooling for immutable data structures - memory allocation primitives instead of getting sizeof wrong to malloc() - collection library instead of reinventing the wheel in each project - RAII - smart pointers - templates instead of erro…

I'm more interested in the the actual statistics for security vulnerabilities found in C vs. C++ programmes, rather than theoretical benefits one language might have over the other.

Re: GNU Coding Standards: Writing Robust Programs

#48
post #9
post #3

> When you want to use a language that gets compiled and runs at high speed, the best language to use is C. C++ is ok too, but please don’t make heavy use of templates. So is Java, if you compile it. Back in the early days, this sentence was more like "When you want to use a language that gets compiled and runs at high speed, the best language to use is C." . So we switched from a path where all major desktop environ…

Yep, you see it also in the split away from Qt (C++) to GTK (C).

GTK is polyglot.

Re: GNU Coding Standards: Writing Robust Programs

#50
post #43
post #19

Earlier quoted context omitted.

C++ up to and including '98 spec was terrible from security perspective, not a iota better than plain C.

On the contrary, - proper string and vector types (most compilers allow to enable bounds checking anyway) - stronger rules for type conversions - reference types for parameters - better tooling for immutable data structures - memory allocation primitives instead of getting sizeof wrong to malloc() - collection library instead of reinventing the wheel in each project - RAII - smart pointers - templates instead of erro…

All of which were heavy enough at the time to slow programs down enough that people chose to not use them in favor of faster, more portable C.
Post reply on HN