3 ms·
The working draft standard for C++ (2022-12-18, document N4928) is 2,110 pages long at a reasonable-sized font. I'd actually go the other way: I think most pra
by shadowgovt 2y ago
The working draft standard for C++ (2022-12-18, document N4928) is 2,110 pages long at a reasonable-sized font.
I'd actually go the other way: I think most practicing programmers have not read the entire standard specifying most languages they use day-to-day and have no real idea what the abstraction-break looks like that turns their code into a format consumable by the next layer down.
How many Java programmers do we assume know anything about the bytecode of the JVM, for example?
- pjmlp 2y agoWhich includes the whole standard library. The corresponding Java, C#, Python standards, equally with the standard library, are even bigger. To come back to the point, many don't know how deceptively complex Python happens to be, even though on the surface looks like a BASIC replacement.
- int_19h 2y agoTo be fair, even if you look at just the language alone, C++ is still extremely large. But the real problem is when you combine this sheer size with the amount of subtle footguns. If we compare to equivalent Python code, for example, the behavior is simple and straightforward: division by zero causes a runtime error that is reported in a well-defined manner. Similarly with other arithmetic issues in C++ that can trigger UB - e.g. integer overflow is just not a thing in Python (short of OOM). The detailed rules may well be complicated, but it doesn't matter as much when the behavior is intuitive and conforms to common sense expectations.
- kccqzy 2y agoAnd that's why Python is slow and a director at a previous employer initiated a project to rewrite all Python in C++ and the CPU savings far exceeds the cost of some programmers.
- shadowgovt 2y agoIt depends on what you're writing. I've seen slow C++ and fast Python. Not to imply your director made a bad call; especially if you already had a reference Python implementation to check against the new C++ implementation for correctness, you can gain quite a bit depending on The domain you're operating in by swapping out a Python engine with an engine written in another language (if for no other reason and it gives you an opportunity to check all your assumptions against a system solving real problems for real people).
- int_19h 2y agoPython is slow because it is insanely dynamic - much more so than, say, JavaScript. Look into what gets executed for something as simple as a method call before it even gets to the method body. Descriptor protocol etc.