Live data from Hacker News

PHP Addiction

marco.org

81–90 of 320 posts

Re: PHP Addiction

#81
post #7

I'll sound like a broken record, but I'm convinced Flask is the perfect transition. It's built for smaller web apps, and rapid prototyping. The system of mapping endpoints to functions is incredibly intuitive -- if you've used Python before, learning Flask is incredibly easy.

Flask is not built for smaller web apps.

The idea of Flask is to build a good foundation for all applications. Everything else is up to you or extensions.

http://flask.pocoo.org/docs/design/#what-flask-is-what-flask...

There's even an entire section in the docs about scaling your application up: http://flask.pocoo.org/docs/becomingbig/#becomingbig

Re: PHP Addiction

#82

The only thing actually wrong with PHP, is that it's popular but not cool. And that's a terrible place to sit for any product. It runs half the Internet quite well, but if you went by the posting on HN, you'd think it was Windows Vista. I've probably read every article critical of PHP that has hit the front page of HN in the last few years, and the one thing they all have in common is the vague refrain that PHP is a…

PHP "runs half the Internet quite well"? Source?

Re: PHP Addiction

#83
post #33

Here is another point that highlights the problem: If I want to write a hello world application in PHP, it's neither as long as nor as short as Rather it's simply: hello world. Just type in those 11 characters in a text file and save it as hello.php. Now load it on your browser [or run it from command line] and it will print hello world. I don't think it can get any more simpler than that in other languages. PHP was…

Are you seriously basing a whole argument on what the hello world program looks like? That has nothing to do with actual real world programs. Mixing logic & presentation might make it easier to get something running quickly, but it's one of the downsides of PHP that these things get mixed up when they probably shouldn't for a project of reasonable size. The whole idea that it's an advantage of PHP that you can get so…

> Actually, it's much better if it requires some amount of thought and planning to code something up because that increases the likelihood that you'll do it right the first time and build on a solid foundation.

This is solid advice for an engineer. And absolutely moronic for a businessman.

Choosing what platform to use is a business decision.

If you take too long to get it right, you will never get the chance to make a dime off of your work.

We are all working on limited time frames. It is far better to throw something together that works and rewrite later, when you're actually making money.

PHP is amazing at letting you write something fast and rewrite it into something more manageable later.

Re: PHP Addiction

#84
I was in the exact situation a year or so ago. Everything I wanted to build, I always went straight to PHP.

I stopped myself from, unfortunately, not building things. I've spent the last year learning Ruby, Python, Rails, Django, and a half dozen javascript frameworks to get myself acquainted with it all. Only recently I took a position where I'll be working with Rails full-time. It's a tough addiction to break, but it's so liberating once you learn what else is out there and what you can do with it!

Re: PHP Addiction

#85

>the first question that comes up is what to use instead, and they’re met with a barrage of difficult choices and wildly different opinions and recommendations. The real answer is "it doesn't matter". Of course python people will try to convince you to use python, and ruby people will try to convince you to use ruby. But both groups will agree that either language is far better than PHP. And as someone who likes neit…

The choice does matter. A lot. When I started with ruby, I had to decide between 1.8, or 1.9, or jruby, or several other choices. Then I had to pick sinatra or rails or merb or whatever. mongrel or passenger or thin or unicorn. It didn't really seem like the choice would matter, but then you run into some tiny annoyance, do a bit of research and find out that some other framework doesn't have that problem. So you swi…

"... run into some tiny annoyance, do a bit of research ... So you switch ..."

If you pick a solution and run into a tiny annoyance learn to work around it in some way. It is a tiny annoyance.

Best case scenario, learn why it's happening, how you can fix it, and (in a dreamland) submit a patch that fixes this for everyone else in the future.

Worst-case scenario just find a workaround.

Re: PHP Addiction

#86
post #4

Earlier quoted context omitted.

x3 - it's far simpler to learn due to consistency, more powerful to do both low & high level programming and a pleasure to work with. Just as simple to setup for web as php. Not real reason to be in knee deep php mess.

As easy as PHP in what sense? That Python is basically part of all OS' now or as easy as putting in in a .php file and uploading it to your server? I severely doubt it's as easy as the latter. I'd like to see an article that explains in less than 140 chars how to deploy a simple app as Hello World to the web in Python without the use of a framework like Django or Flask. Edit: In the amount of chars Twitter accepts, h…

Your example of simplicity is a bit conflated since you don't even need PHP to put hello world on a internet visible web page in the first place:

echo 'hello world' > /var/www/index.html

Set up something a little more useful albeit trite such as a blog and you wouldn't be able to do that in 10 minutes with PHP without using a framework either. PHP is great for "unit testing" of ideas but once it grows out of that it's debateable

I do concur that deploying a Python or Ruby web app is a pain in the ass. Installing git and installing Heroku, you're only 2 lines of code away though.

Re: PHP Addiction

#87
post #82

The only thing actually wrong with PHP, is that it's popular but not cool. And that's a terrible place to sit for any product. It runs half the Internet quite well, but if you went by the posting on HN, you'd think it was Windows Vista. I've probably read every article critical of PHP that has hit the front page of HN in the last few years, and the one thing they all have in common is the vague refrain that PHP is a…

PHP "runs half the Internet quite well"? Source?

Common sense. Calculate how much traffic Wikipedia + Facebook + Wordpress + All The Rest generate. Calculate in the fact that most services talk to other services and more importantly, talk to Facebook.

Click on a link?

I promise, at some point, PHP is involved.

Re: PHP Addiction

#88

>"Whichever language I choose to replace PHP will have its own problems that will take me years to master" What? Really?

There is some truth to this. However, if you define a "better language" as one which is more consistent and predictable and less buggy, that implies less time to master.

One thing I love about Ruby is how many methods suggest one another. For example, Enumerable collections, like arrays, have an `any?` method. It takes a test function and returns true if any of the items pass that test.

[1, 2, 3, 4, 5].any? {|i| i > 4 } # true

Ok, you just learned `any?`. Now, you can replace `any?` in the above with

1) `all?` - do all elements pass? 2) `one?` - does exactly one pass? 3) `none?` - do none pass?

If you can remember one of those, chances are you can remember others. And if not, `myarray.methods` will remind you.

That same array has a `max` method and a `min`, a `max_by` and a `min_by`. It has a `select` to get all matching items and a `reject` to get all non-matching items. Knowing one helps you remember another.[1]

The key is consistency. It speeds up the learning process and makes you refer to the documentation less often.

That's the advantage of choosing a good language. It reduces the very pain that the OP is worried about.

==========

[1] (But wait, there's more! Any class you create, if you define `each` and `include Enumerable`, gets all these methods for free!)

Re: PHP Addiction

#89
post #81
post #7

I'll sound like a broken record, but I'm convinced Flask is the perfect transition. It's built for smaller web apps, and rapid prototyping. The system of mapping endpoints to functions is incredibly intuitive -- if you've used Python before, learning Flask is incredibly easy.

Flask is not built for smaller web apps. The idea of Flask is to build a good foundation for all applications. Everything else is up to you or extensions. http://flask.pocoo.org/docs/design/#what-flask-is-what-flask... There's even an entire section in the docs about scaling your application up: http://flask.pocoo.org/docs/becomingbig/#becomingbig

You're completely right -- I phrased that badly.

What I meant was that it lends itself well to small apps because the lack of code/architectural overhead, as opposed to Django, where coding small apps often feels like only furnishing one room in a five-bedroom house.

Re: PHP Addiction

#90
I propose this as a blueprint for a solution:

    {%
    name = request.get('name','world')
    list = ['this','language','rocks']
    %}
    Hello {{ name.upper }}
    
    {% for item in list %}
        {{ item }}
    {% endfor %}
    
Save it as 'index.nxt' and run it in any future language you are going to design.

Create a mod_next and try it on any web server like apache, nginx, etc. It should work without any extra fiddling with config files or installing frameworks or template engines.

It should just work!

That's the kind of platform that would leave php behind once and for all.

Post reply on HN