views:

1340

answers:

26

I have often thought about trying to learn a language like C++ to get a better understanding of computers. To me knowing C/C++ is like the black belt of programming. But then you look around at some great developers and I don't think that they have ever learnt C++.

Is it a good idea for some rainy day (more like rainy year) or should I just keep pushing the boundaries on the languages I already know.

EDIT: To answer some questions. I have a good couple of years of experience in Java. Have worked quite a bit with Delphi and about a year and half ago started using C# for some web applications I had to create.

+18  A: 

Of course it really depends on where you want to improve. If you are to do some systems programming, for example, then you should. However, if you want to develop on the web apps front, don't bother. For more detail on this, see: Which sector of software industry uses c++

The first thing to remember when starting to learn, though: There is no such language as C/C++.

Pukku
Nice answer and good references. :)+1
jalf
+20  A: 

Every single language and tool you learn makes you a better programmer. Yes.

Rayne
If someone votes this answer down, I request you give a logical explanation as to why you are voting it down. This is what I've been taught from hundreds of sources. I don't see how it can possibly be wrong.
Rayne
People downvoting this answer make me lose hope in society.
Juliano
It's been downvoted twice so far. No one has explained why.
Rayne
SO has its fair share of idiots, I'm afraid.
anon
I did not vote it down. However, you'd give the same answer for any question of the form "should I know foo". While your answer is right, it does not answer the implicit question which is "Should I make it a high priority to know bar"
David Lehavi
This answer lacks a 'because' clause that is relevant to the topic. The implicit question to me is 'Why learn C/C++ when I could learn other stuff?'
Adriano Varoli Piazza
Agreed, while this answer is correct to the general question, the specific question here deserves a more detailed explanation including things such as priority. I don't think this should be voted down however, just that you should expand your answer=]
Burly
I don't think so. His question was "Will knowing C and/or C++ make me a better developer?" the answer is yes. There is no he never asked whether it was high priority or any of that noise. If it's not explicit then this answer works fine. If he wants to expand his question I'll expand my answer. :D
Rayne
Maybe we don't agree on what a “better” programmer is. If you already know C#, what's the point in learning Java? Maybe you will find a job more easily, but to me that doesn't make you better. My point is: learning a new language which doesn't teach you new principles is of little or no interest.
Bastien Léonard
+1: You can learn something new from every language you learn; just as you can learn something new by talking to other programmers in your main language(s).
John Dibling
@Bastien - the point to learning Java would be that someday a client may ask you "I have this Java application and I need feature X added by next week. Can you help me?" Even if you could have done it better in C#, As far as your client's concerned knowing Java made you a better developer.
Joshua Carmody
I'd add that if any of my developers said to me anything like "I already know <Language-X>, what's the point in learning <Language-Y>?", that developer would be immediately placed in the queue for replacement. I don't need developers that have no interest in enhancing themselves as professionals.
Juliano
@Bastien If you learn Java after knowing C# you gain the knowledge of an entirely different platform. The JVM. That is a great power to hold.
Rayne
JVM has no interest, its market share has. Now if you want clients, go ahead and learn Cobol. I'm not sure it will make you a better programmer though.
Bastien Léonard
What are you talking about Bastien? Learning that platform opens up a world of new things. New languages like Clojure and Scala, all kinds of new tools... The hell with it's market share, I don't just program for Ca$h.
Rayne
A: 

Are you talking about C or C++ ?

You don't say what you currently know. If you've not done C, I would certainly recommend it. It will help you understand what's going on at the low-level, close to the metal. Its design and styling influence so much of current language/script implementations.

If you want to learn an OO language, I would perhaps suggest a simpler introduction to OO - perhaps Java or C# initially. C++ can be a intimidating introduction to this subject.

Brian Agnew
Or Scala. Scala is more OOPish than Java. :p
Rayne
But also more complex and functional.!
Martin K.
Yes. I think the functional aspect will obscure the OO concept from the POV of learning OO as a concept
Brian Agnew
Sorry, have edited my question to include which languages I currently know.
uriDium
More complex and functional, how? The functional aspect can in no way cloud the OOP learning experience. It's not OCaml for Heaven's sake.
Rayne
Your comments about Scala would apply just as well to C++. Its generic or functional aspects would (and *should*) obscure the OO concepts as well.
jalf
I don't get how, Scala forces object orientation like Java. The functional style of programming is just a plus. C++ I could understand, but you would have to detail exactly how the functional aspects would effect the ability to learn OOP from Scala.
Rayne
+8  A: 

I would learn C++ templates as a brain exercises. This as any other programming technique will force you to think on a task in a more wider basis.

Mykola Golubyev
heh, "brain exercises". That's a good way of putting it. +1 :)
jalf
+10  A: 

Expanding your knowledge base is always encouraged. And as often stated by Joel Spolsky.

His argument is, that it is like driving with a stick and know about the mechanics, coding in C (or easy-to-use assemble) helps you to understand what’s going on under the hood

Ólafur Waage
Agreed - learning C or C++ won't make you a better programmer because you "learned another language", but because the nature of those languages requires a different level of understanding what's going on under the hood, and *that* will certainly make you a better programmer.
Matt
A: 

Yes, if you mean knowing in depth, not just some basic knowledge. C++ combines proximity to the computer internals with high flexibility so deep knowledge of C++ implies you understand how a computer works very well. And the latter certainly gives you an edge.

sharptooth
+1  A: 

It's never bad to know a language more! If you learn C and Assembler, you'll see how it all started. This is really helpful for talks at meetings ;)

Thats more about you, than your programming skills.

Martin K.
+8  A: 

Knowing language doesn't make you a better developer. Applying the language in a right way( most of the time avoid abusing the language concepts).

using the Power of the language makes a better developer

aJ
+1, you've got it ^^
Martin K.
Not -1, but knowing a language enough to be practical does make you a better developer; you'll be better able to find a useful tool for a job and you'll better cement other concepts you know about by doing them in different ways.
Adam Hawes
To know a language, but apply it incorrectly most of the time seems unlikely.
Don Reba
That requires that you actually /know/ the language. I don't know what you are getting at bro...
Rayne
We don't live in ideal world. knowing C++ concepts was just enough then we don't need Effective C++ by scott meyers!
aJ
Also, I am not denying the fact that you should know the language but it is not just sufficient -- apply it in right way.
aJ
You are creating your own definition of "Knowing a language" I'm afraid. My definition of knowing a language requires that you /can/ apply the language effectively.
Rayne
Knowing a language certainly does make you a better developer, even if you're actually coding in that language. -1
jalf
+1  A: 

Yes. (kind of)

Every single time you program in a memory-manged language you allow the compiler to do work for you, and over time you come to rely on things that you have little or no knowledge of the inner workings of.

In a non-memory managed language like C or C++ you have to spend time thinking about where a pointer will point to at the end of a method, whether to pass by reference or return a variable, and other things that make you think about the code you're writing in a far more objective way.

The thing is, the ability to know things like whether using a vector or an arraylist in java is the right way to go can never be learnt until you understand the fundamental concepts behind many of the data structures you use on a day-to-day basis.

So yes, learning to use C or C++ will make you a better programmer, but whether you choose to take this knowledge and use it to make you a better developer is your choice.

Ed Woodcock
+3  A: 

There has been great debate about this by Joel and Jeff on early podcasts and it is inconclusive and very controversial.

Like most older programmers (not giving away my age here) I tend to believe that the more you know about the underlying system and its inner workings, the better you will make use of more modern and abstracted ways of programming.

Therefore knowing about (m)alloc (allocating memory for a variable like a string or structure) and thus understanding why some string manipulations are slow in high level languages can be profitable. This is just one example.

If you want to learn about OO concepts, there are better places to go then a hybrid language like C++ (can feel the break between OO and non-OO layer).

So, I would say, having a look at C can't hurt.

Ralph Rickenbach
C++ doesn't "just add an oo layer". It adds a lot of far more interesting features than OOP, and it is worth learning for those other reasons. Screw OOP, that's so last decade ;)
jalf
+3  A: 

I would say that every new language improves your programming skills, so learning new ones is always a good idea. However, I find that learning languages belonging to other paradigms than the one I'm currently most used to is a smashing way of becomming a better programmer. For example, learning prolog made me truly understand recursion for the first time, smalltalk and ruby helped me understand the beauty of dynamic typing, lisp just blew my mind and C made me realise what was going on behind the curtains...

If you're thinking of learning a new language, I say go for it. C will help you understand memory allocation like nothing else (unless you're going for even nitty-grittier stuff like assembler), and C++ will help you love any other language you may know so much more. ;)

Best of luck!

Banang
A: 

There is a saying:

You're worth as many people as the number of languages you know .

That's the only real reason to learn them ;)

Azder
+4  A: 

There is a great article on self-improvement in programming: "Teach yourself programming 10 years"

It says, that it is always good to learn new stuff. C++ is hard to learn, and even harder to master.

But it teaches you all sort of low-level processing, that is crucial to understand when writing large-scale software.

Glorphindale
Thanks for the article.
Liran Orevi
+3  A: 

Knowing C/C++ makes you a more useful developer. C/C++ are quite pervasive and the syntax of many other languages is derived from them.

It never hurts to learn C either, because it really hides nothing from the developer. You'll learn about compiling, linking, libraries, etc in gory details. You'll learn about raw system calls and machine architecture; things that higher level languages hide from you with their own abstractions of concepts.

Learning another language well enough to solve practical problem will make you a better developer simply because now you have a new tool that can be applied to solve some problems better than other tools. More tools is always useful. Learning the new ways of solving problems in another language will further cement your knowledge of concepts, design patterns, data structures, etc. It can only be a good thing!

Adam Hawes
+9  A: 

I suggest that you read this book: http://csapp.cs.cmu.edu/.

It's an extremely good reading for any programmer. It will really teach you how your programs work at low level.

This book uses assembly and C, but I don't really know if it's readable without C knowledge. Anyway I suggest not to spend much time to learn C. You would probably need at least a year before you begin to understand how to write good C programs (I needed two years, personally).

C and C++ don't teach much about low level stuff (yes, I know many people claim the contrary). You learn to allocate/deallocate memory yourself, but I think that's all about it. On the other hand, the book I linked above will teach you how to write your own memory allocator, how to optimize programs, and much more.

Bastien Léonard
Good book indeed.
Liran Orevi
Yay, +1 for stating that C/C++ don't teach as much low level stuff as people often believe.
jalf
Um, you do realize that the book you linked to uses C to teach low-level stuff, don't you?
TMN
I mentioned it in my message.
Bastien Léonard
do you know the asm keyword? -1 sorry - c++ teaches as much low level as you are prepared to learn
Michael
A: 

It might. There are some very important concepts that are shoved in your face particularly in C that you have to deal with.

I'd say take it a step further and learn assembly. I've never programmed professionally in any assembly language, but the time I spent working through every chapter and exercise in Assembly Langauge for the PC has payed the most dividends of any of my studies, school or independent. You will know what a pointer and an offset is, you'll have a deeper understanding of why character encoding matters, you'll know about the stack and the heap, memory management, etc. You may never use any of that directly, but it will make yo u a better programmer.

zimbu668
+1  A: 

Learning another language will make you a better coder. Especially when the language's paradigm is significantly different from any other language you already know!

Learning C will give you a much better grasp of what you are actually doing. It will be like being accustomed to a full featured graphing calculator and then learning to do all the arithmetic, algebra, calculus, and graphing yourself with just a blackboard and chalk. It will be a lot of work, but if you succeed, your mental model of the code will be much closer to what is actually happening in the machine.

This isn't really necessary to be a good coder. Actually, I believe one of the characteristics of a good coder is the ability to understand the code in a higher level of abstraction, and to see the system as a whole. Low level knowledge doesn't help you with the big picture. However, if you want to be great, you have to move beyond just good. You should be able to understand the system at many different levels of abstraction from the upper conceptual diagram level down to the bare machine code level. Knowing C will help you with understanding the low levels. Being able to debug C will help you with troubleshooting at all levels!

C++ allows you to do the low level operations of C, but adds a bunch of abstraction mechanisms and code reuse facilities so you can be a little more productive. If you already know a higher level language like Python, Ruby, Perl, VB, Java, and so on, I would recommend that you make some effort to become skilled in C and not try to tackle C++ just yet. The purpose of learning another language should be to expand your horizons. That way, even if you don't end up using it in a professional or hobbyist capacity, you will still improve your coding and analysis skills for the languages that you do use.

A. Levy
A: 

A programming language is just a tool. To be get better, you have to know your tools better, whether your tool is C/C++, a paintbrush, or anything else.

samoz
+2  A: 

C++ - I'm not sure.

C - certainly:

  • It will make you aware of memory mennagement - e.g. nobody who does not "think" C can understand, or think about Apache pool

  • It will make you aware of performance issues like vector/bit-set computation and loop unrolling (because sometimes you'll do it by hand)

  • You'll feel more comfortable with Unix

  • C is still the industry lingua franca

David Lehavi
+1  A: 

One of the most important things when designing applications is the amount of user code/libraries around the language, code snippets, tutorials and everything else.

That said, C, altho old language, is what Esperanto should have been in human languages - the language everybody should know :)

Why ? Its not important. Whats imporrtant is that you will encounter C everywhere around.

majkinetor
A: 

You should try to learn C and you should try to learn C++. When you do, you soon realize why I separated the two.

It will make you a better programmer too, because you will learn more about the machine the code is running on compared to the languages you know so far. That in itself would already be reward enough. Learning C++ might also make you learn multiple inheritance which is another useful programming concept that is not so wide-spread around other languages. If you learn to use the preprocessor well, then you certainly miss it in other languages as well.

However, one thing to keep in mind: to really learn these two languages takes a long time, because it is not enough to read about them. You need to work with them and solve real problems. That is the most rewarding part when learning these languages, but it is also the most frustrating and time consuming part. I am learning for 10 years now and I feel unable to say that I now know both languages. I feel quite comfortable, but I know that I am far from perfect.

HS
+3  A: 

There is nothing special about C and C++, other than:

  • C is a remarkably unambitious language. Its goal is/was more or less to create a portable assembly language. Anything more advanced than that, has no place in the language. As such, language-wise there is nothing to learn from C. It's in no way a difficult language, but it requires a lot of work to achieve even the simplest things. And it is of course very error-prone and unsafe compared to higher level languages.
  • C++ is a remarkably complicated language. It has had a lot of different influences over the years, and has stolen ideas from a wide range of languages and programming paradigms. And then in the last decade or so, this has been topped off by the C++ community pretty much inventing their own paradigm (generic programming). As such, C++ has come up with some pretty clever solutions to a lot of common (in all languages) problems. As much as people like to look down on C++, I frequently miss it when working in C#. There are a number of high-level techniques and abstractions that are simpler, cleaner and more elegant in C++. So from a pure language perspective, I think C++ is worth learning. (And I wish Javas or C#'s designers had bothered to do that, rather than basing their languages on what can be more accurately described as "C with classes".

But I think what you're getting at is that learning these languages will give you a better understanding of "what's going on under the hood".

I can see the point in that. C/C++ gives you pointers which can be almost mapped directly to the underlying memory addresses. Learning these languages certainly gives you a kind of intuition about what's going on underneath. (But as always with intuition, it's not always correct. One of the most common mistakes in C++ is to assume that "pointers are memory addresses". They're not. In many ways they behave similarly, but pointers obey a lot of additional constraints that may or may not exist in the actual hardware.)

So for these things, why not go directly to the source? Learn assembly, learn about the CPU itself, learn about compilers.

All of the above is worth learning, and will make you a better programmer. But learn C++ for the sake of the language (it's not beautiful, but there are lessons to be learned from it), and learn about all the underlying mechanics (compilers, the hardware you're running on, the CPU) by studying those directly.

But whatever you go for, definitely diversify. You should learn the languages you actually work in, obviously, but don't stop there. Learn something else, almost regardless of what it is. More languages, or a better understanding of the underlying infrastructure, it'll all make you a better developer.

Finally, don't think of C/C++ as the "black belt". C++ in particular may be one of the hardest languages to master, but that doesn't mean those who know it are the best programmers. Far from it.

jalf
Actually, I have mapped pointers directly to memory addresses. Very handy when you're using memory-mapped I/O and control registers.
TMN
Like I said, there are strong similarities, but they are not the same. there are things you can do with memory addresses according to the underlying instruction set, that you can not do with a C++ pointer.In some pointers can be treated as memory addresses, but not always.
jalf
A: 

I suggest you to learn C language. This will help you to learn everything about computer programming. To me there is a good book available for programmers to learn C programming from programming to memory management, OS concepts and other stuffs.

http://www.cs.cf.ac.uk/Dave/C/

have a look at this web book you will able to know how powerful the language is....

chinnagaja
A: 

If I had to answer your question in one word, "YES". It's good to master at least one language, but it's always better to learn more than one... who knows what happens tomorrow.

As far as understanding of computer goes, C++ may not be that very helpful, but C++ does provide you a lot of options while programming.

And yes, does learning it make you a better programmer? It does. Every language is unique in certain aspects. Learning more languages helps you explore the possibility of implementing the uniqueness of one language in another.

Shree
+2  A: 

if you learn C + +, consider using these books:
Effective C++
Code Complete

lsalamon
Thanks for the resources :D
uriDium
+1  A: 

Coding in C gives you a closer perspective to what the real system is doing. It is really "coding to the metal" of the machine.

It also gives you a deeper appreciation for what languages like Java/C#/Python/Ruby are doing for you.

And finally, a vast majority (though not all) of nix/BSD code is written in C, as well as many modern systems, so knowing it opens the doors for you should you be considering a patch, or trying to join a team at a certain company.

gregturn
That is another motivation. To get involved in open source projects because then I will have a lot of people looking at my code and giving me pointers.
uriDium