cpp and their operator overloads are also insane. It makes understanding cpp code impossible. A "+" could actually do something completely different or have insane side-effects. Truly superior language for spreading confusion.
post
Funny that you put rust as the "uses parenthesis for function calls". When in rust you can use any bracket for macro invocations:
let v1 = vec!(1,2,3);
let v2 = vec![1,2,3];
let v3 = vec!{1,2,3};
These are valid and have the exact same meaning.
That's always funny to me. In a language that's so particular about different syntax features, they let macros of all things have a little bit of arbitrariness.
Yeah, I always wonder, if it was an intentional decision or just some first draft that stayed in.
Because I do think, it's kind of smart. Some macros make sense to call with either () or {}, depending on if you pass a code snippet that's multi-line or not.
So, you could come up with a complicated syntax to define which bracket types are acceptable, or you could just not bother. 🙃
I have honestly never seen parentheses called "round brackets" before. It totally makes sense, I have no idea why it's not used more often.
Might be a German thing. For us, they are all "Klammern" and we call them either round (rund), angular (eckig) or curved (geschweift).
I wasn't sure which word to use so wikipedia to the rescue https://en.wikipedia.org/wiki/Bracket
Ehh, who needs functions anyways, you got one big one and thats your whole codebase.
Good meme, but I'm really not sure why you wrapped everything in asserts which kind of ruins the aesthetics. IMO would have worked better as e.g.:
x = sum(1, 2, 3); // x = 6
That's funny because I'm the opposite. I always enjoy the assert statements in example code.
I haven't kept up to date with C++ development in the last 16 years, I only recognize the first two of those four.
You can overload the indexing operazor "[]" (std::vector does this for example), and since c++23 this operator can have more than one argument.
The last one is a constructor call with an overloaded conversion operator. The {} syntax is possible since c++11 I think. The conversion operator was already available before that
Weird opinion: I like square brackets, angle brackets are neat, curly braces range from neat to ok.
But I just don't like the look of parentheses compared to the others. They especially look ugly and clunky when you need a bunch of them in a row, in a way that's not true for the others.
I can't think of a reason why I feel this way apart from the fact they tend to be very clunky in math too. They're also the ugliest one when handwritten despite being the arguably simplest shape.
All that said it annoys me how parentheses are the most used bracket type in programming.
You can do most if not all of this in Perl if you're twisted enough. Some hoop jumping may be required*, but I can think of ways to do something that looks like each of these.
*: The braces are especially tricky if warnings are turned on. I'd probably abuse the deprecated multidimensional syntax and tie a hash to the actual function.
I asked the other day in another thread about hating on C++ what makes C++ so bad and never got an answer.
There are lots of ways to write C++ code that looks perfectly reasonable but introduces horrible undefined behaviour. You need to be aware of lots of edge cases all the time and you will still make mistakes that can introduce difficult to trace bugs. One of my personal favourites is object slicing.
class A {
int foo;
};
class B : public A {
int bar;
};
B b;
A a = b;
Looks OK? Well, a now only contains the A part of the object. The field bar is lost in the assignment. There are reasons for this behaviour but its a sharp edge nonetheless.
These kinds of problems are numerous and you have to keep them in mind while programming C++. Some people don't mind it but many do. Static analysis tools that can catch many of these errors exist, but I understand people who say they don't want to deal with that and rather use a language where these kind of errors are not possible. Personally, I would also discourage people from starting new C++ projects today if they can avoid it.
I don't really know myself, probably the many footguns and complexities. Like taking a reference to a value in a vector and then resizing the vector, boom undefined behaviour. There a re a lot of things like this. Maybe also the verbosity and multie ways to do things. Look at the linked code, there is a lot of overhead to the function definitions, sure there is a point to all of it and I put it there for a reason, but to people less familiar to the language it is probably quite offputting.
Personally I like the language, second only to rust for me
If you have a couple of hours, and can stomach the AI art, then this video covers a lot of the niceties of C++:
all 42 comments