Only engineers care about programming languages. Seriously. That's it. No one else cares about them. I work in a large public university alongside a revolving door of student interns who are always 19. In 10+ years of work, I've still yet to meet the person who talked about their favourite website or app, but lamented that it was written in Php or JavaScript or Go or Java. It's only us (the HN'ers) who fret about this.
Don't believe me? Imagine the look on everyone's faces at the tech publishing houses around 2009 when books about Objective-C sold a few hundred copies a year to doing tens of thousands per month when the iPhone rocked the world. This happened without a proper language hot stove on Hacker News, no?
People care about outcomes. People care about products. People care about being dazzled. People care about showing their friends this incredible thing they saw on the web/this new app.
Rarely. Mostly they care about meeting quarterly goals and budgets; and ease of finding inexpensive, more-or-less competent talent. In both of these, PHP excels.
I'm currently maintaining an app stack for a Fortune-100 company that, if I told you what it was, you simply wouldn't believe I was telling the truth. That's how out of date it is. "Scalability, performance, technical debt and quality" never entered into it. All anyone ever cared about was "does it get the job done and what does it cost to keep it running for another year as-is?"
This. In my previous job, I was literally told by my boss, that they'd consider switching from PHP to something like Ruby or whatever, but PHP programmers are cheaper so that's why they stick with it.
https://blog.famzah.net/2016/02/09/cpp-vs-python-vs-perl-vs-...
http://benchmarksgame.alioth.debian.org/u64q/compare.php?lan...
But I think, what's important to note is that PHP 7 has improved in speed department by a great deal.
Java-8 is using java.util.regex which is written in Java, PHP is passing the regex requests to it's own regex process which is actually a C package and performs a lot faster.
What we're actually comparing here is:
time(java.util.regex) > time(php compilation + c regex package)
No, the fastest Java program shown does not use java.util.regex
The fastest Java program shown uses com.basistech.tclre
> a C package and performs a lot faster <
You're welcome to contribute a Java program that uses the PCRE library --
Back in 2012:
"5) The idea is to help you understand that you aren't comparing what you say you're comparing.
If your intention is to compare time taken to grow a list, then shouldn't you start with lists that are the same size, and start with program heap that's the same size, and use the same max heap size?
user+sys for your Java program = 20.56s
But change ArrayList<Integer> s = new ArrayList<Integer>();
to ArrayList<Integer> s = new ArrayList<Integer>(8192);
and run with java -Xms1G PrimeNumbersBenchmarkApp
user+sys = 6.9s
I don't think you're comparing what you say you're comparing."http://www.famzah.net/download/langs-performance/java-discus...
You seem unnecessarily argumentative about this, almost like you're angry and I really don't understand why. There really isn't that much difference between languages like Ruby and PHP to warrant this and almost anything can be expressed in almost the same way, the only real differences are syntactic sugars and the "flexible" type system.
Modern PHP frameworks and tools are good, perhaps even excellent. Composer and the PSR-# efforts have spurred a renaissance in code quality and interoperability, and PHP7 brings some truly impressive speed improvements. For those of us who aren't stuck supporting legacy code, that is. One of these days I will be working with a language whose syntax I enjoy, but until then the language that puts the "sin" in "syntax" will (for better or worse) keep getting the job done.
plus like you say PHP might be faster to get started with but becomes much slower on larger projects due to inconsistent error handling and language design.
"Will your toy benchmark program be faster if you write it in a different programming language? It depends how you write it!" ;-)
Don't trust everything you read on the internet, run the benchmark yourself and see if that result is actually reproducible. (Depends on the heap size.) There is also a "non-std lib" java test case, which doesn't generate as much garbage and, of course, performs much better.
It's at this point that shit falls apart and the manager starts to care about these technical choices and all of the time and money that will be needed to be spent to rewrite.
Call it maintenance costs if you want but those costs are directly affected by the technology decisions you make.
Process fork, CoW overhead every time you mutate a page, and a full OS thread per request. Oh, and let's not forget negotiating a new database connection per request.
I think by the time you've added up all those overheads, you're not off to a scalable start. It's possible to work around the limitations, but it's not easy.
In Zend Framework it's slightly better because it includes an autoload option, which implies only PHP files that are actually used by athe request, get loaded. That way the overhead is "only" 50ms.
http://php.net/manual/en/intro.opcache.php
https://blog.famzah.net/2016/02/09/cpp-vs-python-vs-perl-vs-...
You need a lot more than a "Sieve of Eratosthenes" code snippet to back that up :-)
This only proves Drupal is slow.
Eh, any PHP developer worth their salt is implementing PHP-FPM. The days of forking expensive Apache processes have long been over.
But that said, forking processes is not really a problem unless you do really long lived connections (such as longpoll handlers). Many other languages do that. Not many other languages have kept the CGI-like request model that PHP has, though.
It encourages things like parsing code or even opening database connections on every request, unless you cache them. (Which you probably do if you are a PHP developer. But it's not always as automatic as one would hope. Have you checked your application still fits in the cache you set up?)
That was a pretty common truism 10 years ago, but machines haven't gotten faster at the same rate lately.
i wrote and ran a big php app (Zynga's Mafia Wars). this is just about the app server (apache + php side), single-master MySQL will give you far greater problems at that scale.
everyone is tearing away adding features, and the code just keeps getting bigger. everything includes everything else. so you can't just start fresh with every request, it takes way too long. so you use APC or whatever. now you have global shared state (and people start using it), but as long as no one really fucks it up that's ok.
php processes are always erring and dying in weird ways that no one can figure out, especially if anyone uses the half-baked OO stuff (circa 2008-9), and tracking down obscure php state errors ranges from difficult to impossible since you're never quite sure when or where something went wrong, but it works for most people most the time, as long as you remember to clear out the error logs so they don't get big enough to crash the box.
memory use still sucks at around 30M a process, meaning you can only have around 500 workers on at 16G RAM server, but it's workable. at least it's not rails.
because it takes a while to talk to even Memcache (go forbid you talk to MySQL) and do all your silly user updates (games are really write-heavy) you are taking a few hundred ms per request, so 16G mem servers (it's 2008) safely top out at around 500-600 req/sec, and i think would melt close to 1000 or so. remember, your throwing everything you have at growth and features so you're not really optimizing shit.
cool, just need more hardware. which is no problem. if you can get hardware. when you're co-located it takes forever to get new hardware online. not really an option. and even the F5 load balancers can only take so much. and there are issue with getting too many app servers talking to too many memcache servers. or something like that. after i left i think they saturated the data drops, which really puts you in a bind.
but that's not a problem now, with cloud services, right? except that those are not limitless either. i think FarmVille ran into a wall where AWS wouldn't / couldn't supply more instances (again, this was around 2009-10 so prob a lot better now). and those are still physical machines in physical datacenters somewhere that will have all the same problems and limitations and then some.
but you're going to have problems with any app runtime at that scale. and php's performance was an order-to-two or magnitude better than rails, and we never figured out how to get significantly complex and traffic-heavy java apps to stop leaking memory. though i'm sure you can. and you will! like i said, it's all solvable. hell, even MySpace didn't fail because of tech infrastructure.
what i'm saying is that php wasn't (and maybe still isn't?) particularly fun when throwing hardware at it doesn't work, and you end up losing a lot of the purity / simplicity of the model because it's too damn expensive. ffs, Facebook re-wrote the runtime. that's what it took for them. and my friends there tell me it's pretty much like writing java at this point. it's a fine choice, but i'd rather not use it again. had a much better time with python before javascript ate the world.
Again PHP (the language) vs. Rails (the framework).
What framework was that `big php app` using?
PHP is a framework. True it's not a particularly nice one, and some people build even more layers on top, but it comes with all manner of HTTP/url/DB/etc. stuff out of the box. It's also a templating language (that's what the "<?php" tags are for); although, again, not particularly great, and some people layer more abstractions on top.
I can (and have) just grabbed Rack and rolled most everything myself in Ruby and it has way less overhead and is much more performant than Rails. Ruby also has it's own templating language; ERB is part of Ruby core.
So comparing PHP to Rails is a bit apples and oranges.
If you are making a technical comparison then it needs to be at the correct layer of abstraction. If we were to compare performance of Laraval and Rails that would be a fair comparison.
If we are comparing on performance then PHP should be probably be compared to Ruby+Rack since that is sort of the lowest common denominator.
I'm not dogging on PHP here either. Even comparing at the correct level; PHP is still faster, but lets make sure we are making the right comparisons.
i was clarifying the compassion.
it was a huge pain to try and get php to do anything else. it was totally unpractical to do the kinds of back end processing that we needed (since the database was pretty much off limits during a http request)... long running processes with hundreds of millions of objects were a no-go. believe me, we tried. which meant you had to sync all your logic into Java or something else that could handle the job. which is really error prone when you have a bunch of people moving fast on something.
one of the greatest things about php is that it's a super minimal focused framework. it's also one of it's major short-comings when that model no longer suffices.
you can layer something else on top of it, but the stuff available at the time certainly didn't help the performance or memory characteristics.
Dealing with limited resources such as MySQL and Redis is a problem you still have to fix when you move away from PHP though.
As for the Facebook runtime, for us it was a case of drop in HHVM, fix a handful of issues and get a 4x or 6x speed increase for free. You only need to change the way you write if you move to Hack, but I think I agree with you that's probably getting to the limit of the effort reward tradeoff before you rewrite in a different language.
Sure, they'll be some guy who's memorised all of PHPs quirks, but for most of us the inconsistencies make it hell to program, because you're always looking up stuff. As a result, writing secure PHP is possible, but far harder than it should be.
IMO the laughable security track record of e.g. Wordpress have damaged PHP's reputation more than anything else.
C is also a language with a frankly horrific security track record; at least an order of magnitude more so than PHP. But C continues to be used because it is a useful and relatively simple language despite its warts and pitfalls.[1]
Security is just as much a business process as it is a technical feature.
______________________
1. Granted, one of the major design goals of Rust is replacing C, but you get the point.
I think your comment about C is right, however in many cases mercifully the C code isn't facing the internet :) When it does, it can go very wrong, e.g. OpenSSL.
The extra cognitive load doesn't guarantee failure, it just makes it easier to slip up. Even with Python or Rust, you can put insecure code in there (e.g. with Python's subprocess.call(..., shell=True)). Realistically, strict modes and linters are always a good idea and can catch most of these pitfalls.
The gist was that PHP was designed for web use, so it's almost always facing the internet. C on the other hand is very much multi-purpose. Both can be made secure, but maybe it's less effort using something that helps you with security (Hack, Rust, etc.).
(BTW, your comment contains a huge fallacy: Just because a majority of packets touches something written in C, that doesn't mean a majority of C code written is exposed to the internet. This is arguably the entire point of e.g. iptables.)
You could say the same thing about cars people don't care about what sort of engine is under the hood or how it works they just want to go places! It doesn't then follow that all cars are the same and you are just as well getting any one of the millions of cars or even any one of the models out there.
Indeed it isn't. "Maintenance" has opposite meanings in those worlds: maintaining a car means keeping its original functionalities still available; maintaining an application means letting it evolve.
So what? Who else could care for something apart from those professionals using it?
Maintenance is the biggest part of software development. A wrong technological choice can turn my nice job into my worst nightmare. Why shouldn't I care?
I think the intention is: While they are important to us, languages are frequently distorted to the point that we believe that company success as a whole is dependent on it. Companies like Facebook flatly contradict that. I agree with you in spirit: Facebook would obviously prefer not PHP. But if the choice is: Learn something other than PHP or use language I know to test some idea, I think the latter is an obvious choice.
You call it poor management in retrospect, but it's succeeding in spite of the tools when you're still doing ok. There's a lot of companies that exist in between failure and "Facebook" who don't have hockey stick growth curves who also can't afford needlessly higher technology costs, whether that's in infrastructure or staffing or opportunity costs in getting features to market. If PHP does't incur a higher cost personally, go for it, but it might be a strategic disadvantage later if you don't hit it big.
That's not a reason to use horses instead.
It's sadly quite common for non-engineers to make technical decisions such as what language, tool, or hardware will be used, and everyone else just has to live with it.
Asking as I've developed in a slew of languages and never found the PHP-bashing credible. Most of the complaints seem to come from Rails people, but there are no shortage of MVC frameworks in PHP, including at least one that is a direct clone of Rails.
Plenty of A rounds have been spent trying to make a sand castle taller.
This is not unique to php - I'm sure you can do it right - but it's more common to it.
A truly good idea will generally find a way to succeed despite the technology it is built on, though. Look at Facebook, Slack, and countless others running PHP or Minecraft running Java and its apparently horrible code base (I've never seen it, so that is secondhand)
- We aren't very good at judging the relative virtues of tech
- Most tech is good enough to express most concepts even if not equally well. If its possible to express it even if it takes 3 times as much work and is only 70% as good you wont notice from the outside how much the tech mattered.
- Good ideas are worth enough money to throw enough time/money at them to be moderately successful
The language you use pay second- and third order dividends, but most battles are fought and won on first order.
I'm a C++ developer, have shipped Java and C# and Haskell and Python and a bunch of other code in production. If a friend asks me to spin up a website for him/her quickly, I'd still do it in PHP.
Horses for courses.
For many use cases where it is relevant, static site generators like Jekyll can actually imitate "dynamic content" from the perspective of the people running the site.
The most important use cases for dynamic content these days are web applications, as distinct from "websites". On the other hand, web applications are also the most important use cases for better development ecosystems than are easily attained with PHP.
In my experience and observations, the cases where PHP's easy provision of dynamic content capabilities make the most difference are websites (as distinct from "web applications") on shared hosting platforms or bootstrapped by existing content management systems like WordPress and Drupal (which are, in turn, often easily used because of either hosting platforms specifically for those CMSes or shared hosting providers).
NOTE: I'm not sneering at "websites", as distinct from "web applications", as many people who draw such distinctions do. I'm just pointing out there is a distinction to be made between two different types of projects involving deployment of a codebase to a web server. Speaking only of the technology's proximate purpose: in one of these, the primary purpose of it is to make content accessible to the public; in the other, the primary purpose is to make functionality accessible to a userbase.
To expand on this, static website generators are best for generating documentation and small blogs. It falls apart when you have a large often-changing content. This is where PHP is still king of the web.
Today, when one can have workflows via jekyll/git/Continuous deployment, at what frequency of "often-changing" should one move away from static websites to a php based solution?
Or a simple guestbook or hit counter.
Where the lines may blur is JS front end talking to a BaaS... This may make it possible to glue up impressive sites using just HTML and JS with no custom backend requirement.
PHP is still widely used, but there's a myriad of other contenders: Java, ASP.NET, Python (Django,Flask,etc), Ruby (Rails), Perl, Javascript (Node,etc) and others.
I'm not sure about PHP being the "king". PHP might be the most widely deployed thanks to either FB or the huge number of legacy bulletin boards and wordpress sites, but in terms of new deployments does it still dominate? Probably not. (For novices, a static site generator is definitely the way to go, until you run into it's limitations.)
I also made a start with PHP. Still, PHP has been slow to learn from other languages and frustratingly refused to change established behaviour. I found PHP to be far more "dangerous" for the amateur programmer than other languages. Finally, I switched and never looked back.
From teaching beginners, I actually think Python + Flask has a similarly shallow learning curve, but more room to grow and to "do it correctly" (e.g. the templating is much cleaner and the routing much more powerful). I recommend it.
Hopefully you get the point.
(I do agree that PHP without something like Symfony, Yii, ... Laravel, even Cake could be very dangerous, or at least, counter-productive for amateurs trying to learn though)
Some companies are succeeding in spite of [insert language]. There are many, many users of [insert language], and we'd expect that there would be considerable variance, with some users doing awful (no traction, buggy sites, etc) and some hitting home runs (facebook). Because it's such a popular language, it will have users across this entire spectrum.
It's easy to cherry-pick the winners and miss all of the tremendous losers who picked [insert language] and got nothing for it.
I mean, essentially all you're saying is "startup success is largely uncorrelated with the programming language used to implement those startups' products". That seems like not at all an unreasonable position.
(It's not, by the way, equivalent to the statement "choice of language doesn't matter".)
Mind, I agree with you, but given the Holy Documents Handed Down By Our Lord and Savior, Paul Graham, HN... might not be the safest place to say it.
Edit: so, I'm clearly getting a lot of downs on this... maybe sarcasm in reference to PG was going a bit too far. Oh well. I'm not deleting or editing any of it, because that's sort of dishonest.
You can go to any Ruby meetup and you will see it's different than PHP meetup which both are quite different from Functional Programming meetups.
Thus I would say that it's not about the technology but about people whom you attract (i.e. culture).
I skip luck & timing, these are mostly random and one has very little power to influence them.
Finally, if you went travelling to any other country (except Austria or Switzerland maybe), the rest of the world had Facebook. So to keep in touch, you also needed Facebook, which had a better user experience. Why bother with both?
"and miss all of the tremendous losers who picked php and got nothing for it"
certainly applies equally across all languages in my opinion.
The grandparent of your comment suggested that, yes, these projects were lifted up by PHP's un-fancy nature giving them focus. The parent of your comment was suggesting that, basically, the companies that have succeeded using PHP aren't any more numerous than we would expect to have come out of the massive PHP userbase even if PHP doesn't offer any advantages at all.
The observation that "PHP, for quite a few years now certainly has NOT been the language of choice for most startups, yet we still see the majority of them fail" seems to be responding to a nonexistent conversation in which people were positing that startups based on other languages don't fail. Nobody here is saying that other languages magically make your business succeed.
If you aren't following the PHP Framework Interop Group (http://www.php-fig.org) then you really should. I'd hazard that most of the warts in PHP can now be avoided pretty much altogether, and those that can't quite possibly can be worked around through configuration.
It's easier to reroll in another language and retrain or recruit? No. So you probably mean for a new project. So now you've more maintenance and learning curve unless you just happen to have enough skilled in $NEWTHING. Not really easier.
PHP is an inconsistent mess, everyone knows that, but it's cheap, widely understood, and it's perfectly possible to write decent maintainable code. There's ways to mitigate the chaos.
Would'nt the good ones logically move to a different language ( JS/Ruby etc ) where they could bill more?
If this was about JavaScript and Front-End I might've agreed with you (there are transpilers but interoperability with JS modules can be tricky), however in the realm of servers there's so much freedom.. so why choose PHP out of them all?
Depending on the type of project, I would choose PHP over at least some of the languages you mentioned; I guess "great" is not a significant quality when making architectural choices.
Just to be clear: I was thinking about factors like performance, choice of servers, how easy it is to hire good developers, library ecosystem etc.
EDIT: obviously the "awesome aspects" mentioned by GP are a similarly unsubstantiated claim ;-)
Java: keyboard wear
Scala: not enough programmers
Python: not bad
Ruby: too slow
Haskell: math grad required
The documentation is really good. A model for programming language documentation.
Process per request is really simple to understand and scale. Your servers almost never crash completely, you don't get threads silently dying or run out of memory or thrash the CPU doing garbage collection.
It runs like a tank. It will, for better or worse, just keep running when more fussy languages would have seg faulted or shut down
The tooling, framework and libraries are very advanced and in active development
It's easy to train a programmer in php
It's close to the c library
The combination of a very flexible array/map and functional programming tools like map and reduce let you write pretty declarative code and development can be very fast
Php storm
Facebooks replacement runtime
I work with Java and Scala now which I also love but development is much slower and more expensive, whilst deployment is cheaper (less hardware for same request throughout)
How easy is it to train a programmer to use PHP in a way that results in fairly secure, reliable, bug-free code? (Note my use of the word "fairly", knowing that there's no such thing as perfect security, reliability, or freedom from bugs.)
I do know that, for instance, TDD is possible with PHP. In my experience and observation, though, the available developer tooling does not even come close to that of (for instance) Ruby, so I figure I must be missing something if "the tooling, framwork[s,] and libraries" constitute a major advantage to PHP over other options.
Well firstly phpstorm is a very high quality. I can work with php code in various contexts such as running test suites, normal development and connecting to a live server. It definitely has good support for running and debugging test suites including unit, integration and functional. There is support for vagrant and docker as well.
The tooling is good because there are lot of users willing to pay for good tooling, but at the same time it can only exist if the underlying language supports the features needed.
I wouldn't say the libraries and tools give it a significant advantage over other languages actually, but it's a notable factor of php development that there is likely a framework and library for your needs.
Regarding training, once we had a reliable application and we'd figured out as a team some best practises regarding avoiding php's bad parts, how to avoid or detect and handle runtime errors and how to organize and layout code, it's a fairly simple matter to point a new programmer at these documents and code samples.
There's really not much to the language and a smart and/or experienced programmer can be productive in days. I'm not sure that's the case if you move someone from say c to Python or from Ruby to Scala.
In my earlier days I did quite a bit of developer tutoring, and I have trained developers in PHP codebases on quite a few occasions, so I can speak to the training aspect first hand. I actually find PHP is fine to train developers in - certainly to produce simple code that is reasonably bug free, if not particularly high performance. The 'everyday' use of the language is usually quite straightforward - most projects don't deal with concurrency primitives, long running code, or low level interop. Scoping is quite straightforward. The only real gotchas are type coersion (use === for primitives or write comparator functions) and superglobals (use a library).
To be honest, JavaScript causes just as much confusion in my experience with scoping. Heck, a scarily high number of developers I know would struggle to implement a bug-free equals() method in Java.
As for tooling - here are some examples of good tooling in PHP:
- Dependency management - Composer and it's centralised library, Packagist (npm/rubygems/maven analogue)
- TDD and testing: - PHPUnit (ubiquitous, fairly well featured - built in fakes, code coverage) - Behat (BDD-style testing a la Cucumber) - Codeception (DSL-based) - All three tools have decent integrations with IDEs, can be run easily through Composer's CLI, can be combined with stuff like Grunt/gulp easily for file watchers. - I haven't needed the really esoteric features in my Ruby projects so I'm probably not the best to judge, but I can't say that I find PHP testing tools all that lacking compared to rspec, cucumber etc. I don't feel like you need complex tools for good testing... - Frameworks such as Laravel provide bootstrapping on top of e.g. PHPUnit that provide integration test componentry
- PHPDoc - ubiquitous, well documented, well supported by IDEs, linters, docgens
- PhpStorm (on par with the best IDEs out there), Zend Studio (very good IDE in its own right, eclipse-based), and Eclipse PDT are definitely servicable IDEs with good integration, good code inspections, good support for refactoring (especially now with PHP7 and it's further push into gradual typing).
- PDO - something most other languages have to be fair, but a language-supported SQL database engine abstraction layer is a must for working with SQL databases these days
- Gearman for task queues
Libraries and frameworks available in PHP are much the same as other languages in my experience, when it comes to stuff for the web. Not really much point going through them, suffice to say that there are some poor choices (Wordpress), and some good choices (Flysystem).
Not sure whether this is your real opinion or you are just making fun of people who say that.
http://php.net/manual/en/function.usort.php
It has everything I need to know about the function clearly laid out. The behaviour of sort when elements are the same. A list at the side of related functions that I may want to look at instead.
I also like documentation that includes user contributions as these often add useful caveats and usage examples that don't fit well in the general documentation.
1. They have exactly one set of documentation pages for all the php versions.
2. Another thing is that documentation can be quite wrong for even the fundamental stuff. I have seen a core developer blast out in reddit that "The documentation is wrong!", when the other party pointed them towards a piece of documentation.
3. Incomplete or shallow description. Go check out the documentation page for Exceptions in php and try to find information regarding the behavior of return statements in a 'finally' block. Now go an see the respective page in Python documentation and see how in depth the documentation is.
And having code samples is not exclusive to Php's documentation..
That will never happen, you can't write code like this in Rust:
<!-- Snippet taken from an example of tightly-coupled and unmaintainable code in the Clean Architecture in PHP book[1] -->
<body>
<?php $results = mysql_query('SELECT * FROM customers ORDER BY name'); ?>
<h2>Customers</h2>
<ul>
<?php while ($customer = mysql_fetch_assoc($results)): ?>
<li><?= $customer['name'] ?></li>
<?php endwhile; ?>
</ul>
</body>
Even when the previous code is an abomination, it is absolutely easy to write, this is why languages like PHP are a success, the barrier to entry is definitely low.The issue comes when the whole industry buys the idea that PHP equals bad code, fail to appreciate the progress the language has had in the last years, fail to appreciate the effort behind projects like Symfony, and become completely foreign to the current best practices.
Then a month later that guy that pulled those couple things into a web page is going to go "Hey, maybe I could make a thing to manage those.". And he's going to learn more.
Then a month later he's going to have another bright idea.
And suddenly someone with no programming background is a PHP programmer, and he's putting together ugly but functional websites and everyone is looking and going "MAN PHP IS AN AWFUL LANGUAGE".
There's a huge contingent of people that are maybe moderately technically savvy but are not programmers and are not necessarily interested in deliberately becoming one. These are the people that end up setting up entire businesses in some Lovecraftian Excel sheet. PHP is a language with a learning curve (even for a non-programmer), not a learning cliff, and it makes it really easy for these people.
Your argument is a bit spurious; you're right insofar as you can't write PHP in a language that's not PHP.
That is my point. You require effort in an order of magnitude greater than with PHP in order to achieve the same result, which in the case of a beginner, is the difference between continuing their journey in programming or abandoning the ship.
You are failing to see the big picture and are taking for granted the plethora of initial setup you have to do to begin working with a language like Rust (ex. generating bindings for a database driver written in C if it doesn't exist in cargo), you were just nitpicking in the syntax of the previous example (which BTW, I took care to clarify it was an example of bad code to avoid people not familiar with PHP from getting the wrong idea).
It was my fault to say "you can't" in my previous message (see Atwood's Law), I really meant "it requires too much effort".
An order of magnitude? Really? I don't think so.
Rust has a library (probably among others) called Horrorshow[1], that exports macros to do html templating.
You claim that it is easy in Php to do html templating. But you miss the fact that it provide zero sanity/security checks while doing so. You need to sanitize every one of those variables before inserting into the html stream.
You see, Php just trades off every bit of sanity and security for a little bit of ease of use. It is that simple.
Remember that a beginner programmer doesn't always have a background in Computer Science, maybe it's a child, maybe a graphic designer, maybe an elder person or a housewife. Are you really expecting from a person foreign to CS to stop tinkering just because they can't write secure and performant code in your favorite language?
Again, stop taking for granted the initial process setup and all the gotchas that you already know, stop nitpicking in the example of templating and see the big picture: A beginner programmer being able to get instant feedback with little effort in their browser of choice. No initial project or repository set-up, no install for external libraries, no huge development environments (like Xcode or Visual Studio), no build process or compilation, no command line, just an app like WAMP (on Windows) or MAMP (which people accustomed to homebrew avoid) and a browser pointing to http://localhost.
PHP is not a perfect language, but it's neither the abomination people like you describe, too many people judge PHP by its former state of the art and are unaware of the progress it has had in the last years, many of the most popular issues are already gone or at least are too difficult to trigger, to name an example, PHP stopped having register_globals since version 5.4, and PHP 7 added strict type hinting, which throws an error instead of doing unexpected type coercions.
That doesn't mean that PHP is a better choice than properly-designed alternatives, just that it's less worse than before. I agree with the sentiment of using a well-designed language like Rust, but only when a project really requires that degree of security and performance (ex. writing a browser like Servo).
A bakery website written by the kid of a patissier doesn't require that degree of security and performance... Or are you really going to demand that child to use your favorite language just because you despise PHP?
>A bakery website written by the kid of a patissier doesn't require that degree of security and performance...
I don't think so. Everything that is put online need to be secure. One day it is just a bakery website. Next day it is accepting credit card numbers. And the kid who did this can get employed as a php developer based on this experience, and might build stuff like that for years, with out a clue in the world that they are using a toy language.
You can, using some web framework crates, but PHP is many many years ahead from Rust in making web apps. And I'm not sure if its the right language for the web. You'd probably be fighting with the borrow checker and type system most of the time while the php dev is busy cranking out new features for his/her web app. There is also the problem of compiling huge websites.
Haskell doesn't support OOP if I remember correctly. And it is complicated too.
Python is a great beginner-friendly language, but that doesn't mean it's well-designed in other respects or appropriate for large software projects.
It wouldn't really make sense for Haskell to "support OOP" in the usual since. The OOP paradigm is mostly useful when you have mutability. Another way of looking at it is that you don't need OOP in Haskell because it exposes better ways of interacting with data that aren't present in most OO languages, like ADTs and Typeclasses.
That said, it is true that Rust has tricky parts. The domain is inherently complex.
Some companies are succeeding in spite of php. There are many, many users of php, and we'd expect that there would be considerable variance, with some users doing awful (no traction, buggy sites, etc) and some hitting home runs (facebook). Because it's such a popular language, it will have users across this entire spectrum.
It's easy to cherry-pick the winners and miss all of the tremendous losers who picked php and got nothing for it.