Wednesday, February 23. 2011
Posted by Thomas Koch in Debian, english, eZ Publish, free software, PHP
Yesterday I had my last day at $company and today is my first day in freedom. I'll write about my future plans in another blog post. Here I just want to express the joy I had yesterday afternoon when I did:
aptitude purge php5
I've started using PHP in 2006 and used it almost exclusively until the end of 2009. I believe I've learned most of what one can learn about PHP in this time. In 2010 I started to work in Java and only started to understand how limited PHP is.
I know that java is far from perfect. So I don't stop there and already started to learn Scala and looking forward to learn other languages too. But Java is for sure a better answer then PHP, regardless what the question was.
There are many reasons, why you should not, never, for no project ever use PHP. I'll only tell you my personal top reasons:
Display comments as (Linear | Threaded)
Without willing to sound harsh, this exact post shows one thing, you are still a young lion, not really understanding today's business
tip: watch our (johann and me) IPC 2010 keynote, or my SfDay's one.
PS: so we can remove you from planet-php right?
Yes, please do remove me from planet-php. The only things I might write in the future that could be interesting for a PHP developer, are what other nice things are there outside of the PHP world.
Thank you for your nice comment.
You are welcome, and as I said it was not meant to be harsh. But this post is the perfect example of so many young (not necessary age related but experiences) developers get wrong.
Not the language make code unmaintainable, the bad developer do.
Maybe you were not able to produce clean, structured, decoupled and reusable code with PHP, but I say, its still possible to produce such code in PHP.
Yes, you can say, php allows you to produce very bad code, and that java makes it a lot harder to do so. I have not seen much java code in my life, but i can say, even in Java you could produce bad Code.
Maybe no one will notice it, because your compiler dont say anything about it, but sometime someone could come and say "thats shit, we need to redo it from scratch"
Iam not the type of developer who likes to bash a language, because it makes no sense. There is no real bad Language out there. You only think so, because every developer has other tendencies and so every developer is attached to an other language.
In response to your points:
1) The advantage? Less bookwork, and more flexibility in passing vars into functions and methods creating a lower level of prototyping. In Java a function that must handle both strings and integers in the same function argument must be overloaded. In PHP you can do a type check in a single function.
2) XDebug and var_dump are great tools. I've spent time talking to some of the founders of the computer world, many of the engineering greats both present and past dump their variables to the screen. Even without that Zend provides some tremendous tools for inspecting running code and setting debug points (I just don't use them).
3) PHP5 is much more similiar to C++ than java, java also took alot from C++ so the similarity is understandable.
4) PHP is chosen for many reasons, and the reality is that for many projects the best language is really quite arbitrary. Availability of talent and price do become the biggest factors, I can assure you that having worked on many many codebases in many many languages Java is far from innocent in the maintainable code world. I have worked on java code that is abstracted so far that it's nearly impossible to work on, you see this is a tendency in java, abstraction to the n'th degree, sure its pretty but refactoring can literaly be a nightmare when classes are abstracted 10 or more levels of inheritence further than they need to be, not to mention how expensive it is in time to do the extra programming.
Certainly Java has its place, but saying that there is no correct time to use PHP is blatantly incorrect, many of the problems you refer to are problems of management and not engineering.
Hm, I like PHP very much. Of course not everything is perfect, but what is perfect?
There are many frameworks like Zend, Symfony, etc which help one to build good applications.
Magento is one example of a well constructed eCommerce solution, written in PHP.
This is somewath true but ... A good developer ends up knowing the language and creating good documentation phpdoc. If you use Zend Framework 2 ends up being very similar code to Java. A few details that you miss to mention is that PHP uses less memory and is faster then JAVA.
PHP 5.3 also came to add some ways to keep developers sincronized.
So you posted this to Planet PHP and the fan boys are here; fun.
Anyway, to be somewhat honest: Why should one use Java? You might have gone from PHP to Java without weighting alternatives. You might feel just as wrong about Java as you were about PHP in three years time.
Welcome to level two. At level two you pretend to understand everything. The truth is that you are still a newbie on the level two. Although your self-confidence might tell a different story. A couple more years, and you might get to the level three. It seems that you have found your silver bullet in Java. Later on you will understand that you didn't.
You just moved away from spaghetti, but without guidances, you will probably end up with lasagne. You might also learn things hard way. And yet, this has nothing to do with the programming languages.
So you are no longer working for $company, where presumably you had to use PHP. Do you have a new job where you get to use Java? Or are you now self-employed? Or independently wealthy? (:
Okkkkk ... so in college they forced me to use Java and I hated it. I still can't bare to use any language except PHP. You know what that proves? People don't like being forced. That's about it. I can write anything in PHP you can write in Java, and of course, vice versa. You know what that proves? Languages are about personal preference. Keep yours to yourself.
I agree with you Thomas.
Of course using php env and tools we can create good or even great apps, but the community of programmers and people involved into php's projects are in many cases weaker and worse developer than avarage java developer. in many cases they are typical scriptkiddies. of course in last years we received great libs like : PHPunit, symfony, zend etc, but only that libs are great. often projects created by means of that sucks (are unmaintainable etc, not well tested) and it's because in php community is too much weaker developers that should be.
unfortunately I've been developing apps in php with the same sins. but now I also realised that I have to escape from that world and I do it since few monts.
I don't want to offence any php devs but that's my point of view
Congratulations on freeing yourself from PHP! I started using PHP without knowing anything about it as a desperate tactic for getting my first job out of college and now I don't know the proper trajectory for getting away from it.
So how do you finally land the job that uses Java (or any serious language) without already having 5 years of experience using nothing but Java?
how to get away from PHP while being trapped in a PHP shop:
- learn as much object orientation in PHP as possible
- Introduce Java projects and tools (SOLR, Hadoop, Jenkins, Eclipse) and get into those java projects
- Invest many evenings at home to learn Java (and the java standard libraries)...
Once you feel confident enough in Java, quit the PHP shop!
Neither the post nor the commets mention python, which is as powerfull as java.
Here is a nice screecast:
its always nice to finally feel like you have found the tool that makes you most productive, sometimes its not always the most popular one. good luck moving forward, but don't feel like you couldn't ever use php again, hey you spent all that time learning, might as well cash in on it again sometime in the future.
I find it fascinating you believe that in 3 years you have learned "most that one can learn about PHP."
I think that's fantastically naive. So folks that have been doing PHP for 10 years have not learned anything new for 7 of them? It couldn't be that PHP continues to grow and evolve--that would blow away your premise.
There's certainly a lot more to PHP than can be absorbed in 3 years.
I agree with others, PHP can't save you from a bad developer. I'm 4 years in and still there's a bunch of PHP I haven't tackled yet. Is it the perfect language? No, but its assets outweigh its liabilities and the scale continues to tip in PHP's favor as the language improves over time.
Measuring the ability to grok a language or more precise one's knowledge of it in years feels incredibly wrong to me.
I agree. In PHP's case, since there's no language specification, to know PHP one needs to know the C code behind the interpreter.
Regarding your opinion that Java is superior to PHP, I just have to respond that it depends. If you quickly need something to get started and don't need your application to scale into infinity you are probably better of with PHP. And of course you are right, PHP developers are usually cheaper but that's mostly because it's easier to get them started learning the fundamentals without being overwhelmed by large IDEs (and Eclipse teaches many newbies respect), dependency problems etc. As a (beginner-)PHP developer you are happy with a good editor. Most PHPers can start Web-Development on their own - Web Spaces supporting PHP are cheap, try to find the same for Java. Of course, Java is not a bad language at all. There are many great frameworks, libraries and technologies out there. And as Java has huge utilization in the enterprise field and is already around for quite a lot of time, there are many tools that may be of great support to you.
I wish you all the best for your future but I suggest, that you don't lay your full attention to the language but also try to think more abstract. Study Design Patterns (http://en.wikipedia.org/wiki/Design_Patterns_(book) is a good start for that - I can really recommend you that book) but also learn when they make sense to use, study architectures of large software solutions but don't make the mistake to over-engineer your code. And most importantly don't let the tools you use keep you from thinking.
I'm disappointed. You should know me better. I've already read several books about design pattern.
Hope to see you soon!
no need to be disappointed, I was sure that you already read several books about that topic. It was more a general hint, that you (and of course all the others reading this) should think in more abstract concepts than a programming language and its eco-system.
Regarding another comment, it's true that nothing forces you to build the ten-layered, complex java monster, but java makes it all to easy to go that way sometimes. And sometimes even that monster might make sense.
The pragmatic programmer is also not a bad suggestion.
Hope to see you soon, too.
Just take a look at this movie: http://ia700209.us.archive.org/14/items/SeanKellyRecoveryfromAddiction/Recovery_from_Addiction.mov
Thank you, but I've already seen this movie like two years ago.
The movie may be right in the point that some/many Java people tend to over-engineer.
However I believe that there's actually nothing in the language itself that forces you to build the typical ten-layered, complex java monster.
There are many places where Python is a much better choice then Java.
Just a link:
The only silver bullet that exists is knowledge.
I suggest you read the pragmatic programmer and the [url url=http://www.amazon.com/Refactoring-Improving-Design-Existing-Code/dp/0201485672]refactoring[/url] book before you move on.
I spend my time 50/50 in PHP and Java - they both solve problems, but often different ones.
"The resulting projects however become a mess of unmaintainable code sooner or later."
If you are not able to deliver a clean project, you are simply failing at PHP.
No Java or whatever language will save you.
So basically, you don't like PHP because:
- There's no good tools. That's not an argument, IMHO, to comment on the language itself...
- You don't like types and OOO in PHP. Well, types really sucks in Java, have you ever seen streams being casts 2 or 3 times in a raw in the same source? Well, if you didn't it means you didn't play enough with Java streams. Then for OOO, well, PHP is meant for fast and easy coding, not for 100 years of OOO design before you code, and for the same reason you don't bother with casting in PHP. It's a mater of tastes really.
- Then your last argument is the most stupid one: code quality level. Basically, you are saying that because PHP is easy to use, the resulting code quality is crap because everyone can do it. That's really silly: get a good PHP coder, the code quality will be good. Get a bad Java coder, and you know the result. This really isn't an argument.
Nice try, but you really didn't make your point here, and it feels like copying things read elsewhere.
Why is Facebook not rewritten in Java? Or Digg, Flickr, Yahoo...
Congratulation! My personal experience is, that each language you learn makes you a better programming. With Scala you are pretty far ahead of the crowd. If you are looking for other language that are worth learning, consider Haskell. It is a very advanced, strongly typed, purely functional language. It may be very demanding at first, but very well worth the effort. And if you get it, it will make you a better programmer, even if you end up using Scala, Java or even PHP (perish the thought!) at your day job.
Languages are just tools. The right tool should be used for the right job. You should never forget that and be religious about a particular language.
Are you sure that Java is what you really want to focus? Just think about how productive you'll be using a static typed language. IMHO static typed languages should be used only when the performance of dynamic languages is not sufficient, which nowadays is not the usual case.
I think that you should study more about SE practices and then you'll be able to write good PHP code (and indeed much faster than Java). Usually people don't like a language because they write spaghetti code (not OO and without using SE techniques).
It's not the tool (programming language) that makes you a better programmer, but your design and problem solving abilities.
The only thing that still eludes you is being humble and recognizing your limits, my friend...
Wow .. #4 takes the cake!
"The resulting projects however become a mess of unmaintainable code sooner or later." .. Can you explain which feature/bug in PHP forces this on you?
I'm going to assume you are either A) a crap programmer .. or B) a average at best programmer who's part of a crap team.. or C) put under unreasonable deadlines by management.
There really are no other valid excuses for spaghetti code.
I've played with the newest JSP and java server technologies and I can tell you that Php compared to that platform is nothing. The closest you can get is Zend Server, its not about the Php Frameworks, its not about the Php Libraries, but the core language tools needed to develop Php in a (code) scalable / maintainable way. This is where Php falls apart. Within a few minutes you can get Glashfish up and running in Netbeans while starting to develop, debug and deploy. In Php your in the soup of hodge podge of software, settings and trying to get Php, XDebug and other debugging tools setup to get it working in an IDE to step into, out of and over code. I know Php is finally integrating a built in webserver, but it needs to integrate xdebug and stop making it so difficult, and make Zend Server the defacto to developing Php applications on.
Oh look what this childish website is running ... pretty embarrassing actually.
$ curl -s -D - www.java.net | grep -i x-pow
It's a Drupal installation.
Guess there isn't any good Java CMS out there yet, but probably you are going to write one, are you?
I am a big Java fan, and also I like PHP alot.
But I think it's unfair to think about a programming language like that.
Java is a very good language and I like it's static typed feature. But PHP on the other hand, is fast, lightweight, and easy to learn.
So use every tool in it's place. One day you will get back to PHP too.
here is one opposite view on that matter from 'java developer':
although it is not php, but js - however many of those principles apply on php too.
It's so stupid to say that PHP creates bad code.
I guess in all that time that you spend with PHP you really never learned anything, If you were crappy dev with PHP you'll be crappy with java.
Java is the antiPHP, and that is not necessarily a good thing.
Learn Scala or Ruby and you will quickly discovery how needlessly verbose Java the language is.
Java the language is total crap, but Java the platform is quite nice. With Java 7, Oracle flat-out admits that other languages on the JVM is the future. They put features for Java(real anonymous functions that are closures, array and hash literals, miglayout, etc) on the back burner to make sure that good languages like Scala and Ruby can be first class citizens on the JVM.
Please don't use the IDE to excuse Java. An IDE is absolutely required for Java because Java has so much boilerplate. The need to have an IDE to be productive is a serious negative for the language.
And to the idiots that try to claim that since all languages are flawed that somehow make PHP equal to better languages, please get a clue. Yes, all languages have flaws, but the severity and amount of those flaws are not equal.
A bad programmer will produce bad programs. A good programming will produce good programs in any language except PHP. PHP is flawed to its core and there is no workaround for that.