Submit Your Site For Free!

Email Address:
* URL:
*
*Indicates Mandatory Field

Terms & Conditions

CProgramTrends
FlashNewz
DevWebPro








Why Generic C Programming Has Not Taken Off

By Dean Michael Berris
Expert Author
Article Date: 2011-01-21

I thought about the subject a little more and tried to look into myself and what was stopping me from learning generic programming earlier in my C++ programming experience. One recent interview I had still sold C++ as an Object Oriented Programming language, which was surprising to me because it was only half-true. I knew better than trying to correct the interviewer, but that's a different thing. After a little introspection, here are a few reasons why I think GP has had a hard time getting into the mainstream.

This list is not meant to be exhaustive - I have to keep it to a sane list however, so I'm listing down the top 5 reasons why I think GP is having a hard time becoming a dominant programming paradigm. Drum roll please…


5. Lack of Personality


Just like with any movement, you need a charismatic leader who's screaming and pushing for the practice to be adopted by a larger mass of the unwashed. Although Dr. Stepanov is the godfather of the movement, I don't think a genius needs to be the one leading the charge. Look at DHH - although I have respect for him, I hate his guts and pretty much disagree with a lot of what he says about business and when it comes to Rails. But, he's an effective figure head to lead the Kool Aid selling of Rails. There's also Steve Jobs - I don't buy the Apple hype because I think their machines are over-priced - but man if there was anybody who can sell Kool Aid, Steve is the man.



GP needs a brash outspoken hippie or "down in the trenches" person to lead the charge. Someone who's willing to say that "OOP for everything is BULLSH*T". Someone who also has a lot of experience under his belt and has had successes with GP would be a good candidate. Of course that person shouldn't mind being in the spotlight and still be the figure head of an ideology - new Kool Aid - but still be effective in what he/she does. I'm not this person yet because I don't qualify - nor do I want to be this person, I can only stand so much FUD being spread around me. ;)


4. Lack of Direction


Think of it as a lack of propaganda, organization, and vision. Although the "GP Monks" that I've alluded to at an earlier post - I shall not name names - have had it good, much like the Buddhist Monasteries that I know, it's pretty much "every man for himself". You don't see conferences, websites, books, or even Google Tech Talks about the subject. And those who understand seem to be content in just understanding - there aren't a lot of fervor around it even though I believe it's the best thing since sliced bread. And I'm not just talking about GP in C++, because GP can be applied in a lot of other programming languages - it's the paradigm that hasn't been getting much direction/promotion.


It's like "Buddha has left the building" in the Monasteries, and the Monks have no idea what to do next except to live by the code and just be content in their life. GP needs a champion or a league of champions - like what happened to Agile Software Development. We need the leaders of the cause to come together, come up with some sort of manifesto, and sell it like Kool Aid for it to be anything but the best kept secret of successful library developers.


We need more libraries written to be generic so that everybody wins. I get so tired with libraries that are so rigid and cumbersome to adapt that they're pretty much useless except in the context in which they were developed. The world needs more generic libraries and GP needs to get a direction - and that direction should be towards mainstream.


3. Lack of Information


Who in the world knows about GP except those who bother to read about the C++ Standard Template Library? (There's a great book about that too, STL Tutorial and Reference Guide: C++ Programming with the Standard Template Library (2nd Edition) (C++ in Depth Series)). And you just get a taste of GP with the Elements of Programming book (again written by the venerable Dr. Stepanov) - unfortunately that book is a workbook for those wanting to sharpen their generic programming chops, assuming pretty much that they already know GP from the start.



If only everybody learned programming from the start and heard about this great thing called Generic Programming, then perhaps the OOP languages start looking like they were designed decades ago - except that they really are - and that there were programming languages way older than these (C++ and Common Lisp) which support GP already. I want people to start asking why the world ever tried to live with just OOP when GP can do what OOP provides *and still* provide more things that OOP can't. Then again people generally don't get that Common Lisp is powerful despite how many people are able to do with it.


2. Lack of Support


This is a business issue, but because GP didn't become a buzzword unlike OOP, nobody supports it in the industry. Every other programming language that comes out now either has to look like Java because that's what the college kids learn, or they come out like Ruby because that's what the snobby new-age web 2.0 hackers like. Very few people bother creating powerful programming languages like Common Lisp or C++ because they're scared of what they don't understand.


Like people who write novels for the masses, they try to appeal to the broadest audience possible and in the meantime losing the essence of being a great and powerful tool. Perl is a programming language that I have respect for, but because it has cultivated its own niche of programmers and kinds of programming, it's really hard to be hacker-level in Perl. The technology behind it (recently I listened to FLOSS Weekly about Rakudo Perl 6) is incredible and I really wish it becomes more mainstream and beat out the likes of Ruby - I also wish it would be JIT'ted to Machine Code just because I like it that way (it may already happen, I don't know much about Perl 6 to be honest, just wishful thinking).


Even D might have great support for GP but then it's not being touted as one of the good things with the language. I recently looked at the language again (version 2) and it looks promising - things like not requiring ‘->' when dealing with pointers is such a good idea, why doesn't C++ just adopt it and get rid of the C legacy for crying out loud. The good parts of D are really good, while the good parts of C++ are missing (like templates). I'll write about D at a later time and what I would like to see happen in C++ 2.0.



And the #1 reason I think for GP is…


1. Apparently It's Not Obvious


It's hard to argue about this one. I know when I "got it", it wasn't immediately obvious. GP is so much on the "meta" side of programming, that it's not easy to tell the normal programmer that "look, just deal with the abstraction, leave the details for later". Largely because it's apparently not how 99% of the people think. It's not obvious that there are parts of this implementation that can be lifted out and made generic - sorry, even I sometimes need to squint a little and think hard about which parts of the solution I have in my face can be made generic, and I've been doing this the past 10 years! (of course that says more about me than the paradigm, but I digress).


There isn't a programming language yet out there where GP is obvious. Maybe in Common Lisp it might be more obvious, but even there the only abstraction you have that really matters is whether something is a list or an atom - that's powerful abstraction, but not nearly high level enough which is why people unfortunately came up with CLOS to make it a little more manageable, and also because of that the OOP bug bites you because of the rigidity, coupling, etc. Other languages like Haskell have promise with the Type Classes (acting like Concepts) and its close lineage with Math - maybe I should start writing more in Haskell and have the C++ I write take on a more Haskelly feel, but I'm afraid that's not nearly as natural as just doing GP in C++ for me.


One of the things I'll give to OOP is that you can teach anyone how to think in terms of objects because nearly every human language in the world addresses the issue of classification to some extent. Because OOP thrives on taxonomy and the idea of putting things under hierarchies (a Dog is a Mammal is an Animal is an … Object?), getting people to think this way is almost natural. However, GP works in the domain of Math and any Mathematician will tell you that Math is much more beautiful than the real world - and sometimes it's sad that way.


Somehow if GP is going to thrive, there has got to be a higher premium on thinking like a Mathematician, in terms not of hierarchy or taxonomy but rather dealing with abstractions - concepts - instead of types of "things". And that's the sad part, not enough people doing programming know their Math well enough to be able to understand and properly use GP in their daily programming lives.


Conclusion


There's a lot of work cut out for those (like me) who love GP and want to see it applied in more places. I think these barriers to entry to the mainstream can largely be broken down with enough determination and with a vocal enough group of followers. I don't claim to have that much of a pull, but I guess the Internet is a huge place and people just might hear the frustration of someone who's convinced "there's a better way" of programming and either agree or at least think about what this one guy is yapping about.


Help spread the word about GP even though you don't understand it fully or just get to use it through the STL in your daily life. You might not understand it, but those who understand might hear you and might take up the cause and tell the world about this beautiful little paradigm called Generic Programming. Maybe they'll think the world will be a better place with more Generic Libraries out there and so the may be inspired to either keep doing what they're doing, or convince more people to do the GP thing too.



Comments

About the Author:
Dean Michael Berris is the writer of C++ Soup! C++ Soup is a blog about what’s new, up-coming, and what’s going on with C++. C++ Developer with years of experience building high performance applications and implementing multi-threaded highly scalable systems.



Newsletter Archive | Article Archive | Submit Article | Advertising Information | About Us | Contact

C Programming Trends is an iEntry, Inc. ® publication - All Rights Reserved Privacy Policy and Legal