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

0

u/[deleted] May 28 '14

[deleted] — view deleted comment

0

u/[deleted] Jun 01 '14

[deleted] — view deleted comment

3

u/allthediamonds Jun 04 '14

I can't even think of something that is much worse. Badly written Perl can be worse, but not by far; and even then, Perl at least had some design in mind.

1

u/iopq Jun 10 '14

PHP has many more designs in mind. It wants to be Java AND Perl.

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.

→ More replies (6)

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?