Hacker News new | ask | show | jobs
by nnq 4619 days ago
If you did a python/ruby/node-javascript that would capture the best features of PHP, instead of inventing a whole new language, I'd actually be tempted to use it.

The features (or what others would call anti-features, but one man's "bug" can be another's "features" so lets ignore the long talk) would simply be:

1. Ultra-Ease of deloyment - I want to be able to just:

- load a module for my webserver of choice (Apache, NGINX etc.)

- drop code in a folder via ftp and have it "just work"

- have a shared nothing app model with no long running processes, PHP style, because this way I can ignore 99% of security and performance problems, both as a provider of dirt-cheap shared hosting and as the developer of a web application that doesn't need to scale that much and isn't that much of a target for hackers either (so I can have the following mindset: "I don't need to care about scalability/performance or security, because by the time I'll need to care about these I'll be already making enough profit from it to be able to hire some very smart guys to rewrite everything from scratch the right way or I will have already sold the company and be enjoying my $ while others care about this")

2. Ultra-Eease of app/site setup:

- I want to just drop files in a folder and have it work, just like that, just like magic

3. "Don't make me think" style of development:

- I want the same language in my controllers, in my db code AND in my templates

- plus points if it's in the browser too

- have all the component I and other might need in "one pack", "batteries included" style

4. Almost non-existent learning curve:

- someone should be able to go from A - "poetry major with no knowledge of what computers are" to B - "expericenced full-stack developer" withouth feeling any learning curve: yeah, it will take time to get from A to B, the first 10% of the road should be made as easy as possible

...and to "kill" PHP you'd still need to add a killer extra feature. I can imagine something like an object persistence feature (Maglev/Gemstone style) baked into the language/library/framework that would allow you to simply persist objects without even thinking about a database (it could be implemented as a very smart ORM underneath, but it should be as opaque/black-boxed as possible and 99.99% of users shouldn't need to know how it works) - this imho would be the kind of thing really enjoyed by PHP developers.

2 comments

> drop code in a folder via ftp and have it "just work"

This is essentially what Zed Shaw was working on for Python:

https://github.com/zedshaw/fuqit (https://news.ycombinator.com/item?id=6039146) and here's another for Node https://github.com/ricardobeat/fuqit

I'd love something like this fully fleshed out for Ruby. Some things PHP did "get right" like how it "just works."

Isn't this asking for all the features that lead HN-readers to despise PHP?
There is a lot more wrong with PHP than these (anti-)features. It's loose comparisons for instance, with gems like 0 == "php" returning true, but 0 == "1" returning false [1] [4]

Having a function like nl2br [2], which converts newlines to br tags. The only reason this function would be useful is when you want text to HTML. The problem is, this requires a lot more than just replacing newlines with br tags.

A function like intval [3], which according to the documentation when passed a string "will most likely return 0".

And just about anything on http://www.phpwtf.org/

My main point is, that PHP is not broken because of these features. PHP is broken because the language has been hacked together from the start and there is no way to guess what built in functions will do if you haven't looked up the full documentation for them first.

[1]: http://www.decontextualize.com/wp-content/uploads/2010/01/ph...

[2]: http://php.net/manual/en/function.nl2br.php

[3]: http://php.net/manual/en/function.intval.php

[4]: http://i.imgur.com/pyDTn2i.png

All languages have odd quirks. One can cherry pick from any of them: https://www.destroyallsoftware.com/talks/wat
PHP is built on odd quirks. that's the difference.

It's only popular because it's easy to setup shared apache+php hosts and deploy scripts via FTP on it.

Yes, only ;)
...yes, but these are also the features that led people to use and keep on using PHP. one man's poison is another's drug of choice ;)

(to be honest I'd love to see PHP dead and buried, but there's still no other tool that fills its niche, and I hope that when one such tool gets developed, it's actually based on a sane programming language - PHP as a language means nothing, it was just "something" that grew organically into a language to fill an empty niche, and the only other alternative for this niche back then would've been Perl).

Heh, I spend about 80% of my working life writing PHP, I use it for some of them!
I think most people hate the language itself but recognise its strength of crazy-easy-to-get-started-with.
PHP has some ugliness, but in what way are any of these specific features bad?
"- I want the same language in my controllers, in my db code AND in my templates"

I read that as "let me mix them together like a PHP spaghetti app". The original poster may not have meant that, but after 13 years of writing PHP, the common complaint I still hear from newbies is "but structuring my code/using a framework has such a steep learning curve!". I'd rather like separation of concern enforced at the language level :)

And no, I don't have a clue how that'd work ;)

Their complaint is valid imho. They can use PHP to learn the basics of programming, and after this, as the next logical step, learn to structure their code. PHP is a bad language to get started with to learn programming for a number of different reasons (much worse than Python or Javascript), and this is why it would be cool to have the "PHP way" but based on a different language.

...now, I first learned coding by solving algorithmic math problems in C, but if someone would've tried to make me learn C++ or Java and OOP at that point I would've had the same complaint your newbies are having about "why learn so much just to 'structure' my code?!" :)

He didn't say implementing those functions in the same code, but using the "same language". To me, PHP's use in templates is pretty much its core idea. I think it's a good idea, and basically defines what a ruby/python version would be like.

Unfortunately it also makes possible the abuse you note - hopefully there's better solutions than requiring a different language in those 3 places.

Would love to know where the downvotes came from :)