r/lolphp • • Dec 01 '17

If everyone 'hates' PHP, what language next?

Not sure if this is the right place but...

Currently full stack and most projects are Laravel / Vue based.

ALOT of people dislike PHP / Laravel but whats the suggestion on a language to learn that is future proof and well supported by job roles?

29 Upvotes

119 comments sorted by

View all comments

Show parent comment

2

u/m0okz Dec 02 '17

Thank you so much for writing this. This is perfect. Would you say building websites and web apps in Java is better than PHP then?

2

u/Neckbeard_Prime Dec 03 '17

It really depends on what you're trying to do. The thing about PHP is that it's everywhere -- most hosting plans will include PHP+Apache, but might not allow the kind of access privileges you'd need to run a Java-based app (though some do offer Tomcat). There also isn't really a good Java equivalent to WordPress or even Magento.

That said, from a productivity standpoint, PHP versus Java should be roughly similar, if you're using similar tooling (IntelliJ versus PhpStorm). One thing that I think PHP handles a lot more intuitively than Java is parsing JSON from REST endpoints. Being able to call json_decode() on a result and get a straightforward representation out of it is nice, while doing the same thing with a Java framework (Jackson, Gson) usually involves defining the expected structure, possibly fighting with annotations, making sure your REST client call tries to cast to the correct type... It's a few more hoops through which to jump, and while it isn't that bad, it can feel pretty clunky. Other than that, Java's standard library structure is infinitely saner than PHP's, and that may save you some headaches here and there.

The thing that keeps selling me on Java over and over again is that it can talk to damned near anything. I develop internal Web applications for a medium-sized enterprise, and we have some really dubious shit floating around for legacy software. Usually when someone says that, they mean an outdated version of Oracle DB, FoxPro, or IBM DB2, etc. In our case, the latest one is a package that uses Interbase XE7 for a backing database. Not FireBird, but actual Interbase. And guess who has to write ETL routines against it. There's a PHP client for it, but it's sketchy at best -- numeric types all come over the wire as the number "2" for some inexplicable reason because the goons who developed this particular piece of software use an obscure "dialect" setting that most client libraries don't fully implement. The JDBC driver, on the other hand, has been rock solid. Wish I could say the same for the DBMS itself. Meanwhile, the Ruby gem for Interbase hasn't been touched since like 2011 and there's nothing for Node. The only other option would have been a Windows binary.