Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Possible Duplicate:
I don't know C. And why should I learn it?

My goal is to be able to create online apps and dynamic, database driven websites. For instance, if in the future I get the idea for the next Digg or Facebook, I want to be able to code it myself.

To arrive there I think I have basically two paths:

Path 1

Start at a basic level, learning C, then C++ for OOP, then algorithms and data structures, with the goal of getting a solid grasp of computer programming. Only then move to PHP/MySQL/HTTP and start working on practical programming projects.

Path 2

Start directly with PHP/MySQL/HTTP and getting my hands dirty with practical projects right away.

What would you guys recommend?

share|improve this question
3  
Possible duplicate - programmers.stackexchange.com/questions/14744/… –  ChrisF Dec 28 '10 at 13:17
show 3 more comments

migrated from stackoverflow.com Dec 28 '10 at 13:14

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Mark Trapp, bigown Dec 28 '10 at 23:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

21 Answers

Here's the $100,000 question for you: is developing web sites the only thing you want to do? PHP is a very domain specific language, but arguably has a fairly low barrier of entry. I wouldn't call it object oriented, because that isn't it's focus. PHP exists for one reason: web sites.

If you ever have the possible idea to go in other directions in your carreer, I highly recommend learning on a more traditional language. It doesn't have to be C/C++, it can also be something like Ruby, Python, Java, C#, etc. Each of these are pretty good object oriented programming languages. That said, object oriented languages aren't the only way to do programming--even though it appears to be the most prevalent (at least it has better marketing).

PHP is also just one of many ways to do web programming. You have a host of options with Ruby, Python, Java, and C# (as well as Smalltalk if you are so inclined).

share|improve this answer
6  
+1: learning Ruby, Python, or Java will give ample opportunities in the web development arena. Pick up PHP after you know a real language, so that its "quirks" don't infect your other coding. –  syrion Dec 28 '10 at 14:04
1  
Not Ruby!!! –  Nathan Osman Dec 28 '10 at 16:44
3  
@George, why not? –  Berin Loritsch Dec 28 '10 at 16:58
6  
I don't know who you've been listening to, but I've had nothing but good experiences with it. I might venture to guess that the neigh-sayers aren't as proficient with the idioms and practices of the language. Once you do, you'll long for them in other languages. –  Berin Loritsch Dec 28 '10 at 17:23
3  
I want to add that sever side technology isn't everything when it comes to web development. I would tell you to learn (I meaning really learn these not just "Oh, I know how to make a link") really learn HTML, CSS and Javascript. Many people focus on the server side tech, which is important, but neglect the foundation of a web page. –  Carlosfocker Dec 28 '10 at 18:56
show 4 more comments

Huh, this got migrated as I was composing my answer on StackOverflow. Oh well.

First of all, you do not need to learn C before learning C++, and in fact I wouldn't recommend going that route; a well-written C program doesn't look or behave much like a well-written C++ program. There's a popular superstition that you need to learn C first in order to be a "real" programmer; this isn't true (besides, Real Programmers use Fortran). C's just another language with its own set of advantages and disadvantages. One of the bigger disadvantages is that it is a horrible teaching language.

As for Web programming, neither C nor C++ are all that popular, and can safely be skipped. I've done a little programming in PHP, and while it's good for small, quick-n-dirty work, my impression is that it's not appropriate for anything on the scale of Digg or Facebook (which are projects far beyond the capabilities of any single programmer). My experience with it is very limited, but I've heard very good things about Python.

share|improve this answer
1  
@Charles: if you really need to learn low-level details, learn assembler. The fact that a lot of modern infrastructure is built in C is an accident of history more than anything else. It really is just another language in a long line of systems programming languages. Just because it forces you to roll your own containers before you can get to work solving the actual problem doesn't mean it's teaching you anything useful. –  John Bode Dec 28 '10 at 19:23
1  
A lot of things we take for granted today are accidents of history - that doesn't change the fact that C's current place in existing software infrastructures, accidental or not, is certainly something special. –  Charles Salvia Dec 29 '10 at 14:33
show 1 more comment

I would pick option 2.

I do agree that if you have C++ or C background it helps. but if you don't - just skip it and lean to properly use the tools that you need.

This does not mean however that you should not learn stuff like OOP, Algorithms & Data Structures. It just means that you can do all that using PHP.

share|improve this answer
1  
Definitely. I'd recommend learning about databases (normalization and tuning), but for an awful lot of web projects, PHP is perfectly fine. Start with the basics, add some AJAX goodness, and you should be good to go. Of course, if you're going to do this for money you should spend some time learning "proper" development, as @epeleg suggests, but I think you can defer that until you figure out what it is you want to do. –  TMN Dec 28 '10 at 15:55
add comment

Answer: No. Don't learn C/C++ yet. In fact, never learn C++ unless your education or job requires you to. It's not worth it. C, however, is very useful to know, but see it as "advanced" and learn it once you need to.

So definitely get your hands dirty. But don't limit yourself to just PHP. Nothing wrong with PHP, but...well, yeah, actually there's plenty wrong with PHP, but it's good enough and there are a lot of jobs in it. But instead of C, also learn Python (which also has loads of jobs) and a functional language (to get perspective). It's also unclear if you already know PHP or not. If you don't, I suggest you start with learning to program using Python, which is a great beginners language.

Then learn C when you need to, for example if you need to write a C extension to Python for performance reasons, etc.

share|improve this answer
1  
I didn't say it was wrong. I recommended him to do something else that IMO is better. That doesn't mean one is "Wrong" and the other "Right". –  Lennart Regebro Dec 28 '10 at 17:19
2  
I completely agree. There is no need to start diving into managing your own memory until you have to - there are definite merits to learning to use other languages than PHP but C/C++ are not the ones I would recommend until you're really ready for them and you need features that nothing else will offer you. Or you want to. Either works. –  glenatron Dec 28 '10 at 20:07
2  
Also: C is small enough to be easy to learn. C++ takes years to become a master, which might be off topic for what the OP really wanted to do (web programming) –  RyanWilcox Dec 28 '10 at 20:13
show 1 more comment

First path is the long one, but it will give you a solid background in programming. You'll understand the concept, which is the most important if you ask me. Then the programming language becomes just a tool, you stop thinking about a language, and start thinking about the problem domain. Go for C/C++, understand the pointers, and references, recursion, etc.

Bottomline. Learn how to program, this practice is language independent.

share|improve this answer
add comment

Start getting your hands dirty with PHP. When you notice that you need more than that, that's the right moment to start learning e.g. C. Getting too much knowledge at once, without practical application, will only confuse and demotivate you.

share|improve this answer
add comment

You could start at a basic level with PHP (PHP5 is OOP) directly.

Anyway you should consider doing algorithmic and data structures, this is the basic knowledge. Know how to transform your way of thinking into code, data, etc... and then apply it.

Iy you start directly with coding, you may be better in the first time because you'll have practical knowledge, but this doesn't mean you'll be able to write code efficiently.

share|improve this answer
show 4 more comments

Digg and facebook are both extremely high traffic sites and you need to know more than just php to make anything as scalable.

On the other hand unless you get put on the front page of Digg, you won't need to scale for a while.

Ultimately it's your choice and nobody can make it for you, but from personal experience, learning about and implementing data structures is lots of fun.

share|improve this answer
add comment

I don't see the point of learning C or C++ in order to do web programming. They're great languages to learn, sure, for a foundation in software development. If you really want to learn OOP, pick a language that is object-oriented in nature, such as C#. (Disclaimer: I am a C# / ASP.NET web programmer). With C# (or similar languages) you can learn object-oriented concepts at the same time as learning web programming. That way you can create something practical fairly quickly.

share|improve this answer
add comment

I love PHP, but it is not the best language to learn programming, as it is very permissive and sometimes encourages dirty programming habits.

Getting a solid foundation in clean C or C++, and OOP first and then switching to PHP is definitely an option worth considering. You will have little trouble learning PHP afterwards.

share|improve this answer
1  
@Pekka I'm surprised at you! You know this question is off topic and duplicated many times. Why answer? –  C. Ross Dec 28 '10 at 13:10
show 2 more comments

If you want to do web programming then skip the C and C++.

I would suggest you start with xhtml, css, and javascript, since these are at the core of what you want to do. When you no longer have to look up anything about these 3 subjects then you will have a rock solid foundation in web programming. One more thing, take a deep dive into object oriented javascript and don't just play around with the DOM.

Good luck, stay focussed, and have fun.

share|improve this answer
add comment

Do it for fun and knowledge, it will actually make you a better programmer. Knowing C/C++ will give you an excellent perspective of what other languages lack in "power" and how they make for it with simplicity and/or domain-specific features.

Personally, C/C++ has given me some insights on how js and PHP work underneath without having to ponder much about it (e.g. the delete operator and copy-on-write/pass-by-reference respectively).

share|improve this answer
add comment

Digg and facebook are both extremely high traffic sites and you need to know more than just php to make anything as scalable.
You don't. At least for digg. It's very simple data model. Facebook is a different story, but 90% of the time you'll be scaling database than webserver. With opcode caches you can get webserver machine to connect to several saturated DB machines, and on the webserver side you won't even notice any load.

I'd try C++ first (before any high level language like PHP/Python). Or any language that allows you to play with algorithms (Pascal)... it's always big difference when you know how the things actually work instead of just doing eg. sort($x)

share|improve this answer
show 1 more comment

I strongly recommend that you spend some time getting to know your way around C. At the least, get enough under your belt where you work through exercises that show you just how tricky memory management can be.

A great many PHP programmers do not know how pampered they really are when the following code 'just works'

$foo = array();

Even $foo = "string"; is something to appreciate.

I'm not suggesting that you chase a language that you are hardly likely to use, but I would recommend getting to know it to the point where you can appreciate other languages more.

share|improve this answer
show 1 more comment

I don't think it is neccesery to know C. While it is a simple language it is very difficalt to use. C++ is a vast language (maybe 10 times the size of C).

If you are getting started, Then start with the non programming languages that you suggested (html). Then look at scheme try this ebook http://mitpress.mit.edu/sicp/full-text/book/book.html After that try eiffel, its a very fast, easy to learn OO language.

share|improve this answer
show 1 more comment

The benefit of learning any strongly typed language like C,C++,Java helps you understand the basics of programing. Secondly before learning any database applications try to learn about the RDBMS and basic SQL.50% of your job is done here.After that learning anything like MySql,Oracle etc will be much easier.

If you want to be a web programmer then i will prefer learning C and (C++ or Java) first.Then go for PHP .It will be very easy to grasp.

share|improve this answer
add comment

There's only so much you can do with the whole PHP stack. If you want to make a career out of programming, web and otherwise, you should not base it off of PHP. For all you know, it'll be gone in a few years.

I recommend learning C first, skip C++ and learn Java or C# (and OOness, design patterns) while learning PHP. You'll find that it comes down to your knowledge of the fundamentals and technologies and not the specific languages.

PS Web programming kicks awesome butt! Good luck!

share|improve this answer
show 5 more comments

The trick is to learn each paradigm from a language that does it well.

Learn a statically typed OOP language like Python, C#, Java etc.. Learn C for the low-level systems. And if you have time, learn Haskell, Scheme, Lisp etc. for functional/declarative programming.

My first language was C++. It took me years to unlearn the quirks and bizarre hacks.

share|improve this answer
add comment

My re-introduction to PHP, which was required for us to just pick up in a few days for a final project in a Database class at UW-Madison consisted of, "if you know C++, then you should know PHP, just remember to use dollar signs"

If you don't do OOP and you actually like to program, you'll learn 'em simultaneously. The only hangup with PHP is when to use -> and when to use => and for that I'd really suggest actually reading a book to learn PHP, not just picking up what you need off the internet.

I think that's probably the only way to learn C++ as well. Don't fret about C though, I mean if you're in high school, then go learn C - otherwise forget about it.

One fun thing you may be able to do if you master them simultaneously is write extensions for yourself.

The thing people despise PHP for is that it is often coded as if it was a bunch of throwaway batch files - and that's what you need to avoid if you're going to make it as a web programmer. People despise C++ code that looks like C code for the same reason.

Go the distance with your code (in PHP use classes instead of infernally nested arrays; in C++ use classes instead of infernally nested struct's) and it will go the distance for you

share|improve this answer
add comment

Go and learn the basics: C and then C++ for OOP. It's important to understand those languages before learning high level languages. Although learning PHP as a first programming language can be possible but not recommended.

share|improve this answer
2  
I've also seen it go other way round: People who understand how things "really" work at lower level look like they're trying to fit a square peg into round hole when learning high level languages. When you know (or think you know) what's going on under the hood, it's hard to resist doing all kinds of silly optimizations. For example, I've seen people setting object references to null in Java to "facilitate garbage collection" instead of just letting them fall out of scope, caching test expressions in for loops (when the compiler would actually do that for you) and such "too smart" stuff. –  Joonas Pulakka Dec 28 '10 at 13:46
1  
@Charles Salvia: I think it depends on what one is aiming for. If you want to do just web programming (the question's title is Should I Learn C/C++ Even If I Just Want To Do Web Programming?), then yes, I suggest that it's better to not learn C/C++. The point is that you're not getting paid for what you know. Nobody cares about that. You're getting paid for producing good enough, working code. And to produce good enough, working PHP / MySQL / HTTP stuff, knowing C/C++ is about the least important thing you need. Time is always limited, so focus on e.g. CSS, Javascript instead. –  Joonas Pulakka Dec 28 '10 at 14:28
1  
C++ for OOP is terrible, sorry. The very term 'OOP' was invented by Smalltalk crowd; Smalltalk or Python or Ruby are good for learning about OOP. C++, like Fortran or even C, is a necessary evil when you need high performance and know the underlying mechanics well. –  9000 Dec 28 '10 at 15:51
show 3 more comments

I would start learning python the most beautiful programming language I know. Then if necessary trying to learn dirty things like PHP.

share|improve this answer
show 2 more comments