Live data from Hacker News

Modern C (2019)

gustedt.gitlabpages.inria.fr

1–10 of 57 posts

Re: Modern C (2019)

#4

I enjoy programming in C a lot, though I wish they would fix C's biggest mistake[1]. [1] https://digitalmars.com/articles/C-biggest-mistake.html >

C biggest "mistake" (there are historical reasons for this, though, but it doesn't make it acceptable nowadays) is the concept of undefined behavior, period.

Re: Modern C (2019)

#5

I enjoy programming in C a lot, though I wish they would fix C's biggest mistake[1]. [1] https://digitalmars.com/articles/C-biggest-mistake.html >

The declaration syntax and the lack of a proper module/namespacing system is also a mistake, but perhaps not as big as the way arrays decays into pointers. Implicit conversions I suppose could also be classified as a mistake.

Re: Modern C (2019)

#6
post #4

I enjoy programming in C a lot, though I wish they would fix C's biggest mistake[1]. [1] https://digitalmars.com/articles/C-biggest-mistake.html >

C biggest "mistake" (there are historical reasons for this, though, but it doesn't make it acceptable nowadays) is the concept of undefined behavior, period.

Every language has undefined behavior - it's just that some compilers emit an error when it's encountered. You can make a C compiler that refuses to compile code with undefined behavior.

Re: Modern C (2019)

#7
post #4

I enjoy programming in C a lot, though I wish they would fix C's biggest mistake[1]. [1] https://digitalmars.com/articles/C-biggest-mistake.html >

C biggest "mistake" (there are historical reasons for this, though, but it doesn't make it acceptable nowadays) is the concept of undefined behavior, period.

There is a tradeoff though because it allows the code to be optimised more which is often something you want from C code

Re: Modern C (2019)

#8
post #4

Earlier quoted context omitted.

C biggest "mistake" (there are historical reasons for this, though, but it doesn't make it acceptable nowadays) is the concept of undefined behavior, period.

Every language has undefined behavior - it's just that some compilers emit an error when it's encountered. You can make a C compiler that refuses to compile code with undefined behavior.

Most undefined behaviour can’t be reliably detected at compile time, though you could throw the error at runtime or make the behaviour defined instead

Re: Modern C (2019)

#9
post #4

I enjoy programming in C a lot, though I wish they would fix C's biggest mistake[1]. [1] https://digitalmars.com/articles/C-biggest-mistake.html >

C biggest "mistake" (there are historical reasons for this, though, but it doesn't make it acceptable nowadays) is the concept of undefined behavior, period.

Should a compiler be allowed to optimize:

    int x = 0;
    int y = 42;
    foo(&x);
    bar(y);
to:

    int x = 0;
    foo(&x);
    bar(42);
without performing analysis on foo? If so, how can that optimization be legal without UB?

Re: Modern C (2019)

#10
Related:

Modern C - https://news.ycombinator.com/item?id=24361469 - Sept 2020 (165 comments)

Modern C, Second Edition - https://news.ycombinator.com/item?id=21006995 - Sept 2019 (233 comments)

Modern C by Jens Gustedt - https://news.ycombinator.com/item?id=19733852 - April 2019 (2 comments)

Modern C [pdf] - https://news.ycombinator.com/item?id=13054705 - Nov 2016 (385 comments)

Modern C [pdf] - https://news.ycombinator.com/item?id=9018247 - Feb 2015 (43 comments)

Post reply on HN