hsutter / cppfront

A personal experimental C++ Syntax 2 -> Syntax 1 compiler
Other
5.44k stars 238 forks source link

[SUGGESTION] Why not contribute directly these features to Rust and not develop "another new" syntax? #98

Closed devendranaga closed 1 year ago

devendranaga commented 1 year ago

I am a C++ programmer with lots of personal projects using C++. I am really curious to understand why is there a need of "new syntax" for C++ and why not contribute to the Rust community? Rust already limits a lot of undefined behaviors that C and C++ couldn't, and uses the same backend as the clang (LLVM).

Thanks !

JohelEGP commented 1 year ago

The README is very helpful on that, as is the linked CppCon video.

devendranaga commented 1 year ago

Thanks will check this. Does this project solve Aerospace / Automotive typical safety and security challenges ? (MISRA for example) .

Most of the C++ STL is prohibited even today from using them in safety critical software. How are these addressed?

filipsajdak commented 1 year ago

Regarding Safety features: https://github.com/hsutter/cppfront/wiki/Design-note%3A-Unsafe-code

We can do better then rust.

devendranaga commented 1 year ago

Thanks. This is an example of restricting the unsafe code by failing (compiler error? warning?). Could there be a possibility of listing these unsafe errors? MISRA and CERT C have a big list, and many mandatory ones can be taken into consideration for code safety. For example, sign conversion, sign comparison, non standard type use for a specific target platform (use of int vs int32_t), unsafe cast (cast a buffer to a structure pointer).

I would like to ask, that such kind of mistakes can be treated as compiler errors to force the programmer to fix them rather giving them as warnings.

Is there a some list like this within this project also?

What made me think rust was the use of syntax in cpp2 which is almost looks like a copy of some of rust's syntax.

JohelEGP commented 1 year ago

https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines is one such list.

vladimir-kraus commented 1 year ago

Because Rust is Rust. And cppfront is very different and has different goals. For me the key feature is seamless interop with existing C++ code. Seamless interop is not provided by Rust and probably never will be. Moreover Rust has completely different mental model (you know, the borrow checker), which imposes a certain barrier for C++ programmers. I do not want to fight the compiler as in Rust, I just want a fast safe low friction (quoting Jon Blow) programming language. I believe cppfront could provide this. Looks very appealing to me.

ilqvya commented 1 year ago

The cppfront syntax is ugly Why I should write the -> = symbols for each function ? What's wrong with cpp1 way to declare type\return type before the variable name

cpp2 is some bad looking trash like a SCALA or ERLANG no one will love it

filipsajdak commented 1 year ago

This is for expressiveness reasons and for easier creation of tooling.

@hsutter described it here: https://github.com/hsutter/cppfront/wiki/Design-note:-Postfix-operators

I spend some time writing a project using cpp2 syntax. It is really easy to use and understand. What is more it is consistent - you use it everywhere.

For sure you need to use to it but I support @hsutter point of view.

ilqvya commented 1 year ago

The code is for humans, not a tooling. It's not cpp at all, but some scala2 or golang2

filipsajdak commented 1 year ago

Humans use tools. Good tooling is a weakness of c++ (compared to other languages).

Even from readability point of view cpp2 syntax is read naturally but you need to use to it as to anything else that is new.

vladimir-kraus commented 1 year ago

@effolkronium I find cpp2 syntax very nice, consistent, approachable and readable. Function declaration is uniform for any function-like thing. Do you really want to say you like cpp1 syntax where you have different syntax for functions and completely different syntax for lambdas? Are you sure you really know what you are talking about?

Moreover, this issue tracking page should be for constructive suggestions and it definitely is not a channel where you should try to bother and annoy the author to do the things the way you like. If you do want to do things different way then Herb Sutter does, you certainly can. Just start making your own projects. In other words, go away please...

vladimir-kraus commented 1 year ago

@effolkronium Cpp1 syntax is not for tooling and not for humans either. It is a total incoherent mess.

ilqvya commented 1 year ago

@effolkronium Cpp1 syntax is not for tooling and not for humans either. It is a total incoherent mess.

Mess is calling this creation cpp2, when it has nothing similar with cpp

ilqvya commented 1 year ago

@effolkronium so why do you care? Why are you here? To annoy anyone who is interested in cpp2? You should really go away, you are useless here.

I'm care because cpp1 still does not have networking library in 2022 year, but instead of doing their job the cpp committee discussing some useless not realistic and not useful for current time things like this one... It'd be better to sold rights of cpp to some proprietary company and boost its evolution by 100 times

vladimir-kraus commented 1 year ago

You are not entitled to tell other people what to do. There are a bunch of networking libraries all around, so go and use any of them. And if you are not happy with them, go and make your own.

filipsajdak commented 1 year ago

This is Herbs private initiative not standard committees. And it is not about new features but safety - we want to experiment how to make c++20/23 better (not 10% better but 10x better).

It's all about c++ and not something else.

seanbaxter commented 1 year ago

It's all about c++ and not something else.

If that's the case, it would be nice to disaggregate the cpp2 features and prepare wording for them so they can actually be implemented in a C++ compiler. I am ready to implement the parameter directives, but there is no wording, so no way to progress.

hsutter commented 1 year ago

Hi everyone, I appreciate all the feedback. In a nutshell, the reason for a distinct syntax is summarized in this 1-min clip from the talk and if you have more than 1 minute the bit right before and after that clip.

BenHanson commented 1 year ago

It's all about c++ and not something else.

If that's the case, it would be nice to disaggregate the cpp2 features and prepare wording for them so they can actually be implemented in a C++ compiler. I am ready to implement the parameter directives, but there is no wording, so no way to progress.

Is there any chance you will implement metaclasses Sean?