Live data from Hacker News

Modern C [pdf]

icube-icps.unistra.fr

41–50 of 396 posts

Re: Modern C [pdf]

#41
post #36
post #9

It's been a decade or more since I've worked in C (and have never been a heavy C coder). Is "modern C" really a thing? I mean, is there some subset of C that is safer than what I think of when I think of C? I know about stuff like reference counting techniques, rather than manual memory management, for example, and that goes miles towards safer coding. But, even so, the variety of ways you can shoot yourself in the f…

Go has chosen to omit assert(), because assert() is frequently misused they say. Antibiotics are also frequently misused, but that is not a good reason to prohibit them. The omission of assert() makes Go a non-starter. Rust seems more promising, but it is still not to the point where I am interested in rewriting SQLite in Rust, though I may revisit this decision in future years. Some current reasons to continue to pr…

Pragmatism over "Oooh Shiny", one of the reasons I have huge respect for the sqlite project ;).

Rust looks pretty decent but I'm still in the wait and see stage as well.

Re: Modern C [pdf]

#42
post #36
post #9

It's been a decade or more since I've worked in C (and have never been a heavy C coder). Is "modern C" really a thing? I mean, is there some subset of C that is safer than what I think of when I think of C? I know about stuff like reference counting techniques, rather than manual memory management, for example, and that goes miles towards safer coding. But, even so, the variety of ways you can shoot yourself in the f…

Go has chosen to omit assert(), because assert() is frequently misused they say. Antibiotics are also frequently misused, but that is not a good reason to prohibit them. The omission of assert() makes Go a non-starter. Rust seems more promising, but it is still not to the point where I am interested in rewriting SQLite in Rust, though I may revisit this decision in future years. Some current reasons to continue to pr…

>The omission of assert() makes Go a non-starter.

A small syntactic sugar you can trivially implement yourself makes Go a non-starter?

Go doesn't include assert in the language because you're supposed to do better than assert. Assert easily allows lazy programmers to let their programs freely crash without properly handling error conditions. Go prevents you from compiling with unused variables, and that combined with the Go documentation goes a long way towards teaching new Go programmers how they're expected to work.

And neither Go nor Rust could possibly be good fits for SQLite. A Go hello world is bigger than all of SQLite while an idiomatic Rust one is on par, and neither's nearly as portable as the current C implementation, one that is both programatically and battle-tested like pretty much nothing else in the world.

Re: Modern C [pdf]

#43
post #9

It's been a decade or more since I've worked in C (and have never been a heavy C coder). Is "modern C" really a thing? I mean, is there some subset of C that is safer than what I think of when I think of C? I know about stuff like reference counting techniques, rather than manual memory management, for example, and that goes miles towards safer coding. But, even so, the variety of ways you can shoot yourself in the f…

> Would anyone choose C for a new systems project with no legacy baggage or dependencies, in a world with Rust and Go? I imagine it is easier to hire C programmers than Rust programmers, at the moment, especially in fields like embedded development.

Also Rust doesn't support compiling to certain architectures like the Xtensa ISA used in the popular ESP8266 and ESP32 wi-fi chips.

Re: Modern C [pdf]

#44
post #36

Earlier quoted context omitted.

Go has chosen to omit assert(), because assert() is frequently misused they say. Antibiotics are also frequently misused, but that is not a good reason to prohibit them. The omission of assert() makes Go a non-starter. Rust seems more promising, but it is still not to the point where I am interested in rewriting SQLite in Rust, though I may revisit this decision in future years. Some current reasons to continue to pr…

>The omission of assert() makes Go a non-starter. A small syntactic sugar you can trivially implement yourself makes Go a non-starter? Go doesn't include assert in the language because you're supposed to do better than assert. Assert easily allows lazy programmers to let their programs freely crash without properly handling error conditions. Go prevents you from compiling with unused variables, and that combined with…

> Assert easily allows lazy programmers to let their programs freely crash without properly handling error conditions.

This is what he meant by misuse. Properly-used assertions are meant to document and check conditions that were thought to be impossible by the developer. Not just unlikely, or illegal, but impossible. If a condition is possible, and you check it with assert, that's a bug.

Re: Modern C [pdf]

#45
Sounds like an Oxymoron. "Make sure your buffer flow exploits are up to the minute! Make sure your systematic lack of memory safety totally captures the zeitgeist!"

Re: Modern C [pdf]

#47

Earlier quoted context omitted.

Sure, "systems programming" has a variety of meanings. But, there are a lot of areas where C was the obvious choice in the past but Go might be a suitable replacement today. Areas where concurrency and safety is maybe more important than raw performance: Databases (and there are many now written in Go, including alternative types of databases like time series, key/value, etc.), servers, etc. I tend to consider those…

Databases have been written in Java, too; but the combination of performance unpredictability (not something Go has addressed, since it is also garbage-collected) and a bad C compatibility story has proven to limit the reach of these projects.

True. Even very successful database projects in Java have some issues with GC pauses.

Go seems to be, IMO, taking the things Java is best at and trying to make something better. Basically, how would you build Java today if you could do it again?

Re: Modern C [pdf]

#48
post #32
post #21

Earlier quoted context omitted.

> Does it advocate good best practices? That may come down to opinion. For example, type qualifiers are bound to the left. Traditionally you would write: char *var; They advocate keeping type on the left, name on the right, so: char* var; A few things like that are covered under "Warning to experienced C programmers". Personally, I prefer it, but have always done what everyone else expects, so there are no fights ove…

Note that var1 and var2 are not the same type: char* var1, var2; Traditional style makes this clear.

> We bind type modifiers and qualifiers to the left.

Good idea in theory but your example shows how bad it behaves in practice.

Re: Modern C [pdf]

#49

I've had no luck learning a language on its own. But I've had a lot of luck learning languages as part of something bigger. Like C# via. Unity, Swift via. 2D game dev in XCode. Any suggestions on what I should apply C to as a way to learn it?

Arduino and other micro controllers. First of all it's really fun (YMMV). There is something about writing code that makes things happen in the physical world which is satisfying in ways that writing code that just affects bits on a computer isn't. Secondly it's one of the realms where C is still genuinely important. When you are working on problems where a few hundred bytes this way or that is difference between success and failure you really start to appreciate what C has to offer.

Re: Modern C [pdf]

#50
post #36

Earlier quoted context omitted.

Go has chosen to omit assert(), because assert() is frequently misused they say. Antibiotics are also frequently misused, but that is not a good reason to prohibit them. The omission of assert() makes Go a non-starter. Rust seems more promising, but it is still not to the point where I am interested in rewriting SQLite in Rust, though I may revisit this decision in future years. Some current reasons to continue to pr…

Pragmatism over "Oooh Shiny", one of the reasons I have huge respect for the sqlite project ;). Rust looks pretty decent but I'm still in the wait and see stage as well.

I was trying to teach myself some Rust and found the state of the documentation to be very frustrating. The core language is decently documented with the manual, but the standard library documentation was out of date in many places, most annoyingly in the first few hits on Google.

I found 5 different ways to read a file on Google, and only one of them still worked. Plus I saw the release notes on the newest version that the syntax that worked is now obsolete in favor of a new operator.

Post reply on HN