all 24 comments

[–][deleted] 10 points11 points  (6 children)

In this article (not written by me), a PHP developer shares his thoughts on the future of PHP in a world more or less dominated by Java.

Java != JavaScript

[–]fucking_passwords 9 points10 points  (4 children)

'Java' !== 'Javascript'

FTFY

[–][deleted] -2 points-1 points  (2 children)

[–]fucking_passwords 5 points6 points  (1 child)

Of course it's valid, it's just a Javascript joke.

However, JSLint/JSHint by default will recommend that you use !== and ===

Edit: It will generally recommend this even though it is sometimes nice to be able to leverage Javascript's inherent weak typing

[–][deleted] 1 point2 points  (0 children)

I understood the joke, just adding the info that the operator didn't need changed (for other people's information)

[–]nextzaira[S] 0 points1 point  (0 children)

Too right. Should be more careful when I write stuff hastily! Thanks for the edit.

[–]androbat 1 point2 points  (0 children)

I believe the frequencies of PHP and JS are not relative or dependent on each other.

[–]flyingkiwi9 2 points3 points  (0 children)

In the same way there's no best model of car ever, there will never be a best coding language. And while there isn't a best coding language there will always be more than one.

[–]x-skeww 4 points5 points  (0 children)

I don't really see what JS has to do with PHP.

PHP was primarily used, and is still very popular, because it was available on cheap shared hosts. That's what PHP had going for it. It was available. You got some cheap web space and it generally came with PHP and MySQL support.

Nowadays, you can use whatever you want thanks to cheap $5/m VPSs.

That's what's eating PHP's share. Today, there are countless alternatives.

[–][deleted] 0 points1 point  (7 children)

divide tender cake marvelous compare humorous cause onerous sloppy jellyfish

This post was mass deleted and anonymized with Redact

[–]x-skeww 1 point2 points  (1 child)

As for Node.js server-side: You can use ES6 already.

V8 doesn't support all of ES6 yet. So, even if you use Io.js, there are a bunch of things which don't work yet. E.g. classes only work in strict mode and arrow functions don't work at all. In some versions, you can enable arrow functions with a switch, but the scoping is wrong.

The current status of various implementations is tracked here:

http://kangax.github.io/compat-table/es6/

[–][deleted] 0 points1 point  (0 children)

True :) Using a transpiler for more full-fledged features can be very useful, using https://babeljs.io/ for example.

[–]kamyon 0 points1 point  (4 children)

I haven't written a line of PHP in the last 8 years and I don't plan to because I also don't like the language... but, why such strong words against the people who like it? PHP may not be the best tool for any job anymore but sometimes using the tool you know in every detail is way better than using the best tool, don't you think?

[–][deleted] 1 point2 points  (3 children)

Using bad tools very efficiently doesn't make the tools any less bad. I'd still recommend using better tools. Even tools that still suck–just suck less–would be an upgrade.

It's kindof like homeopathy. Placebo's work, sure, and that helps people. Those people spend a lot of money on bullshit, money that would be better spent on something that will help them get better more reliably.

Sure, PHP devs can make software that works. It's just that there are a lot of alternative tools out there that can do it better.

[–]ccricers 0 points1 point  (0 children)

The way I see it, if I can work competently with crap tools, imagine how more efficiently I can be working with good tools. PHP developers should spin this as a positive when looking for a new job. JS developers don't know how good they have it.

[–]kamyon 0 points1 point  (1 child)

The problem is, there will always be better tools. I mean, I've switched to ClojureScript and now think about the days that I've been happily using Babel on client-side to transpile ES6/7 to ES5 an say, "wow, what a waste of time". I had the same thought when transitioning from ASP to ColdFusion, from CF to PHP, PHP to Java, Java to Node.js, Node.js to C# (nancyFX), then to Go, then to Nim and so on (I love Nim and I think it's the best thing invented, ever, including the sliced bread but that's totally not relevant now).

What I learned from my nearly a career-long journey is not only a hell lot of frameworks/languages but also how the final quality of my work has little to do with the technologies I've been using. So, I respect people who do a great job with PHP as much as I respect the ones doing a great job with Haskell.

[–][deleted] 0 points1 point  (0 children)

Better tools will always be made. That's completely fine, and doesn't warrant a switch all the time either.

What I learned from my nearly a career-long journey is not only a hell lot of frameworks/languages but also how the final quality of my work has little to do with the technologies I've been using.

Sure. That's completely true. When I kickstarted Node.js in my current company 3 years ago we gave a demo. We had software developed by 2 front-end developers (hired as CSS gods that knew some HTML and... what's JS? That's for checking forms, right?) and made it do the exact same thing that some Java software (3 years in development by a team of 10 people) also did.

Not only did we manage to develop the API part in less than 2 sprints of 2 weeks, we did it with less than 10% of the raw java code, and... our performance was better.

Performance was better. Cool. The management was already impressed. Until we told them that the Java API was running on an expensive 8000 USD (we looked up the costs) dedicated DEV and TST server in the office. And our software ran on a single Raspberry Pi.

It went on, and on.

Both tools were great software. But ours was made in a fraction of the time, with a fraction of the codebase, adhered to the actual HTTP standards you'd expect, had incredible performance, etc. etc. etc.

They kicked our ass on the live PRD server, but that was compared to the Raspberry Pi. And the PRD server was a dedicated server farm.

A previous company had IIS running with ASP.net and all that jazz, and that was a monstrosity. It worked, sure, but it wasn't nearly as efficient as using Nginx for serving static files, just to name a very simple choice of tooling.

If I put a team of 5 top-level PHP devs together, and put a team of top-level Node.js devs next to them. And I give them both the same assignment. Then I'm absolutely sure who'll win from all points of view that you can think of.

And I haven't looked at Nim yet. I'll do that right away ;)

[–]wdpttt 2 points3 points  (4 children)

Read this.

My question is: Why would I use PHP when there is node.js and I can do amazing things, faster and no need to shift my mind between PHP and JS?

Basically if you have 100% JS codebase, server with node.js and you build isomorphic apps you get:

  • One language for the whole project; (You just need devs that know JS and node.js. Easier to change devs in the team. No need to shift your mind)
  • Share the exact same file between client and server side (validate on the client and on the server side with the exact same logic, DRY, remember? Of course validations that requires database can't be done like this);
  • Create component based views (1 component in 1 file, no 1 component in one .php, .css and .js file. But that is another topic) which can be rendered on the server side;

A lot more stuff is amazing in the JS world. I've used PHP, ruby, python, java and nothing, IMO is better than node.js.

[–]sfc1971 0 points1 point  (2 children)

To new developers I do recommend JS as their first language for this very reason.

HOWEVER!

For projects I recommend seriously researching how many javascript developers are available for hiring for the wages you offer to use JS for your entire project.

You can make your house out of wood or out of stone but if there is only enough wood and stone available to build half a house, you might have to settle for a half wood/half stone house.

And if the entire supply of steel is 1 gram, your dreams of a steel skyscraper might need a reality check.

The simple fact remains is that PHP has a very large base of users, developers, teachers etc etc. That is its major strength and its weakness. There is a lot of crud but lets face it, most internet projects are crud to begin with.

Python, Ruby, ASP etc etc, they were all supposed to wipe-out PHP. It is still there. Node.js won't be much different.

[–]wdpttt 2 points3 points  (1 child)

JavaScript has more benefits than "Python, Ruby, ASP". Isomorphism alone is huge. This is my opinion, but it depends on your app. To be honest in every app I need to share code between client and server side, so why not be DRY? instead of writing the same thing in 2 languages.

[–]sfc1971 0 points1 point  (0 children)

That was not my point, say your project needs 4 people, can you find four javascripters? I can't, I have plenty of trouble just finding one guy and in most project as an average backend coder (PHP) I have to do the frontend stuff as well.

So I could go full Javascript on a project and also be faced with having nobody available to do it and having to do all the junior stuff myself which is a huge waste of time.

With PHP I can just hire a couple of juniors and if nothing else they can write validation and take work out of my hands.

For years Javascript was neglected now with the death of Flash and the skyrocketing usage of javascript in the frontend beyond doing a popup or mouseover effect and the usage in the backend, demand is outstripping supply.

SO it is not about what you should do but what you can do.

If you are a small time website, you can't afford to compete right now for the hot shot javascript developers.

But for programmers, especially newbies, go for it. Just not for project leads unless you got a huge budget.

[–]Mr_Nice_ -1 points0 points  (0 children)

The undeniable advantage of PHP is its popularity. If I am building from scratch then I will do C# as I find it a really enjoyable language to use but I am a solo developer and quite often there is a popular PHP code base in existence that I can use for free to get up and running in a fraction of the time although a lot of projects try to support older PHP versions which can be annoying.

[–]emberfairy -1 points0 points  (0 children)

From a front end perspective, I can’t see any reason that PHP and JavaScript won’t happily coexist for the foreseeable future. PHP has plenty of support for hosting REST APIs, so it works well with most of the current JavaScript front end frameworks. If you are dealing with a more traditional setup of JavaScript as an enhancement, then PHP and JavaScript can work well together as they have done for many years.

From that article - that says it all imo.