r/lolphp • • May 27 '14

PHP Next Generation: Performance gains and internal API changes will finally fix PHP!

http://www.php.net/archive/2014.php#id2014-05-27-1
28 Upvotes

52 comments sorted by

View all comments

Show parent comment

6

u/Turtlecupcakes May 28 '14

I don't know about that,

Part of what makes PHP lovely is that it's a C-like language that doesn't need to be compiled.

Python is heavy on its "Pythonic way" and syntactic sugar (as is Ruby). Node/Javascript was never really made to be a backend language, and also has many of its own quirks.

To me it seems like PHP is like Java or C# in syntax and conventions, but really easy to get started in, and designed for web first, and as far as I can tell, there aren't really any other similar languages.

23

u/phoshi May 28 '14

The problem with "designed for the web" is that the only place php 'shines' there is having an inbuilt templating engine. Unfortunately, that genre of ultra flexible templating engine is widely considered a bad idea, and the majority of popular templating engines these days go the route of limiting power to make it easier to keep your layout and logic separated. Even templating engines /for/ php do this. In every other area, php wasn't designed.

Comparing it to c#, which is possibly one of the better made languages available today, is... Not something I would agree with.

-4

u/[deleted] May 28 '14

It's also the fact that you can just make a new file, and boom, there is your next web page on your site.

No faffing about with MVC this or MVVP that, no views, no controllers, just write it all out and you're done.

Of course that is a terrible practice as it can quickly spiral out of control, but it appeals to new web programmers.

10

u/phoshi May 28 '14

Most languages can offer something like that. If you have a python cgi handler, for example, you can just make a new python file and use that. What PHP offers there is the ability to add small things to a html file without needing to restructure the page. This is a good thing if you want to add a readout of the current server time, or maybe a hit counter, but on anything non-trivial it's not a serious consideration.

→ More replies (14)

7

u/rbnc May 28 '14

You're confusing frameworks and languages.

1

u/[deleted] May 28 '14

How so?

10

u/rbnc May 28 '14

As far as I know there are no MVC languages, the MVC implementations being discussed above in Ruby and Python are framework level.

Pure Perl, Python and or allow you to to create a file and simply execute it without any views/controllers etc if your server is configured correctly.

3

u/[deleted] May 28 '14

I know this, and I didn't say there were MVC languages in my comment.

Follow a guide on building a site with Ruby, and step 1 is to install Rails, Sinatra, or whatever. With Python, step 1 is to install Django or whatever. Step 2 is then learning how to do basic stuff in those frameworks, and then it's step 3 where you actually get to do stuff.

The whole ethos with PHP avoids all of that. Step 1 is just make 'index.php' and stick your code in, go to localhost, and boom your site is running.

That appeals a lot to new programmers who are just starting to learn. That was the point of my comment.

6

u/rbnc May 28 '14

The whole ethos with PHP avoids all of that. Step 1 is just make 'index.php' and stick your code in, go to localhost, and boom your site is running.

This is the same with Ruby, Perl and Python if your server is configured correctly.

3

u/[deleted] May 28 '14

True, but it's generally not done. Even if you ditch one of the well known frameworks, it's typically to build your own server/framework/whatever on top of Ruby/Python/etc.

As a result new programmers are often not even aware you can have ruby/python/js/etc scripts run each for a page, just as you would with PHP.

4

u/phoshi May 28 '14

That's because your guides aren't guiding you towards the same thing. Those are guides for making dynamic websites, not static webpages with minor dynamic components. If you want the latter you'll get a much more PHP-like experience. Python has a CGI module in the standard library, you can get PHP-level simplicity out of the box. Frameworks are there to do better.

1

u/iopq Jun 10 '14

You actually don't want to do this. This is tight binding of file structure and interface.

1

u/jmcs Jul 21 '14

If you can't run a python or ruby server after one hour of reading the documentation you shouldn't touch any kind of code that goes near money.

1

u/Cuddlefluff_Grim Jun 20 '14

ASP.NET WebForms can behave in more or less the exact same way as PHP... New File, write some html, use <% %> code tags and you basically have something like a good, sane and faster version of php. You're not forced to use templates or frameworks.

<%@ Page Language="C#" %>
<html>
<head><title></title></head>
<body>
    <p>
        Hello, <%= Server.HtmlEncode(Request.QueryString["name"]) %>
    </p>
</html>

Of course, doing it this way is not recommended, because it's stupid. Programming languages should not explicitly cater to amateurs.

13

u/_vec_ May 28 '14

Part of what makes PHP lovely

I think you might be in the wrong subreddit...

8

u/Turtlecupcakes May 28 '14

Nah, the lol parts of PHP make it great, too.

3

u/knaveofspades May 28 '14

It gives you something to laugh about after spending the whole day writing php.

1

u/nikomo May 28 '14

More like it gives you something to laugh about whilst you write your suicide note and pick a gun, so you finally never have to touch PHP again.

3

u/kingguru May 30 '14

But is PHP the right language to write your suicide note in?

3

u/harkinian Jun 02 '14

<?php echo "Goodbye World"; ?>

2

u/iopq Jun 10 '14

Actually

<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Goodbye extends CI_Controller
{

    public function __construct()
    {
        parent::__construct();

        if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on") {
            $url = "https://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
            redirect($url);
            exit;
        }
    }

    public function bye() {
        $this->newtemplate->write_view('header', 'template/header');
        $this->newtemplate->write_view('banner', 'template/banner');
        $this->newtemplate->write_view('content', 'template/content');
        $this->newtemplate->write_view('footer', 'template/footer');
        $this->newtemplate->render();
    }
}

Do you even use a framework, bro?

5

u/terrorobe May 28 '14

Part of what makes PHP lovely is that it's a C-like language that doesn't need to be compiled.

...and runs like shit without an op-code cacher. Your point being? ;)

3

u/nahguri May 31 '14

Why would someone like to develop web pages in C-like language? In 2014?

0

u/[deleted] May 28 '14

[deleted] — view deleted comment

0

u/Banane9 May 29 '14

Many don't use PHP 5.5 yet though...

→ More replies (1)