News for hackers. Stuff that matters.
Re:Std::visit is everything wrong with modern C++ (2017) by FartyMcFarter on Saturday December 05, 2020 @10:17AM (#25315121)
Maybe there's some truth to what you're saying. But at the same time, there aren't many alternatives that tick all the boxes C++ does (performance, portability, maturity and stability). Together with the amount of C++ code that exists, I don't see C++ going away anytime soon.

Ironically, if one wants all of those things, the best alternative at the moment may be the C language.

Re:Std::visit is everything wrong with modern C++ (2017) by jandrewrogers on Saturday December 05, 2020 @11:44AM (#25315852)
A major feature of modern C++, and one of the most difficult to replace, is its expressiveness and optional strictness. You don't get this with C (or most other languages). The metaprogramming and compile-time facilities for example, while complex, are indispensable for some code bases. This becomes evident when you try to port rigorous modern C++ code bases to other programming languages du jour. A surprising amount of C++ is difficult to express with equivalent behavior and performance in a similar amount of code.

I play around with new system languages by implementing parts of database engines (typically written in modern C++) in the new language. It terms of abstract code architecture, you can port a C-style database design with relative ease -- most new system languages aim to be an improved C with direct portability in mind -- but not modern C++-style database design, and the latter is unambiguously superior for performance and correctness when writing database engines. C++ will continue to see a lot of usage as long as it is difficult or impossible to write code in other languages that is functionally equivalent to C++.

Re:Std::visit is everything wrong with modern C++ (2017) by ncmncm on Saturday December 05, 2020 @12:51PM (#25316563)
This.

For C++, the overarching criterion for almost any language feature is how useful it is for capturing semantics in an easy-to-use, performant, powerful, and generally usable library.

The consequence is that using new core language features in non-library code often seems unnecessarily complicated, but a library constructed using the feature as intended is insanely powerful.

The result is that you can write libraries in C++ you cannot write in other languages, and you can call into libraries that are so powerful only from C++.

In most other languages, using a library means you give something up: usually performance, and often it comes with restrictions. The standard of usefulness for C++ libraries is very high, and always increasing.

Re:Std::visit is everything wrong with modern C++ (2017) by steveklabnik on Saturday December 05, 2020 @01:06PM (#25316713)
While this is true in general, we are talking about a library feature that many people want to move into a language feature, specifically because of the drawbacks of it being a library.
Re:Std::visit is everything wrong with modern C++ (2017) by ncmncm on Saturday December 05, 2020 @11:16PM (#25320988)
That a library implementation of pattern-matching would be unsatisfactory exposes a weakness in the core language. Usually, it is better to strengthen the language to the point where a library component can do the job. Sometimes, though, that is too hard, and you give up and do it directly in the core language. It should always be noted as a failing.

Something similar happened with coroutines, although what we did get has hooks that a library should be able to patch into, to achieve wonders not yet seen.

Re:Std::visit is everything wrong with modern C++ (2017) by steveklabnik on Saturday December 05, 2020 @11:53PM (#25321147)
Yeah, I do agree that this is the best way to go. We'll see!
Re:Std::visit is everything wrong with modern C++ (2017) by socialdemocrat on Saturday December 05, 2020 @11:43PM (#25321097)
I have the complete opposite experience. Through my whole career writing C++, that language has been in the way due to all its idiosyncratic behavior. One spends so much time trying to figure out a way around some crazy boiler plate code requirement in C++ only to realize that no, it simply isn't possible to do it in a sane way in C++.

Switching to Swift I felt almost everything worked as it should. It was almost a bit boring not having to deal with all the usual crap that C++ would give me. I am willing to be you can write any C++ system much better in Swift. C++ would probably have a performance edge, but in 95% of cases not enough to be worth dealing with an ugly language like C++.

> C++ will continue to see a lot of usage as long as it is difficult or impossible to write code in other languages that is functionally equivalent to C++.

I would challenge you to give me any language construct that is indispensable for a particular type of program which cannot be done more elegantly in another language and with less headache.

I cannot think of a single feature in C++ which I have ever missed in any other of my preferred languages.

Re:Std::visit is everything wrong with modern C++ (2017) by jandrewrogers on Sunday December 06, 2020 @02:10AM (#25321758)
You likely design very different software systems than I do. I don’t have the luxury of ignoring performance, efficiency, and scalability. I don’t have any particular love for C++, there are many things wrong with it, but sadly there isn’t a practical alternative that doesn’t have worse trade offs. Ironically, I largely refused to use C++ until C++11. I delivered systems in a long list of other languages before that time; my usage of C++ is relatively recent. My choice is pragmatic and based on experience.

If you can’t think of reasons to use C++, that isn’t because reasons don’t exist.

Re:Std::visit is everything wrong with modern C++ (2017) by rualca on Sunday December 06, 2020 @03:37AM (#25322069)
> One spends so much time trying to figure out a way around some crazy boiler plate code requirement in C++ only to realize that no, it simply isn't possible to do it in a sane way in C++.

It seems you're complaining about the outcome of poor and ill-advised engineering practices instead of a programming language.

And your description also covey's the idea that you had people who knew very little about C++ trying to figure out how to use it in ways that they have no idea was possible to use.

I get the appeal of a good scapegoat. Yet, from your description it seems you're trying to dump the blame on a lot of engineering problems you're creating for yourself on a tool.

Re:Std::visit is everything wrong with modern C++ (2017) by a-nikolaev on Sunday December 06, 2020 @01:14AM (#25321537)
Maybe the idiosyncratic BS of C++ is what's hard to express in a saner language? If someone only used hammers all their life, then they will say that a microscope is a bad hammer, which is kind of true =D
Re:Std::visit is everything wrong with modern C++ (2017) by bennofs on Saturday December 05, 2020 @11:51AM (#25315956)
Can you summarise how modern C++ database design differs from C-style design?
Re:Std::visit is everything wrong with modern C++ (2017) by jandrewrogers on Saturday December 05, 2020 @12:51PM (#25316565)
C-style designs rely heavily on macros and aliasing, there is minimal type safety and most correctness properties can only be determined at runtime. Resource management is extremely manual which is both fiddly in the amount of code and error prone. Lots of function pointer passing instead of generics. Macros are used to hide just how tedious a lot of it is but they aren't safe. PostgreSQL is an exceptionally tidy example of a C-style database engine.

In C++-style designs, you end up writing surprisingly little code, having metaprogramming scaffolding generate most of the code for you while doing fairly deep correctness and type safety checks at compile-time. Someone has to write the scaffolding libraries but they aren't that large, just tedious, and they get reused. Resource management, change detection, etc is automagic because C++ makes that easy to hide even in complex cases like DMA I/O. Every data structure and algorithm is highly optimized for the local use case and using the most highly compressed representation reasonable in context. It would be impractical to write all of this code and analyze it manually.

I used to write databases in C99. It required several times the lines of code relative to C++17, with worse results, even if you include the scaffolding libraries. C++17 implementations, done well, is much closer to writing a specification for a subsystem design and behavior and having the compiler generate an optimized implementation for that specification and exporting types that hide the fiddly details that can be safely composed with other generated types, than writing code. The scaffolding is also generic and flexible: some can generate an OLTP database engine just as easily as an OLAP database engine largely by changing the subsystem specifications and composing things differently. This would not be possible without heavy use of the metaprogramming facilities to both generate the types and guarantee that type interactions will still be safe and reasonably optimal.

Re:Std::visit is everything wrong with modern C++ (2017) by noahl on Saturday December 05, 2020 @02:23PM (#25317468)
I'd be curious to know what the libraries are that allow this sort of database engine design. Are there any open source examples?
Re:Std::visit is everything wrong with modern C++ (2017) by jandrewrogers on Saturday December 05, 2020 @11:34PM (#25321060)
I’ve never seen one in open source but I’ve written a couple over the years and seen a few others. It forces you to solve many difficult metaprogramming challenges elegantly so it is a good excuse to achieve some mastery. I’ve burned more hours than I care to admit trying to figure out how to achieve seemingly simple results. Also, until C++17, this was an exercise in masochism due to the limitations of the expressiveness and type inference, which is why so few people tried. Basically, there were a lot of unpleasant rough edges that went away with C++17 because the language wasn’t smart enough previously. C++20 will also be a big step forward for this, whenever the compilers become usable.

One thing to understand is that these libraries are highly opinionated about the abstract architectural model. It doesn’t make a lot of sense to mix components from user space and kernel space designs, for example, though both have advantages separately. It tends to be more along the lines of one abstract architectural model and enormous amounts of elasticity and flexibility within that model based on the data models, workloads, transaction semantics, and hardware you are targeting. You also still have to write a spec that makes sense from a database engineering standpoint.

At least for me, there are still significant parts of a database engine for which I haven’t built a metaprogramming scaffold. That is largely a matter of time and effort. Other parts I haven’t had to write much code for years but still get state-of-the-art implementation to spec.

Ultimately, I’m trying to automate away my job.

Re:Std::visit is everything wrong with modern C++ (2017) by socialdemocrat on Saturday December 05, 2020 @11:49PM (#25321124)
The problem with such fancy meta programming in C++, is that while it may be a thrill to program for a C++ wiz you may end up with making something that is completely unmaintainable, because nobody else can grasp what you wrote.

Compare to writing a database system in something like Go. Sure you make end up with 50% more code, but you could have anybody up and running reading and understanding the code within 3 days.

IBM have done studies of this and found that fancy code is not all that valuable. It ends up falling in disuse over time as people don't get it. I have seen my fair share of C++ code which simply had to be tossed because nobody at the company could understand what the previous whiz kid had written.

Re:Std::visit is everything wrong with modern C++ (2017) by jandrewrogers on Sunday December 06, 2020 @01:43AM (#25321660)
That’s the beauty of the evolution of C++. Metaprogramming has become increasingly maintainable, as making it a first-class capability of the language is a core focus of the people designing it. The learning curve is finally low enough that it is practical. I think it is fair to say that C++17 is the first version where that is true.

You can’t write a comparable database engine in Go, fundamentally. The language lacks features required for competitive performance. The code difference will be much more than 50% trying to get the most out of what Go is capable of in this domain.

The point of writing code this way isn’t to be clever or for a “thrill”, it objectively produces superior performance, reliability, and maintainability. Defects scale with the number of lines of code regardless of language. Type safe code gen is a powerful tool.

Re:Std::visit is everything wrong with modern C++ (2017) by krelian on Sunday December 06, 2020 @10:51AM (#25324254)
>The learning curve is finally low enough that it is practical. I think it is fair to say that C++17 is the first version where that is true.

What are the specific C++17 features that make this a reality?

Re:Std::visit is everything wrong with modern C++ (2017) by coliveira on Sunday December 06, 2020 @01:24PM (#25325376)
Just look at the new features in C++17 that simplify the use of templates, like variadic templates, constexpr everywhere, automatic type detection working together with templates, etc. The last versions of C++ are mostly about making using templates easy, which allows programmers to operate at a different level than languages such as Go and Python.
Re:Std::visit is everything wrong with modern C++ (2017) by Silhouette on Saturday December 05, 2020 @10:48AM (#25315381)
But at the same time, there is no alternative that ticks all the boxes C++ does (performance, portability, maturity and stability).

As you identified yourself, that's not entirely true, because C offers all of those things. But the really tragic thing about the status quo is that because there is so much sunk effort behind the C and C++ ecosystem, the resulting momentum makes it difficult for new languages that are simply better to gain traction.

In a way, C++ is the ultimate demonstration of how important the surrounding tool, library and developer ecosystem is to the success (== usefulness in practice) of a programming language. If the language itself were the dominant factor, the writing would have been on the wall when almost every language at a higher level than C was adding features like first class functions and C++ was trying to do something vaguely similar with overcomplicated binder templates.

A language with nicer syntax for working with higher-order functions, Haskell say, might have used

    xs = [1, 2, 3, 4, 5]
    n = count_if (<3) xs
But for many years in C++, the closest theoretical equivalent would have been to write something like

    xs = // some standard container type, tediously constructed
    n = count_if(xs.begin(), xs.end(), bind2nd(less<int>(), 3))
instead. Obviously hardly any real programmers ever did that, and it's true that modern C++ is better in several relevant ways, but it's been literally decades and it still hasn't entirely caught up.

Meanwhile, several much more promising languages are struggling to break into the kinds of markets they deserve to because they haven't achieved a critical mass of support. And the world continues to suffer the loss of productivity and problems with security and reliability that come from using a language like C++ for things that do actually matter. It's an understandable situation, but still a regrettable one.

Re:Std::visit is everything wrong with modern C++ (2017) by FartyMcFarter on Saturday December 05, 2020 @10:54AM (#25315412)
> As you identified yourself, that's not entirely true, because C offers all of those things.

You're right, I contradicted myself there a bit. Fixed. But C is almost a subset of C++, except for some technicalities. So it's a bit hard to call it an actual alternative. Switching from C++ to C is more or less a matter of restricting oneself to less functionality (which in some cases is a good thing, but I digress).

Other than C it's hard to point at a solid alternative for many C++ use cases.

> In a way, C++ is the ultimate demonstration of how important the surrounding tool, library and developer ecosystem is to the success

Indeed! This is something that any language wanting to compete with C++ must get right. It's a hard thing to do.

Re:Std::visit is everything wrong with modern C++ (2017) by Silhouette on Saturday December 05, 2020 @11:29AM (#25315722)
This is something that any language wanting to compete with C++ must get right. It's a hard thing to do.

I suspect it's actually an impossible thing for a new language to do on its own, because it's not really a technical problem in the first place. It needs a new language with a "killer feature" and serious resources backing it to break through. Several of the relatively success new(ish) languages have combined those two attributes, with the language being in some sense the favoured one for writing software that runs on a certain platform.

Re:Std::visit is everything wrong with modern C++ (2017) by socialdemocrat on Saturday December 05, 2020 @11:34PM (#25321061)
My point was that you should just use old-school C++ if you need to use C++. If your desire is to use fancy language features, and that is your primary focus, then you should switch language.

People should just accept that they work with a legacy language and not try to turn C++ into Haskell, Rust or something it isn't. They just turn it into a worse mess than it already is.

Most C++ code that exists and which is useful is written in old school C++ anyway and could be continued to be maintained that way and wrapped for other users.

And really C++ performance is IMHO somewhat overrated. It depends entirely on what you are doing. I think it was the CouchDB creator. He made his first version in C++. He struggled hard. Then he switched to Erlang, despite Erlang running on a VM he got magnitudes higher performance and had to write less than half the code.

You know the ones who squeezed the most performance out of the Playstation 2 did it using LISP and not C++. They used LISP to create a DSL for PS2 assembly code. Thus they could do high level LISP coding as well as low level assembly all in one.

And today you got many scientists needing high performance computing switching to Julia. Fortran will usually outperform C++ on number crunching. And there are quite a number of cases where Julia will outperform Fortran.

Yes in real time systems with tight memory requirements something like Julia is not a good choice. But then again in those cause you may actually want to prefer C or Rust.

Re:Std::visit is everything wrong with modern C++ (2017) by arc619 on Saturday December 05, 2020 @11:00AM (#25315462)
Another option is to gradually replace parts of the C++ with Nim code set to output to C++. As such you get the advantages of a high level, low friction language with fast compile times and move semantics, ABI compatibility with C++, and a really nice FFI. You can import or export functions and so on between the languages, use any C++ libraries in Nim (or visa versa), and even directly emit C++ from Nim if required.

Gradually porting like this lets you keep using your code base whilst introducing new or overly complex stuff in a language that's faster and easier to write (usually ends up with less than half the LoC of the equivalent C++ but often way, way less than that). Metaprogramming is also very nice, easier to reason about and perhaps most importantly, even with lots of macros doesn't noticeably affect the fast compiles.

Another advantage is once you have some Nim code you can choose to change the target to C or ObjC (or even JS or LLVM) so you're actually increasing portability.

This all depends on how you rank 'maturity' of course. Nim's been around for longer than Rust and Go IIRC, and it's been rock solid for me but you may have different parameters. It certainly helps being able to directly use libraries for C and C++ if you can't find an appropriate Nim implementation.

Edit: For contrast, consider the challenges in the article for variants in C++, then the equivilent object variants in Nim:

    type
      MyVarKind = enum mvkNumber, mvkString
      MyVariant = object
        case kind: MyVarKind
        of mvkNumber:
          num: int
        of mvkString:
          str: string

    var myVariant = MyVariant(kind: mvkNumber)
    myVariant.num = 1
    myVariant.str = "Oops"  # Error: 'str' is not accessible using discriminant 'kind' of type 'MyVariant'
Re:Std::visit is everything wrong with modern C++ (2017) by FpUser on Saturday December 05, 2020 @11:40AM (#25315804)
How do you deal with debugging?
Re:Std::visit is everything wrong with modern C++ (2017) by arc619 on Saturday December 05, 2020 @12:09PM (#25316147)
In VSCode and Neovim there's a visual debugger but in general you can compile with `--debugger:native` and use GDB, for example:

A guide to debugging and profiling: https://nim-lang.org/blog/2017/10/02/documenting-profiling-a...

Guide for working directly with GDB-Nim: https://internet-of-tomohiro.netlify.app/nim/gdb.en.html

A walk through and extra info with the language devs: https://www.youtube.com/watch?v=DmYOPkI_LzU

Re:Std::visit is everything wrong with modern C++ (2017) by FartyMcFarter on Saturday December 05, 2020 @12:27PM (#25316316)
But would you then be debugging the automatically-generated C++ code, which is presumably harder to read than the original Nim source code?
Re:Std::visit is everything wrong with modern C++ (2017) by arc619 on Saturday December 05, 2020 @01:42PM (#25317049)
Technically yes, but directives are inserted so GDB reports the line number, source code, and parameters of the Nim file.

However GDB shows the name mangling suffix in generated code, and types are their native types. There's a script called nim-gdb to add pretty printers for types to the GDB output to show the Nim source types.

Perhaps surprisingly though, the C and C++ generated output itself is fairly straightforward, even with name mangling suffixes. The inserted directives tell you the Nim source line so you can navigate it fairly well if you want to, and the suffix means the variable is unique referenced in the code. As far as I know you can use any debugger that supports the target language, though I've not tried anything but GDB myself.

It's very rare for me to dig into the generated code but sometimes I'm curious about the data structure analog in the target language. In the case of Nim's object variants, last time I looked when compiling to C they were ultimately reduced to simple checked union types.

Re:Std::visit is everything wrong with modern C++ (2017) by FpUser on Saturday December 05, 2020 @03:36PM (#25318073)
Looks more or less workable but I guess not as good as what you get in Visual Studio
Re:Std::visit is everything wrong with modern C++ (2017) by arc619 on Sunday December 06, 2020 @04:43PM (#25326936)
Not yet, no. I hope with companies like JetBrains working on their Nim plugin https://plugins.jetbrains.com/plugin/15128-nim we'll see more focus put on a smooth IDE based debugging experience in particular.
Re:Std::visit is everything wrong with modern C++ (2017) by vips7L on Saturday December 05, 2020 @11:19PM (#25321002)
When compiling to C++ does nim use a GC?
Re:Std::visit is everything wrong with modern C++ (2017) by arc619 on Sunday December 06, 2020 @03:51PM (#25326511)
Yes, if the target is C++ then the whole output will be in C++, including code for GC operations, so you can directly inspect how this is translated. You can actually choose between several GCs for different needs: https://nim-lang.org/docs/gc.html

It's worth mentioning that by default all types in Nim are stack allocated, and you have full manual memory management to the same level as C/C++ but with better type safety and less boilerplate. The GC is only used when you tag a type as `ref`, in strings, and the 'vector' dynamic list type, `seq`.

The newer GC, ARC (not related to Swift's ARC), is similar to RAII - scope based, non-atomic, deterministic, shares memory between threads but not stop-the-world, and uses move semantics: https://nim-lang.org/docs/destructors.html

This makes the GC a nice to use addition for resource management but not a fundamental requirement or speed limitation.

In my experience the default (thread-local refc + cycle collection) GC is very performant already, but it's straightforward to write code that works entirely on the stack, or create objects that wrap manual heap allocs, or use custom external memory allocators. Passing `--gc:none` removes the GC entirely from the compilation target, for example if you're working with very constrained embedded devices with the caveat that less of the stdlib is available (currently).

The ARC GC (doesn't handle cycles unlike it's sibling ORC) is aiming to be lean enough to be used in hard realtime and memory constrained embedded systems. For hard realtime though I'd expect most people would just manually manage their types anyway on the heap or stack.

If you're doing interop between Nim and C++ and want Nim's GC to manage types that you're passing directly to pure C++ code, you can tell the GC that the data is still being used with GC_Ref() or not with GC_Unref(). There are a few libraries for C/C++ interop, such as: https://github.com/nimterop/nimterop

Personally in this case I would probably just manually allocate memory memory in Nim or C++ and not use GC'd types across boundaries for clarity if nothing else, still it's an option if your design requires it.

Finally, there is a tool to help auto-translate C/C++ to Nim with the c2nim tool: https://github.com/nim-lang/c2nim and docs: https://github.com/nim-lang/c2nim/blob/master/doc/c2nim.rst

Re:Std::visit is everything wrong with modern C++ (2017) by jeltz on Saturday December 05, 2020 @10:21AM (#25315167)
Rust has all of those other than portability. Rust's ecosystem while it is missing some things it also has things which are lacking in C++ like a good mature package manager.
Re:Std::visit is everything wrong with modern C++ (2017) by cycloptic on Saturday December 05, 2020 @11:02AM (#25315482)
C++ has several package managers, of varying levels of maturity. Here's a few:

https://github.com/conan-io/conan

https://github.com/microsoft/vcpkg

https://github.com/cpp-pm/hunter

Another option if you're on Linux/BSD is to use your native package manager. C++ packages are usually included in those repositories. You also may be able to install Brew, Nix, or Guix on any given distribution.

Re:Std::visit is everything wrong with modern C++ (2017) by xigoi on Saturday December 05, 2020 @12:37PM (#25316418)
>Another option if you're on Linux/BSD is to use your native package manager.

There goes the portability.

Re:Std::visit is everything wrong with modern C++ (2017) by cycloptic on Saturday December 05, 2020 @01:09PM (#25316756)
No, portability is easily achieved with those by using containers.
Re:Std::visit is everything wrong with modern C++ (2017) by andi999 on Saturday December 05, 2020 @11:45AM (#25315858)
I never learned rust, but from what I read loving the borrow checker also requires Stockholm syndrom.
Re:Std::visit is everything wrong with modern C++ (2017) by cxvxx on Saturday December 05, 2020 @12:23PM (#25316291)
It's more like snowboarding or any activity with a high initial learning curve before a big payoff: It's hard, even painful, at the beginning, and you might come home covered in bruises, but eventually it "clicks" and it's a lot of fun.

Stockholm Syndrome is more about convincing yourself that a bad situation is good because you're stuck in it. I don't think there are too many people "stuck" with Rust yet. On the contrary, I think the borrow checker is a draw.

Re:Std::visit is everything wrong with modern C++ (2017) by User23 on Saturday December 05, 2020 @10:49AM (#25315386)
> Rust has all of those other than portability.

That's crippling. Arguably the best use case for C++ is coding video games, and portability is huge there.

Re:Std::visit is everything wrong with modern C++ (2017) by stu2b50 on Saturday December 05, 2020 @10:54AM (#25315421)
The modern video game platforms are: PC, Xbox Series, PS5, Xbox One, PS4, Switch, Android, iOS, Web

Of which Rust has backends for all them, even the web via wasm.

While Rust is not as portable, it's not like it's strictly limited to well functioning x86 boxes, it'll produce binaries for anything that LLVM supports, which is quite a lot by now.

Re:Std::visit is everything wrong with modern C++ (2017) by FartyMcFarter on Saturday December 05, 2020 @10:58AM (#25315449)
> Of which Rust has backends for all them, even the web via wasm.

Are those backends officially supported on consoles? Do all those consoles have libraries and tools (profilers, debuggers, etc) that support Rust?

Re:Std::visit is everything wrong with modern C++ (2017) by steveklabnik on Saturday December 05, 2020 @12:32PM (#25316359)
They are not directly supported by the vendors. That said, tools that work on C and C++ will at least somewhat work on Rust, so you also get sorta kinda half support even if it's not officially supported.

We'll see if this changes in the future, especially with some of the names doing Rust dev in these places.

Re:Std::visit is everything wrong with modern C++ (2017) by bsagdiyev on Saturday December 05, 2020 @11:23AM (#25315677)
Internally I know Sony had a Rust compiler for the PS4, I don’t know much more than that (like if it was used for anything). Just saw the repo was updated quite often so it was definitely still WIP at least, and it had some code samples for console apps. Never tried it on my dev console to see if it worked.
Re:Std::visit is everything wrong with modern C++ (2017) by stu2b50 on Saturday December 05, 2020 @11:22AM (#25315659)
Yep, like in C++ it's trivially easy to use the platforms C apis. And indeed the debugger does work on all platform.
Re:Std::visit is everything wrong with modern C++ (2017) by Torkel on Saturday December 05, 2020 @11:04AM (#25315500)
Modern C++ isn’t all that portable either.
Re:Std::visit is everything wrong with modern C++ (2017) by FartyMcFarter on Saturday December 05, 2020 @11:10AM (#25315554)
IMHO the last big upgrade to C++ was C++11, which is supported by lots of toolchains. It added move semantics, decent smart pointers, and a crapload of other improvements.

C++14 and C++17 were minor upgrades by comparison, so I'd say C++11 can rightly be called modern C++, though others may disagree.

Re:Std::visit is everything wrong with modern C++ (2017) by ncmncm on Saturday December 05, 2020 @12:54PM (#25316599)
I see that you are wholly unaware of C++20, which (combined with '14 and '17) is as large a step from C++11 as C++11 was from C++98.
Re:Std::visit is everything wrong with modern C++ (2017) by FartyMcFarter on Saturday December 05, 2020 @01:13PM (#25316785)
C++20 is barely out yet, and not supported by any toolchain. If that's the only version that counts as modern C++, then I agree that modern C++ isn't portable :)
Re:Std::visit is everything wrong with modern C++ (2017) by jcelerier on Saturday December 05, 2020 @11:46AM (#25315879)
c'mon, you can run C++17 code on Commodore 64 (https://www.youtube.com/watch?v=zBkNBP00wJE) and MS-DOS (https://www.youtube.com/watch?v=yHrC_rZUaiA), what more do you want ?
Re:Std::visit is everything wrong with modern C++ (2017) by rndgermandude on Saturday December 05, 2020 @11:48AM (#25315909)
I'd argue that Rust is as portable as C++, if not more so, in the sense that there are no real barriers in the language itself that limit portability. It's harder to write un-portable code in Rust than in C++, because a lot less in idiomatic rust is undefined or food-gunable.

Of course when it comes to practical portability today then you're right as there are plenty more C++ compilers for different platforms than Rust compilers (then again, there are more C compilers than C++ in that regard). This may eventually change over time, tho, but it sure is something to consider today.

PS and edit: I don't mind you disagreeing with me, but would anybody care to illuminate me as to what your disagreement is about?

Re:Std::visit is everything wrong with modern C++ (2017) by tester756 on Saturday December 05, 2020 @11:19AM (#25315635)
>performance, portability, maturity and stability

sounds like C# and Java with only performance being questionable, but Java's used in HFT, so it definitely can compete.

Re:Std::visit is everything wrong with modern C++ (2017) by whimsicalism on Saturday December 05, 2020 @11:23AM (#25315674)
> Java's used in HFT, so it definitely can compete.

This is a bad argument and if you're using Java, you're not competing in the very speed-critical parts of HFT. Nor is Java common among HFT shops at all.

well-written C++ is much faster than Java.

Re:Std::visit is everything wrong with modern C++ (2017) by tester756 on Saturday December 05, 2020 @06:39PM (#25319493)
I know people who sit in HK and have been doing HFT/Quant stuff for years and they say something completely different - that Java's popular among biggest trading/stock systems.

So saying that

> Nor is Java common among HFT shops at all.

Sounds weird, especially when it appears among job postings.

Re:Std::visit is everything wrong with modern C++ (2017) by qppo on Saturday December 05, 2020 @11:21AM (#25315655)
GC is usually out the window if you're debating using C++