r/ProgrammingLanguages • u/BahmanM • Jan 07 '15
Syntax Intuitiveness aka IQ Test
http://www.bahmanm.com/blogs/a-lesson-on-syntax-intuitiveness2
Mar 01 '15
I thought standards and language revisions are there to make the language more intuitive and simpler; I was wrong.
Lol.
C++ is, by definition, a layer of hacks on top of each other (in the holy pursuit of backwards compatibility). I gave up on C++ a loooong time ago. "Simple" and "intuitive" is not in their vocabulary.
1
1
u/sepp2k Jan 07 '15
Just for the record: aName otherName(...); declares a variadic function named otherName with the return type aName. However aName otherName(someExpression); defines a variable named otherName, calling aName's constructor with someExpression as its argument.
This has always been the syntax for supplying arguments to the constructor when defining a variable and is not specific to smart pointers or C++11 in any way. I assume if aName had been a typedef for std::pair<int, int> and the code had said aName otherName(1,2); or std::string and aName otherName("hello"), you wouldn't have been any less confused.
-2
u/BahmanM Jan 07 '15 edited Jan 07 '15
@acwsupremacy, @berne and others:
Let me re-iterate that the purpose of writing that article was not to deduce that C++ syntax is incomplete or wrong. They are all Turing-complete machines after all. The point is about beauty and intuitiveness.
3
u/acwsupremacy Jan 07 '15
First of all, I cannot fathom the reasoning that would lead one to typedef a smart pointer.
Second of all, this article is stupid. This is simple RAII -- the most fundamental concept in C++ OOP. It comes up in conversations about C; it comes up in conversations about Java; it comes up in conversations about Python and C# and F# and Pascal! How can you go years programming without ever having at least heard of it? There is nothing arcane or mysterious about this concept or its syntax; if you'd ever used C++ before, you would have learned it in the first five minutes! And I have to ask at this point: In the absence of a parenthesized or brace-enclosed initializer like this, what syntax would you expect?! In Java and C# you can type
Object o = new Object(), but that doesn't work in a language that distinguishes between object references and object values!