About two months ago Alexander Katrompas wrote a post on medium titled Java will kill your startup. PHP will save it.. I already posted a short response as a comment there, but I thought it might be worthwhile to elaborate on that a little.
Again, if there's anything of which I can call myself an expert, that would probably be PHP. I don't really like PHP anymore, I don't write a lot of PHP anymore, but I do know it very well.
The arguments
Just to quickly recap, here are Alexander's arguments in a nutshell:
- Many large-scale projects started off being written in PHP and over 80% of the top 10M web sites use PHP.
- PHP programmers are more plentiful and cheaper than Java programmers. (web-only)
- PHP has excellent performance and it continuously gets better and in-practice easily rivals compiled languages.
- PHP application time to market is a fraction of Java EE applications.
- PHP is not a “scripting” language (whatever that means), it’s a fully function, object oriented, web powerhouse.
- PHP 7.x is a vast improvement over previous versions and 8.0 promises to surpass all expectations.
- Frameworks are plentiful and powerful. The power, popularity, and dominance of Symfony and Laravel is undeniable.
- WordPress (PHP driven) is the dominant CMS with almost 60% market share. The next top 5 CMSs, are all PHP driven.
- PHP is simply made for the web. No extra servers, processors, hacks, tricks needed. It is literally one with your web server.
- Most dominant open source e-commerce systems are all written in PHP. (WooCommerce, Magento, OpenCart, PrestaShop, ZenCart, Drupal, Joomla, OsCommerce, and on, and on, and on…
My comments on the arguments
As the title and the above list shows, Alexander was comparing PHP to Java EE. Now I have very little knowledge on the latter, but I can tell you that for most startups PHP is no longer the best choice.
Just to clarify, there are a few points that I strongly disagree with. In my opinion:
- PHP is a scripting language. It does have decent OO features, but that has nothing to do with it being a scripting language. What it does affect is first that not all of your code will be loaded into memory when a request is served (good), that all of your errors will be runtime errors (bad) and of course that your code will be interpreted on an as-needed basis instead of having it all compiled to byte code or some intermediate language. Sidenote: Alexander mentions "function, .. oriented" there as well, but I'm hoping that was nothing more then some copy-paste mistake.
- PHP 7 is a step in the right direction, but it wasn't brave enough to really clean up the API and I doubt PHP 8 will be.
- PHP is made for the web but there are extra servers, processors, hacks and tricks needed. It is absolutely not one with your web server and if you've been close enough to operational teams of big PHP projects you'll know how much a pain in the ass it can be. Not that it's a PHP-specific thing but just to get things straight. I'm guessing that Alexander was referring to the PHP apache extension, but that's not something I've seen running live in the last 10 years and probably you shouldn't either...
- PHP is fast enough for serving as the backend of an API. If you need true performance for complicated stuff (databases, crypto-mining, etc.) then it probably isn't.
Still, with all these corrections I think the problem lies in what's missing from the list, not what's in there.
First of all if your startup is about selling flip-flops, then by all means go ahead, install Magento and off you go. You'll still be able to ditch it for something more flexible when you actually start to make money and feel the pain of running an over-engineered, yet rigid system. (wink-wink Zalando).
If however you want to build something that's a true Zero-to-One type startup, you need a system that gives you agility:
- Fast to learn.
- Fast to prototype in.
- Straight-forward to harden.
- Enables fast and safe refactoring.
Plus I'd consider these things as nice-to-haves for startups but absolutely must-haves for mature companies:
- Maintainable
- Secure
And finally two nice-to-haves for the most successful startups, the corporations:
- Exciting
- Trustworthy
Fast to prototype in
Now I have the feeling that Alexander focused way too much on prototyping for which PHP is quite good indeed. Not the best, but certainly decent, probably better than the famously verbose Java is.
Just to clarify, Java is famous for being verbose but I wouldn't call PHP concise either. It's not a really a criticism, simply a statement. (In comparison Python and Ruby code tend to be significantly shorter and easier to read than equivalent PHP code.)
Straight-forward to harden
When it comes to hardening, your only real choice is adding more tests because the type system is just very hard to rely on. You can harden your own code ensuring that you use types everywhere (you'll need at least 7.1 to really do that) and marking each of your files to be type checked strictly, but it's a hassle, error prone and it's tough to get all your dependencies to provide similar safety. Also, if you end up using any of the popular frameworks (Symfony, Laravel, Zend, etc) you're out of luck, as they all -support 5.x still- (Correction: they require PHP 7 lately, but don't enforce strict type checking). And the truth is that 99.9% of all PHP teams will decide to use these tools because of familiarity and the size of their ecosystems.
If the choices only came down to PHP and Java, I'm sure Java would easily win here. It still suffers from the billion dollar mistake, but at least the compiler will yell at you if you change your API in one file and forgot to update it in another. In PHP you'll just hope it will be caught in a test or during code review, given you have those. (Spoiler alert! In most start-ups you don't, because you know, they take time and therefore money)
Enables fast and safe refactoring
When it comes to fast and safe refactoring there's hardly anything worse than PHP, so Java would win easily, mainly still due to its type safety and the compiler being able to check your whole application by default. Again Java is probably far from the best choice as some functional and functional-inspired languages will go further in this regard, but I think it should already be decent.
Fast to learn
This is the final point in the must-have section for startups, but it can be very important in some cases. Alexander avoids this problem by saying it's cheaper to hire PHP devs and Java devs. While it's probably true, the difference likely not to be comparable to choosing the wrong language and having to rewrite everything later. Yes, as a startup you might want to cut that 20% on IT salary expenses, but you should understand that you're playing with fire. I myself would rather risk running out of money 2-10% earlier then risking years of suffering of wrong choices early on.
So if we agree with the premise that you can always bring in people already familiar with your stack then Alexander was probably right, but the difference shouldn't make or brake your startup.
I'd however argue that I'd prefer working with a language that less people know but is very easy to learn. That way you can get the best domain experts bring tremendous value and you never risk of running out of local talents because any engineer you'd get would be able to get productive in a few weeks.
Now this is where I'm fairly sure both PHP and Java suck, and they actually suck big time. Both these languages try to satisfy everyone, putting all sorts of features into the language and both of these have huge-huge ecosystems which take years and perhaps decades to fully oversee and takes tons and tons of reading to make sure you understand best practices and things to avoid. Not to mention how much terrible advice must be out there for both of these languages... Still, as a beginner searching for good answers must be a nightmare both for Java and PHP.
In contrast many newer languages try to keep things straight forward. Go is the most obvious example here but Elm and Rust can also simplify many things even if they bring in some concepts which are harder to grasp at first.
Ecosystems of these new languages are also cleaner and in the case of Go most things you'll use are in the standard library, tested at Google-scale and quality that you can easily bet your company on. The community also lives and breaths the Unix-philosophy, which means popular tools tend to do one thing and do that well. It's definitely not true for PHP and I doubt it would be for Java EE, although I can't really judge that.
Note: I hinted it before, but to be clear: if you can utilise one of the many open source PHP applications out there then it can be a much larger save than just 2-10% and it might make a lot of sense. Most obvious example is e-commerce, but there are some others as well. In case of e-commerce, you should either just use an existing ready-made service, some marketplace or build on top of Magento, Thelia or Sylius. Prestashop might have some use cases too, but if anyone recommended me WooCommerce, OpenCart, ZenCart, Drupal, Joomla or OsCommerce for e-commerce, I'd run away and I'd run far.
Maintainable
I spent most of my professional carrier working on huge (>1.000.000 lines) legacy applications trying to clean up the mess my predecessors left behind themselves. Most of the pain came from over-engineered OOP monstrosities. Because of that, I truly appreciate the simplicity of Go and Rust and for me both PHP and Java would score really badly.
I also enjoy the extra safety functional languages can provide but they can affect how fast a language is to learn, so you'd have to take that into account while assessing them for "fast to learn" and "excitement".
Secure
This is a point where I really lack the knowledge to properly assess Java, but PHP does have a pretty bad track record. I have the feeling that Java would fair better, but I'd rather skip this topic saying that there are better languages out there than PHP. In fact, I believe PHP is among the worst.
Exciting
Now this is certainly not important for all startups but if you are thinking about something technologically challenging, then you should try to appeal to the best minds available in your area. These people will be able to learn a new language, but they won't learn just any language you throw at them. Not because they can't, but because they don't want to.
Unfortunately PHP is among the least respected languages out there and this means that the brightest software engineers probably never learned PHP and probably aren't willing to learn it.
Java is slightly better off here because anyone who got a computer science degree in the last 2 decades have learnt Java at some point and many even stuck with or sticked to it. On the other hand it's also not the most popular language to learn for people outside of the Java community these days.
On the upside however there are other JVM languages with current momentum (Scala and Kotlin mostly) which claim to provide easy access to anything written in Java, so that could be a safe way forward I think.
I will admit that this is not a topic I can't fully assess, but I have the feeling Java still wins here.
Trustworthy
This is an easy knockout for Java EE. If you want to go public or sell your product to fortune 500s you'll want Microsoft (C#), SAP and Java EE on your portfolio. And that's pretty much a complete list as far as I know.
Conclusions
So I had PHP winning one point easily and another one potentially. There are many points where I admitted I don't necessarily have the Java-knowledge to assess both but in these cases PHP scored pretty bad, forcing me to believe that Java is the better technology to start a green-field project.
This does not mean that PHP will kill your startup and Java will save it. What this post meant to say is that you should understand the consequences of your choices, understand the risks you make and choose whatever will make you sleep better.
- If cutting 2-10% of IT expense is all you want then PHP (or NodeJs) is reasonable.
- If you need to have your blog or e-commerce site available ASAP then PHP is probably your best choice, but you should make a good reason not to use an existing service instead.
- If you want to sell your product to Fortune 500 companies then Java is probably still the keyword to score a deal, although other JVM or .NET languages might also make sense.
- If ensuring you won't find yourself in a situation where you have to rewrite everything then use a statically typed, compiled language. I'd recommend Go but I hear Kotlin might be a reasonable choice as well.
- If you don't need first class support by major cloud providers, but runtime errors can kill your company then consider Rust or Haskell.
Finally, if you really wanted a simple answer to the question "will PHP save your startup?", I'd have to say no. Not unless you're building something on top of an existing PHP application. Will PHP kill your startup though? Probably not, but it's likely to make it less agile than it could be.
Top comments (26)
github.com/laravel/framework/blob/...
github.com/symfony/symfony/blob/4....
TO doesn't want for some reason type-hints in the Laravel.
Have you spent same time with Go / Rust projects professionally (being paid for)? I think the over-engineered point is not fault of programmers but the company culture as a whole... feature this feature that, change request
$this
and you get the over-engineering, I think it's language agnostic.Sorry I just realized that I didn't really give you an answer on the over-engineered point. Reality is, it's a complicated issue, at least in my opinion, but in short: No, I think company culture is the least of the problem. Not that it can't be, but it won't be a defining factor when I judge a language. You can write shitty code in any Turing-complete language, that's guaranteed.
Community culture may be a bigger problem with a whole range of issues from terrible and outdated examples out there, through terrible but successful legacy applications like Wordpress or Joomla to overengineered ones like Magento, a fair amount of elitism and feature-envy, etc.
Still, I think the biggest problem is the language itself as it just gives you (and promotes) things I personally consider harmful. Among them many things that many others swear by but I just don't have time or space to explain my reasons in detail here. Anyway, here's a quick list: inheritance, exceptions, implicit type conversions, falsy-truthy madness, typeless variables, ternary operators (arguable, but definitely often abused), inconsistent standard library, terrible track record retiring deprecated extensions, configurable error levels, errors vs exceptions, etc.
But if all of these were somehow fixed by the language or your coding standard, I'd still know that I broke my API within a second or so with Go while you'd have to wait for minutes for the CI server and hope that your test suite will catch it. That feedback loop is invaluable to me and I do believe it leads to better code. Even if it doesn't, at the very least there's less "self-defense" in the code base...
Finally, PHP is just full of flaws and compromises. I won't go as far to say that PHP is a fractal of bad design, but it's definitely not great.
There should be a drinking game for referencing that blog post in any articles that are trying to prove PHP is less than X technology.
I wrote thousands of words and all you have a problem with is that I dared linking something that I even stated I don't completely agree with?
I'm sure you're aware that most people on dev.to never read that article, it just triggers you that it's still around, doesn't it?
Also the post didn't mention it, the only thing it mentioned is that classic OOP is in my opinion evil, which I will stand by, but I'm aware that's still not the popular opinion.
Not so much as triggered, but finding it amusing that that blog posts works it's way into comments of any PHP pros v cons related article sooner or later. I assumed referencing a drinking game would make it seem clearly more light-hearted comment, my bad.
I actually was going to write a longer and more meaningful reply, but decided I should take my time with it and left it for when I get home.
I liked that you came to a conclusion that PHP on it's own is not necessarily going to kill any startup. It's pretty uncommon actually, because articles usually end with very strong statements like - technology X, only morons use it OR technology X, only morons would use anything else - so what it's worth, I found the overall tone pretty neutral, which is a good thing.
You can write very good code with all of you 'design patterns' stuffs with PHP 7 :)
Stop referencing that blog from 2012.
If I referenced it in the blog post you'd be right. I'll stop referencing it in a comment about why PHP is not a great design, when it really becomes obsolete. That post contains many things which are unfair or very subjective and few which have been fixed, but the overall number of actual issues remaining is huge. You've learned to live with them and so have I, but it doesn't make the design any better.
Also stop telling me what to reference and what not to.
So they don't support PHP5 anymore. True, I should have checked the very latest version. Still, they don't enforce strict typing. Also if they did, it would make things slightly better, wouldn't be a game changer.
I have been paid to write Go. Rust no, and might never be. I will agree that it's totally possible to write good code using PHP, but I will argue that it's much more of an effort than with Go or Rust.
Laravel last versions use strict types and you can use them in Symfony. It's already used in API platform.
Good to know. Seems like I'm getting a bit rusty. ;)
Facebook is written in php and it seems to be a really decent company. It started up, and has kept php. My point is if you can find an application well written in PHP and a bad application written in Java, then the whole argument falls apart. I think , should be obvious,the programming language is just a tool, the good practices don't depend on language. When it comes to easier or more difficult to the programmer, with so many IDE tools, that is just not a discussion. It seems to me, these discussions are quite similar to football ones when you try to argue a team over another but there is not real substance. Of course a web site written on c would not be optimal, but we are assuming none would think so already. So if the language provides the set of tools to develop the product, the success of the company doesn't depend on it, but in the good usage of it.
I do not think this is an accurate characterization. As popularity rose, they ran into problems, especially performance. So they tried a number of things, including creating their own custom compiler and language clone for PHP. All of that was deemed cheaper than rewriting their code base in another language. You can google for HHVM and Hack for more information. This Quora question has a lot of good insights from FB employees. Including this quote.
But your latter point is quite correct: Like most successful companies, their success has almost nothing to do with their choice of tech stack. And everything to do with creating a product consumers wanted and an effective way to monetize it.
Why? Do you feel I suggested that all PHP projects are inherently worse than all Java projects in existence? Because if so, I probably messed up somewhere really badly. The closest to this is that I said it's probably a safer bet to start a green field project in Java than in PHP, given you really have to choose from these two and there's no deciding factor like building on top of existing app or big dog clients.
I don't see how IDEs can help you better understand or utilise programming language concepts. For example how do they help with understanding implicit interfaces, inheritance, borrowing, union types or generics?
How will these tools help the developer understand whether adding one more level of abstract inheritance is a good idea or not? Or whether that method should really be final or not? Or whether using "==" is okay or not. I could go on, but the point is that languages are different and they do affect the likelihood of your project becoming legacy in no time or not.
Well, you're probably a software engineer and what you're saying probably makes a lot of sense to you, since you're probably aware of your capabilities. I'm not even saying you're wrong. The post however was also not to convince you that you're working with the "wrong" tools but to convince potential entrepreneurs that PHP will not save their startup. For them it's always about investments and risks and I tried to help them get a clearer picture on that.
Fun fact: kore.io/
I saw the "Java will kill ..." article on medium suggestions but I ignored it, and now after reading a part of it I don't regret it.
We can start and end with those "facts", most of them are subjective or false statements. Some of them are just some random irrelevant statistics, like the number of companies that use PHP (most likely most of them have a Wordpress website) instead of comparing number of jobs, company profit, salaries or the number of users of those products, companies with over x number of engineers and so on.
Neither language is going to "save" or "kill" your start-up.
When you take an inherently flawed blog post and then try to make some argument on top of those false premises, what you say only makes sense in the context of these articles.
Your conclusion is fine, but it doesn't mirror reality. Vast majority of startups are going with LAMP or MEAN stacks.
All you have to do is take a look at the statistics on SO.
This debate is a perfect example of premature optimization. We don't know what it is we are building, but let's spend two hours arguing about it.
If this post ever helped a very small minority think a little bit harder about this topic before hiring a LAMP or MEAN team for their next project, I'd consider that a huge success. Chances are, I'll never know.
It would be awesome to revisit this topic once RFCs for stricter types, especially the typed-properties one, are approved. I think that would put PHP at just the right spot compared to Java's type system.
I haven't seen a live PHP + Apache combo since 2012 and unless you have very good reasons to stick with it, you probably shouldn't either.
Please note, I don't want to defend Java really, but keeping a PHP app afloat that is used by tons of people is not a walk in the park and keeping a growing codebase managable and stable is extremely hard.
Could you please explain why you think that PHP is a script language and not an object language in 7.2+ ?
Considering strict_types, typehint etc ?
Ruby is a scripting language and yet it is a purely object-oriented one.
Python is a scripting language that like PHP has gain OOP and FP features lately.
Being a scripting language is not tied to the paradigm it follows.
Please open php.net/ and read the very first sentence:
"PHP is a popular general-purpose scripting language that is especially suited to web development."
Whether it has OO features or not is simply irrelevant.
"What it does affect is first that not all of your code will be loaded into memory when a request is served (good), that all of your errors will be runtime errors (bad) and of course that your code will be interpreted on an as-needed basis instead of having it all compiled to byte code or some intermediate language"
Symfony cache isn't a solution to this one problem ?
To clarify, I don't necessarily think that working with a scripting language is "a problem" in itself. It's just a fact. The only problem in the cited part is the runtime errors, and for that your only compensating tool is testing, testing, more testing, a good CI flow and maintaining a healthy log. Plus some more testing.
Don't believe me, just try a simple Go project and see what happens when you break something. It should be obvious within hours... Btw, Go is not free of runtime errors at all, but they occur much less frequently. (Rust is free of them unless you use stuff marked as unsafe...)
PHP has been on my mind more and more lately. From working at a few marketing companies where PHP was the default then transitioning to a .Net enterprise. However, I have noticed recently that one of my most popular blog articles is PHP. There appears to be a great demand even though I feel like nodejs should be rivaling a lot of what made PHP successful except for some specific reasons why it currently does not. One, I think that university courses put a big focus on PHP+Mysql as the easiest place to start for creating an app and learning about databases. The learning feedback loop is very small compared to a a statically compiled language. Two, most people dipping their toes into their own website may still start with a hoster that offers mysql+php and does maintenance for them vs. starting with a cloud provider. Third a lot of businesses have some kind of PHP laying around somewhere and I wager there is a vacuum of knowledge around PHP where other ecosystems have taken the attention. There seems to be some demand for creating libraries or documentation on how to do some things in PHP that would be easier in some languages.
That's funny and the observation is probably right. :)
I see Rust as a more complex but safer version of Go to some extent and I like both languages. I guess that's the reason.