New language on top of PHP?

前端 未结 12 1736
甜味超标
甜味超标 2021-01-30 02:39

I\'m a PHP developer. I like PHP! It is a really good language if you know how to use it, but I know it allows very bad design sometimes.

It reminds me of JavaScript whi

相关标签:
12条回答
  • 2021-01-30 02:45

    I'm like 8 years too late, but I'll answer anyways for anyone else who stumbles upon this.

    Hack is a language developed by Facebook to deal with some of the issues of PHP, since Facebook had a large PHP codebase. Hack adds some nice features on top of PHP such as gradual typing (what TypeScript has) and generics, among other features, and gets rid of some of the more dangerous PHP features. Hack was at one point a superset of PHP, but is no longer completely compatible after removing some of the worse PHP features.

    This is slightly different from what you were asking, since at this point Hack has its own interpreter, written by Facebook, but this started out as "better language that compiles to PHP", so I thought it was worth mentioning here.

    0 讨论(0)
  • 2021-01-30 02:46

    Writing a PHP syntax transformer would probably be a neat project.

    However, don't forget that PHP's standard library is a huge mess. Cleaning that up, would be a far bigger task.

    0 讨论(0)
  • 2021-01-30 02:48

    I can see writing compilers to JavaScript (because the web imposes it upon us), but this sounds like a waste of time.

    Haxe already does this, although it's not specifically targeted at PHP (linked to the Wikipedia article instead of their website because I'm afraid I'm going to get exploited if I visit the real site...)

    PHP is easy to deploy anywhere

    ...as are its vulnerabilities.

    I know it allows very bad design sometimes.

    That's a bit of an understatement, it doesn't even have a module system, has no encapsulation, and has tons of silly things such as dynamic name resolution.

    PHP is slow enough as it is, do you really want something an order of a magnitude slower?

    Java is much more easy to deploy anyways, and lets you drop down to the bytecode level if you want. Java also gives you access to moderately sane libraries.

    0 讨论(0)
  • 2021-01-30 02:49

    It is here now. A new language which is to PHP what CoffeeScript is to Javascript. (I.e., awesome.)

    SNOWSCRIPT

    Snowscript code looks like this:


    fn how_big_is_it(number)
        if number < 100
            <- "small"
        else
            <- "big"
    

    PHP output looks like this:


    function how_big_is_it($number) {
        if ($number < 100) {
            return "small";
        } else {
            return "big";
        }
    }
    

    All it needs now, is you.

    0 讨论(0)
  • 2021-01-30 02:51

    This is something I have thought about already often. PHP just is messy at some points.

    Actually, I already have a project PrePHP focusing on providing PHP 5.3 functionality to PHP 5.2. But it adds some minor language features, like func()[0]. I haven't developed this project for some time and it definitely isn't "clean", but it shows, that what you want is possible and actually even not that complicated.

    If you are serious about this, I am perfectly willing to collaborate with you.

    0 讨论(0)
  • 2021-01-30 02:52

    If it would be to PHP what something like sass is to CSS, I'd be interested. But what would exactly would you want to add? Or would you just want to weed out the bad?

    And what would you consider to be the bad?

    0 讨论(0)
提交回复
热议问题