News for hackers. Stuff that matters.
Re:Modern C++ Won't Save Us by fooker on Monday April 22, 2019 @11:51PM (#19725471)
I don't see the problem. You are free to use such a modern library (Google does, it's called absl).

The good thing here is that the standard library doesn't require 'magic' to be implemented (unlike Swift where the standard library relies on hidden language hacks).

Re:Modern C++ Won't Save Us by nimrody on Tuesday April 23, 2019 @03:08AM (#19726251)
The difficulty here is combining multiple libraries each using its own abstractions.

For example, since the standard library does not have a Matrix class suitable for numerical applications (or maybe it does today...) using multiple libraries each with its own Matrix class is difficult. Multiple libraries are needed since one library may not contain all numerical algorithms one may require for a given app.

This is not a problem for Google where I assume everyone is using internally written code -- but is a problem for most of us.

Re:Modern C++ Won't Save Us by jcelerier on Tuesday April 23, 2019 @03:25AM (#19726333)
> For example, since the standard library does not have a Matrix class suitable for numerical applications (or maybe it does today...) using multiple libraries each with its own Matrix class is difficult.

well, Python comes with a builtin "matrix-like" array type and yet it's not the one which is the most used in scientific computation.

Re:Modern C++ Won't Save Us by aldanor on Tuesday April 23, 2019 @07:55AM (#19727675)
Python provides the buffer interface, however (which `array` module implements), which links Python's buffers and memoryviews to numpy arrays to multiple other 3rd-party array-like and table-like types and structures.
Re:Modern C++ Won't Save Us by RayDonnelly on Tuesday April 23, 2019 @07:50AM (#19727642)
.. because it's (relatively speaking) brand new?
Re:Modern C++ Won't Save Us by nradov on Tuesday April 23, 2019 @12:04AM (#19725532)
Sure it's possible to use a non-standard "standard library". But at that point you're already halfway to using a different language so why not consider switching from C++ to D / Rust / Go?
Re:Modern C++ Won't Save Us by ncmncm on Tuesday April 23, 2019 @12:50AM (#19725692)
The whole point of C++ is that it enables writing more powerful libraries, capturing semantics in libraries that can then just be used. C++ is still quite a lot more powerful for this purpose than Rust. Rust will get better at it, over time, but it has a long way to go and C++ is not siiting still.

Rust is still a niche language, and if its rates of adoption and improvement do not keep up, it will remain a niche language, and fade away like Ada.

I cannot imagine a serious programmer switching from C++ to Go. If you can, you have a much livelier imaginary life than I do.

Re:Modern C++ Won't Save Us by ajxs on Tuesday April 23, 2019 @01:57AM (#19725950)
The Ada partisans are all out in force here in this thread to defend Ada, all four of us. haha... For what it's worth, niche as Ada may be, it's an _important_ niche. It remains widespread in safety-critical applications, and isn't going anywhere anytime soon. It's really good to see Rust taking lessons from Ada/SPARK in the area of formal proofing! If any language is going to threaten C++, it looks like Rust. I don't expect an Ada resurgence to happen, unfortunately.

> I cannot imagine a serious programmer switching from C++ to Go. If you can, you have a much livelier imaginary life than I do.

This got a laugh out of me.

Re:Modern C++ Won't Save Us by pjmlp on Tuesday April 23, 2019 @02:05AM (#19725984)
A large majority of Ada partisans found their corner in Java, C# and C++'s type system improvements over C, and made the best we could from the sour grapes of C's copy-paste compatibility.
Re:Modern C++ Won't Save Us by ajxs on Tuesday April 23, 2019 @02:18AM (#19726058)
Calling myself an Ada partisan is a bit of a stretch. I've recently begun using it for embedded development, which is a domain almost completely dominated by C. That's the angle I'm coming in from.
Re:Modern C++ Won't Save Us by pjmlp on Tuesday April 23, 2019 @02:40AM (#19726152)
It depends on each one naturally.

For me, coming from Turbo Pascal 3 - 6, it allowed me in 1993 to use a language with a similar level of safety and language features, instead of having to deal with PDP-11 constraints.

I was always the weird kid that asked the professors if I could deliver C projects written in C++ instead, which thankfully some of them did accept.

Specially given that at my degree, C was already out of fashion by the early 90's. First year students got to learn Pascal and C++, and were expected to learn C from their introduction to C++ programming.

Re:Modern C++ Won't Save Us by nicoburns on Tuesday April 23, 2019 @07:11AM (#19727392)
> Rust is still a niche language

Only just barely at this point. It has significant projects from a lot of the largest companies (Google, Microsoft, Amazon, etc). Firefox is using it, Dropbox is using it, Red Hat is using it.

Re:Modern C++ Won't Save Us by ncmncm on Tuesday April 23, 2019 @10:32AM (#19728978)
In five years it might be just barely a niche language. In ten, if it catches on, it won't be.

If it does, its users will have come over from Java, C#, and C.

Re:Modern C++ Won't Save Us by rootlocus on Tuesday April 23, 2019 @02:15AM (#19726042)
Is this the "no serious programmer" fallacy?
Re:Modern C++ Won't Save Us by Y_Y on Tuesday April 23, 2019 @03:21AM (#19726317)
No true hn commenter would make such a mistake.
Re:Modern C++ Won't Save Us by machinecoffee on Tuesday April 23, 2019 @07:19AM (#19727427)
From what I can see, the whole point of C++ is to wrap existing C libraries and call them OO :-)
Re:Modern C++ Won't Save Us by fooker on Tuesday April 23, 2019 @12:09AM (#19725548)
No, using a library is not halfway to using a different language.

Languages exist to allow you to define your own layers of abstractions. The language choice ideally reflects what abstractions are useful for your project.

Re:Modern C++ Won't Save Us by geezerjay on Tuesday April 23, 2019 @01:36AM (#19725866)
> But at that point you're already halfway to using a different language

This statement makes no sense at all. Using a third-party library that's not specified by the same ISO standard that specifies the core languagr does not create "a different language".

It just means you're actually using the programming language to do stuff.

This isn't the case even if someone uses a toolkit that relies on preprocessor tricks to give the illusion of extending the core language, such as Qt.

Re:Modern C++ Won't Save Us by mempko on Tuesday April 23, 2019 @12:32AM (#19725635)
C++ is designed for people to make nice libraries. Unlike other languages there is nothing special about the standard library (no magic language hacks). All libraries are first class citizens by design.
Re:Modern C++ Won't Save Us by usrnm on Tuesday April 23, 2019 @01:00AM (#19725721)
Good luck implementing something like std::is_standard_layout without "magic language hacks". No, not all libraries are made equal and std is part of the language now, there is no way back
Re:Modern C++ Won't Save Us by geezerjay on Tuesday April 23, 2019 @01:47AM (#19725904)
You've cherry-picked a type trait as your example, which arguably could be a core language feature made to look like a third-party module.

Meanwhile, do you believe it's hard to implement a container?

And no, adding cruft to the STL is not a one-way street. See for example the history of C++'s smart pointers.

Re:Modern C++ Won't Save Us by int_19h on Tuesday April 23, 2019 @03:02PM (#19731729)
It is pretty hard to implement a container with all the precise invariants and guarantees that the Standard requires.

But more to the point, your implementation might still not be as fast as the standard library one, because the standard library can make assumptions about the compiler that you cannot in portable code - what is UB to you might be well-defined behavior to stdlib authors. Thus, for example, they might be able to use memcpy for containers of stdlib types that they know are safe to handle in that manner.

Re:Modern C++ Won't Save Us by fooker on Tuesday April 23, 2019 @04:50AM (#19726671)
A look into the type_traits header reveals that is_standard_layout is implemented with standard C++.
Re:Modern C++ Won't Save Us by Kranar on Tuesday April 23, 2019 @08:37AM (#19727960)
Re:Modern C++ Won't Save Us by fooker on Tuesday April 23, 2019 @09:08AM (#19728191)
It checks if a non standard feature is available, otherwise falls back to a standard implementation.

My argument was that it was possible to implement it with standard C++.

Re:Modern C++ Won't Save Us by Kranar on Tuesday April 23, 2019 @01:54PM (#19731093)
There's no way to implement that type trait using standard C++. The implementation does check if a non-standard feature is available, and if not it delegates to is_scalar which in turn delegates to is_enum which in turn delegates to is_union. is_union can not be implemented in a standard conforming manner without compiler support and libc++ unconditionally returns false if compiler support is not available, which does not conform to the standard.
Re:Modern C++ Won't Save Us by pjmlp on Tuesday April 23, 2019 @02:03AM (#19725972)
Lack of tooling for HPC, GPGPU, mixed language graphical debugging across Java and .NET, native support for COM/UWP, game engines like Unreal, CryEngine and Unity.
Re:Modern C++ Won't Save Us by Const-me on Tuesday April 23, 2019 @09:55AM (#19728574)
Many libraries only expose C or C++ APIs. Some of these libraries are hard requirement, like OS kernel APIs or GPU APIs.

Insufficient SIMD support in other languages, Intel only supports their intrinsics in C and Fortran.

Tools for C++ are just too good, IDEs, debuggers, profilers.

Re:Modern C++ Won't Save Us by Razengan on Tuesday April 23, 2019 @02:05AM (#19725980)
What are the hidden language hacks in Swift?
Re:Modern C++ Won't Save Us by Someone on Tuesday April 23, 2019 @03:38AM (#19726384)
I wouldn’t call them hacks, but there are things in the runtime that you can’t implement yourself in Swift. Examples (corrections welcome):

- you can’t allocate memory and then turn it into an Swift object.

- you can’t write Decodable in pure Swift (reflection isn’t powerful enough to do “set the field named “foo” in this structure to “bar”)

- reference counts are hidden from Swift code (yes, there’s swift_retainCount to read them, but that’s documented as returning a random number (https://github.com/apple/swift/blob/master/docs/Runtime.md) because it should not be used). So, if the compiler emits more reference count logic than needed in the data structure that your library uses, there’s no way to improve on it.

Re:Modern C++ Won't Save Us by fooker on Tuesday April 23, 2019 @03:59AM (#19726476)
There are a lot more of these, I can't find a comprehensive list unfortunately.
Re:Modern C++ Won't Save Us by rimliu on Tuesday April 23, 2019 @03:34AM (#19726370)
What are those "hidden language hacks" in Swift?