Sunday, May 5, 2013

C++ : The good old thing

Today, I remember a comment from a friend of mine when I started into the world of programming taking up a course in C++. He said "Dude, C++ is an old thing. Who uses it today? Arent there fancier suff out there? And why would someone take a C++ route?"  That was my first day at programming. I didnt know much about these languages to have a good answer to that. But, 8 years later I have an answer to it. Yes, Thats a pretty long time. But I know what I like now and that is what the title of the post says. Yes, To me, it comes as a trade off between the needs to prioritize development speed over execution speed, which is where all these “fancy” languages tend to shine. In my experience, these other languages execute fast enough on smaller projects, but start to break down on larger ones. If you still dont agree look at the list of software written in C. Thats a big fat list with some of the most used software out there. Here is a list on the same. Pheww thats loooong. Isnt it? Well, I cant guarantee the authenticity of each and every item on that list but I see names of which I know that they are written in C++. So, I do trust it.

As much as C++’s large feature set and "strict" syntax may be seen as a complex thing for newbies to master, it is about giving the power to express everything one wants directly, unlike any other “simpler” language. I cant stop myself from throwing out something I  read on wiki recently.
 A widely distributed "satirical" article portrayed Bjarne Stroustrup confessing that C++ was deliberately designed to be complex and difficult, weeding out amateur programmers and raising the salaries of the few programmers who could master the language :D.

Yes, thats the challenge. You have all the design tools and if you have the expertise you will definitely love C++. As a matter of fact, I love C for that matter because it gives all the more development speed but then I think its incomplete without all the features and libraries C++ offers on top of it. C++ with its object oriented capability and STL looks a lot more powerful. And with the latest addition being C++11 it adds to the power. Here is a list of things I see in C++11 which excites all the more. Though I am not sure about the stability of all these set of features, it definitely pleases me on the first look. Its time to get your hand dirty trying out all these. Lets have a look at the list:

1) Important Syntax cleanup
2) Automatic type deduction with Auto
3) Range Based for loops
4) Lambda Functions
5) standardized support for multithreaded programming.
6) regex support
7) Chrono library to deal with time duration and points
8) Containers such as unordered_map, unordered_set and Tuples etc
9) Headers for random number generation and ration class templates.

I will try and cover a post on each of these in future. But for now, lets play around with these
new tools. And once the tools are sharpened lets discus them.

Cheers !!!


  1. I almost forgot you started a blog. Good post. Some points -

    1. Execution speed matters more for CPU bound application. Today most of the application work on the web or rather network/io intensive where execution of code is not the major bottleneck rather data transfer,waiting for something etc. are. A approach adopted by companies like Dropbox is to code everything in a language with faster development rate (Python here) and replace parts which need better execution speed with C wrappers or C/ C++.
    2. Learning some particular language is easy. You would want the language to go out of way so that you can express yourself freely. C++ by design has a more steeper learning curve once you move outside of C and STLs rather than say Python. I found myself going back to Python for almost every task except for things where time limit exceeded was a problem :)
    3. A dynamic language which you might consider higher level language than C/C++ provides some constructs which allows you to implement ideas in a much cleaner way.
    4. People using the other languages use them in a rather stupid manner which further degrades the application. A poorly written piece of Python can be optimized to an extent before thinking of other options.
    5. Things were written in C for lack of better options :P (just kidding!) System software (and databases. browsers,compilers) will still be written in C/C++ or languages with better execution speed.
    6. The list is wrong. YouTube as far as I remember uses Python majorly (there might be some components in other languages)

    I would ask you to check Go, a new language (NO NOT ANOTHER LANGUAGE !!!) which is high performing and somewhat easier to use.

    So its 8:30 pm and i cannot continue writing more as I was waiting for this to go to cafeteria for food. I dont' know what I wrote. Bye :P

  2. Good points Mr Psychonoob (what a name ;)). The post was written keeping in mind that I dont criticize anything out there but Just to emphasize that C/C++ is still equally good for certain stuff. Given I work in a database company even more. And i still firmly believe that one should learn C and C++, its not a waste of time. You come to know a lot of basic stuff when you write things in C.

    And as far as python is concerned, its really good. Sometimes development speed is of utmost importance, so its not a bad idea to stay away from C at that time. You need to choose your language of preference to express yourself better. Completely agreed. I am actually thinking on updating the post with some of ideas mentioned in the comment. Thanks for enlightening us Mr Pro :)

  3. your blog' s design is simple and clean and i like it. Your blog posts about Online writing Help are superb. Please keep them coming. Greets!

    data science training institute in bangalore
    Data Science certification course in Bangalore