DEV Community

Will PHP save your startup?

Peter Aba on September 09, 2018

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 res...
Collapse
 
kyslik profile image
Martin Kiesel

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.

github.com/laravel/framework/blob/...
github.com/symfony/symfony/blob/4....

TO doesn't want for some reason type-hints in the Laravel.

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.

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.

Collapse
 
peteraba profile image
Peter Aba • Edited

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.

Collapse
 
perttisoomann profile image
Pert Soomann

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.

Thread Thread
 
peteraba profile image
Peter Aba

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.

Thread Thread
 
perttisoomann profile image
Pert Soomann

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.

Collapse
 
marufalom profile image
Maruf Alom

You can write very good code with all of you 'design patterns' stuffs with PHP 7 :)

Stop referencing that blog from 2012.

Thread Thread
 
peteraba profile image
Peter Aba

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.

Collapse
 
peteraba profile image
Peter Aba • Edited

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.

Collapse
 
vasilvestre profile image
Valentin Silvestre

Laravel last versions use strict types and you can use them in Symfony. It's already used in API platform.

Thread Thread
 
peteraba profile image
Peter Aba

Good to know. Seems like I'm getting a bit rusty. ;)

Collapse
 
jarturoangeles profile image
arturo de los angele

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.

Collapse
 
kspeakman profile image
Kasey Speakman

Facebook is written in php ... It started up, and has kept php.

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.

The flavor of PHP we use at Facebook, Hack, is very far removed from the what you typically think of when you picture PHP.

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.

Collapse
 
peteraba profile image
Peter Aba • Edited

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.

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.

When it comes to easier or more difficult to the programmer, with so many IDE tools, that is just not a discussion.

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.

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.

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.

Collapse
 
peteraba profile image
Peter Aba

Fun fact: kore.io/

Collapse
 
bgadrian profile image
Adrian B.G.

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.

Collapse
 
_vlad_ko profile image
vlad ko

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.

Collapse
 
peteraba profile image
Peter Aba

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.

Collapse
 
alchermd profile image
John Alcher

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.

Collapse
 
peteraba profile image
Peter Aba • Edited

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.

Collapse
 
vasilvestre profile image
Valentin Silvestre

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 ?

Collapse
 
matteojoliveau profile image
Matteo Joliveau

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.

Collapse
 
peteraba profile image
Peter Aba

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.

Collapse
 
vasilvestre profile image
Valentin Silvestre

"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 ?

Thread Thread
 
peteraba profile image
Peter Aba

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...)

Collapse
 
alanmbarr profile image
Alan Barr

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.

 
peteraba profile image
Peter Aba

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.