3 ms·
Anyway, if this is how people use PHP these days, why not just use Java? I guess deployment is different (PHP is not compiled), but code/concepts seem pretty mu
by megous 9y ago
Anyway, if this is how people use PHP these days, why not just use Java? I guess deployment is different (PHP is not compiled), but code/concepts seem pretty much the same at this point if you want to use this style of programming.
- tyingq 9y agoDynamic types, and less verbose. Which, I agree, can be downsides as well.
- megous 9y agoIs it really less verbose for OOP programming than Java, if you're using type annotations, etc.?
- tyingq 9y agoJava is still burdened with a lot of this.that.this.that.whatever(something) I don't know that I've ever encountered something like: RequestProcessorFactoryFactory.RequestProcessorFactory.getRequestProcessor(XmlRpcRequest) In any other language. And that's not the most egregious example. It's quite common.
- cutler 9y agoHave a look at Zend's SDK. It's full of such nonsense. Symfony also tries very hard to look like Java, complete with verbose naming and files paths.
- tyingq 9y agoMaybe. I avoid stuff like that. See https://www.slimframework.com https://www.slimframework.com for example.
- davidjnelson 9y agoSeems more like a dig on inheritance and the resultant code than java as a language.
- tyingq 9y agoWell, two layers of factory classes, one calling the other, plus a big xml blob is pretty Java specific. I'm open to to common counter examples in some other language. There's inheritance, and there's overindulgence.
- davidjnelson 9y agoInterface based polymorphism is pretty useful. Been thinking more functionally lately, and can’t remember needing it. Parametric polymorphism ( aka generics ) are still useful for the immutable state graph.
- Akujin 9y agoBecause php is just in time but Java isn't. Also Java syntax is horrible to both learn and write.
- wvenable 9y ago...or C# or anything else. I programmed in PHP for many years and I agree. I mean there are good reasons for maybe not using Java but it's hard to imagine a good excuse to start PHP these days if you don't already know PHP. On the other hand, things in PHP-land are improving at such a rapid pace (but without the churn of JavaScript) that if you are a PHP developer there isn't much reason to switch to something different but similar.
- whamlastxmas 9y agoHigher quality development jobs tend to use things other than PHP. I say this as a PHP developer. So there's at least that reason to get away from it.
- RhodesianHunter 9y agoPretty much this. Switching from PHP to Java resulted in dramatic salary increases for me.
- whamlastxmas 9y agoWhat was that transition like for you? I'd like to get away from web development because I'm bored out of my mind with the front end aspect.
- kilburn 9y agoI'd say that web programming architecture has been converging between most languages. What's shown here is: - Setup a library tracking system (composer, the autoload stuff) - Setup basic Dependency Injection (using code in this case, but the same could be done through config files or annotations) - Parse requests into a request class - Setup a middleware chain, including a router, and dispatch a request through it How is this different from flask/django (python), rails (ruby), or gin (golang)? I'd say the basic concepts are pretty much the same, except maybe the library handling part. In other words, I don't think there's enough "meat" in this example to appreciate actual relevant language differences. Also, you can write "java-like, enterprisey" code (Symfony) that values explicitness over magic, or go the other way around following the "convention over configuration" mantra, and end up at Laravel that is much more Rails-like. Finally, PHP is still has several advantages over java for many people out there: - Every request starts from scratch, meaning it is impossible to accidentally provoke side-effects on other requests - The package system (composer) is just a package management system, and hence MUCH simpler to understand than ant/maven/ivy, that are entire build systems that also want to control testing, deployment, and everything - Development is faster-paced thanks to the lack of compilation. You can even easily setup an environment with auto-reloading and just "save updated code" -> "see result in less than a second". - You can deploy your app to any of a horde of (cheap) hosting providers and let others deal with the ops side. The service may exist in java-land, but it certainly isn't as ubiquitous. - PHP programmers are cheap (yes, cheaper than java-programmers).
- hrktb 9y agoI think there is strong sense of “we’re not the old PHP anymore, we cut our hairs and wear suits with ties now” in the community. In a lot of fronts it means mimicking Java, but I think it still is more flexible (and less reliable as the other side of the coin). It’s still very easy to drop down to “quick and dirty” code anywhere it’s needed, and it still benefits from a very low bootstrap cost to deal with single command/requests.
- patricklouys 9y agoPHP handles null better than Java. That's the one thing that kept me from switching to Java tbh.
- linoge 9y agoImplying that having null is a good idea at all.
- patricklouys 9y agoThere is nothing wrong with using null in PHP...
- gtsteve 9y agoSo how would you represent an absence of a value? In an enum that'd be easy, but there is a semantic difference between an empty string and a null string. Or would you propose sending a boolean to indicate null as well as a string in a data type?
- paulddraper 9y agoSee the Option/Maybe pattern, which uses sum types rather than unions or sentinel values. https://www.lucidchart.com/techblog/2015/08/31/the-worst-mistake-of-computer-science/ https://www.lucidchart.com/techblog/2015/08/31/the-worst-mis...
- RhodesianHunter 9y agoCheck out Kotlin. String is not nullable String? Is nullable and the compiler/ide will force you to check for null when you use it.