tags:

views:

901

answers:

16

I'm a programmer with 2 years experience, I worked in 4 places and I really think of myself as a confident, and fluent developer.

Most of my colleagues have CS degrees, and I don't really feel any difference! However, to keep up my mind on the same stream with these guys, I studied C (read beginning C from novice to professional), DataStructures with C, and also OOP with C++.

I have a reasonable understanding of pointers, memory management, and I also attended a scholarship which C, DataStructures, and C++ were a part of it.

I want to note that my familiarity with C and C++ does not exceed reading some pages, and executing some demos; I haven't worked on any project using C or C++.

Lately a friend of mine advised me to learn C, and C++ extensively, and then move to OpenGL and learn about graphics programming. He said that the insights I may gain by learning these topics will really help me throughout my entire life as a programmer.

PS: I work as a full-time developer mostly working on ASP.NET applications using C#.

Recommendations?

+9  A: 

For practical advancement:

From a practical sense, pick a language that suites the domain you want to work in.

There is no need to learn C nor C++ for most programming spaces. You can be a perfectly competent programmer without writing a line of code in those languages.

If however you are not happy working in the exact field you are in now, you can learn C or C++ so that you may find a lower level programming job.

Helping you be a better programmer:

You can learn a lot from learning multiple languages though. So it is always good to broaden your horizons that way.

If you want more experience in another language, and have not tried it yet, I would recommend to learn a functional programming language such as Scheme, Lisp, or Haskell.

Brian R. Bondy
As far as I know, C and C++ are kinda low level, and actually that's a major reason why I like the idea of digging into them; on the other hand, I've heard about functional programming (precisely F#) and i'm excited to learn one of them, if and only if it was low level. is Lisp a low level one?
Galilyou
No functional languages are not considered low level, but they will help you think of solutions to problems in a new way.
Brian R. Bondy
So. Lisp or Haskell?
Galilyou
Scheme is probably the easiest one to start with.
Brian R. Bondy
Googled and got a good resource but i'm not sure it's Lisp or Scheme. "http://mitpress.mit.edu/sicp/"
Galilyou
SICP is Scheme. Good book, and often used as a text for CS classes.
crashmstr
A good CS education would give you exposure to many different types of programming languages. IMO this is a good thing, though, frankly my experience with LISP is what keeps me from looking at F#, now. Too many #@!#@!@ parentheses. Maybe having a better IDE than vi helps, though.
tvanfosson
@tvanfosson: The parentheses are unique to LISP and SCHEME. Other functional languages, like F#, don't have them.
jalf
OK, I feel more excited towards the SCHEME idea, and functional programming, and because you provided these ideas first, i'm goona give you the point. Thanks for all of you Guys:)
Galilyou
+1  A: 

Do you have to learn it extensively? I expect not.

However it's best to always be learning things that help you look at programming from a different perspective. Learning C or C++ are worth it for the insight into how things work at a lower level. For C and C++ programmers the same thing might be accomplished by learning assembly. Most people won't use assembly in a project, but knowing how it works can be very helpful from time to time.

My recommendation is always to learn as much as you can. If you're not working on a C++ project in the near future I wouldn't be too worried about learning the ins and outs, but it's always good to be able to look at problems from another angle and learning new languages is one way to do that.

Dan Olson
+2  A: 

I've been working as a developer with no degree for almost 15 years now. I started with Ada and moved quickly into C/C++, but it's been my experience that there will always be some language that you "have to learn." If it's not C++, it will be C# or C or Java or Lisp. My advice is make sure you're solid on the basics that apply to any language(my best friend as a dev with no degree was the CLR book), and you should be able to move relatively easily between languages and frameworks.

Jeffrey D Johnson
+1  A: 

Today for the majority of applications, C and C++ can be viewed as an academic exercise: "How can we write programs without garbage collection?"

The answer is: you can, but it's a mostly painful experience. Most of the details of best practices in C++ are related to the lack of garbage collection.

Given the brilliant performance of modern GCs, and the general increase in computing power, even cell phones have GCs these days. And in a platform with a GC, you can always code in such a way as to limit the pressure you put on the GC.

Daniel Earwicker
A: 

Without a practical reason for learning a programming language it is pretty hard going. If you can think of particular problems or a specific task which the language is suit for - Then the learning experience is driven by needs, rather than simple academics.

I only just recently switched from VB to C# (1 month ago) while not as significantly different as a switch from C# to C, because I switch for a particular reason I found it much easier to learn. I had dabbled previous without a specific problem to solve, needless to say I switched back

Harry
+6  A: 

Experience is the best teacher.

While you can read about things like memory management, data structures (and their implementations), algorithms, etc., you won't really get it until you've had a chance to put it in to practice. While I don't know if it's truly necessary to use C or C++ to learn these things I would put some effort into actually writing some code that manages its own memory and implements some common data structures. I think you'll learn things that will help you to understand your code better; to know what's really going on under the hood, so to speak. I would also recommend reading up on computer organization and operating systems, computer security, and boolean logic. On the other hand, I've never really found a need to do any OpenGL programming, though I did do some X Windows stuff once upon a time.

tvanfosson
I'v already done these practices you mentioned (implementing common datastructure and stuff), the question was, do I have to learn it EXTENSIVELY? (i.e to be able to build an entire GUI app with DB access and these sorta things using C++?
Galilyou
My point wasn't C/C++, but rather the algorithms, etc. In my mind demos don't really cut as they are usually too simple. You might want to implement a priority queue or red/black tree. One of the most challenging things I ever did was write my own cooperative process scheduler in C using setjmp..
tvanfosson
... The thing that is most important from my perspective is that you develop a good understanding of the fundamentals of your craft. Some of these things are harder to learn in a managed environment.
tvanfosson
I somewhat disagree. I've seen people who've been doing the wrong thing for 15+ years.
cletus
@cletus -- The point about learning is not that everyone gets it right, but rather that you learn better by doing than by reading.
tvanfosson
@tvanfosson: Some don't learn at all by doing, is his point. Or another way to put it: Doing makes you more experienced (and better) at doing the same thing you've been doing all along. Reading might teach you *new* things. Which is best? I'd say both are useful.
jalf
@jalf -- I don't disagree -- both are important. Ask yourself, though, whether you want the surgeon who has just read about performing open heart surgery or the one who has done it a few times. Me, I want the one who has read/learned about it AND done it, preferably many times.
tvanfosson
Agreed. But then experience is not the best teacher, as you implied. Experience plus a good book, is the best teacher. ;)
jalf
@jalf -- actually I was quoting a well-known proverb (Caeser?) as an introduction to my message, thus the italics.
tvanfosson
A: 

If you have a different style of learning as in self-taught then my recommendation to be a better programmer is to research topics regarding your domain. From bottom to top, slowly climb up the ladder.There is a fairly amount of different programmers, no one will excel in all, so don't start off with that context in mind.

Best of luck to you.

Cristina
+1  A: 

Listen or read SO podcast 44, where Joel plays his favorite song Write in C

Spolsky: Yeah, it's not paying the proper royalties to the Beatles anyway. We'll link to that from the shownotes. Awesome song, Write in C.

Atwood: That's right, Joel's favourite song. Write everything in C, because Joel does in fact write everything in C, don't you, Joel?

Spolsky: I started using a little bit of C99, the latest version of C, which let you declare variables after you written some statements.

...

gimel
haha I love Joel's last line
Brian R. Bondy
I wonder where he found a C99 compliant compiler. Does one even exist? :p
jalf
+4  A: 

Having degree has got nothing to do with C/C++ actually. Now, stuff like big O() estimation, data structures or even mathematical background. For example linear algebra results very useful, even in context that seemingly have nothing to do (eg. search engines).

For example typical error that a good coder, but without any theoretical knowledge, might commit is to try to solve NP-complete problems by exact algorithm, rather than approximation.

Now, why in universities they teach you C/C++? Because it let's you see how it's all working "under the hood". You get opportunity to see how call stack works, how memory management works, how pointers work. Of course you don't need that knowledge to use most modern languages. But you need that to understand how their "magic" works. Eg. you can't understand how GC works, if you got no idea about pointers and memory allocation.

vartec
+2  A: 

You don't absolutely have to learn C/C++, but both languages will teach you to think about how your software interacts with the underlying OS and hardware, which is a essential skill. You say that you already know about pointers, memory management and so on, which is great. Many programmers without a CS degree lack this important knowledge.

Another good reason to learn C/C++ is that there's a lot of code written in these languages and a good way to learn more about programming is to read other people's code. If you're interested in writing low level code like drivers, OS, file systems and the like C/C++ is pretty much the only way to go.

Brian Rasmussen
Sigh .. So what do you think about a functional programming language, Brian? Something like Lisp or Scheme! And if i'm planning to do both C/C++ and Functional programming, with which should I start?
Galilyou
Re a lot of code: This applies to almost every language, not only C/C++.
Brian R. Bondy
I'm not sure I follow you here. I you didn't find my answer helpful, please elaborate so I can clarify.
Brian Rasmussen
@Brian R Bondy: I agree, the point I was trying to make is just that there's a lot of C/C++ code out there, so it is not hard to find something to read.
Brian Rasmussen
@Ramsussen I got your point, and I'm really interested in doing this kinda low level coding(drivers and others). The thing is, i'm advised to learn a functional programming, and i really like it (i.e.I'm goona learn C/C++ and a functional language too) Now, which one should i start learning first?
Galilyou
@7alwagy: functional programming will most likely teach you to look at programming in a different light, so I certainly agree that it is a good skill to learn. As to which you should learn first, I would pick the one where you can find a project you want to do.
Brian Rasmussen
If you have to choose which to learn first, I'd say functional, for two reasons: 1) it's easier to grasp if you're not yet *too* entrenched in the imperative mindset, so the sooner you learn it, the better. And 2) learning the concepts of that isn't going to take as long as learning C++ extensively
jalf
@jalf: That's a good point.
Brian Rasmussen
+3  A: 

I've often asked this question (to myself). I think the more general version is, "how can I call myself a programmer if I don't know how to kick around a language that doesn't have automatic garbage collection, with pointers and all that 'complex' stuff'?" I've never learned C++ except to do a few HelloWorlds, so my answer is limited by that lack:

I think that the feeling that you need to learn C++ (or assembler, really) comes from the feeling that you're always working on someone else's abstractions: the "rocket scientists" who write the JVM, CLR, whatever. So if you can get to a lower level language, you'll really know what you're talking about. I think this is quite wrong. One is always building on a set of abstractions: even Assembler is translated into binary, which can be learned as well. And beyond that, you still couldn't make a computer out of firewood, even if you had a pair of pliers and a bit of titanium.

In my experience as a corporate trainer in software dev (in Java, mostly), the best people were not those who knew C++, but rather those that took the language that they are working in as an independent space for "play." Although memory management comes up all the time in C# and Java, you never have to think about anything beyond freeing your object from references (and a few other cliche places, like using streams instead of throwing around huge objects in memory). Pointers and all that stuff do not help you there, except as a right of passage (and a good one, I'm sure).

So in summary, work in the language you're in and branch out into as many relevant things as possible. These days I find myself dipping into Javascript though the APIs are supposed to make this unecessary, and doing some stuff in Fireworks while I mess with CSS by hand. And this is all in addition to the development I'm really doing in RoR, PHP and Actionscript. So my point is: focus on abstractions that you need, because they're more likely to be relevant than the lower-level stuff that underlies your platform.

Edit: I made some slight changes in response to jalf's comments, thanks.

Yar
+1 Well thought out and presented. I'm not sure why someone would downvote you but you've got it back now.
Mark Brittingham
+1, but one minor quibble would be that actually doing memory management by hand gives you a better feel for why one approach may be more efficient than another and can provide you with insight into how to diagnose and fix your performance problems in a managed environment.
tvanfosson
Assembler isn't really an abstraction. It's a 1 to 1 mapping to machine code. Writing "add" instead of 0x43ab isn't an abstraction, it's just easier to remember. And there is a lot of value in understanding what goes on under the hood. Also, having a degree has nothing to do with knowing C++
jalf
Interesting points, jalf. I don't doubt the value of understanding what goes on under the hood. I question its RELATIVE value compared to other things one can learn with the same time.
Yar
A: 

C++ is just a programming language. What you don't have that other students (if they paid attention in class) have is the deeper understanding that comes through studying concepts.

Being a programmer is not and should not be the end goal of any CS graduate. However it is as far as most people get without such a degree.

Here is an analogy: An engineer and an architect both at some point learn to draft buildings using CAD. Also, someone completely untrained can come in and start work using CAD and be very effective. This is a good career and it pays well, but for both the engineer and the architect it is not where you want to be when you are 30.

Klathzazt
+1  A: 

Without a professional reason (other than the good practice of self-improvement) to learn C or C++, then you should have a passionate side project planned out that you could write in C or C++. Once the going gets tough on the side project, you'll need your enthusiasm and curiosity to take you over the hump (since on a side project, you naturally don't have the motivation of pay or de-motivation of a superior looming over you).

Also, most CS degrees are using Java as their language of choice now. This just proves the point that experience gained in the language of choice and exposure to some of the theory involved in the other classes in the degree is the main benefit for people with CS degrees, and not so much the specific language (though I think the higher they go up the abstraction scale, the worse it is for the students in the long run).

Kyle Walsh
+7  A: 

First, having a degree has nothing to do with knowing C++. I know several people who graduated from CS without ever writing more than 50 lines of C/C++. CS is not about programming (in the same sense that surgery is not about knives), and it certainly isn't about individual languages. A CS degree requires you to poke your nose into several different languages, on your way to somewhere else. CS teaches the underlying concepts, an understanding of compilers, operating systems, the hardware your code is running on, algorithms and data structures and many other fascinating subjects. But it doesn't teach programming. Whatever programming experience a CS graduate has is almost incidental. It's something he picked up on the fly, or because of a personal interest in programming.

Second, let's be clear that it's very possible to have a successful programming career without knowing C++. In fact, I'd expect that most programmers fall into this category. So you certainly don't need to learn C++.

That leaves two possible reasons to learn C++:

  1. Self-improvement
  2. Changing career track

#2 is simple. If you want to transition to a field where C++ is the dominant language, learning it would obviously be a good idea. You mentioned graphics programming as an example, and if you want to do that for a living, learning C++ will probably be a good idea. (however, I don't think it's a particularly good suggestion for "insights that will help throughout your live as a programmer". There are other fields that are much more generally applicable. Learning graphics programming will teach you graphics programming, and not much else.)

That leaves #1, which is a bit more interesting. Will you become a better programmer simply by knowing C++? Perhaps, but not as much as some may think. There are several useful things that C++ may teach you, but there also seems to be a fair bit of superstition about it: it's low-level and has pointers, so by learning C++, you will achieve enlightenment.

If you want to understand what goes on under the hood, C or C++ will be helpful, sure, but you could cut out the middle man and just go directly into learning about compilers. That'd give you an even better idea. Supplement that with some basic information on how CPU's work, and a bit about operating systems as well, and you've learned all the underlying stuff much better than you would from C++.

However, some things I believe are worth picking up from C++, in no particular order:

(several of them are likely to make you despair at C#, which, despite adopting a lot of brilliant features, is still missing out some that to a C++ programmer seems blindingly obvious)

  • Paranoia: Becoming good at C++ implies becoming a bit of a language lawyer. The language leaves a lot of things undefined or unspecified, so a good C++ programmer is paranoid. "The code I just wrote looks ok, and it seems to be have ok when I run it - but is it well-defined by the standard? Will it break tomorrow, on his computer, or when I compile with an updated compiler? I have to check the standard". That's less necessary in other languages, but it may still be a healthy experience to carry with you. Sometimes, the compiler doesn't have the final word.
  • RAII: C++ has pioneered a pretty clever way to deal with resource management (including the dreaded memory management). Create an object on the stack, which in its constructor acquires the resource in question (database connection, chunk of memory, a file, a network socket or whatever else), and in its destructor ensures that this resource is released. This simple mechanism means that you virtually never write new/delete in your top level code, it is always hidden inside constructors or destructors. And because destructors are guaranteed to execute when the object goes out of scope, even if an exception is thrown, your resource is guaranteed to be released. No memory leaks, no unclosed database connections. C# doesn't directly support this, but being familiar with the technique sometimes lets you see a way to emulate it in C#, in the cases where it's useful. (Obviously memory management isn't a concern, but ensuring that database connections are released quickly might still be)
  • Generic programming, templates, the STL and metaprogramming: The C++ standard library (or the part of it commonly known as the STL) is a pretty interesting example of library design. In some ways, it is lightyears ahead of .NET or Java's class libraries, although LINQ has patched up some of the worst shortcomings of .NET. Learning about it might give you some useful insights into clever ways to work with sequences or sets of data. It also has a strong flavor of functional programming, which is always nice to poke around with. It's implemented in terms of templates, which are another remarkable feature of C++, and template metaprogramming may be beneficial to learn about as well. Not because it is directly applicable to many other languages, but because it might give you some ideas for writing more generic code in other languages as well.
  • Straightforward mapping to hardware: C++ isn't necessarily a low level language. But most of its abstractions have been modelled so that they can be implemented to map directly to common hardware features. That means it might help provide a good understanding of the "magic" that occurs between your managed .net code and the CPU at the other end. How is the CLR implemented, what do the heap and stack actually mean, and so on.
  • p/invoke: Let's face it, sometimes, .NET doesn't offer the functionality you need. You have to call some unmanaged code. And then it's useful to actually know the language you might be using. (if you can get around it with just a single pinvoke call, you only need to be able to read C function signatures on MSDN so you know which arguments to pass, but sometimes, it may be preferable to write your own C++ wrapper, and call into that instead.

I don't know if you should learn C++. There are valid reasons why doing so may make you a better programmer, but then again, there are plenty of other things you could spend your time on that would also make you a better programmer. The choice is yours. :)

jalf
Jalf, first, thanks for the detailed explanation. Second, well, i'm a little bit confused now :S. You mentioned a lot of choices one can't choose from them easily(Compilers, CPUs, etc). So, if you were to list all of these things you mentioned in an ordered list, how would that list look like?
Galilyou
Dunno. :) Depends on what you want to learn the most.However, if I had to pick one subject to learn in order to understand "what goes on under the hood", I'd say learning how compilers work would be the best choice. A valid strategy is just to go for what you think sounds interesting. :)
jalf
But one of the points I was trying to make is that there isn't a simple prioritized list of "what you should learn". It all depends. I've just tried to outline some possible directions you can go, and what you might learn from some of them. I can't say what the best choice for you would be. :)
jalf
A: 

One value of knowing C is that many other languages including C#, Java, C++, JavaScript, Python, and PHP have their roots in C syntax.

Another value, and arguably more important, is that it will build your confidence. Programmers are a confident group and very optimistic (you have to be confident to think that you can write the equivalent of a 1000 page book without a single spelling or grammatical error). And confidence in your ability to learn and effectively use any language will grow considerably with a pure C application or two under your belt.

So write a non trivial program in C; something that at least reads and writes files, allocates and deallocates memory, and manages a data structure like a queue or binary tree.

Your confidence will thank you.

CLaRGe
+3  A: 

I have a 1st class Software Engineering degree and work for a large console manufacturer developing a game engine in a team of programmers all of whom program across a wide range of languages from Asm to C++ to C# to LUA and know the hardware inside out.

I would say that 5% of my degree was useful and that by far and away the most important trait to furthering my career has been enthusiam and self development.

In fact many of the colleagues I've worked with haven't had a degree and on average have probably been the better ones.

I'd say this is because they've had to replace that piece of paper from a university degree with actual working code that they've developed in thier own spare time learning the skills off thier own back rather than being spoon fed it.

My driving instructor use to tell me that I would only start learning how to drive after I pass my test ie you only really learn from the practical application of the basics. A CS degree gives you the basics which if you've had a job programming any of the major languages for 6 months you will already have. A degree just opens up doors that you may not have otherwise - it doesn't help that much once inside the door.

Knowing how the software interacts with the hardware by the sounds of it is the most important area for you at the moment only then does the 'mystery' or 'magic' really disappear and you can be confident of what your talking about else where. Learning C and C++ will undoubtedbly help in this respect as will knowing an API like OpenGL.

But I'd say the most important thing is to find something you have interest in and code that. If you have real enthusiam for it you will naturally learn more low level information and become a better programmer, if indeed that is what your definition of being a better programmer is!

billythefisherman