With a bit of fiddeling you can use every kind of bracket to basically make function calls in c++
Here are the links to the snippets, all compile and run
Rust: https://godbolt.org/z/bM3d7bG14
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.
Operator overloads is something that sounds like a good idea until you experience them firsthand. Just properly name your functions for fuck’s sake.
Operator overloading is awesome in a functional language. Haskell allows for a lot of creative stuff with operators, but since they can’t have side effects, must conform to predictable types, and have specific requirements they are somewhat understandable. Idris is also very ergonomic when it comes to operators.
C++ allowing a library to override the
+operator withsystem("rm -rf /")is a lot less awesome.As a computational physicist, I appreciate operator overloading IF used properly.
Example of a good use: + for matrix addition
Example of a bad use: left shift operator << as a pipe
I still don’t understand who’s in the C++ committee that they would choose this garbage over a function
When I was an intern, I was tasked with writing a file converter for 3D geometry files. There was an official cpp library to read the source files, so I was using that to read the data, restructure and transform it as needed, then write it to the output file format. Near the end, I was having a problem where I was SURE that my math was correct for the transform coordinates, but the resulting file would load in the viewer with all the correct looking pieces but all in the wrong locations. The senior guy there helped me debug it since I wasn’t super familiar with cpp at the time, and we found that the library I was using had overloaded the multiply (*) operator specifically for the objects I was using it on, and it was actually multiplying and saving the result directly to the first variable used in the multiplication. I assume it was done for memory efficiency or something, but I had no idea it would behave that way, so I was accidentally changing the values of variables I didn’t intend to.
Example: I was doing something a = b * c, which caused the value of b to be changed (to b * c). Which screwed things up when I needed the original value of b later.
This is the type of shit that haunts me. Imagine overloading “>>” for piping and hiding threading behind that. The idea was to create an async pipe, but nowhere are you aware of async or threading or whatever was chosen. You look at the code and think “of it’s like piping to stdout” or whatever, only to find out that the method immediately returns.
Tracking down what the hell is happening with code that has such hidden side effects is a nightmare.
Are you still in the C++ world?
That is WILD lol. No, after that, I did a bunch of backend server apps for a few years mostly in C#, and then I got put onto some web app stuff after that. For better or worse. I do enjoy it and appreciate the abstraction, and I have found that I do love frontend dev a lot, but I do sometimes miss the lower level languages haha.
I talked to a frontender recently who said they had less pleasure writing frontend, because AI could make it look as good as they wanted in a fraction of the time. Has AI changed anything for you?
I was “encouraged” to use AI at work for frontend and while it output functional stuff, lifting the hood on the how, terrified me. 😅
Yeah, in my experience, it’s very hit or miss with frontend code architecture (I primarily work with React). And I am very particular about keeping code clean and maintainable, so that can be a challenge sometimes for sure. It’s not bad for smaller one-off tasks, but I still do a majority of my larger tasks by hand because I typically already know what I need and how to do it correctly.
Yeah it’s like a knife, wildly superior to cut stuff up in the kitchen, but you can also like stick it in your eye (but why?).
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
“round brackets” sounds pretty hilarious
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 = 6That’s funny because I’m the opposite. I always enjoy the assert statements in example code.
In example code, yes, but in this meme specifically which is all about function call syntax, it ruins the point. E.g. every line in the C++ snippet includes parentheses.
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
Yeah sameish, normal and template?
No time for arguments, pipelines go brrrr
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.
(best-syntax? '(lisp clojure)) ;; => true




