16 ms·
Cooperative C++ Evolution – Toward a TypeScript for C++
- x-shadowban 3y agoC++ only needs 4 things: gradually-introducable memory safety, static reflection, first-class compile time string manipulation, and adoption+refinement of its modules feature.
- jb1991 3y agoLol “only”
- papichulo2023 3y agoI'd add less verbose ranges. Idk about memory safety, optional and expected are working pretty well for me (i just use it on personal projects though)
- uxp8u61q 3y agoYou can't possibly put syntactic sugar on the same level as memory safety.
- zerr 3y agoI'd also vote for std::string split and join functions. And networking.
- LeSaucy 3y agoQt?
- harrid 3y agoC++ is a memory safe language if not abused.
- uxp8u61q 3y agoJust don't write bugs!
- harrid 3y agoIt's impossible to memory leak even with bugs if you don't use antique parts of the language that won't pass any static analysis anyways.
- uxp8u61q 3y agoWhat antique part of the language am I using in this bugged code? class A {}; std::unique_ptr<A> array(new A[256]); It's very easy to produce innocuous-looking code that contains leaks. (And yes, I know that make_unique solves the problem here.)
- frankjr 3y agoConsidering that Chromium, being one of the most heavily statically analyzed code bases, is full of commits which fix memory leaks, your comment makes absolutely no sense. https://github.com/search?q=repo%3Achromium%2Fchromium+memory+leak&type=commits https://github.com/search?q=repo%3Achromium%2Fchromium+memor...
- deschutes 3y agoChromium is a massive project spanning decades of intense active development that intricately connects just about every domain of programming. A few leaks fixed per month is nothing. Further there is no major language promising no leaks once you include things like retained references to garbage and reference cycles. Leaks are one thing modern C++ solves pretty well.
- pjmlp 3y agoThat is the idea of C++ profiles, based on Ada's language profiles, being pushed by Bjarne Stroustoup. Now, how willing WG21 and the compiler vendors are open to the idea, is anyone's guess.
- dazzlefruit 3y agoWhat’s the use case for static reflection?
- bfrog 3y agoBecause c++ doesn’t already have enough bullshit it needs some more
- hcks 3y ago[flagged]
- afavour 3y agoI wish there was a clarification of the differences between the “Dart plan” and the “TypeScript plan”. If I had to guess I’d say the Dart approach is a whole new language that transpiles to C++ while the TypeScript plan is one that augments the current language with useful additions.
- coffeebeqn 3y agoC+++
- mike_hock 3y ago[&] { auto D = C; C += 2; return D; }()
- jeffreygoesto 3y agoDis you, Walter?
- mike_hock 3y agoLol, this would imply that D is the old C, so I doubt Walter would write this. :) I should have just called the variable oldC.
- andai 3y agoYeah, the whole article rests on this premise, but does not explain it. I guess that's behind the "timewall" of the talk?
- IAmLiterallyAB 3y agoYeah you really have to watch the talk video to understand the article. Which is a time sink but I felt it was worth it
- acover 3y ago> Both plans have value, but they have different priorities and therefore choose different constraints… most of all, they either embrace up-front the design constraint of perfect C++ interop and ecosystem compatibility, or they forgo it (forever; as I argue in the talk, it can never be achieved retroactively, except by starting over, because it’s a fundamental up-front constraint). > cppfront is on the TypeScript plan: > full seamless interop compatibility with ISO Standard C++ code and libraries without any wrapping/thunking/marshaling, > full ecosystem compatibility with all of today’s C++ compilers, IDEs, build systems, and tooling, and > full standards evolution support with ISO C++, including not creating incompatible features (e.g., a different concepts feature than C++20’s, a different modules system than C++20’s) and bringing all major new pieces to today’s ISO C++ evolution as also incremental proposals for today’s C++.
- ktbwrestler 3y agoI’m not a frontend guy but heard that typescript is already falling off and contentious at this point. Is it truly something that’s going to stay?
- pferdone 3y agoWhere have you heard that? Because Typescript is the defacto standard right now. Projects like bun and deno cement that status further.
- zukzuk 3y agoTypescript has a lot of momentum on all fronts and is almost certainly the future of Javascript. The big problem is that it still requires transpilation, which can set up all sorts of shitty traps. Not to mention that the Javascript ecosystem in general is a horrendous mess, which Typescript on its own can’t fix.
- rewmie 3y agoI understand that being a Microsoft employee there's always am incentive to promote Microsoft initiatives, but I feel that it's disingenuous to describe this sort of initiative in C++ circles as "TypeScript for C++" when C++ originated from "C with classes", which is the same transpiling-based approach but without Microsoft marketing attached to it. Also, I think that promoting a new programming language as "TypeScript for C++" is a marketing move to try to force their way into a market share in spite of the language's merits.
- cylinder714 3y agoIf you watch the video linked in the OP, his reasoning for calling it that becomes clear. It's not a case of "promoting Microsoft initiatives."
- surfmike 3y agoThe article claims nobody’s tried a language natively compatible with C++, but that’s the approach that Google’s Carbon is taking: https://github.com/carbon-language/carbon-lang https://github.com/carbon-language/carbon-lang
- gpderetta 3y agoAnd Circle and cppfront. Edit: of course this is about cppfront :)
- BalinKing 3y agoIndeed, I think the article is about cppfront.
- whoiscroberts 3y agoCarbon is on my list of things to experiment with.
- iris2004 3y agoCarbon is disappointing and feels like a missed opportunity. It feels more like a syntax refresh. C/C++ desperately need a safety overhaul. I work in the embedded functional safety space. Rust has shown it can be done. Not having lifetime/borrowing support or something that achieves the same thing from the start gives the impression nothing has been learned in the last decade.
- scaredginger 3y ago> Note that Carbon is not ready to use
- logicchains 3y agoNo, it says "No one else has tried the TypeScript plan for C++ yet". Which is true; Carbon isn't a compiler/transpiler to C++, it's a whole new language, albeit one with strong C++ interop.
- pjmlp 3y ago
- jmisavage 3y agoI'm confused doesn't C# fill this role?
- mgaunard 3y agoNeither TypeScript nor Dart are relevant technologies to people interested in C++. It's weird to refer to these arguably bad web technologies to market an unrelated initiative.
- tentacleuno 3y agoWhy is TypeScript a "bad web technology"? It's not really a "web technology" at all. It's a language which transpiles to standard JavaScript. The only real web-geared parts of TypeScript are the included (optional) DOM typings.
- mgaunard 3y agoType annotations for dynamically-typed languages is just a bad idea. JavaScript's only reason for existence is web browsers. If you're not doing web stuff do yourself a favour and use something else.
- mplewis 3y ago“C++’s only reason for existence is legacy GUI apps. If you’re not doing embedded stuff do yourself a favor and use something else.”
- seabird 3y agoI would say this is largely true. C++ is incredibly fun and incredibly hard to wrangle. I think it's one of the most interesting ecosystems out there and you would have to do a lot of convincing to get me to start a new project in it. Everybody says they're going to be more disciplined this time, but after enough time, they remember the not-so-fun parts of the language. I'm not one of those freaks that has a fanatical drive to rewrite existing C++ software in Rust, but I do think it's something that's best avoided if you can help it.
- _flux 3y agoAs far as I recall, all compiled languages use untyped target languages. The only downside with TS/JS is that the JS implementation loses an optimization opportunity by not being aware of the TS-checked types.
- davedx 3y agoCppfront: https://github.com/hsutter/cppfront https://github.com/hsutter/cppfront
- pjmlp 3y agoThe real Typescript for C++ is Circle. https://www.circle-lang.org/ https://www.circle-lang.org/ Just like Typescript to JavaScript, the syntax is an evolution of what already exists, not a completely different syntax.
- Quekid5 3y agoSuch a shame it isn't open source, so it's really impossible to eyeball QoI without actually investing a huge amount of time into the language. (Plus the usual bad things about closed source.) I have no doubts about the qualifications (or even intentions) of the author, but one feels that a language meant for serious things should have an open implementation and/or standard. Of course, I realize this may not align with Baxter's goals, but it is going mean ~0 adoption.
- pjmlp 3y agoOnce upon a time the only C and C++ compilers that one could get for free, were the ones available alongside UNIX tapes.
- deleted 3y ago[deleted]
- mike_hock 3y ago> not a completely different syntax > [new_decl_syntax] There's too much pining for Rust syntax and non-conservative changes or additions that aren't consistent with the rest of C++ syntax. It repeats C++'s mistake of having too many non-convergent features and adds as much new syntax on top as C++ already has. This is a problem because to be able to read code, you have to know all language features at least superficially. Instead of doing what plain C++ has been trying to do and stabilize on a smaller feature set and (at least verbally) deprecate legacy cruft, this is going the exact opposite route. Sorry, but this is DOA.
- pjmlp 3y ago
- synergy20 3y agoAfter the talk, the activity on it is nearly zero since then, in a world where ideas are cheap, show me the code, this does not seem promising to me. On the other hand, carbon has been very actively developed since its announcement, which also claims to be a typescript-for-c++. Now it also wants to be a memory safe: https://www.youtube.com/watch?v=1ZTJ9omXOQ0 https://www.youtube.com/watch?v=1ZTJ9omXOQ0 I'm forced to learn rust but I hope carbon will take off ASAP so I can be more productive and my (carbon) code can interface with c/c++ code easier than rust.
- timmg 3y ago> After the talk, the activity on it is nearly zero since then... Is that true? Seems like he is actively working on it: https://github.com/hsutter/cppfront/commits/main https://github.com/hsutter/cppfront/commits/main
- synergy20 3y agocompare to carbon it is way much less
- suby 3y agoBut Carbon doesn't have a working compiler or prototype version I can download and try out does it? Compared to cppfront where I have downloaded, built, and compiled / run some demo code.
- synergy20 3y agohttps://github.com/carbon-language/carbon-lang/blob/trunk/docs/project/roadmap.md https://github.com/carbon-language/carbon-lang/blob/trunk/do... next year 0.1 will be usable, 1.0 is about 3 years away, sigh, back to my rust fight
- wsve 3y ago[dead]
- ddaalluu1 3y agoBut C++ already is a typed language confusedsmiley
- papichulo2023 3y agoVoid pointer and 3 pages template errors joined the chat.
- layer8 3y agoEver heard of typeclasses? ;)
- lloydatkinson 3y agoRust
- weinzierl 3y agoThe article assumes that the reader is familiar with what is meant by the “Dart plan” and the “TypeScript plan”. I only have cursory knowledge of Typescript and know nothing about Dart. Others in this thread already went into more details about this, but it doesn't help me much as long as I don't have an idea what the basic difference between both approaches is. Can someone ELI5 the gist of both approaches?
- Jtsummers 3y agoSomeone already wrote up a comment on that: https://news.ycombinator.com/item?id=38141390 https://news.ycombinator.com/item?id=38141390
- deleted 3y ago[deleted]
- magnio 3y agoDart was made by Google as a new language for the web. In the beginning, it was already quite different from JavaScript at the time, and crucially the main way to use it is through the Dart VM (that was embedded into a build of Chromium). It did have compilation to JS, but AFAIK never caught on. In the end, Dart diverges from JS so much so that the split in ecosystem means it's not viable for the web anymore. TypeScript, on the other hand, has always set its goal to be a superset of JS and to transpile to JS only. This means a more familiar syntax, as well as (practical, IMO) design choices that ensure higher compatibility with the existing JS ecosystem. There is no TypeScript without JavaScript. Its development coincided with that of VSCode, and arguably is one the main facilitators for the latter's feasibility. I have to say Microsoft's grand plan of VSCode and TypeScript has to be one of the most astonishing software revolution in this decade. The foresight and acuity of Erich Gamma and Anders Hejlsberg is just amazing.
- damagednoob 3y agoI can't think of anyone besides Anders Hejlsberg that has a better track record with programming language innovation. At least 3 different languages that have all been commercially successful.
- up2isomorphism 3y agoI know he wrote tons of books in C++ but just curious what software he had actually written in c++.
- jmull 3y agoI'm heartened by the success of the Typescript model of improving things when there's a deficiency/problem. The alternate approach (which is extremely popular unfortunately), is to throw it all out and rebuild everything from scratch. I guess it's fun and exciting, which attracts developers, but it takes a long time to achieve any level of maturity and are hard to sustain (the people who are in it for the fun and excitement will move on before too long).
- eviks 3y agoThe alternate approach is also popular because there is no success in the typescript model, as in critical deficiencies get unfixed for decades (with some of the same "not fun" challenges )
- dist-epoch 3y agoC++ needs to be rewritten in Rust. Only way forward.
- Subsentient 3y ago>TypeScript for C++ Visceral disgust reaction.
- theusus 3y agoThe title gives too much credit to TypeScript, that in my experience has been a subpar experience working with types.
- skrebbel 3y agoIt's not about that, it's about the plan towards wide adoption. TypeScript's uncompromising embrace of existing JavaScript semantics, patterns, and quirks has been key to its growing popularity.
- MR4D 3y agoWasn’t C++ the typescript for C ? The title strikes me as ironic that it’s talking about a typescript on top of a typescript.
- Andoryuuta 3y agoYep. I don't believe it's mentioned in the linked article, but Herb has mentioned in other articles/talks that cppfront is intentionally named after / following the same model as C++, which originally had a C++ to C transpiler named cfront[0]. [0]: https://en.wikipedia.org/wiki/Cfront https://en.wikipedia.org/wiki/Cfront
- skrebbel 3y agoMaybe every couple decades you just need a new typescript on top of the previous typescript.
- fooker 3y agoIt's ~~turtles~~ typescripts all the way down.
- scriptproof 3y agoC++ adds class and other features to C++, and this is like TypeScript to Javascript, but what he supports is simplicity and safety thank to a TypeScript approach. Not what C++ brings to C !
- IAmLiterallyAB 3y agoPrecisely. He mentions that in the full talk in the video
- rwaksmunski 3y agoPlease let it fade away with dignity.
- Animats 3y agoIs there a paper for this? The video is an hour and 35 minutes. Edit: found the Github repository.[1] "Where's the documentation? I'm not posting much documentation because that would imply this project is intended for others to use — if it someday becomes ready for that, I'll post more docs." The examples don't have comments. [1] https://github.com/hsutter/cppfront#wheres-the-documentation https://github.com/hsutter/cppfront#wheres-the-documentation
- IceMichael 3y agoIsn't typescript the typescript of C++?
- seabird 3y agoHerb is infinitely more qualified to speak on the matter than I am, but I don't think I understand the point. We've had multiple decades to bring C++ under control for safe general purpose usage and it's still very loosey-goosey, to the point where people are rightly afraid to start work in it not because it's a bad or deficient language, but because keeping codebases sane is challenging and requires a lot of discipline even from experienced programmers with an eye for detail. I think C and C++ are two of the most interesting languages out there. I think it's rarely worth bothering rewriting existing C/C++ software in something else for the sake of safety. I think there's an appreciable amount of applications where C/C++ are still justified. I don't think this will end up being much different than the last two decades worth of attempts to put some guardrails on them. TS is relevant because JS has severe functionality deficiencies and you've historically had no other choices when writing for web browsers. C++'s deficiencies are less with the functionality of the language itself and more with properly and safely using it, and you're very rarely forced to use it.
- jonex 3y agoIt's not at all hard to build a sane codebase in C++ if you are a group of experienced C++ devs with an eye for detail. Not saying mistakes never happen, but most of the time the tools available are sufficient to build correct code if you know how to use them right. However, the problems abound when you have less experienced devs in a less structured environment and working with legacy C or C-style code, the latter often being the reason for why C++ was used in the first place. For this, something like cpp2 can be revolutionising as it makes it easier to write correct code and provides mechanisms to disable many of the unsafe patterns.
- esrauch 3y agoI think the reality is that companies like Microsoft, Google, Apple want to write C++ but safer. The reason you're seeing Herb and Google's Carbon on the "ok fine well make a new language which has C++ interop instead of fixing C++" is because the C++ standards have been resistant to evolving the language into something that those companies want, to the degree that they may end up adopting Rust despite the absurdly high migration costs just because C++ refused to evolve into something those companies could use safely (even with people from those companies on the committees advocating for it).
- emmanueloga_ 3y agoThis video is about cpp2, a proposed new syntax for C++ by Herb Sutter, a famous C++ expert. "The goal is to address existing problems in C++ by embracing the solutions and guidance we've already de facto adopted, and to have to explain less rather than more." [1] I found a repo with some examples of the syntax [2]. For example: myclass : type = { data: int = 42; more: std::string = std::to_string(42); // method print: (this) = { std::println("data: (data)$, more: (more)$"); } // non-const method inc: (inout this) = data++; } main: () = { x: myclass = (); x.print(); x.inc(); x.print(); } -- 1: https://github.com/hsutter/cppfront/wiki/Design-note:-Cpp2-name https://github.com/hsutter/cppfront/wiki/Design-note:-Cpp2-n... 2: https://github.com/ntrel/cpp2 https://github.com/ntrel/cpp2
- synergy20 3y agowhat about nim, already works great with c++, easy to integrate with existing c++, python style syntax, seems like a really good, production ready option to me