32 ms·
C meeting is over. C23 added:
- RcouF1uZ4gsC 5y ago> typeof(...) is standard I thought C++11 went with decltype because typeof was implemented by compilers as an extension with various subtle semantic differences than what they wanted. I wonder why the C committee went with typeof instead of decltype?
- bonzini 5y agoIIRC typeof is implemented in the same way by all compilers that have it, but it had some subtle differences with what the committee wanted. The differences presumably do not matter for C, in fact I think it was something related to references.
- pwdisswordfish9 5y agoBecause that would then create subtle incompatibilities with C++, stemming from the fact that C has no reference types. http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2927.htm#existing-decltype http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2927.htm#ex...
- deleted 5y ago[deleted]
- mungoman2 5y agoI can't tell if this is serious. Surely if you're still using C now it's for legacy reasons. And if using it for legacy reasons you are likely stuck using an old C standard. So who will use C23?
- jonp888 5y agoThere are many many people out there using C for embedded software.
- sam_bristow 5y agoThe problem is that embedded compilers are not known for keeping up with the standards. The only hope is that the moves to GCC and Clang continue.
- pkrumins 5y agoNo one cares about the standards. We only care about getting things done by writing regular C code that works.
- uncomputation 5y agoHuh? What do you think defines “regular C code that works”? Standards. Every compiler you have used operates at a bare minimum on the C standard. That’s why they are often advertised (if not GCC/Clang which are assumed to be up to date) as “C(89|99|11|17) compliant.” “Code that works” is code which is operates under constraints and guarantees specified by a standard, anything else is undefined or unportable.
- flyinglizard 5y agoEmbedded environments are specific and esoteric enough that compiler portability is the least of your concern when migrating code from one platform to the other.
- pkrumins 5y agoOnly the standards people care about standards. We (programmers) want to just get things done. We don't care about the standards. No one reads the standards. Also no one cares about portability. All computers have been the same for the last 20 years.
- drran 5y agoWe, developers, care about standards, because we want to get things done once.
- pkrumins 5y agoWe all use C because it works and we love to get things done.
- drran 5y agoNot all of us use C, because it's very easy to create security holes in C. For example, web browsers are using slow JavaScript just because it memory safe.
- deleted 5y ago[deleted]
- dkjaudyeqooe 5y agoC is a portable alternative to assembly language.
- pjmlp 5y agoWhen the world is a PDP-11.
- nec4b 5y agoAnd x86, Arm, PIC, Xtensa,... and everything else.
- pjmlp 5y agoThere is where you went off rails, with greetings from ACM. https://queue.acm.org/detail.cfm?id=3212479 https://queue.acm.org/detail.cfm?id=3212479
- nec4b 5y agoI'm so glad that you have linked this article from Chisnall. I can now ask you in what ways is the abstract model of a machine on which assembly language operates on, different from the one on which the C language operates on? This is the claim which started this thread: >>C is a portable alternative to assembly language.
- pjmlp 5y agoC's abstract machine is leaky and full of surprises when UB comes into play for one. Second when people talk about C being portable Assembly, they mistakenly assume to know what comes out of the compiler's backend. Third, unless we are speaking about PDP-11 like CPUs, modern CPUs have tons of capabilities not exposed to ISO C. Finally, since 1958 there are portable alternatives to Assembly in systems programming with JOVIAL being one of the first remarkable ones, yet another thing that C did not invent.
- brian_cloutier 5y agoAt a previous employer of mine we would have happily switched to c23. Postgres is written in c and if you want to write an extension for Postgres you're going to have the easiest time if your extension is also written in c. However, there's no reason not to use the newest c version. So, c is not just for legacy code.
- kstenerud 5y agoI will. C is everywhere and is not going away (it's #2 on TIOBE and on the rise again). Now that fewer people are learning it, I get more juicy contracts.
- reassembled 5y agoI feel like there’s actually a growing subculture of C programmers of late, seemingly spawned by Casey Muratori’s Handmade Hero series, Zed Shaw’s “Learn C The Hard” way and other more recent popularizations of C and low level programming ideas. There’s a whole “Handmade” software scene growing up, seemingly as a reaction against the bloat and over engineering of more recent software trends like Electron and web apps. Just the other day I stumbled across a vibrant Discord group focused on a fairly new but surprisingly feature complete game engine called Gunslinger, written entirely in C99. I’ve been working on my own C-based game engine for awhile too after having been exposed to the ideas of Handmade Hero, as well as from the influence of a good friend who has been writing games in C for many years. He’s now working on an application called Pixel CNC for generating 3D tool paths from 2D images.
- saagarjha 5y ago> seemingly spawned by Casey Muratori’s Handmade Hero series, Zed Shaw’s “Learn C The Hard” way It's kind of unfortunately, really, because both authors have very skewed viewpoints of C that are arguably quite incorrect.
- edflsafoiewq 5y agoWhat viewpoints are those, for those of us unfamiliar?
- saagarjha 5y agoZed Shaw doesn't really like C because it lets you shoot yourself in the foot. This is an OK opinion to have, but then he goes and writes books about C that basically talk about how the language is bad (ok, I guess?) but the then claims he has solutions to these problems, without understanding that the problems he has with C are not solvable within the language (for example, when handed an arbitrary pointer, there is no way to tell whether it is valid). Casey Muratori is fundamentally at odds with how undefined behavior works in C and has opinions™ on how to fix the language to make things work the way he wants them to, when in reality he just probably wants another language.
- aardvark179 5y agoHuge amounts of software are “legacy” but built with perfectly modern tool chains and will support c23 just fine. Even for large bits of software which have been mostly rewritten you’ll often find core libraries that are still actively developed but have never been ported away from C.
- sgt 5y agoSounds like you're not really in touch with the real word. C has many benefits and it is super practical. Yes, you can write unsafe code, but safety isn't always your #1 priority. There are also tools you can use to identify issues, which will mitigate risks.
- KnobbleMcKnees 5y agoI'm really starting to believe that there's a cohort of modern programmers that only see programming languages in terms of the high level syntactical features they provide. The logic of it is something like: I write the code, I run a command written using similar code, scenes deleted, my program runs and my IDE tells me if there are problems in my code. This is sometimes defined as the difference between developers and engineers, but I don't really buy the analogy because they're mostly highly competent and able to build solid and principled architecture into their software. This is the only reason I can summise that educated programmers would say something like C is irrelevant. I guess not everyone needs to have a depth of understanding of the platforms that underly their languages of choice, but - as demonstrated here - it certainly doesn't inform the future of languages when they are inherently tied to their ability to integrate with different hardware and OSs.
- pjmlp 5y agoIt was already irrelevant when using MS-DOS with Turbo Pascal/Modula-2/Basic compilers, or Mac OS (originally written in Object Pascal/Assembly). It was UNIX industry adoption, followed by GNU Manifesto that made to more relevant than it should ever have been.
- rixed 5y agoSo, it's not relevant, but then it's more relevant? Well, sure, merit and popularity rarely align, and one with enough technical culture can always imagine a better world.
- Koshkin 5y agoThe truth is, C is merely a historical artifact, one step above the PDP-11 assembly, created in order to make the UNIX source code portable. It has transcended its original purpose, and with it being elegant and simple as it is, I would still never trust it to run a pacemaker.
- rwmj 5y agoMany things on a Linux system is written in C, and despite the noise on HN, developers who gets stuff done are constantly writing new code in C all the time.
- pjmlp 5y agoIncluding plenty of new CVEs, we have to keep the security industry job market safe.
- rwmj 5y agoSure, I'm certainly not arguing that C is a good language. In RHEL we turn all warnings on, compile everything with hardening flags, use valgrind during development, and feed everything through Coverity.
- pjmlp 5y agoThe exception that confirms the rule.
- rossy 5y agoThe exception? It's standard practice for distros to compile with hardening flags, and if RH submits the bugs they find with Coverity upstream, that protects the 1000s of C projects they package.
- pjmlp 5y agoStandard practice they say, https://googleprojectzero.blogspot.com/2021/12/this-shouldnt-have-happened.html https://googleprojectzero.blogspot.com/2021/12/this-shouldnt...
- torstenvl 5y agoMozilla is not a Linux distro. You have made dozens of negative (and sometimes rude) comments in this thread. I'm curious why you're spending so much time and energy being negative. If C isn't something you're interested in, why not just ignore it and move on?
- DyslexicAtheist 5y ago> So who will use C23 I can't say if I'd immediately jump to C23 but I'll be thrilled to give it a try. Currently I'm rewriting an entire automotive OCPP charging point and it's associated CSMS in C because the original dev (who has no experience with Edge/IoT and just Cloud/SaaS) thought it was a great idea to implement this in golang. The binary size alone is already a problem where all I have is 30MB (needs to be shared with logs, sqlite, and 2 another "user-space" application). I could have chosen Rust/Zig/Nim (I really wanted to) but the client rejected it for very good reasons that have nothing to do with type-safety/performance/security but are all about good-business practice and risk management: - when I leave in a few weeks, there are plenty engineers inside the company who can maintain the system. - the domain is quite niche so to understand their solutions and requirements you can't do away without an occasional trip to their office. the client is not in a capital city with a vibrant tech-scene and weekly meet-ups and lacks the talent-pool. The constraints by the market (scarcity) makes Rust/Nim/Zig (my personal front-runners) very risky tools. C++ could have been an option but it's total overkill because most of the components you need to build this (websocket, mqtt, http, sqlite, zlib, openssl, ...) are anyway implemented in C and I actually don't want things like exceptions or templates in this _at all_ for performance reasons. If you split your OS into layers from HW (ring-0) all the way to layer-5 (process management e.g. systemd etc) then 99% is still written in C. So your argument throws every layer under the bus except user-land (L-6). C isn't going away only because of embedded/IoT. It's going to stay because choosing a language is like the "3 most important rules in real-estate: location. location. location". The language is your location and your primary lock-in factor for your solution/business. Once you've decided on language the only way to change this is an entire re-write. Even if you rewrite you still have to consider culture and available resources that must be in place long before you chose the programming language. And keep in mind the people who all took stakes in the original implementation and must all be sold on the idea that whatever new replaces the old "is sooo much better". That's not an engineering problem but a power/people problem. Edit: So just because "the engineer inside of me" wants to use Rust/Nim/Zig or whatever new to satisfy my intellectual curiosity is not enough reason. In fact my potential inability to see beyond that is a good reason for them to be very very careful about what advise I give.
- WithinReason 5y ago
- 10x-dev 5y agoC is the best choice if you want all of: small (both language and binaries), fast (both compiler and binaries), obvious (no/minimal complex magic), close to the metal, with excellent debugging support, portability and integrations. No other language has been battle tested for longer and more extensively than C. Your kernels, OSes, drivers, databases, web servers and compilers are written in C. If some of these features are not important to you, there are hundreds of slower, more complex and less portable languages to choose from, that provide other benefits instead, such as more convenience, more correctness and higher level abstractions.
- WithinReason 5y agoLanguages exist that compile to C which gives them many of the above advantages and more, so why choose C over them?
- raptorfactor 5y agoHaving never used such a language, I'm curious, what's the debugging experience like? Can I source level step the application in the original language or do I have to debug the generated C?
- rwmj 5y agoOne of the criteria is "excellent debugging support" which you don't get with transpiled languages, since you'll be buried in generated code when you open the debugger.
- shakna 5y agoHow many of your preferred programming languages are written in C? Yes, many self-host, but a considerable number of them don't want the complications that can bring.
- pjmlp 5y agoModern C compilers are written in C++. So much for C's simplicity in writing compilers.
- shakna 5y agoYes, C can be simple for writing a compiler. [0][1] No, optimisation, on the other hand, is not a simple problem. [0] https://github.com/rui314/8cc https://github.com/rui314/8cc [1] https://github.com/rui314/chibicc https://github.com/rui314/chibicc
- pjmlp 5y agoNaturally it can be simple, it was already a basic language when compared with what 1960's have produced. The evolution of Bootstrapping CPL compiler + a set of basic types.
- uecker 5y agoThere are plenty of C compilers written in C. Large compiler suites for C/C++ are usually written in C++. But as a contributor to GCC, I can say that large parts of the code still look very much like C.
- pjmlp 5y agoPlenty of compilers... right. If you cannot compile GCC with a C compiler, it isn't C.
- uecker 5y agoThere a couple of open source C compilers TCC, SDCC, tendra, chibicc, ACK, LCC, PCC, etc. and also many commercial ones. It is true that GCC is not written in C anymore, but it is easy to see that the code is still relatively close. I am also myself writing a C compiler in C at the moment and there is no problem at all.
- foxfluff 5y agoI will continue to use C because I haven't seen an appealing alternative.
- phendrenad2 5y agoI'll keep writing things in C, because it maximizes my productivity and gives me extra time to make it secure (less time than it would require to write it in Rust in the first place).
- Svetlitski 5y ago“`typeof` is standard” Hallelujah, after only five decades generic, type-safe macros which evaluate their arguments exactly once will finally be possible with standards-compliant C.
- saagarjha 5y agoHow so? You'd also need statement expressions for most of them.
- throwaway3neu94 5y agoNo, you can use do{}while(0) usually. You only need statement expressions if you want it to evaluate to a value as well.
- CyberRabbi 5y agoWhenever I use C I use it for the express purpose of supporting ancient platforms. These platforms often only support C89, so that’s the dialect of C to which I restrict myself. If I am able to ignore those old platforms, I use C++. RAII is just so convenient.
- rwmj 5y agoSo true and false keywords are the only thing that has been added, or am I missing a part of this thread? Edit: I think one of these could be a better link: https://en.cppreference.com/w/c/23 https://en.cppreference.com/w/c/23 http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2864.pdf http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2864.pdf
- NotSoVeteran 5y agoThe linked tweet is the 4th in a sequence. If you scroll up you should see 3 more tweets with more info.
- deleted 5y ago[deleted]
- rwmj 5y agoThanks - Twitter UI is terrible. I'm glad the terrible "defer" suggestion didn't make it, but unfortunate that they didn't standardise the existing and widely used attribute cleanup.
- wartijn_ 5y agoThis is off topic, but I don't think the problem is just that the Twitter is terrible. If you want to link to a thread, you should click on the first tweet of that thread and copy its url. It's easy to see the rest of the thread: just scroll down. If you want to link to one tweet in a thread you should click on that tweet and copy its url. The person who posted the link to HN did the latter, while they should have done the former. Twitter could make it easier to see that a tweet is part of a thread though.
- secondcoming 5y agoTwitter is bad if you don't have a twitter account. It'd be great if HN could change twitter links to go through nitter.net
- 5y ago
- sgt 5y agoBased on another thread - I think the following topic should be an interesting one for HN to chew on: If someone wanted to write systems type of programming (whether it be embedded or Unix tools or even writing a library), should they go for C (C23) or Rust today?
- bruce343434 5y agoI'm going for C, because I am experienced with C and despite it being more tedious, with having to do everything yourself, I stick with it because the compile times, and in fact the compile process, are so much faster and simpler. I really enjoy the direct feedback I can get. I considered C++ but that too had terrible compile times. Ideally a debug build should simply not take longer than 100ms for a codebase that isn't even 5KLoc, and only C seems to be able to offer that experience.
- gefhfffh 5y agoI get that the compile process is faster, but simpler? In my experience, the compile process usually consists of "cargo build" A advantage of Rust is that usually you spend way less time debugging, because the compiler prevents many mistakes from compiling in the first place.
- bruce343434 5y agoI have an IDE with clang-lint and I find that it can spot pretty much every mistake. It can even detect some lifetime issues. Other than that my programming style is very much pass-by-value, trust the compiler to inline it, so the typical memory safety issues are simply not relevant to me.
- pornel 5y agoPass-by-value and let LLVM clean it up is also the idiomatic Rust way. rust-analyzer is pretty good for IDE integration, and it will catch way more than clang-lint (global lifetime analysis with guaranteed correctness, not just best-affort local, and thread safety/data races). Regarding compile times, Rust has a different approach. Instead of a fast cycle of run and see if it broke, it's more of following compiler nags until the program is correct and runs on the first try. Incremental (cached) compile times aren't too bad these days.
- deleted 5y ago[deleted]
- junon 5y agoHaving trouble figuring out if this is real. It sounds way too good to be true.
- mojuba 5y agoRemoving K&R style function prototypes though is kind of big. I remember when one of the Objective-C upgrades started enforcing K&R. I don't think ObjC will be upgraded to C23 (ever, as it's a language being deprecated now I presume) so it will be stuck with K&R... while the rest will move on? Could someone also explain what this means for pure C in terms of compatibility? If there's void foo(); would the meaning of it depend on which C standard is activated?
- flohofwoe 5y agoIME ObjC (unlike C++) automatically supports the latest C standards, because ObjC just adds some syntax sugar on top of C, but otherwise doesn't 'mangle' its C subset into its own dialect like C++ does.
- melissalobos 5y ago>IME ObjC (unlike C++) automatically supports the latest C standards, This is only true as long as the changes in C aren't conflicting with ObjC. In the future if ObjC is deemed dead by the council it won't have to worry about such things. So C58 may have tons of things that don't work in ObjC98 (or whatever the ObjC version is).
- dgrunwald 5y agoWhat's being removed in C23 is the ancient K&R syntax for function definitions: int max(a, b) int a, b; { return a>b?a:b; } My understanding is that C23 does not change the meaning of function declarations. So "void foo();" remains a declaration of a function accepting an unknown number of parameters.
- zh3 5y agoWow, that's annoying. There's a bunch of old code we have that'll need updating (written that way to keep the line lengths down).
- 5y ago
- vkazanov 5y agoIt's probably better to just follow the original WG14 Document log: http://www.open-std.org/jtc1/sc22/wg14/www/wg14_document_log.htm http://www.open-std.org/jtc1/sc22/wg14/www/wg14_document_log...
- blastonico 5y ago> [dropped] Representations for signed integers other than two's complement May I assume that there won't be signed int undefined behavior after C23? INT_MAX + 1 == INT_MIN?
- Someone 5y agoI doubt it, and wouldn’t want it. It would break all kinds of optimizations. For example, with wrapping for(int i = 0; i <= m; i++) { foo(); } Wouldn’t terminate if m = INT_MAX. That means compilers either have to special-case that value, or can’t use the loop instructions of some CPUs (M68000 has “decrement and branch if larger than zero”, for example) Also, with wrapping, a[i] and a[i+1] aren’t guaranteed to be adjacent. That can make auto-vectorisation difficult.
- hfsrgbcfuknbft 5y agoThose things are very subtle and complex, so I'm not 100% sure, but I think your first example is not great: For example, with wrapping for(int i = 0; i <= m; i++) { foo(); } Wouldn’t terminate if m = INT_MAX. This is undefined behavior in the current standard when m = INT_MAX. The condition i <= m is always true and i will overflow. So it could result in an infinite loop (or worse). AFAICT, with wrapping signed ints, it would infinite loop but at least not yield UB?
- Someone 5y agoYes, for m = INT_MAX and wrapping signed int, it is undefined behavior. Because of that, the compiler is allowed to assume m ≠ INT_MAX, and that can mean it can generate more efficient and/or smaller code. Assuming m ≠ INT_MAX isn’t (considered to be [1]) a big loss because chances are the programmer who wrote that didn’t intend to write an infinite loop. [1] of course, is an opinion, but it’s the opinion the standards writers have had for decades.
- pkrumins 5y agoC is the only sane language left. It never changes and it lets us write code that just works. We can focus on getting things done and shipping rather than learning new features and Googling compiler errors. Learn once, ship forever.
- drran 5y agoMajority of CVE's are because of C memory model, which is fixed in modern languages. C memory model is the constant source of vulnerabilities, thus it better to write new code in a memory safe language, like Rust.
- pkrumins 5y agoRust is a syntax error, not a programming language.
- DrMeepster 5y agowhat does this mean? It sounds like you tried to make a funny programming insult, but it fell flat if that's what you were going for
- moralestapia 5y ago>Majority of CVE's are because of C memory model I haven't checked that but I believe you. My only nitpick is that I wouldn't put the whole blame for that on C, as there are proper ways to produce "safer"[1] code. What other languages did was lower the entry barrier to write better code, but that doesn't mean one language is inherently better that another. 1: No code is ever safe, not even formally verified code.
- masklinn 5y ago> Majority of CVE's are because of C memory model “Memory safety” (or lack thereof) is probably less ambiguous: usually “memory model” is the interaction between program and memory, specifically as it pertains to concurrency. And in the latter understanding I believe C has about the same model as C++, which is also the one adopted by Rust. And while it’s fiddly, it’s not a complete disaster.
- sys_64738 5y agoIt used to be that every new language starts off with a translator to C. Not sure if that’s the case nowadays.
- qayxc 5y agoWith the advent of LLVM that's not common anymore. Bootstrapping can be done in pretty much any language nowadays.
- pjmlp 5y agoNeither it was common before, Objective-C, C++, Eiffel are probably the only known ones with mainstream market share that actually went via the compile to C as initial implementation.
- pjmlp 5y agoNot really, some did follow that path.
- dragonwriter 5y ago> It used to be that every new language starts off with a translator to C. No, it really never was that way, though there were some languages (especially ones that started as C plus some additional features, like C++ and Obj-C) that did that.
- beeforpork 5y ago> Support for calling realloc() with zero size (the behavior becomes undefined) OMG! Please do not add more undefined behaviour! We really need less UB, not more! What was wrong with 'implementation defined' as in C17? UB means that code that exists will now break if a new compiler decides that it can be smart. And we know how inventive this can get, right? Like removal of 'if(new_size==0) {...}' if the compiler can prove that 'new_size' went into 'realloc' before.
- c-linkage 5y agoThey'd better not convert that to undefined behavior! First, the specification for malloc() says you can call it with size 0 and it will still return a pointer to zero bytes; this means an array of bytes having size zero is legal. Second, having the compiler detect when realloc() is called with size zero changes what should be a library call into an intrinsic, whose very presence in the code is determined by the value of its arguments[0]. If you're going to do that you might as well just put exceptions in the language! [0] Most compilers assume UB "can't happen" and just remove the offending code altogether.
- enedil 5y agoManual says > If size is 0, then malloc() returns either NULL, or a unique pointer value that can later be successfully passed to free(). So it's not really an array of bytes of size 0.
- MichaelBurge 5y agoWhat qualifies something as a "real" array of bytes? All RAM is an array of bytes, so any pointer to real memory(vs. virtual memory) is a pointer to an array of bytes.
- enedil 5y agoC mandates that arrays have positive size. It's not really a discussion about what the target platform does, rather it's what the abstract C machine mandates.
- sys_64738 5y agoDoes anybody bother about the stuff after C99?
- pkrumins 5y agoNope.
- rossy 5y agoMSVC just got C11 support a little over a year ago, so you won't see many big cross-platform projects using it yet, unfortunately. Some projects can optionally use C11 stdatomic.h and stdalign.h to replace old OS and compiler-specific extensions, but most of them still keep fallback code in case C11 isn't available.
- tpoacher 5y agoFor all of us that follow an "I do not want to log in to twitter" philosophy, can someone here please post an alternative link? Incidentally, I'm glad Twitter now blocks you from reading if not signed in. I'm hoping this will encourage the use of alternatives.
- deadmercury 5y agoUse nitter.net https://nitter.net/__phantomderp/status/1494884135688626180 https://nitter.net/__phantomderp/status/1494884135688626180
- sebow 5y agoThere is indeed nitter.I also recommend using an extension for general redirecting.A popular one I use with presets for big sites is Privacy Redirect (ff) but there are also ones for that allow customization (Redirector for example, also ff).
- sva_ 5y agoI'm not signed in and read it fine. My uBlock filters are twitter.com##[id^="layers"] > [class^="css-"]:has([dir^="auto"]):not(:has([aria-expanded])):has(a[href^="/"]):has-text(/Log in|Sign Up/) twitter.com##html[dir]:style(overflow: auto !important;)
- deleted 5y ago[deleted]
- deleted 5y ago[deleted]
- bo-tao 5y agoYou can paste this on console to remove the popup (function () { document.querySelector('html').style = ''; document.querySelector('.css-1dbjc4n.r-aqfbo4.r-1d2f490.r-12vffkv.r-1xcajam.r-zchlnj.r-ipm5af').remove(); })()
- npteljes 5y agoThe Privacy Redirect addon can automatically forward you to a Twitter alternative. Sometimes the alternative instances don't work, but at least it's fully configurable, YMMV. https://addons.mozilla.org/en-US/firefox/addon/privacy-redirect/ https://addons.mozilla.org/en-US/firefox/addon/privacy-redir... https://chrome.google.com/webstore/detail/privacy-redirect/pmcmeagblkinmogikoikkdjiligflglb https://chrome.google.com/webstore/detail/privacy-redirect/p...
- childintime 5y ago> In its London 2019 meeting, WG14 has found consensus to elevate false and true to proper keywords. The committee settled this over a beer, or some other substance? Because the elevation to a proper type is opportunistic at best, and against the spirit of C at worst. Next people celebrate this with the use of capslock. The futility of it all blows my mind :C
- jb1991 5y ago> the elevation to a proper type is opportunistic at best, and against the spirit of C at worst Can you explain what you mean by this?
- childintime 5y agoSo C is all about the machine, in this case about storage, memory. Other languages emphasize types, whereas C instead emphasizes values and their representation. So a condition or comparison does not result in a boolean, it results in a value that can be stored in 1 bit. Its values therefore are 0 and 1. There is nothing to understand, except that the values are dictated by the width of the storage, as usual. The stdbool annotation is cultural, optional, but not C. C does not have boolean values. True and false are mental crutches, names that are somewhat helpful in the absence of an explicit bit type, but still very much a lie. I think people coming from other languages are driving the future of C now. They are used to booleans as a distinct type, exclusive from other types. Yet in C any int or pointer value has a boolean interface defined on it, and the ambiguous nature of, for for example a timeout, being both a value (time remaining) and a boolean (timed out), highlights the why of C and why C is the king of embedded programming. So at minimum there are multiple aspects of "booleans" in C that other languages specifically de-emphasize, like storage, representation and the ambiguity of values with other types. The synthesis of the newly introduced C booleans seemingly doesn't take this impedance mismatch into account. From reading it seems there is no synthesis. Bits have been a traditionally dark corner of C, as I can't declare or index an array of bits; and bit-fields are not my cup of tea (don't use them). I think that's where improvements can be made. Specifically the introduction of a bit type would be in the spirit of C. No need to rename the values, 0 and 1 are more truthful than true and false. If true and false are needed, then a distinct boolean type (as in other languages) might make sense, as an addition, not a replacement. Just to get true/false values and conceptual isolation. stdbool could not do that and made compromises. Cxx enshrines that compromise, instead of genuinely improving on it. So maybe a bit type for the C programmer and a bool type for everybody else.. :/ Yet C is an impossible ship to turn around, in terms of culture and sunken investments. Changes are virtually impossible and, even more so, highly undesirable. Instead it's time to move on and sunset C. The best C at this point is a sealed C, with a tombstone on it. Then at least it's a known entity, and then C code shall exist side by side with say Rust or Zig code, to be compiled and linked by the same compiler, without language churn. Such systems will proudly carry C into the future. Any C language changes, if needed, should focus exclusively on making that coexistence work.
- pwdisswordfish9 5y ago> Oh, and a big deal: true/false are KEYWORDS NOW, and all of the bool/thread_local/etc. are all KEYWORDS NOW!!!! Why does it even matter? I could take true and false to be an improvement (having them as macros expanding to int literals had its problems, but even for that one I would not mind _True and _False at all), but the rest? Who cares? It’s literally the least significant change.
- pjmlp 5y agoFinally C catches up with Algol 60 boolean types, it only took 60 years. Maybe in another 60 it will get proper strings and arrays.
- moralestapia 5y ago>Maybe in another 60 it will get proper strings and arrays. If you think this is missing, there's a big chance you don't "get" C. Also, if you don't know how to properly emulate strings in a safe way in C nowadays (for which plenty of code sample and librariesexist), your skills with the language are quite poor.
- pjmlp 5y agoI surely get C, having to deal with its casualties in DevSecOps. I have been "getting" C since 1992, across Xenix, DG/UX, HP-UX, Solaris, AIX, FreeBSD, Linux, Amiga, Windows 3.x,.....
- moralestapia 5y agoWell, then, you must know it's not really a big deal to write code with proper memory checks.
- coldtea 5y agoIf you think that, then you really don't get C - not as in "it's intents", but as in its actual history and repurcursions...
- pjmlp 5y agoI have found yet another C expert. https://www.cvedetails.com/vulnerability-list/opmemc-1/memory-corruption.html https://www.cvedetails.com/vulnerability-list/opmemc-1/memor...
- dnautics 5y agoIt's a big deal, you need about 1/3 of sel4 proofs
- belter 5y ago
- cpeterso 5y agoAnother nice convenience: a new #elifdef preprocessor directive to replace longhand #elif defined(). https://en.cppreference.com/w/c/23 https://en.cppreference.com/w/c/23
- guenthert 5y agoOomph. There seem to be more meaningful changes in C23. I sure hope they wouldn't consider a new standard for such trivialities alone. There's cost to those changes. Compilers will naturally need to be updated, but other tools, e.g. static code checkers and documentation, e.g. MISRA-C, too.
- stjohnswarts 5y agoCan't believe they still denied us anonymous functions.
- buyfttyfytt 5y ago666 aku pn mi