-
Ugly syntax
Am I the only one that thinks that the C++ syntax is ugly when you are getting more advanced?. If you just use simple classes no stl and use a workflow similar to C it looks really crisp and is easy to read. But when I add muliple inheritance. maps and pointers I think it is flat out ugly to read. I know some of it is my lack of deeper knowledge. What do you guys think?. What if you compare to C# that isn't as advanced or power full but it always sems to stay clean and easy to read.
-
you're asking opinion. my opinion is no. Sloppy code is ugly, not C++. I've seen much uglier code written in C than I have in C++. Weither it be because of macros, globals, gotos, externs whatever, C is NASTY. Multiple inheritance is not bad. Poor use of it is. ActiveX/COM is ALL using multiple inheritance for its interfaces. There is nothing wrong with that.
pointers? you think pointers are hard to deal with? how is that different than C?
-
And the error messages get worse too.
This is an error message I had in MSVC++.NET when I made the simple mistake to try to push a A* to a vector that contained A.
http://strandmark.com/prog_fel.gif
-
well alternatively you could turn to COBOL or BASIC :)
-
Don't get me wrong. I wouldn't trade C++ for anything. I don't have a problem with pointers it's just that when you mix all the powerfull C++ components together I think it gets really cumbersome to both read and type. I know the reason C++ is harder then anything else is that it is more powerfull then anything else but I often get the feeling that the code syntax is just blocks randomly stacked ontop of eachother. This is of course due to the history of C++ and compability requerments with C and the latest .NET add on? Use Cobol or Basic?? Get real!!
-
I agree that on first glance a section of C++ code with templates, typedefs and inheritance everywhere can look a total eyesore....
Dean posted a section of code on Flashdaddee and was complaining about how the typedefs make the language look bad.....had to agree...on first glance it looked nasty :)
I suppose though that once you have a basic idea of what a section of code is trying to achieve, it makes reading it easier.......
-
I agree with you there Fordy. Once you figured out what it is supposed to do it all make sense, and no other syntax would make sense. I guess it looks complicated just because it is. I read something that Bjarne wrote as a replay to a similar question and his point was that if Java, C,C#, Basic,,etc was as advanced as C++ those languishes(sp) would be hard to read to.
-
are typedefs not a C feature?
-
If you read stroustrups book most of the code looks clean.
I guess otherwise no one would use
c++.
You can do little things like typedef your iterators and if
you think a variable is too long you can always create
a referance to it. I like Upper and then lower case typedef.
So I would do
typedef int Int_32. Most people do
typedef int INT_32 but I think that shouts out too
much to the reader. hungarian notation looks
ugly. But using little
of hungarian notation such as p, m_ or n looks ok in some
places. Then again hungarian notation is ugly.
template code is really harder
to read/write. I think most people write it using something like int and then go over and change it to use templates.