I think that's due to people having flash backs to terribly written code in both languages.
For example, PHP apps pre-2005 rarely if ever used frontend controllers, preferring instead to twine in configuration and helper functions into isolated pages that were directly served by Apache. This meant that there was no single obvious place to put things like caching.
Additionally, once upon a time, PHP didn't really have well developed ORMS, so everyone just wrote queries and hopefully parameterised queries---but not always. So if you had a hobby project that took off, then within 3 years it'd be a roiling ball of mud where it's difficult to do basic things like tracing which calls happen per page.
PHP came to prominence early in the web, and it was easy to use so everyone had a hobby project that took off, or had to work within something like that. Hence the hate.
To compare it to Javascript, I think the disdain for both languages is due to their initial nature---they were both written over an short period of time, and evolved in spurts rather than being carefully designed from day one or designed to overcome the shortcomings of another language.
The quality of the above really shows up in the inconsistency of the standard libraries, and the fact that certain semantics were inconsistent or danger zones in practice but couldn't be changed.
---
I do remember though when everyone hated C, and loved C++, then went back to loving C... so maybe programmers are just fickle and none of what I said makes sense. :)
That shouldn't be seen as a mark against the technology. Nobody is forcing you to switch tools.
Except when they do because they're the front end team. :P
(Or just have a rule that as a team you try e.g. '1 new thing' per project).
Again this shouldn't be a reason to hate on the JS community.
As a hobbyist Node developer (day job is not in Node), I find it hard to talk with other Node developers as there is some build-tool or even full framework that sits on top of Express that I "should" be using but I'm not. But maybe it's just me.
I think the dislike comes from the idea that JavaScript-development can be or at least was very messy and that "the JS-people" now try to carry that over to the server-side.
npm also has many issues and node as a server-side VM wasn't very dev-ops friendly in the beginning, if I'm not mistaken.
Note: This doesn't mean I don't like JS or node, I use them daily, though I have never used a production node-server. I'd rather run my JS on the JVM.
And yes there is a lot of horrible PHP code out there, writting by bad developers. I guess newer or not as accessible languages don't have as many bad devs as PHP/JS.
But if you have good devs, I prefer a good PHP codebase to any other language that I have come across (I tried a lot of them).
I have never felt so uninspired by a language. My overwhelming feeling from the get-go was that it was a collection of libraries, which would be fine -- but why create a new language?
PHP has the rare distinction among languages of not containing any novel features or ideas. Not only that, but it borrows liberally from several other languages, resulting in an overabundance of syntax. Instead of a tool for attacking problems, it's a reheated leftover. There is not suggestion of a better or worse way to accomplish some goal.
Finally, the original premise of PHP, interspersed functional code and HTML, is high on my list of really bad ideas. Code written in this style is doubly-challenged in terms of reuse and maintainability. Again, there is again no semblance of better or worse with this approach. If you had Richard Stallman and Linus Torvalds produce the same website with PHP, there would be very little in common between their approaches.
Given the success of Facebook et al, I presume that the interspersed code/html thing has been superseded, and further that the egregious security issues in PHP have been fixed. But the picture in my mind's eye is something that lumbers along despite its thorough mediocrity. I will allow that making PHP adequately consistent and secure are impressive feats.
Sincere question: how am I wrong here?
====== edit ====== Drop extra 'the'
I'll counter that one of the main reasons PHP became such a used language (other than ease of deploy) is exactly the reasons you dislike it. There are multiple ways to do things - that coincide with the ways you do things in many other languages (which it steals from).
You dont have to learn anything radically new to use it, and that makes it very easy to do things quickly.
It doesn't. But if your language ideas are admittedly no better than the next guy's, what's the point?
Its the lowest barrier to entry web language - and honestly, I'm ok with people writing shit PHP. It gets good Ideas out there quickly - allowing the business to grow without a focus on the Development. This creates opportunities for sharp developers to come in and work on proven ideas.
For me PHP is like Java but with sane nullability. It's like python but it actually has interfaces so that I can do proper OOP.
That's one big important point.
Nobody sanes mixes HTML and PHP code anymore these days. Most people are using Twig for templating or at least something similar. Everything (decent) is object oriented these days.
So your views were correct 15 years ago, but have a look with fresh eyes and you will see something completely different.
But if you narrow that down to actual developers who have a job working on a product, not someone hacking a wordpress template, then it will look much different.
Not saying the average PHP developer is great at OOP, but at least things are moving into that direction. And the code quality has come very far since 2001, just look at at current open source libraries (see packagist.org) and compare them to old PHP code.
I agree with this sentiment very strongly. I understand that there's a lot of hate, flamebait, etc etc about the language, with which from my own experience I agree with or disagree with in fairly equal parts. At this stage, I have written more large web projects in PHP than any other language (for varying reasons). I don't proselytize on why it is (or is not) a good language. But for me, personally, a huge chunk of whether I'm happy or not comes from whether I feel inspired while I'm working. Quite separate from the excitement of solving problems: while working with Rust or Python, I get excited, and am generally happy (even when fighting with Rust's compiler); while working with PHP, I tend to feel vaguely annoyed. Take from that what you will.
I'm of the opinion that the best tool for the job is the one you know how to use, and in the real world of deadlines and opportunity cost, if you get a great PHP dev to write your application in Python it's going to be far more expensive and far worse than if it had been written in PHP. But it's also going to be far less fun to both write and maintain. I think you have to make your language decision depending on your priorities.
> the egregious security issues in PHP have been fixed
This I strongly disagree with. And I don't think it's possible. It's not that the existence of the language includes vulnerabilities, it just makes it extremely difficult to write applications securely. I actually teach an upper-division university class on Network and Application Security, I am writing my PhD dissertation on the topic. I have worked on the internal security team of a very large company, and I have worked as a penetration tester / security auditor. I am very familiar with the vulnerabilities that plague web applications. And I still occasionally find the odd XSS vulnerability, timing concurrency attack, etc. in PHP code that I myself have written. And most PHP applications are not written by people with my background.
Exactly! I was never satisfied with my PHP code, as there does not seem to be a better and worse answer in many cases.
For the record I did not mean to assert that PHP has become secure, I meant that I presumed it had. Some years ago it was a laughingstock on Bugtraq.
Thanks for the feedback!
You can easily create a collection from data and process it. For example using the DB class to get data returns an array of Std objects.
For a legacy app I'm working w/ --it needs to be an array of arrays... I could for loop, and then add each to a new array.. or I can simply do:
$data = DB::table('something')->where('something')->get();
return collect($data)->map(function($x) { return (array) $x });
There's a talk at lara-con on using collections to replace just about all loops, and it's pretty insightful and makes code so much more readable and enjoyable.
PHP by itself can be ugly -- but the Laravel community has created something beautiful from what used to be akin to horse shit.
Static calls and active record are not good OOP. Neither are Std objects.
Have a look at doctrine if you need an ORM. Otherwise read up on DDD and SOLID.
If you need anything more resilient server side then I'd recommend using a Golang or Elixir framework like Phoenix which has multi-threading.
In the end good PHP code ends up looking like good Java code I think. But you don't have to worry about everything being nullable.
But then horrible PHP code is something else... Luckily I don't really have to touch that very often.
This is my life right now... lol
It's not so bad, but the frustrating part is when I talk to people in interviews about all of the great work I'm doing modernizing (the surrounding) WordPress infrastructure and the tools I've built for it, their eyes just glaze over.
I frequently get told "you're a talented developer and you're wasting your time working at X". Well, at least at my job I get to remove technical debt constantly. I don't feel like that's the case at these places I'm interviewing.
Luckily I'm currently working with a PHP7 app, so all is good, but my next app will likely not be PHP at all.
Guzzle doesn't look that bad. It looks like requests from Python, but you have to create a client first.
> $client = new Client(['base_uri' => 'http://httpbin.org']); > $response = $client->get('http://httpbin.org/get');
Or in Python
> response = requests.get('http://httpbin.org/get')
Not a knock on php on my part, PHP is equally suited.
I would have personally probably chosen Flask (python).
Poll: What's Your Favorite Programming Language? (2012) https://news.ycombinator.com/item?id=3746692
Poll: What's Your Most Disliked Programming Language? https://news.ycombinator.com/item?id=3748961
***** Python, Rust, Lisp
****' Go, Swift, C, PostgreSQL
**** Elm, Elixir, Typescript, Haskell, OCaml, JS-ES6, Kotlin, Crystal
***' Scala, Lua, Clojure, Erlang
*** C#/.NET, Java, C++, Ruby, JS-ES5, MySQL
** Node JS, RoR, Meteor, MongoDB
* PHP, VBasic, Cobol, CoffeescriptIf we're including MySQL and PostgreSQL, SQLite should be way up there based on the universally positive comments. MongoDB might be ranked too high at 2, though people have begun to acknowledge that was because they tried to use it for the wrong task.
* * * * * WASM
Dare to question the pragmatics of diverging web dev practices into a whole new realm of complexity and drown in downvotes - and a litany of people being downright personally insulting/condescending. This is sort of a corollary to JS being * (I think you ranked ES6 too high) and I've been inured to people hating/ranting against JS to a point - but even I was shocked by the personal rancor that oozes out if you try to have an objective discussion about whether the web really needs one more language.
A lot of HN users are for example startup owners/creators so it's normal that they will prefer easy and semi-automated language like Python.
Maybe something investors should think about? Ehh, who am I kidding...
Developers will handle that. And if they want jobs, startups must be made. As you might know, successful startups are made by less technical people mostly...
But I rarely see any positive mentioning on HN about c#, .NET, C++ or Java.
I think that might be a slight exaggeration. At present, zero of the stories on the HN front page appear to be about Node.js.
If half of all HN front page items were about Node.js on average, the probability of getting (let's say, conservatively) 40 with none about Node.js would be (1/2)^40 or about 10^-12.
Of course people exaggerate and I am fallible. If 30% of all HN front page items are about Node.js on average, the probability of getting at most one such item out of 40 is about 10^-5. Which is, y'know, still much less likely than ten consecutive heads when flipping a coin.
Over time my excitement changed. I assume others may share my thoughts hence the less excitement:
* It is on the JVM and there are lots of languages on the JVM competing with Java.
* While the fusion OOP + FP fusion is interesting I have grown wary of kitchen sink languages. There are so many ways people write Scala. Scala from one project looks vastly different.
* The endless DSLs
* Java 8 is often good enough. Particularly for interop and community support.
* Every time I have to add Scala to a Java project I'm thinking here comes 9MB jar that some classpath scanning thing is going to take its sweet time on (Spring, Servlet 3.0, etc).
But I think most of the reason is Rust has filled that hard core typers niche with the added novelty of unique memory management and competing with other LLVM languages instead of JVM languages. Scala has become "old" like Java and OCaml :) .
* It also compiles to Scala.js (it's actually the independent best compile-to-JS language out there in terms of libraries, tooling and IDE support). Support for compiling directly to native is coming around nicely.
* Scala is quite far away from the kitchen sink, and many of the questionable parts have been deprecated and/or removed.
* I have never seen much DSLs while writing Scala. Sure, it's probably quite nice, but I have rarely seen endless DSLs in practice.
* The jar is around 4MB (2.12) and when writing idiomatic Scala (~ not Spring/Servlet) there shouldn't be any kind of reflection or classpath scanning happening.
As far as kitchen sink I'm still not sure what idiomatic Scala is especially with the likes of Scalaz. Maybe modern Scala is finally abandoning the OOP fusion.
Of course my biggest reason of not liking Scala is completely arbitrary and almost illogical (of course most reasons to (dis)favor things are arbitrary). If I write in an FP language I hate using curly braces. I prefer Haskell, OCaml, and even Lisp syntax for FP. For some reason curly braces makes me think hmm imperative shit. Not to mention Scala has lots of scoping and closure use so you see lots of curly braces.
And that brings me to another point. Scala code isn't really that much more compact (lines of code or even compressed size) to Java 8 (compared to Haskell or OCaml).
[1]: https://mvnrepository.com/artifact/org.scala-lang/scala-libr...
[1] https://mvnrepository.com/artifact/org.scala-lang/scala-libr...
I would disagree with the comment on verbosity compared to Java 8/Haskell/Ocaml. Most of the things I do regularly in Scala would require a magnitude of more code. Ocaml doesn't even have higher-kinded types or implicits, so I don't think it can win much on that front (except of saving a line where Scala's curly brace might be). With Haskell it really depends. There are certainly ways to write much more succinct code, but what I see in practice is that it's not that much different from Scala. Haskell has it's own unsolved issues though: broken typeclasses, lacking module system, poor tooling, and a weekly-changing, terrible dependency management.
HKTs are great for a generic library writer (aka standard library) but I think the over abstract nature ends up confusing your average developer. You basically have your type aficionados obfuscating the codebase for developers who can barely handle generics. It is sort of analogous to using massive reflection / meta-programming in scripting language (albeit far more safe).
Being extremely implicit and abstract comes with a cognitive load.
OCaml's Functors (ie super strict and explicit) on the other hand can get massively repetitive.
I vaguely remember HKTs being expensive compile time. Is that still the case?
I think they're a necessary evil. I need extension methods, ad-hoc polymorphism, and a way to use ad-hoc polymorphism while still writing nice DSLs (i.e. what spray calls the magnet pattern). I'm nervous about implicits, but I haven't seen a better solution.
> HKTs are great for a generic library writer (aka standard library) but I think the over abstract nature ends up confusing your average developer.
There are few things more frustrating than having to copy-paste because your language can't handle the abstraction. There are less cases where you need HKTs than where you need basic generics, sure, but sooner or later you do need them. And since everyone hates copy-paste, they end up using annotations or reflection or string-based templating to generate code, all of which end up more confusing to the average developer. At least with HKTs you still have ordinary values that follow the rules of the language, rather than wondering whether you can still factor out a common method because it's called from an annotated method and an unannotated method, and what annotations you need to put on it to make that work.
> I vaguely remember HKTs being expensive compile time. Is that still the case?
HKTs per se are not expensive. Type inference in the presence of HKTs can be expensive (though note that even in OCaml or pure ML there are pathological cases for type inference - http://cs.stackexchange.com/questions/6617/concise-example-o... ). Scala implicit resolution can be expensive especially when used with recursion; global-uniqueness constraints a la Haskell typeclasses would be one solution, but arguably introduce more trouble than they're worth. One way or another, Scala compilation ends up being pretty slow, which is unfortunate.
The average programmer can enjoy completely consistent names and signatures across different libraries, without having to know that the consistency comes from one method being applicable to various types, not manual labor repetitiously adding the same method to different types which can drift apart at any time without anyone noticing.
HKTs are not that expensive. Slow compile times are usually caused by people doing Prolog at the typelevel in Scala.
Replacing Node.js with JavaScript doesn't help either as the frontend vs server-side vs npm ecosystem vs es2015 becomes a loaded question .)
Lisp *****Anecdotally I would have expected Javascript to be near the top of hours being used.
This person could ROCK at C++, but who's going to look at his resume and give him an interview?
Julia *****
(or maybe that's just my opinion :-)Sure, PHP has it's faults, but as your article points out, it's designed to give people who aren't full time programmers tools with which to build websites or scripts to perform tasks, and there is a large market for that sort of thing.
And just like that, the cyber-security profession was born.
Admittedly, the author of that post lost me pretty early on when he said that languages don't need to be predictable, it's on developers to learn everything about how and why a language implemented things they way they're implemented, and complaining just means you're lazy. Sorry, but when I can guess at syntax in Python or Ruby and be right(because the languages were designed to be predictable and consistent), I don't want to consult arcane documentation in PHP to figure out why things don't work the way I expect them to work.
The author is also pretty rude and flippant, often when he's not even right. He ignores things like the Fractal author explicitly saying that Wikipedia and Facebook have very smart developers, so he can say that the PHP "community of amateurs" comment was about those developers. Pretty disingenous.
He repeatedly complains that the author "doesn't understand" "loosely typed" languages, but never considers that maybe the author understands them but thinks they're bad design, hence the whole "fractal of bad design" in the name of the post?
/ goes to a corner to cry...
Indicators for languages which are liked by the HN community:
- Positive stories get many upvotes and are instantly at the top of HN
- Most comments are positive
- Frequent coverage on HN about the language
Indicators for languages which are not liked by the HN community:
- Rants get many upvotes and are instantly at the top of HN
- Most comments are negative about the language
- Rare coverage on HN
Applying those indicators, following languages should have these like-levels (on a range from 1 to 5):
This is just my feeling, happy to hear your perception. And this does not reflect my opinion about those languages in any way.