Tell me more ×
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.

I want to be a .net developer for the web. However, I see most freelanc developer tend to provide PHP development more than ASP.NET. The question now, is it OK if I learn PHP first and after that I go with C# or will this learn me bad habits that can lead to difficulty in learning C# or maybe I can't pick it up the right way as if I start with it?

Please give me some facts about learning both and where I should go first and why?

share|improve this question
1  
With effort you can write beautiful PHP code. I admit, it is easier to do so in C#. – Job Dec 1 '10 at 13:28
2  
I learnt PHP before C#. I don't think it harmed me. But then, I don't get to see me from the outside :D – Matt Ellen Dec 1 '10 at 13:36
"will this learn me bad habits" that is so shortsighted. – Stephen Dec 1 '10 at 13:37
1  
While there is nothing wrong about learning PHP, your reason for starting out on PHP is vague at best. If anything you should want to start with C#/ASP.NET because there are already plenty PHP freelancers on the market. If you want to learn C#, go for it. – eBusiness Dec 1 '10 at 21:17
5  
Learning PHP after C# may be painful ;-) – Alison Dec 2 '10 at 11:54

10 Answers

I think this whole idea that the first language you use can "corrupt" you or something is an overblown myth created by Dijkstra's offhand comment "It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration". That was a tongue-in-cheek comment bashing the language itself. People have taken it to mean "OMG I DONT WANT TO LOSE MY VIRGIINITY 2 DA WRONG LANGUAGE!" Then the programming community makes it worse by making someone who played around with BASIC feel bad about it by rolling out Dijkstra's stupid quote all the time.

I suggest learning any language that's practical, but keep an open mind.

share|improve this answer
12  
+1 for "OMG I DONT WANT TO LOSE MY VIRGIINITY 2 DA WRONG LANGUAGE!" lol – Darknight Dec 1 '10 at 12:50
Let me guess. You started out on BASIC? Seriously though, I think this is a bit of a strawman. Yeah, if you're really into programming, you'll be able to unlearn any bad habits you pick up. On the other hand, that doesn't necessarily mean it's the optimal way to learn. I absolutely agree that the most important thing to do is find something you want to do and then sit down and do it. But don't kid yourself into thinking that some languages don't provide better foundations than others. – Jason Baker Dec 1 '10 at 21:07
2  
I used to have Dijkstra's comment on my whiteboard at work, just to piss off the VB.NET programmers who sat nearby. :) – Powerlord Dec 1 '10 at 22:21
1  
@Jason Baker: but you'll probably learn more about what's good and what's bad if you experience both. Seems to me that most programmers start out trying to solve a problem, they do, and then they go, "hey, I keep running into these same problems... if only I could do this or that, etc.". That's when you start to understand the reasons why professionals do things a certain way. Even if someone tells you why, you probably don't "get it" until you experience it. – Scott Whitlock Dec 1 '10 at 22:23
1  
Fully agree. If you think that way about programming languages, there is not really much left to start with. Starting with PHP makes it difficult to lean C#? But starting with C# makes it difficult to learn Ruby or Python or Scheme or Haskell. – thorsten müller May 1 '11 at 6:38
show 1 more comment

PHP will simplify how the web works instead of hiding it under layers of abstraction as ASP.NET does.

Its not so obvious to someone brand new to web programming that a control in an aspx actually generates HTML on the client. Its not so obvious that the browser doesn't have any idea what asp.net is. Add that the complexity of postbacks and viewstate and the stateless nature of HTTP itself and you're asking for trouble.

PHP on the other hand simply produces HTML - end of.

Once the OP has got a solid grounding in web programming and how the server communicates with the browser then they will be able to understand the .NET way of things (just don't keep putting inline HTML in your code!)

share|improve this answer
1  
+1 for reducing asp bloat code. – Josaph Dec 1 '10 at 12:16
1  
Or better yet, don't ever put inline HTML in your code. This is one of the worst things about PHP. I would advise that the first thing OP learn is how to use extract and output buffering to create a 4 line template system. – aaronasterling Dec 1 '10 at 12:18
@AaronMcSmooth "don't ever put inline HTML in your code", agreed! However there are far better ways to separate things. :-) – Orbling Dec 1 '10 at 20:00
1  
It was hard not to vote for Scot Whitlock's answer, but I'm giving a +1 here because, like Orbling says, you need to know how stuff works, and ASP doesn't really help you do that. But a nod goes to Scott's answer as well, because it's better to start with some language than no language at all. – bogeymin Dec 1 '10 at 20:46
4  
Just use ASP.NET MVC and all of these problems are moot! – Nathan Taylor Dec 1 '10 at 21:02
show 2 more comments

I would learn whatever is most beneficial to you at this point in time. If the kind of projects that you would like to work on use a lot of PHP fameworks/features, learn that, if there are features or components of C# that would make your chosen work easier, go with that.

They are both very different beasts, but I don't think that learning one will hinder you in learning the other. Previous meaningful experience in one will shape your thinking and I believe will make it easier to transfer to the other.

Remember, a programming language is just a tool to get the job done, it's just that some are more suitable that others in a particular situation!

share|improve this answer
2  
+1 for "Remember, a programming language is just a tool to get the job done, it's just that some are more suitable that others in a particular situation!" – Stephen Dec 1 '10 at 13:51

Anyone who references a bad programmer's work (or lack of knowledge, for that matter) in order to conclude the worth of their chosen language obviously never understood the principle of "correlation does not imply causation."

So, Goma, you can ignore those answers and comments. They are of little worth.

On to the matter at hand, @Scott Whitlock's advice is best:

I suggest learning any language that's practical, but keep an open mind.

In your question you state that you want to be "a .net developer for the web." I argue that you are selling yourself short.

Good programmers are not PHP Programmers or C# Programmers. Understanding a range of languages/tools, and more importantly, getting-things-done is far better than boxing yourself into a package like .NET Programmer.

You will likely benefit not only from the things you learn about statically typed languages (Java, C#, Pascal), but also dynamically typed languages (PHP, Python, Ruby). More important is that you learn what the difference means between the two. And that's just one example.

Understanding why your tool behaves (not how it behaves) is key to becoming a better developer.

You likely "see most freelanc[sic] developer tend to provide PHP development more than ASP.NET" because PHP has a very low entry barrier. Also, many small companies (those looking for freelance work) opt for a LAMP stack due to the cost factors associated with the alternatives.

Don't let any of that get you down. If you apply yourself, while keeping and open mind, you can stop worrying about where to start, and just start.

I recommend starting with C#, if that's your goal. You should also spin up a couple of PHP projects in your spare time so that you can compare the two.

share|improve this answer
1  
+1 Excellent answer, particularly highlighting the root cause of the prevalence of poor PHP code on the net, low cost of entry resulting in a high proportion of amateur coders compared to more costly markets. I know VS Express is now free, this is a relatively recent development, the free and easy market is still dominated by LAMP; LAMP hosting is usually cheaper too. – Orbling Dec 1 '10 at 20:08
+1 - Words of truth - "Good programmers are not PHP Programmers or C# Programmers." – Karthik Sreenivasan Jan 20 '12 at 12:28

Learn PHP and than .NET. Remember difficult is a relative word :-)

Good Luck !!

share|improve this answer

A friend of mine just went through exactly this. Coming from a pure PHP background, he had serious problems trying to grok the idea that some things are string, some are ints and some floats etc. Also type casting and null values was a struggle from him. He had never been subjected to those concepts at all before this, so I can understand his confusion.

Judging from this, I think it will be harder to learn C# if you're coming from a PHP background.

Update: This is an actual real life example of what I think the OP might end up with. The comments below seems to blatantly indicate that my friend is a retard for having these kind of problems. I DON'T AGREE. He's your average PHP programmer, going from a dynamic high level scripting language to a low level, typed language, and that is much harder than the opposite.

share|improve this answer
2  
Sounds like your friend was just a bad programmer. – Stephen Dec 1 '10 at 13:49
+1, know a PHP guy (and quite good in PHP really) who was convincing me that C++ sucked "because of the templates". That just proves that PHP tends to stimulate the "effortless" work (thereby slowly killing off any brain agaility). – Jas Dec 1 '10 at 14:08
1  
@Stephen: Not brilliant, but then again. He had only been using PHP, so I can understand his problems with a new paradigm. – Martin Wickman Dec 1 '10 at 14:12
@Jas, I'm sorry, but: How does "I know a guy who was stupid" prove anything? – Stephen Dec 1 '10 at 14:47
1  
PHP has null... – Macha Dec 1 '10 at 20:08
show 3 more comments

Let me prefix this by saying that I don't think that PHP will corrupt you for life, nor am I saying that PHP isn't useful.

However, if you have the choice, I would recommend learning C# first. PHP allows you to write good code. But it also seems to do little to encourage it. It is incredibly easy to pick up bad habits. Thus, my recommendation is to start with C#. If you have a strong desire to pick up PHP first, then do that. In my experience, that is far more important than anything else. Just remember that you might be learning some bad habits that might need to be unlearned when you start with C#.

However, if it were me learning, I think I would do much better starting with C# and then moving to PHP.

share|improve this answer
1  
+1 for remaining objective. I like your statement: "PHP allows you to write good code. But it also seems to do little to encourage it." – Stephen Dec 1 '10 at 22:27

As an ASP.NET developer you have almost completely different set of tools to work with (database, design tools, IDE). I would recommend you to jump to C# directly and use jQuery for Javascript since it’s also supported by Visual Studio.

share|improve this answer

Why not learn C# first, to grasp important concepts and generally get a proper starting mindset, then learn PHP. You will benefit in several ways, most importantly it will be easier for you to pick up a "language" like PHP once you are proficient in one of the real programming languages (be it C++, Java, C#, Ruby, or Haskell).

share|improve this answer
I argue that if you cannot "grasp important concepts and generally get a proper starting mindset" learning ANY language, why would learning C# first benefit you? – Stephen Dec 1 '10 at 13:48
2  
Because it's next to impossible to get a proper mindset when starting off with a no-design language like PHP. What Dijkstra said about BASIC still holds on today for PHP. But then again, knowing this simple fact requires one to know both sides of the story. – Jas Dec 1 '10 at 14:03
-1 For saying PHP is a non-real, no-design language. It has practically as many decent and poor design features as all the other languages. The fact that you are unaware of this is not reason to condemn it, as you say, you need to know both sides of the story. – Orbling Dec 1 '10 at 20:11
@Orbling - Uhm, you downvoted my ANSWER for a statement in my COMMENT? Now that's something new. And yes PHP is not a real, well designed language. It basically is a badly patched together selection of multiple paradigms. Don't take it personally, PHP sucks. – Jas Dec 1 '10 at 20:32
1  
@Jas My comment included parts of your answer and indeed the comments which were running on. PHP is a real language, obviously. I am not taking it personally, it is not my "chosen" language, I use and know most significant coding languages where appropriate. Your point was just wrong, don't take it personally. – Orbling Dec 1 '10 at 20:35
show 5 more comments

I want to be a .net developer for the web

Why would you even consider PHP (see here and here for some reasons not too).

The biggest reason for me is that embeds the biz logic in the view, going against widely quoted best practice: the mvc(model-view-controller) principle. If you have ever worked on a large project this is a real pain.

It literally hurts my brain to read though html picking out the php.

C# first and if you are lucky you may never even have to code with PHP.

share|improve this answer
-1 "embeds the biz logic in the view...". No, PHP offers plenty of MVC frameworks that provide proper separation. See Codeigniter for example. – Cory House Dec 2 '10 at 17:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.