4

I'm currently working with Java / C++. I'm interested in web development and am planning to shift my stream. I heard that PHP is a good platform to start off and also it does not require that much of knowledge in technologies like JSP / Servlets or frameworks like springs / struts / hibernate.

I have basic ideas about HTML and Javascript as well. I have gone through previous posts in SO and found out the relevant resources as well:

Now, my question is: I heard of PHP frameworks like CodeIgniter, Zend Frameworkd and Yii.

  1. Doesn't learning PHP & MySql implicitly makes us aware of these frameworks?
  2. Am I making a good choice in stating with PHP?
  3. Is it a good idea to shift streams?
yannis
  • 39,547
  • 40
  • 183
  • 216
  • 8
    Do web development in C++ or Java instead. I wouldn't touch PHP unless I had a job requirement for it. – Raynos Dec 18 '11 at 14:39
  • 10
    @Raynos Web development in C++? Are you out of your mind? :) – yannis Dec 18 '11 at 18:08
  • @YannisRizos meh, knowing C++ already I could write a high quality website in it faster then I could in PHP. The main point is using the tools you already know is the better solution in most cases. – Raynos Dec 18 '11 at 18:12
  • 2
    @Raynos Yeap but op states that currently working with Java / C++... Java is a much saner choice for web development, imho, if you stick to what you already know... – yannis Dec 18 '11 at 18:26
  • @YannisRizos it's personal preference. There are good tools for web development in Java and C++, each have their advantages and disadvantages. You might think web development in C++ is a nightmare but others will disagree with you. – Raynos Dec 18 '11 at 18:30
  • @Raynos I did try it once, a long time ago, still wake up at nights screaming... Of course my experiences aren't by default the norm - the same goes with your experiences with PHP :P (flamebait, don't take it...) – yannis Dec 18 '11 at 18:32
  • 1
    One of the best lessons for me was: surround yourself with the best people! ... and you will learn quickly. So if you have a chance, start off with a good language for web development. Haskell is a *very* good language for this. Ruby is somewhat okay. I guess everything is better than PHP. I you choose Haskell, you will read stuff written by *very* good programmers. Look up "Real World Haskell" and also "Learn You a Haskell for Great Good!". – mrsteve Sep 14 '12 at 00:31
  • 7
    "*I heard that PHP is a good platform to start off...*" -- oh dear god. [Don't. Just... don't.](http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/) Anything, anything, is better. Except maybe ASP. – tylerl Sep 14 '12 at 01:17
  • possible duplicate of [What should every programmer know about web development?](http://programmers.stackexchange.com/questions/46716/what-should-every-programmer-know-about-web-development) – gnat Sep 14 '12 at 06:10
  • @tylerl much of that article is outdated, innaccurate, or can be applied to pretty much any other language - there are some real issues with PHP (for example, there are double-claw hammers in the toolbox, but there are plenty of proper hammers, too - the biggest fault is that the double-claw hasn't been deprecated fast enough). – HorusKol Dec 27 '12 at 23:11
  • @HorusKol - Riiiight... it's already several *months* old, totally out of date given the break-neck pace of language development. Except no. It's still made by the same people, supported by the same community, and built around the same lack of understanding of fundamental Computer Science principles; which is **not** common to other languages. The current track of development is like patching a papier-mâché barge with roofing shingles. – tylerl Dec 28 '12 at 22:08
  • @tylerl woo, sarcasm - I feel suitably put in my place. Sorry, I should have said "many of the points in that article" rather than the article itself. – HorusKol Dec 30 '12 at 22:43

6 Answers6

14

Doesn't learning PHP & MySql implicitly makes us aware of these frameworks?

No, in fact PHP's creator advocates not using any additional frameworks.

See: "The no-framework PHP MVC framework"

Another thing is there are quite a few PHP MVC frameworks, neither one is the clear winner.

Am I making a good choice in starting with PHP?

No. I'ts a bad choice.

Technical reasons

  • it's horribly designed and it's a mess (see: "PHP: a fractal of bad design")
  • there is not language specification, only the implementation
  • OOP is just an add-on, it's not part of the core language
  • it's web only, all attempts to enter general purpose market have failed
  • typically used as mod_php which is totally obsolete server model
  • lot of parts that would normally be handled by framework (low level HTTP processing) are hardwired into the language itself. Thus alternative solutions are not possible
  • cannot use as asynchronous framework, because of above
  • it's not thread safe (thus limiting the choice of efficient webservers)
  • cannot self-host, always requires 3rd party webserver
  • terrible security record (see: https://softwareengineering.stackexchange.com/questions/62070/what-attributes-of-php-make-it-insecure)
  • while the language itself is open source, unlike other OSS projects it's not controlled by a foundation, but rather by a private company. Its business model is selling complementary products, which are not open source.

Career reasons

Is it a good idea to shift streams?

It's impossible to give general answer to that. But seems like a bad idea to switch to something which is regarded less and with inferior pay.

vartec
  • 20,760
  • 1
  • 52
  • 98
  • 2
    +1 for PHP is bad. I agree with all of your reasons except for "cannot self host". PHP, I'd argue is the easiest thing to self-host... although configuring it to actually work with your applications is another thing. – Earlz Sep 14 '12 at 18:14
  • @Earlz: what self hosting solution you have in mind? AFAIK, the only alternatives to mod_php are: CGI and FastCGI (FPM). Which of course require separate web server. – vartec Sep 15 '12 at 10:25
  • I almost downvoted you for being to nice about PHP. It's a horrible, horrible, language and the sooner people stop using it the better. *Perl* is much better for gods sake! (Me? Bitter about PHP? Yes, and all in just a few days of using it!) – Kristof Provost Sep 18 '12 at 09:33
  • 2
    +100000 for telling the truth about PHP and taking the risk of being flamed. – Tulains Córdova Dec 27 '12 at 21:17
9

Doesn't learning PHP & MySql implicitly makes us aware of these frameworks?

Nope. As @GrandmasterB mentions it's possible to work with PHP without any kind of framework or any other third party library. Nowadays PHP includes a native MVC framework. It's still in its early days, and mostly undocumented, but it works (for basic stuff).

But, there is no reason at all to avoid working with a framework. A framework is supposed to take care of common stuff and let you concentrate on the important stuff. Some do it better than others, but in general it wouldn't hurt to learn one of the popular ones. A couple of related questions:

But try to avoid Zend Framework at first, as it's not an entry level framework.

Am I making a good choice in stating with PHP?

Yes. Compared to the alternatives:

  • PHP is extremely easy to get the hang of,
  • Is widely deployed, I have still to find one hosting solution that didn't provide PHP by default,
  • Is web oriented, whereas most alternatives are general purpose.
  • It's portable across operating systems and across web servers1,
  • Its core is extendable via C and C++ (which you already know),
  • The manual is fantastic,
  • It's open source2,
  • It has a large and vibrant community,
  • It's the platform of choice for a lot of definitive web applications3

Not to say that many other platforms don't fit most of the above, but AFAIK PHP is the only one that fits all of them.

But there are quite a few traps:

  • One of the reasons it's extremely easy to get the hang of, is that it allows a wide range of paradigms, doesn't enforce anything and it's completely up to you to follow best practices. There's no reason at all you shouldn't be able to write brilliant PHP code, comparable to brilliant Java or C++ code, but there is almost none of the common safeguards against, well, not so brilliant code.
  • And because it's so easy and popular, it provides a sense of false confidence. The internet is full of crappy PHP code, that works fine but it's a horror to look at. And quite a few crappy "tutorials". It's up to you to apply good judgement and successively swim through the seas of PHP @#!$. When learning, that's quite a challenge.

Is it a good idea to shift streams?

That's unanswerable, it's definitely a risk. If it's one worth taking you'll have to decide for yourself.


Unfortunately PHP, MySQL, HTML and Javascript not a web developer make. There is a very long list of technologies and concepts involved, the accepted answer to the "What should every programmer know about web development?" question. It's a very scary list and of course it's impossible to know everything that's on it at first. But it's not the full list. You are not making a language shift, but a domain shift. The web employs an extremely wide range of technologies, and something new pops up every day.

And if that list doesn't scare you enough, I've assembled a few PHP specific ones, as answers to these questions:

It's going to be a very long road. To me it's worth it, but again you'll have to decide for yourself.


1 With minor tweaks across operating systems and not so minor but not that significant tweaks across web servers.

2 Which matters to me.

3 Examples: Wordpress, the most popular blogging platform, phpMyAdmin, the most widely deployed MySQL administration tool, and, ahem, Facebook.

yannis
  • 39,547
  • 40
  • 183
  • 216
  • "But, there is no reason at all to avoid working with a framework." There are plenty of reasons to avoid working with a _bad_ framework. – Raynos Dec 18 '11 at 14:40
  • @Raynos `There are plenty of reasons to avoid working with a bad framework.` Not plenty, just the one: it's bad. You don't need any other reason to avoid it. But the matter is discussed extensively on the two questions I link to... – yannis Dec 18 '11 at 18:09
  • "I have still to find one hosting solution that didn't provide PHP by default" - here you go: Google App Engine – vartec Sep 18 '12 at 11:56
  • @vartec Now you're trolling. GAE is a PaaS app sandbox, not a typical hosting solution. – yannis Sep 18 '12 at 18:18
  • I wouldn't be so sure. PaaS/IaaS solutions nowadays are the most typical kind of hosting. GAE, AWS, Azure, etc. – vartec Sep 18 '12 at 21:54
  • You missed one of the best PHP features: it has GOTO. – Tulains Córdova Dec 27 '12 at 21:19
  • @user1598390 goto is not a feature specific to PHP, a lot of languages have it (or variations of it). – yannis Dec 27 '12 at 21:24
4

PHP is fine to start with. You wont necessarily encounter frameworks. I've been coding in PHP for over 10 years now and have never used a 3rd party framework.

What I would recommend, is rather than immediately diving deeply into the language, is instead put a lot of emphasis on learning HTML, JavaScript, an CSS. The whole point, after all, of using PHP is generally to output something to a browser. The more you know the client side technologies, and understand them, the better off you'll be. The side benefit of that is those technologies are the same, regardless of the language you use on the server side.

GrandmasterB
  • 37,990
  • 7
  • 78
  • 131
1

In my opinion the language choice is not the most influential one. Good practices, knowledge of good software design and architecture, TDD, refactoring they all transcend the choice of a programing language.

Now in regard to your questions:

  1. Learning PHP and Mysql in my opinion doesn't necessarily make you aware of the frameworks. Most of the frameworks out there like Zend, Cake are the traditional MVC frameworks. They where all created with MVC in mind but they use what we call "convention over configuration". And these conventions might differ from one to another: like naming your view, how to pass variables to templates, how to render them and so on. Learning PHP and Mysql would definitely help you dive into their inner workings which could help a lot in the development process.
  2. The last two web apps I've done where one in PHP using Cake and the second Ruby using Ruby on Rails. My suggestion is to choose Ruby and Rails because it's learning curve is leaner and you can get things done way faster. A big plus is the community around Rails which is huge. If you want to implement something I would suggest first checking the gem list, you will be amazed the you will probably find most of the stuff already done by someone else.
  3. It depends on you and your future plans. A programmer in my opinion should be as complete as possible. I think that every developer out there should at least have a basic idea about web development. We should strive to learn and know as much as possible and considering the impact of the web nowadays we should definitely feel somehow obliged to know it's workings. But in the end it all comes down to your judgement.

Hope it helps.

Vadim
  • 547
  • 3
  • 5
0

Two words: Avoid PHP. It was great in 2002 (as was ASP) but in 2013, it's a horrible platform. For 2013 I would suggest C# ASP.NET (BTW, very different from horrible ASP from 2002) or Python. I'd recommend the following in the decreasing order of preference:

  1. C# language (ASP.NET or Mono as the platform. Though Microsoft's support and continuous refinement of the .NET platform deserves respect. C# v5 in .NET 4.5 is ridiculously elegant (lambdas, async methods, dynamic AND static typing etc). This from a former Linux kernel hacker :) ). This is especially true since you have a C++/Java background; you'll be productive really quick.
  2. Python (very close to #1 above, though MS is pouring a LOT of money and talent into .NET to pull away)
  3. Ruby (I personally prefer Python over Ruby)
  4. C++/Java (even if it's outdated, since you have a background in it)
  5. (other languages)
  6. x86 assembly
  7. smoke signals
  8. original ASP
  9. PHP (ok, so the above 3 were a joke to get to this)
DeepSpace101
  • 1,394
  • 5
  • 14
  • 26
-1

One of the best lessons for me was: surround yourself with the best people! Then you will learn quickly.

So if you have a chance, start off with a good language for web development. Haskell is a very good language for this. From my point of view, everything is better than PHP. If you choose Haskell, you will read stuff written by very good programmers.

-- Look up:

If it has to be something else, then use "Scala". If it has to be a scripting language, I would choose in this order: Ruby, Python, and as a last option Perl.

-- Why get interested in Haskell?

A career decision to switch to web programming in haskell (or scala, ocaml, etc.) is good as you can transition back to well paid programming jobs. There a multiple companies that search for haskell and ocaml programmers, as for example: Standard Charter, Citrix, Merril Lynch, Credit Suisse, and to some extend at Google and Microsoft.

Look at why google is interested in haskell:
http://www.youtube.com/watch?v=b9FagOVqxmI

I talked last week with Mark Lentczner and he is a really a very very good programmer.

BTW the snap framework, mentioned above, was initially created by google employees.

Also the advice of Donald Knuth might be helpful:
http://www.youtube.com/watch?v=75Ju0eM5T2c

--
If you need more information on how functional programming is used and why it is considered as one of the best options, look at:
http://www.youtube.com/channel/UCP9g4dLR7xt6KzCYntNqYcw

Also to be clear. I think a very good programmer can program very good in PHP and be productive in the language. BUT, very good programmers tend not to want to program in PHP. So my point is, use a language that very good programmers are comfortable with. You will break even a little bit later, but your investment on learning functional programming will pay off.

mrsteve
  • 450
  • 3
  • 10
  • I'm sorry but I have to downvote this, not because I disagree, but because it's not an answer to the question as asked. This isn't a discussion forum, and answers like this one is why all these Not Constructive questions get closed, because they quickly turn into debates. Please only answer the question, don't discuss it. – Roc Martí Oct 10 '12 at 00:00
  • it's a polite answer to the question ("Am I making a good choice in stating with PHP?"). Nicer then "PHP is a language created by amateurs for amatuers. It's among the worst options. (On par with using javascript to program servers.) – mrsteve Dec 04 '12 at 22:35