Live data from Hacker News

Overview: What are Cpp2 and cppfront? How do I get and build cppfront?

hsutter.github.io

141–150 of 174 posts

Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?

#141

Earlier quoted context omitted.

Java and C# are in their "let's get functional" phase.

:( C# has been at that for more than a decade and a half already. Java's arrival to the party is extremely late and still lacking in many areas.

C# could have been like D back in 2001, yet it had to wait to go open source, away from the wings from WinDev politics, having to provide a replacement to C++/CLI capabilities in a cross-platform way, to finally expose the full CLR to C#, without us having to routinely manually generate MSIL or reach out to C++/CLI.

Singularity and Midori were hardly taken seriously in any form by WinDev.

Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?

#142
post #135

Earlier quoted context omitted.

It would have been possible to, as a special case, type check the formatting, C compilers began doing that in the 1990s IIRC.

It wouldn’t have added support for custom types to printf(), which was an important motivation.

That's true, however neither the mechanism to do this in I/O streams, nor the weighty mechanism for std::format come close to what Rust's derive macro offers for Debug, and in my experience asking for so much means you often won't get anything because programmers are lazy.

That is, for a custom type in Rust having rudimentary Debug output is one word added to the list of derive macros, the word "Debug". Almost everybody will write that, it's barely effort.

To get that in C++ I/O Streams you need to write an operator overload function and must be careful to write it correctly. Trivial types usually don't bother, but many C++ programmers are comfortable writing this for an important type.

For std::format you need to write a template which is already pretty scary, and then it needs to implement custom parse and format steps, this is because std::format allows your custom type to define its own custom formatting rules. This is extremely powerful, but everybody must pay for this power. I have not seen most people bother doing all this at all.

Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?

#143
post #100
post #50

Someone on reddit said that the cpp2 repo was a bit old, and that is true, although he may have started this as an experiment influenced by typescript and left it on the side at some times. Anyway I have no idea if cpp2 would get support from microsoft or other devs, but cpp2 seems like the most humble and "least risky" solution for the future of C++, and I really want it to be. What I remember the most that Herb Sut…

How about Google's Carbon language? https://github.com/carbon-language/carbon-lang

Carbon and Cpp2 are both "C++ successors," broadly speaking. However, they take different approaches in their design:

Carbon is a brand-new language that's designed to have seamless interoperability to C++.

Cpp2 is C++, just with a different syntax. (The goal is to even be able to mix Cpp2 and C++ syntax in the same source file. The initial implementation transpiles Cpp2 to C++ source code, similar to how the original C++ implementation transpiled C++ to C, rather than implementing a full compiler.)

Their overall goals appear to be different, too: The Carbon README states, "Existing modern languages already provide an excellent developer experience: Go, Swift, Kotlin, Rust, and many more. Developers that can use one of these existing languages should." With that mindset, it sounds like more of a stopgap for projects already invested in C++. In contrast, I believe that Sutter would argue that C++ still has the potential to be a viable choice for many tasks, and Cpp2 is a way to realize that.

Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?

#144
post #55

[flagged]

Why would you use cmake to build a single file??

That's the problem, it's a single cpp file because it's built manually. The source code is spread among many hpp files for no reason other than being able to include everything in that single cpp file. The project organization of cpp2 is abysmal.

Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?

#145
post #117

Unfortunately the first example already re-uses one of the less good parts of C++, the "<<" operator for std::cout, which always was a bit of a hack (including strange order of operations since << normally is left shift)

Don't you think it just serves to highlight that Cpp2 is just C++? That it's explicitly not some new language with C++ FFI like Carbon.

Not sure what is meant by this statement. Both cpp2 and Carbon are different languages, neither of them claim to be just C++.

Both languages will have bidirectional compatibility with C++ so that code written in C++ can be directly accessed from Carbon and code written in Carbon can be directly accessed from C++. Neither of them use an FFI for compatibility.

Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?

#146
post #135

Earlier quoted context omitted.

It wouldn’t have added support for custom types to printf(), which was an important motivation.

That's true, however neither the mechanism to do this in I/O streams, nor the weighty mechanism for std::format come close to what Rust's derive macro offers for Debug, and in my experience asking for so much means you often won't get anything because programmers are lazy. That is, for a custom type in Rust having rudimentary Debug output is one word added to the list of derive macros, the word "Debug". Almost everyb…

You can write operator<< as a free (non-member) function yourself for classes that don’t implement it. Furthermore, it’s not necessarily the same output that you want for debugging.

Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?

#147
I do not understand why there is a push to change the C++ syntax. There are plenty of new natively compiled languages like D, Go, Rust, Zig, Nim, Odin, Crystal, and so on. If you do not like C++ you always can use some of them instead. The problems that make C++ unsafe are semantic and not syntactic ones.

Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?

#148
The whole story about what cpp2 tries to be, distancing itself from other C++ wannabe replacements is only due to be coming from WG21 chair, which naturally can't talk about a C++ replacement as per conflict of interests.

Cpp2 isn't an alternative syntax to C++, as much as C++ and Objective-C aren't alternative syntaxes for C, even though they support a subset of it, and were born exactly the same way, code translators into C.

C didn't evolve into them, they became their own ecosystem, tainted by the underlying C compatibility.

The only alternative that is really a Typescript for C++, is Circle.

Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?

#149
post #98

Earlier quoted context omitted.

> Anyway I have no idea if cpp2 would get support from microsoft or other devs, but cpp2 seems like the most humble and "least risky" solution for the future of C++, and I really want it to be. That ship has sailed. They already have C#.

To be fair C# is vastly different in terms of semantics compared to C++. There's a lot of areas where it's not viable to use C#, and IMHO it also has its own share of legacy and bad decisions from its "Java clone" days that make it impossible to prefer it to C++ sometimes. Btw Microsoft is definitely interested into adopting new languages, just look all the effort they've been pouring into Rust lately.

Rust is now the official system programming language for Azure infrastructure, alongside managed languages, and it appears there is a soft spot to use Go instead of C#, when looking at what Azure opens up.

WinDev, Office and XBox is another matter, they are deep into C++ and COM culture.

Re: Overview: What are Cpp2 and cppfront? How do I get and build cppfront?

#150

Earlier quoted context omitted.

The main iteration this cycle for the next C++ is contracts. Contracts are all about introducing undefined behaviour if you don't satisfy a precondition. In practice this improves software quality on many levels by clearly defining requirements on interface boundaries that would otherwise be implicit or just documented. Of course you can have special debug modes where you actually check that contracts are being satis…

> The main iteration this cycle for the next C++ is contracts. As ever the C++ train leaves on schedule with or without anything you suppose is "promised" for that standard revision. This has been the practice since 2011 and I don't expect it to stop unless ISO tells them "Enough" or the whole thing comes apart. > Contracts are all about introducing undefined behaviour if you don't satisfy a precondition. Nope. That'…

With Azure now only considering C++ for existing projects, and new projects require explicit reasoning why C or C++ instead of Rust, I expect some internal pressure at MS to do the right thing.
Post reply on HN