Cpp2 - First Impression [Programming Languages Episode 27]

Ғылым және технология

►Full First Look Series Playlist: • Programming Languages ...
►Find full courses on: courses.mshah.io/
►Join as Member to Support the channel: / @mikeshah
►Lesson Description: In this lesson we take a look at the Cpp2 an experimental frontend for a 10x safer and 10x simpler C++ programming language. This is an interesting look in our series of a language that compiles to a known and active programming language, similar to the way that TypeScript compiles down to JavaScript. Cppfront is the tool, and it uses a 'Cpp2' syntax that compiles or otherwise 'transpiles' down to Cpp1 (Normal C++20 or later) syntax. This should provide an interesting way to write better (meaning safer and simpler) C++ code by having the write defaults enforced, as well as new or otherwise easier ways to access programming language features (e.g. pattern matching, reflection, type safety) within C++. I found this easy to setup, and also something that got me excited about C++ programming. As always, let me know what resources/tools I missed that others should know about in the comments below!
►KZread Channel: / mikeshah
►Please like and subscribe to help the channel!
►Join our free community: courses.mshah.io/communities/...

Пікірлер: 58

  • @mishaerementchouk
    @mishaerementchouk3 күн бұрын

    Mixed feelings. It’s like cpp2 tries to catch an already gone train. There’s nothing particularly wrong about it but nothing stands out as particularly right. Probably, I expected better error messages but the accident with vector was quite bad. I should play with it on some toy project to get a better impression but it doesn’t look like cpp2 is poised for widespread industry adoption.

  • @MikeShah

    @MikeShah

    3 күн бұрын

    I suspect this project still has a few years of development, but indeed we'll know more (and the developers) as it's used for larger projects :)

  • @bobweiram6321
    @bobweiram63215 күн бұрын

    CppFront makes a ton of sense. Modern C++ is already a bunch of macros and meta programming. Why not turn those constructs into its own language?

  • @MikeShah

    @MikeShah

    4 күн бұрын

    I am actually quite impressed with how well this works with cpp2 -- it might be the right way to transition/evolve the language

  • @bobweiram6321

    @bobweiram6321

    3 күн бұрын

    @@MikeShah I agree, but I really wish we had something like Ada's type specifications. It would reduce the need for unit testing and makes the code a lot more intelligible. Also, I'm kind of sick of the terse C style syntax. When code looks like art and reads like a story, it makes it sooo much easier to deal with. C++ and C, as well as Python, encourages sloppiness. It's hard to articulate this to programmers because they have a utilitarian POV. It's why Apple succeeds, function follows form.

  • @hebozhe
    @hebozhe4 күн бұрын

    These vids are like 30 Days episodes, but for PL nerds.

  • @MikeShah

    @MikeShah

    4 күн бұрын

    Exactly 😁

  • @androth1502
    @androth15024 күн бұрын

    something like this can put c++ on life support into the coming decades, to make it a bit more consistent given the awful frankenstein's monster state that c++ is in today. if i had to use c++, i would want to use something like this. though i would prefer something that fixes C instead. that's why odin, zig and the fictional language of jai are so intriguing to me.

  • @MikeShah

    @MikeShah

    4 күн бұрын

    Indeed, Odin, Zig, JAI, and betterC (D's C compiler that adds many nice features) have done an excellent job filling the niche of C (and Rust as well). I'm excited to hear the next update on cpp2, as it would be a nice language to write code in.

  • @Chupe_chupe
    @Chupe_chupe5 күн бұрын

    Great video Mike

  • @MikeShah

    @MikeShah

    4 күн бұрын

    Cheers!

  • @vladimirkraus1438
    @vladimirkraus14385 күн бұрын

    Regarding the features and the syntax, I actually quite like it. It does not hurt my eyes and the code seems very consistent, unlike cpp1, and much simpler and safer. I see one drawback however and please correct me if I am wrong about this... But it seems to me that it cannot generate cpp1 header files (i.e. good old *.h or *.hpp) from cpp2 file. Therefore the adoption into an existing cpp1 project is somehow limited. I can write a module in cpp2 which depends on cpp1 code. But I cannot replace a module written in cpp1 with a cpp2 code if any other cpp1 module depends on it, because I cannot get the backward compatible cpp1 header. Or is there any way to do this?

  • @MikeShah

    @MikeShah

    4 күн бұрын

    That's a good question if there's a two-way interop between cpp1 and cpp2 -- I don't exactly know the answer (perhaps I misunderstand the question). I imagine there could be blocks to just use or ignore cpp1 or cpp2 syntax to mitigate any edge cases.

  • @Nop_90h
    @Nop_90h5 күн бұрын

    Lets overview the HolyC language

  • @MikeShah

    @MikeShah

    4 күн бұрын

    I thought you were joking that this exists, but indeed it actually looks pretty neat :)

  • @kevintucker322
    @kevintucker3225 күн бұрын

    Sounds similar to GNAT(granted,it’s not a unique language, but it compiles Ada to cans then uses the GCc middle/back- end to generate object code

  • @MikeShah

    @MikeShah

    4 күн бұрын

    I imagine there are several other 'prior art' this is indeed learning from -- nice example!

  • @kevintucker322
    @kevintucker3225 күн бұрын

    Will be interesting to see what languages official name will be

  • @muhammadharris4470

    @muhammadharris4470

    5 күн бұрын

    Cpp2?

  • @MikeShah

    @MikeShah

    4 күн бұрын

    @@muhammadharris4470 I think indeed they'll just use 'cpp2' or 'cppfront'. It's probably the least confusing name to me if this takes off.

  • @kevinchopra9111
    @kevinchopra91115 күн бұрын

    Is Cpp 2, backwards compatible?...

  • @MikeShah

    @MikeShah

    4 күн бұрын

    Meaning with previous versions of Cpp2? I'm not sure what kind guarantees will be provided, but I imagine that is something top of mind for the designers.

  • @kevinchopra9111

    @kevinchopra9111

    4 күн бұрын

    @@MikeShah If I were building a Kernel, and I had done so with CPP, would patching it etc or rebuilding it, whether monolithic or modular, require you to alter the source?...

  • @MikeShah

    @MikeShah

    4 күн бұрын

    @@kevinchopra9111 If it takes the C++ approach, C++ does not break backwards compatibility.

  • @matthijshebly
    @matthijshebly5 күн бұрын

    I always feel a bit sorry for Herb Sutter. He's clearly talented, but he shouldn't be wasting his time and talent on a language as horrific as C++.

  • @bertiesmith3021

    @bertiesmith3021

    5 күн бұрын

    It’s a public service. There’s a huge amount of c++ being maintained and celebrated, and the devs need help to avoid the many pitfalls. You can say that we just rewrite it all in but the reality is that re-writing is slow, error prone and expensive. Herb believes that a slow migration is in fact cheaper and more likely to succeed. He might be ambitious, but the cost to the world of failure to deal with all the legacy cruft is huge, so it’s worth his time. I hope it gets picked up by some big corporation and gains significant traction.

  • @theintjengineer

    @theintjengineer

    5 күн бұрын

    I am curious to know on what language you'd say one should be spending wasting his/her time, in your opinion. Thanks.

  • @bsdooby

    @bsdooby

    5 күн бұрын

    @@theintjengineer Good point. Every is a waste of time (for some others).

  • @theintjengineer

    @theintjengineer

    5 күн бұрын

    @@bsdooby, precisely. That's why my motto is: if you enjoy learning and dealing with it - do it. Everything else will be just an opinion/advice that might not work for you.

  • @bsdooby

    @bsdooby

    5 күн бұрын

    @@theintjengineer 100 % agree.

  • @firstname4337
    @firstname43375 күн бұрын

    C++ is such an ugly, ugly language -- absolutely horrible syntax

  • @user-mm9jy8mz1g

    @user-mm9jy8mz1g

    5 күн бұрын

    doing things correctly doesn't always look pretty

  • @thegameoflife9179

    @thegameoflife9179

    5 күн бұрын

    @@user-mm9jy8mz1g c++ and before it c only became popular because programmers did not like assembler or other languages that were available at the time (and i know that because i lived through it)... to be honest i cannot understand why they remained popular for so long... i reckon the main reason is because so much has been written in them now forces programmers into having to use them.... and that is all, not because they are so great in any way

  • @martinjanas

    @martinjanas

    5 күн бұрын

    I would say Rust has worse syntax than C++ lol

  • @MikeShah

    @MikeShah

    4 күн бұрын

    I think C++ 20 has made things quite nicer -- but indeed every language has their quirks, especially when they're 4 decades old :)

  • @user-ft6zh8ny9i
    @user-ft6zh8ny9i5 күн бұрын

    well, it's garbage. I'd better continue using C++. And now I'm using C++26.

  • @martinjanas
    @martinjanas5 күн бұрын

    Cpp2 looks like garbage, I hate when "new" languages overcomplicate stuff as this: s: std::string = "world"; just why??? They should either do s = "world" or like in standard c++ std::string s = "world", this is just extra steps.

  • @mister-ace

    @mister-ace

    5 күн бұрын

    Agree. This looks horrible… So… c++ syntax forever…

  • @simonfarre4907

    @simonfarre4907

    5 күн бұрын

    Because it's easier to parse and lex. It's why almost all new languages follow this convention.

  • @vladimirkraus1438

    @vladimirkraus1438

    5 күн бұрын

    std::string s = "world"; vs s: std::string = "world"; differs in one extra colon character, if I am not mistaken. I think this is a small price to be paid to have fully uniform declaration and assignment syntax. And cpp2 is definitely not the only modern language that decided to use this convention. In other cases the cpp2 syntax is much more concise, e.g. i := 1; is definitely shorter than auto i = 1;

  • @simonfarre4907

    @simonfarre4907

    5 күн бұрын

    @@vladimirkraus1438 exactly my point, but better explained.

  • @martinjanas

    @martinjanas

    5 күн бұрын

    @@vladimirkraus1438 ah ok, now I understand.Tbh I dont mind about the syntax being shorter or longer, for me its the order of the words, but I can totally see myself being accustomed to it.

Келесі