Another C++ Link (Updated with yet another link!)
Thursday, July 22, 2010 3:30:09 PM
I've said a million times over that I like closures. C++ just isn't C++ without them. Here's what the author of the above link has to say.
Everybody knows that calling a member function obj.f(x,y,z) in C++ is actually done by calling f(obj,x,y,z). There would be nothing to it. Since you know 'this' at the time you create the function pointer, you can resolve the funcaddress from the name 'f' at that point - the same way you would when making any method call, including vtables, multiple inheritance, and everything - and the code receiving the pointer would always just run it as (*funcaddress)(obj, ...). So easy. Nothing to it. So very much terrible C++ code would never have been written if this feature existed.
That last line is so very true. And important. With just that one feature, it would make C++ so much more fun to use. Add in properties, and it's actually a joy.
I've also said that I don't like C++ exceptions. Here's that same author's opinion.
First of all, if you haven't done much C++, you need to realize: most of the stuff in there is utter putrid boneheaded crap. This includes the RTTI and exceptions stuff; C++'s versions of those were enough to convince a whole generation of programmers that introspection and exceptions were outright evil and should be avoided. But as it turns out, that's only true in C++.
C++ exceptions are evil. They're slow. And I don't mean this in a way where it's acceptable because most of the time, you won't be using them in time critical areas. NO! They are SLOW!!! Geological timelines are quicker than C++ exceptions.
And while I've used RTTI on occasions, they are slow as well. At least they provide SOME functionality. But not enough. If you have high hopes of checking types, rest assured that disappointment will be your reward.
The author also talks about strings. I use ICU. I love it. It's great. Highly recommended. You can use it in Java, C and other languages.
The author hates on std::string. Can't agree more. I was once trashed for using AnsiString from VCL in Borland C++ Builder. Sorry, but AnsiString rocks for ASCII. It has everything you need from a string. There's also WideString, but I prefer ICU as I've said earlier because it's a library specifically designed for Unicode and not just the processing of wider character sizes.
I'm hard pressed to find anything I disagree with from that author's article. I've said I hate C++, but I hate all languages to some extent. If there was a language that was perfect, then that might change. That's all I'm saying. With that said, if I had to choose a language that I DO like, I'd still have to pick C++. With properties and closures as with Borland's C++ Builder, it's a joy to program in. I actually like it a lot. Even with all the other flaws in it. Why?
1. I have AnsiString from VCL and IBM's ICU Unicode string library.
2. I have VCL for Windows programming which let's me use all the normal windows programming techniques from Visual Studio as well if I so desire though it's much simpler in VCL.
3. Simple closures that store the object as well as the method pointer.
4. Properties. My kingdom for properties. And damn you Stroustrup for standing in its way. Did you know we'd have properties by now if it was not for him?
5. RAII
6. Templates. Probably the only disagreement I have with said author. I like them.
7. Closures, closures and closures. I'm not repeating myself. There are TONS of things that closures make possible. Event handling is a breeze for example. Callbacks are insanely powerful and easy. Pluggable functionality is a snap. It just makes handling functionality simple.
8. Operator overloading.
Note that only 4, 5 and 8 are in standard C++. The rest are available in C++ Builder. I have found a way to implement properties in regular C++. But you need to change the constructor of the object where you use properties. That's better than nothing. Also, it uses extra memory because it needs a pointer back to the container object in question.
We'll see if the next revision of C++ fixes the issues with closures. I hope so. Because then we can start trashing on Stroustrup for not having properties. Because closures without properties is like a beach without water.
I see this author is being trashed on Reddit. I don't know Python so I can't comment on those points. I ignored that part. But as far as the other points about C++, the author is pretty spot on.
What really troubles me is that there are VERY obvious ways to improve C++. Trivial things even. And it's not being done.
Update:
I want to add another link.
Why the private keyword is the modern day goto
I could hardly believe it. This isn't against C++. It's against general use of the 'private' keyword. I've been saying for a long time that the private keyword is evil. Never thought I'd see someone else saying the same thing.


Unregistered user # Thursday, July 22, 2010 10:39:12 PM
Vorlath # Friday, July 23, 2010 1:43:38 AM
I like this site for learning about C++ Builder.
http://www.yevol.com/en/bcb/
For books about C++ itself, not sure. I did find this link at gamedev.net.
http://www.gamedev.net/community/forums/topic.asp?topic_id=396018
They use Sam's Teach Yourself C++ in 24 Hours book. There's a preview of it here though I believe they're up to the 5th edition by now. People either love it or hate it. I haven't seen it myself though. The workshop works with Visual C++. The book does mention other compilers including Borland. There are others by the same author. Not sure why. There is the "one hour a day" and "21 days".
I have used this site on a few occasions.
http://www.functionx.com/cppbcb/index.htm
It teaches C++ with Borland C++ Builder as the IDE.
In all cases, I haven't gone through them to see if it's good or not. If you want me to check something online, I can go through it and give you a review. They all seem to go through the same info though. Depends on what you know already. Do you know other languages? If you know C or Java, you can likely learn C++ rather quickly. Knowing other languages will make learning C++ easier as you can quickly get up to speed on variables, operators, types and other stuff.
Unregistered user # Friday, July 23, 2010 2:37:49 AM
Vorlath # Friday, July 23, 2010 4:22:28 AM
I do have a suggestion with books though. Get something for the level you are at. If you're a beginner, get a book that will ONLY get you started. After that, you can get a book about the more advanced topics of C++. A separate book about OO concepts wouldn't be bad either, especially if it has C++ in it. Book on data structures is a must. Unfortunately, I can't remember this one either. It was VERY good but it was tough to follow because of the notation used. I still have it in one of my boxes. I'll dig it up some day.
This book is really good for algorithms.
Algorithms
There a page in the link below that has free C++ books. There is more than one page. You have to find the link for the next page at the bottom. It's not very big.
http://www.onlinecomputerbooks.com/free-c++-books.php
Here's a C++ online book from that site I can recommend at least in part. It's dated, but I like what I see at the beginning at least. It starts with a Hello World program. Always a good sign. It uses UNIX and gcc. So anyone can follow along on both Linux and Windows. On Windows, just install Cygwin and use that tool to install gcc and g++ in it. In explains the underlying format of the data stored in your variables. I find this to be immensely important and most beginner books don't go into it. I see lots of other good stuff in there.
I did say it's dated. For example, it uses "#include <iostream.h>". You don't put .h anymore for the C++ stardard library headers. It's just "#include <iostream>" Other than that, it should be fine.
Warning: It's a PDF.
http://www.pragsoft.com/books/CppEssentials.pdf
You can then get a book or tutorial on STL. You gotta learn STL after you get up to speed.
You can also ask on the cpp subreddit. They're usually pretty helpful with book requests. You could also search that forum. I'm sure others have asked for recommendations before.
http://www.reddit.com/r/cpp/
Unregistered user # Wednesday, July 28, 2010 6:18:42 AM
Unregistered user # Tuesday, September 14, 2010 9:59:09 AM
Vorlath # Tuesday, September 14, 2010 6:10:04 PM
About Project V, haven't been able to do much on it lately. I've got lots of other things going on. And the motherboard on the machine I was using as a file server went bad. So I need to get that machine up and going again.