News for hackers. Stuff that matters.
Re:The Two Factions of C++ by darknavi on Monday November 25, 2024 @09:43AM (#42236666)
Have you seen some of his recent talks? Lots of underpinnings of cppfront have been added or are in committy.

He compares it to the JS/TS relationship.

Re:The Two Factions of C++ by nox101 on Monday November 25, 2024 @10:19AM (#42236984)
It's not really a valid comparison though. cppfront is a different language that just happens to be compatible with C++. ts/js is were ts is just js with types. You can comment out the types and it just runs. cppfront's language you'll actually have to re-write the code to get it to compile in C++

typescript

    function add(a: number, b: number): number { return a + b };
javascript

    function add(a/*: number*/, b/*: number*/)/*: number*/ { return a + b };
cppfront

    add: (a: float, b: float): float = { a + b; }
cpp

    float add(float a, float b) { return a + b; }
Re:The Two Factions of C++ by HelloNurse on Monday November 25, 2024 @10:35AM (#42237106)
Do you realize that the Typescript example contains strictly more information than the Javascript one (namely, declarations for the type of three things) and is therefore more complex to compile, while the two C++ examples are semantically identical (the last expression in the function is returned implicitly without having to write "return") and the new syntax is easier to parse?
Re:The Two Factions of C++ by Conscat on Monday November 25, 2024 @12:32PM (#42238163)
There are several semantic differences between Cpp1 and Cpp2. Cpp2 moves from last use, which is the biggest one. In a contrived example, that could result in a "hello world" changing to "goodbye world" or any other arbitrary behavior change you want to demonstrate. Cpp2 also doesn't require you to order functions and types or declare prototypes, which means partial template specializations and function overloads can produce similar changes when migrating from Cpp1 to Cpp2.
Re:The Two Factions of C++ by Conscat on Monday November 25, 2024 @03:12PM (#42239723)
I've written a little demo here: https://godbolt.org/z/xn1eqd5zb

You can see where CPPFront inserts a `cpp2::move` call automatically, and how that differs from a superficially equivalent Cpp1 function.

Re:The Two Factions of C++ by nox101 on Monday November 25, 2024 @02:02PM (#42239093)
yes, of course. That's not my point. My point is TypeScript succeeds because it's just JavaScript with types. It's not a new language. cppfront is an entirely new language so it's arguably going to have a tougher time. Being an entirely new language, it is not analogous to typescript
Re:The Two Factions of C++ by EE84M3i on Monday November 25, 2024 @12:53PM (#42238375)
> ts/js is were ts is just js with types. You can comment out the types and it just runs.

Is this true in the general case? I thought there were typescript features that didn't have direct JavaScript alternatives, for example enums.

Re:The Two Factions of C++ by paulddraper on Monday November 25, 2024 @01:06PM (#42238488)
Enums and namespaces are the only runtime features of TypeScript.

So, yes, you can't just strip types, but it's close.

Re:The Two Factions of C++ by EE84M3i on Monday November 25, 2024 @01:37PM (#42238799)
Is there a comprehensive list of such incompatibilities documented somewhere?
Re:The Two Factions of C++ by judofyr on Monday November 25, 2024 @04:24PM (#42240362)
Re:The Two Factions of C++ by paulddraper on Monday November 25, 2024 @05:08PM (#42240657)
That's not the same.

That guarantees that the types do not determine the output (e.g. no const enums), not that you can "strip" types to get the same output.

Re:The Two Factions of C++ by paulddraper on Monday November 25, 2024 @05:07PM (#42240647)
Not that I'm aware of.

Decorators would be another example. (Though they have always been marked experimental.)

And of course JSX, but that's not a TypeScript invention.

Re:The Two Factions of C++ by pjmlp on Monday November 25, 2024 @10:38AM (#42237137)
Nope, that is mostly sales pitch, the only thing added thus far has been the spaceship operator.

He also sells the language differently from any other language that also compiles to native via C++, like Eiffel and Nim among others, due to conflict of interest to have WG21 chair propose yet another take on C++.

Re:The Two Factions of C++ by chipdart on Tuesday November 26, 2024 @12:18AM (#42242804)
> He compares it to the JS/TS relationship.

OP is right, TypeScript is a whole new syntax, and it's shtick is that it can be transpiled into JavaScript.