DEV Community

Discussion on: Which mainstream programming language has the ugliest syntax?

Collapse
 
skyrpex profile image
Cristian Pallarés

We need a simpler syntax for C++ :)

Collapse
 
cbordeman profile image
Chris Bordeman

We need to switch to Rust. :)

Collapse
 
ybalrid profile image
Arthur Brainville

Some recent addition to the language help with that. Things like "if constexpr" permit to get rid of some SFINAE, and lambdas are generally helpfull into simplifying some code.

Well, even if the syntax for lambdas is...

[&](const std::string& some_adjective){std::cout << "... a bit " << some_adjective << " sometimes ...\n";}("laborious");

(this is just an useless example of code that nobody should ever write)

;-)

Thread Thread
 
skyrpex profile image
Cristian Pallarés

Indeed. +1 for using \n instead of std::eol.

Thread Thread
 
ybalrid profile image
Arthur Brainville

Indeed! (You probably mean std::endl ;-))

And yes, this thing is the devil and should not be used. I'm sad so much books and courses about C++ use this thing as a "new line" character, it is not. It happens to print one before flushing.

std::cin and std::cout will synchronize themselves, you don't need to flush by hand, you just makes your program slower that it should be, and this tend to make me angry ;-)

Thread Thread
 
skyrpex profile image
Cristian Pallarés

Oh yeah, I meant std::endl... haha I have read too much about LF and CRLF eol's these days

Thread Thread
 
ybalrid profile image
Arthur Brainville

Remark, I wouldn't be a bad thing to have a global called "eol" or "lf" in std that doesn't flush the output. :-)

But it's really a shame that they called this thing "endl"...