4 ms·
Excellent write up. I am a good C++ developer but my dislike for the language has grown ever since c++11. Many parts of the language are arcane and unfortunate
by general_failure 14y ago
Excellent write up.
I am a good C++ developer but my dislike for the language has grown ever since c++11. Many parts of the language are arcane and unfortunately these parts are used over and over again by many programmers either to show of their 'coolness' or because it's the only possible way.
Here try this for size:
https://github.com/boost-lib/bind/blob/master/include/boost/bind/bind.hpp https://github.com/boost-lib/bind/blob/master/include/boost/... (sorry if that blurb made you blind)
I also dislike perl. A large amount of perl code contains shorcuts - like $^p or %#p (not real perl patterns but I hope you get the point). These patterns are ungooglable and hard to remember. The only people who know them are those who have spent a lot amount of time with the language.
The result is code that is extremely hard to understand and read.
Languages must be optimized for reading and not writing. Of course, nobody is asking one to go overboard (like COBOL) but reading a computer program should not hurt the brain and should not require years of training.
This is why I will not advocate C++. I would advocate C, Python or JavaScript (yeah javascript, it has it's pitfalls but it's very easy to master). There are possibly other languages like Ruby but I haven't taken the time to learn them.
(BTW, If you want to see how C++ could be done right, look at something Qt from an API point of view).
- z3phyr 14y agoWhat are your views on Haskell? Very difficult to master - that's why bad?
- mitchi 14y agoI agree with everything you've said. C++ with templates is absolutely terrifying to read sometimes. Not to mention these error messages and the bloat, the bloat.
- zvrba 14y ago... and the compile-times :S
- Negitivefrags 14y agoLinking boost bind is unfair. I find it ironic that you dislike C++11 but the example you link to is only bloated due to the lack of the very same features that C++11 adds (in this case variadic templates would make that file 10 times smaller). And it only really exists in the first place to paper over the lack of lambda functions, which C++11 also added. Modern C++11 code is much easier to read and understand. The majority of added features are all about promoting that very ideal.
- general_failure 14y agoOK, here's a variadic template example for you :) http://qt.gitorious.org/qt/qtbase/blobs/59fb0328392a5fc47e3a013403fe192c215d8aa7/src/corelib/kernel/qobject_impl.h http://qt.gitorious.org/qt/qtbase/blobs/59fb0328392a5fc47e3a... (search for the #else bits)
- larve 14y agoto be honest I found that to be quite readable.
- justinator 14y agoWell, I'll say this: I'm an Art School graduate, and never achieved a passing grade in any higher math than Algebra 2 in high school (failed Physics 1) and Perl is the strongest language in my personal quiver. Why? It's so damn easy for me to understand. > I also dislike perl. A large amount of perl code contains > shorcuts - like $^p or %#p (not real perl patterns but I > hope you get the point). Well, that's not so fair - as that's... not (capital "P") Perl. That's like mimicking how a foreign language sounds like to you, (without context) http://www.youtube.com/watch?v=Q1VGoKBKR3I http://www.youtube.com/watch?v=Q1VGoKBKR3I and declaring that language unreasonable. So no, I don't understand :) I owe quite a bit to Perl. I couldn't, ever, learn C++.
- general_failure 14y agoAgreed, I was being over-sarcastic :) May I ask how much existing perl code you have read as opposed to written? Like I said, writing code in any language is easy. Making it readable for others is the hard part.
- ufo 14y agoI only "understood" Perl when I read the book and realized how much Larry Wall is a Languages (as in English Language) kind of guy. He expects you to learn Perl just like you would learn an usual human language - through experience and looking at examples from other people. Thi skind of explains why there are so many abbreviations and idioms and the TIMTOWTDI maxim, while also kind o justifying the lack of a simple nuderlying mathematical explanation to the language. Sadly, that was also the day I gave up on learning Perl, since I am the maths kind of guy and I get hopelessly lost if my programming language isn't built on solid logical ground, with few "core" features that I can actually aim to master.
- fauigerzigerk 14y agoYes, some of C++ is indeed arcane. But what sets C++ apart from other mainstream languages like Java is that you can optimize for reading to a much greater extent than with other mainstream languages like Java or JavaScript. You can create entire DSLs all within the language. I'm not saying this is always a good idea, but if you want to radically pioritize readability, C++ is a better language than most. Some of the boost libraries actually demonstrate this very well. If you look at the implementation of the library, you may be intimidated by its complexity (as you have shown with bind), but if you look at examples of its usage, you will often find it a lot cleaner than other languages. Imagine what you would have to do in Java in order to do what bind does: int diff(int a, int b) { return a - b; } auto reverse_diff = bind(diff, _2, _1); assert(diff(5, 2) == 3); assert(reverse_diff(5, 2) == -3); (Obviously, this particular example is trivial in any dynamic language, but that's a different debate) I'm not saying C++ is the only or even the best language for creating statically typed DSLs. But it is a language in which you can optimize for readability in a much more radical fashion than in some other mainstream languages.
- cousin_it 14y agoIf C++ lets you optimize the readability of callers at the expense of callees, that doesn't mean you can optimize a whole system for readability, because it will contain both callers and callees. In Java it's common to have systems that are pretty uniformly readable.
- fauigerzigerk 14y agoI agree, C++ encourages a seperation between library writers and library users. That's not good. In Java, however, lots of things are done outside of the language to solve similar meta-programming issues. For instance, many of the new annotations are only available within a suitable container that interprets them at runtime. Some of these things even need byte code manipulation. The resulting system is not generally simpler than C++ in my opinion and you have the same separation between library/container/runtime makers and mere users.
- pmr_ 14y ago
- jacquesm 14y agoA library that abstracts away a bunch of ugliness will almost by definition contain code exposing that ugliness.
- irahul 14y ago> A large amount of perl code contains shorcuts - like $^p or %#p (not real perl patterns but I hope you get the point). These patterns are ungooglable and hard to remember. Assuming this is a real problem for you, and you aren't just looking for arguments to validate your dislike: `perldoc perlvar` and then search for the variable. When I was doing perl, I used a lot of special variables. I don't see why you shouldn't know what $_, $!, $0, $? do when you are programming perl. I avoided the lesser knowns, but that is how it is in every language - there always are obscure features and it's the programmers responsibility to write reasonable code.