5 ms·
One day in the far away future the standard C++ hello world will use 'import std;' and 'std::print' and it will be glorious.
by fouronnes3 4y ago
One day in the far away future the standard C++ hello world will use 'import std;' and 'std::print' and it will be glorious.
- jmillikin 4y agoWhen I was going to university the computer science department's primary system had two compilers available, GCC 2.96[0] and TenDRA. GCC was generally more popular but it didn't have std::string and any code that threw an exception would crash, so adventurous students would use TenDRA for development. One of the stranger behaviors of TenDRA was that it put all standard library symbols, including the C headers, into namespace std. A hello world in TenDRA looked like this: #include <cstdio> // no <stdio.h> available int main() { std::printf("Hello, world!\n"); return 0; } It was not glorious. If anything ... the opposite. When TenDRA deigned to compile your program it would generally work (excepting bugs in the code itself), but getting it to accept any sort of third-party code was impossible because of the std namespace thing. I ended up writing a bunch of utilities for strings, including a unit testing library that spawned each test as a subprocess (to avoid exceptions) just so I could use GCC instead. [0] There is no such version recorded on the GNU project website.
- jdougan 4y agoGCC 2.96 was a development version that incorrectly got released by Redhat on Redhat 7 (and possibly other distros). https://gcc.gnu.org/legacy-ml/gcc-announce/2000/msg00003.html https://gcc.gnu.org/legacy-ml/gcc-announce/2000/msg00003.htm...
- jmillikin 4y agoThis was on a DEC Tru64 system, very far from any sort of Linux. My personal suspicion is that someone (student or faculty) got their hands on a CVS snapshot and installed it system wide. That's the only explanation I can think of for it being so broken.
- alternatetwo 4y agoFairly sure some PS2 SDKs also shipped GCC 2.96, which is why I know this tidbit of info.
- yyyk 4y ago>There is no such version recorded on the GNU project website. It's sort-of recorded. It's not in the version list since there wasn't a release, just distros making a mess: https://gcc.gnu.org/gcc-2.96.html https://gcc.gnu.org/gcc-2.96.html
- Sharlin 4y agoC symbols are supposed to be in std if you use the cstdio style headers. It’s just that for a very long time compilers put them into the global namespace too.
- Calavar 4y agoGCC, Clang, and MSVC all still duplicate c* header definitions into the global namespace by default as far as I'm aware. In fact, the last time I checked, the MSVC cstdio header was implemented more or less like this: namespace std { #include <stdio.h> } using namespace std; It's kind of crazy how major compilers have been ignoring the standard for so long that people consider a standard compliant compiler to be weird and broken.
- Forricide 4y ago> It's kind of crazy how major compilers have been ignoring the standard for so long that people consider a standard compliant compiler to be weird and broken. I had absolutely no idea this wasn't even supposed to be the case (although I was aware of the duplication in std::). Guess it makes sense that the standard would shy away from global namespace pollution - I suppose one of the compilers perhaps did this for long enough that the others ended up duplicating it to increase code compatibility?
- gpderetta 4y agoThat the as actually not conforming. It was made conforming in c++11 because it was pointless to have the standard say something that all major implementations would ignore.
- tolciho 4y ago2.96 exists, at least in the RedHat world. $ rpm -qi gcc Name : gcc Relocations: (not relocateable) Version : 2.96 Vendor: Red Hat, Inc. Release : 110 Build Date: Fri 12 Apr 2002 10:30:47 PM UTC Install date: Thu 20 Jan 2011 03:34:36 AM UTC Build Host: daffy.perf.redhat.com Group : Development/Languages Source RPM: gcc-2.96-110.src.rpm Size : 8389509 License: GPL Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla> URL : http://gcc.gnu.org Summary : The GNU cc and gcc C compilers. Description : The gcc package includes the cc and gcc GNU compilers for compiling C code. $ cat /etc/redhat-release Red Hat Linux release 7.3 (Valhalla)
- deleted 4y ago[deleted]
- frutiger 4y agohttps://en.cppreference.com/w/cpp/header/cstdio#Synopsis https://en.cppreference.com/w/cpp/header/cstdio#Synopsis.
- deleted 4y ago[deleted]
- germandiago 4y agoThat will be in cpp2 already: https://github.com/hsutter/cppfront https://github.com/hsutter/cppfront
- pjmlp 4y agoAlready available in C++23.
- tialaramex 4y agoThe future tense seems better here. This will (almost certainly) be available in C++ 23. In the context of Chromium, this slide deck, that means in about 2026. So if you're starting a three year degree next week, and you already know Google will hire you for the Chromium team straight after because you're the perfect person for that, you won't be writing std::print() calls in that codebase yet 'cos that's too early.
- pjmlp 4y agoWell, they could convince their management to restart doing clang contributions for ISO C++ compliance, or maybe allocate 20% of their time for that.
- scatters 4y agoThe far away future? You mean next year?
- fouronnes3 4y agoI don't mean available as in the committee has published their final version of the standard that allows it. I mean available in production.
- scatters 4y agoOh, that'll probably be sooner, then; STL is already working on it. Also if you want to use it now, fmt has an implementation.