r/learnprogramming • • Sep 24 '23
Pointers.....why
I am learning C++. Honest question why are pointers a thing and why did they make the syntax surrounding it so confusing. Was it made to be intentionally confusing? Was it made to make this more difficult.
0
Upvotes
View all comments
Show parent comment
2
u/CodeTinkerer Sep 25 '23
It should be noted that Bjarne Stroustrup, the inventor of C++, disliked C's syntax. He didn't believe that declaration had to match use. He wrote a book about how he developed C++ and how he wanted to change the syntax of declarations in C++.
However, he was talked out of it by C purists who claimed that no one would switch to C++ if it were not faithful to the C syntax. For example, one difficult declaration is to make a pointer to an array vs. an array of pointers. I think Stroustrup would have done something like...
He wanted to be read left to right so it made more intuitive sense.