6 ms·
Dependable C
- keyle 11mo agoThere are many problems with this website. I couldn't actually find the meat of it, where the intro page talked about what it could do for us. Inconsistent titles, stuff labelled [TOC]. It might be a work in progress and not really ready to be shared widely.
- Joel_Mckay 11mo agoLanguages like C are simply very unforgiving to amateurs, and naive arbitrary code generators. Bad workmanship writes bad code in any language. Typically the "easier" the compiler is to use... the more complex the failure mode. =3 Vibe coders usually offer zero workmanship (especially with the web), and are enamored with statistically salient generated arbitrary content. https://en.wikipedia.org/wiki/The_Power_of_10:_Rules_for_Developing_Safety-Critical_Code https://en.wikipedia.org/wiki/The_Power_of_10:_Rules_for_Dev...
- vlovich123 11mo agoC is simply unforgiving, amateur or not.
- uecker 11mo agoProgramming is unforgiving.
- keyle 11mo agoWhat are you actually answering to?
- Joel_Mckay 11mo agoReply to bypass a nonsense slop-article that doesn't actually offer any legitimate insights into workmanship standards. Follow the 10 rules on the single wiki page, and C becomes a lot less challenging to stabilize. Could also look at why C and Assembly is still used where metastability considerations matter. If you spend your days in user-space Applications, than don't worry about it... A bit of history where these rules came from, and why they matter. =3 "Why Fighter Jets Ban 90% of C++ Features" https://www.youtube.com/watch?v=Gv4sDL9Ljww https://www.youtube.com/watch?v=Gv4sDL9Ljww
- kubb 11mo agoI agree, seems off topic but let’s be kind.
- Joel_Mckay 11mo agoThe basis of the cited 10 rules helped form many standards for reliable code: https://www.stroustrup.com/JSF-AV-rules.pdf https://www.stroustrup.com/JSF-AV-rules.pdf Best of luck =3
- keyle 11mo agoIs the use of "actually" wrong here? What part of my question was not kind?
- torstenvl 11mo ago> C isn't not a high level assembler Hmm. The text following this heading seems to take the opposite view. I suspect this is a typo. However, I think the heading is accurate as written. The "C is not a high level assembler" crowd, in my view, is making a category error, conflating C itself with an ISO standard and abstract machine concept coming decades later. By the same token, "C is a high level assembler" is a gross oversimplification. "C isn't not a high level assembler" indeed.
- agumonkey 11mo agoWhat would you say C is beyond the high-level assembler ? genuinely curious (i kinda hold that belief personally but i'm not a c programmer by trade)
- _kst_ 11mo agoI see a huge semantic gap between assembly language and C. An assembly language program specifies a sequence of CPU instructions. The mapping between lines of code and generated instructions is one-to-one, or nearly so. A C program specifies run-time behavior, without regard to what CPU instructions might be used to achieve that. C is at a lower level than a lot of other languages, but it's not an assembly language.
- vnorilo 11mo agoAnd yet modern assembly does not correspond 1:1 to the micro-ops the CPU runs or even necessarily the order in which they run. Both ISA-level assembly and C are targeting an abstract machine model, even if the former is somewhat further removed from hardware reality.
- IshKebab 11mo ago> And yet modern assembly does not correspond 1:1 to the micro-ops the CPU runs or even necessarily the order in which they run. Nobody claimed that. It corresponds to the instructions the CPU runs and their observable order. Also it's really only x86 that uses micro-ops (in the way that you mean), and there are still plenty of in-order CPUs.
- aw1621107 11mo agoThis is reminiscent of Orthodox C++ [0], though I think it's perhaps more similar in goal than intent. [0]: https://bkaradzic.github.io/posts/orthodoxc++/ https://bkaradzic.github.io/posts/orthodoxc++/
- fsckboy 11mo agowhat's the difference between goal and intent?
- chubot 11mo agoThere was also "boringcc" https://gcc.gnu.org/wiki/boringcc https://gcc.gnu.org/wiki/boringcc As a boring platform for the portable parts of boring crypto software, I'd like to see a free C compiler that clearly defines, and permanently commits to, carefully designed semantics for everything that's labeled "undefined" or "unspecified" or implementation-defined" in the C "standard" (DJ Bernstein) And yeah I feel this: The only thing stopping gcc from becoming the desired boringcc is to find the people willing to do the work. (Because OSH has shopt --set strict:all, which is "boring bash". Not many people understand the corners well enough to disallow them - https://oils.pub/ https://oils.pub/ ) --- And Proposal for a Friendly Dialect of C (2014) https://blog.regehr.org/archives/1180 https://blog.regehr.org/archives/1180
- pjmlp 11mo agoIt is kind of ironic, given the existence of Orthodox C++, and kind of proves the point, that C isn't as simple as people think, having only read the K&R C book and nothing else.
- lioeters 11mo ago> in the C "standard" Oof, those passive-aggressive quotes were probably deserved at the time.
- flohofwoe 11mo agoIt's still not really wrong though. The C standard is just the minimal common feature set guaranteed by different C compilers, and even then there are significant differences between how those compilers implement the standard (e.g. the new C23 auto behaves differently between gcc and clang - and that's fully sanctioned by the C standard). The actually interesting stuff happens outside the standard in vendor-specific language extensions (like the clang extended vector extension).
- lioeters 11mo agoOff topic but if you're the author of sokol, I'm so thankful because it led to my re-learning the C language in the most enjoyable way. Started to learn Zig these days and I see you're active in the community too. Not sure if it's just me but I feel like there's a renaissance of old-school C, the language but more the mentality of minimalism in computing that Zig also embodies.
- elcapitan 11mo agoWow, lots of C related posts in the last few days. Is that because of vibecoders rediscovering it?
- Joel_Mckay 11mo agoTrolling for rage drives engagement. =3
- sph 11mo agoThe author of this website couldn't be further from any notion of vibe coding: https://www.youtube.com/watch?v=zqHdvT-vjA0 https://www.youtube.com/watch?v=zqHdvT-vjA0 https://www.youtube.com/watch?v=443UNeGrFoM https://www.youtube.com/watch?v=443UNeGrFoM Vibe coders follow the herd (Python, JS, Rust), they don't write any C.
- elcapitan 11mo agoI was talking about the posts on HN and the motivation why they are posted right now, not the author, with whom I'm familiar. Also there's literally a discussion on C for vibecoding on the front page atm https://news.ycombinator.com/item?id=46207505 https://news.ycombinator.com/item?id=46207505.
- sph 11mo agoI stand corrected. I was unaware of the existence of hipster vibecoders.
- a96 11mo agoOr a lot of people are feeling threatened by Rust and trying to push more C.
- rramadass 11mo agoDon't jinx it :-) Given the amount of C code in existence for practically any domain you can think of, i imagine LLMs can do a good job in generating it.
- accelbred 11mo agoIs there a way to force reader mode or force text not to be justified like that? I'm having a difficult time reading the content (on mobile at least).
- randcraw 11mo agoOn an iPad I can't read the web page at all. The insert at the upper right overlies and obscures the main body of text. It'd also be a good starting point to be more concrete in your ambitions. What version of C is your preferred starting point, the basis for your "Better C"? I'd also suggest the name "Dependable C" confuses readers about your objective. You don't seek reliability but a return to C's simpler roots. All the more reason to choose a recognized historical version of C as your baseline and call it something like "Essential C".
- tapete2 11mo agoThere are several ways to do that. The best method is to use a real computer. Of course, the website operator can do something about this as well. On my website I redirect all traffic from mobile devices to the kids section of YouTube.
- fuhsnn 11mo agoHonestly as a hobbyist programmer I'm more interested in knowing which exact platforms/compilers that don't support the non-dependable patterns and why should I care about them. Even better if the author can host a list of "supported platforms" that's guaranteed to work if people's projects invest in the style.
- Joel_Mckay 11mo agoThis list of rules applies to most languages: https://en.wikipedia.org/wiki/The_Power_of_10:_Rules_for_Developing_Safety-Critical_Code https://en.wikipedia.org/wiki/The_Power_of_10:_Rules_for_Dev... A bit of history where these rules came from, and why they matter. =3 "Why Fighter Jets Ban 90% of C++ Features" https://www.youtube.com/watch?v=Gv4sDL9Ljww https://www.youtube.com/watch?v=Gv4sDL9Ljww
- RossBencina 11mo agoFrom the author of "The Power of 10" (among other excellent writings): "Mars Code - Gerard Holzmann, JPL Laboratory for Reliable Software" https://www.youtube.com/watch?v=16dQLBgOwbE https://www.youtube.com/watch?v=16dQLBgOwbE
- brooke2k 11mo agoThe idea is interesting but unfortunately the actual articles are riddled with spelling errors, typos, missing words, sentences that cut off before And so on. Is this a work-in-progress thing not meant for public consumption yet?
- flohofwoe 11mo agoSo basically back to C89... I'm not a fan since the changes in C99 made the language significantly more convenient, more enjoyable and actually safer, and even the MSVC C frontend has a nearly complete C99 implementation since around 2015 (the parts of C99 that matter anyway). Case in point: the article has this somewhere in the example code: struct struct s; s.member = 42; s.other_member = 1138; (ignore the syntax errors and typos, the article is full of them) If new members are added to the struct, you end up with uninitialized memory. With C99 designated init at least the new members are zero-initialized.
- hvea 11mo agoGood point but as far as I know the author takes a stance against zero initialization in general.
- derriz 11mo agoYour example of an uninitialized memory situation will not be so compelling for old-school C engineers because they've "solved" the issue decades ago by integrating tools like valgrind into their work-flows. They don't expect (or require) the compiler to help them deal with issues like this. The problem with post-C89 is that you lose the unique features of old-school C. For example, it can be compiled on basically any platform that contains a CPU. It has tool support everywhere. And it can be fairly easily adapted to run using older C compilers going back to the 1980s. Or that (old-school) C is basically a high level assembly language is actually a feature and not a bug. It's trivial to mentally map lines of C89 code to assembly. No other widely available language can tick these boxes. So the problem with later versions of C is that you lose these unique features while you are now competing for mindshare with languages that were designed in the modern age. And I just don't see it winning that battle. If I wanted a "modern" C, I'll use Zig or Rust or something. Just because a language (C89) doesn't evolve doesn't mean it's dead.