A reboot of PHP: keep the philosophy, improve the syntax with the jvm
code.google.com
code.google.com
If you want a better version of PHP, try Perl / Python / Ruby. If you want a language that can check your code for safety at compile-time, use Haskell. But if you invent your own language, it will have three problem: nobody will know how to use it, it won't be installed on any three-dollars-a-month shared host, and it won't have any libraries.
If you can't solve the "I want to use it for $3 a month" problem, your programming language is a failure compared to PHP. If you can afford more than $3 a month for hosting, then you're not using PHP anyway. Most people learn to program because they want to share something with their friends. They choose PHP because it lets them do that, and they don't have the experience to know that They Are Doing It Wrong. By the time you introduce a PHP "reboot", you're not going to get that "Don't Know That I'm Doing It Wrong" crowd anymore, and then who's your audience?
Writing a new programming language is fun, but don't expect it to replace PHP. That's going to be impossible unless your rewrite is shipped from php.net and replaces what exists now.
I wholeheartedly agree. "phpreboot" isn't PHP, it is a new programming language that looks similar to (or shares traits of) PHP.
I'm not sure how this gains traction associating itself with PHP. As a currently PHP developer, I'm certainly not going to hitch my wagon to something that looks to be a forked version of PHP.
I think that a vastly cleaned up PHP (PHP6 or whatever) would attract the millions of loyal developers that PHP already has.
Many people just don't appreciate how much mindshare PHP has in parts of northern / central europe. And for those people it's not about $3 hosting, for them it's a proven workhorse language in which they can get things done on the web.
Not to mention that a business culture has grown up around these localised skill concentrations in which lots of businesses are now run on PHP.
I think when you say, "PHP has only one feature going for it: it already exists", you are vastly over trivializing steamroller-like traction and market penetration.
When has the elegance or power of a language ever been a consideration in the general business culture?
Or rather, have no compelling reason to replace yet.
BTW: Many people would be amazed how much ADABAS + Natural still runs in government / banking around the world.
They use it cautiously and reluctantly because they don't have much choice at this point. The Asana and Quora founders ditched it at the earliest opportunity.
So if you want Facebook to be your PHP success story, all you get out of it is "PHP didn't kill their company; they were eventually able to move away", which I suppose is not exactly a swimming endorsement.
What about, you can throw it into your HTML real quick and it'll work?
Step 2 involves getting a server somewhere (as opposed to mamp or $3 hosting). Deciding on a framework (or no framework). Probably some command line stuff. etc.
With php, there is no step 2. Some of what you do in step 2 php programmers might want to do anyway (eg install a framework) but it's not necessary for starting out.
Upsides and downsides to that, I guess (I'm not a programmer) but that is core. If you could take that (MAMP-like installation, through your code into html, etc.) and use another language (including an existing one) I think you would have something.
I'm surprised none has tried it.
Yeah. Right.
- Bigger community, thus more resource documentation out there (Perl has Perl Monks going for it).
- More MVC frameworks (CakePHP, CI, Symfony, Lithium) vs. Catalyst.
- PHP has a cleaner syntax
I'm biased to PHP so of course I think it's better. For someone getting started with web development, I would recommend PHP over Perl. That is not to say that one should never "explore" Perl. Hell, Lawrence Livermore Labs uses a lot of it.
As Perl was developed originally as a scripting language for unix, it is fast, but I don't think it's well suited for the web (my opinion).
Plus, like the troll below me said (who apparently wrote a book on Catalyst, hence his bias), PHP was highly influenced from Perl, so if anything PHP is an alternative to Perl, not the other way around (like the OP mentioned).
More frameworks for you:
- http://mojolicio.us/
- http://perldancer.org/
- http://jifty.org (has a pony :)
The Perl culture is often very geeky and actually pretty cool. But it's also "spread out", there's no one-place for everything perl. - http://blogs.perl.org/
- http://perlbuzz.com/
- http://perlmonks.org/
- http://www.perl.org/community.html
++ SO and github, of course..Anyway, here's what Perl has going for it:
* a larger group of core contributers
* an order of magnitude more modules (and module authors)
* Moose
* excellent Emacs support
* higher average level of proficiency among core team, and module authors
Ultimately, CPAN is the reason for using Perl. But after doing a lot of work in Python, I do really appreciate the things that Perl has built-in, too, like all-encompassing regexes.The language is tailored unlike any dynamic languages. Instead of adding features and wondering how to optimize them after, I have worked backward and carefully pick/design features only if I was able to optimize it to be at least as fast as Java.
The hidden jewel of PHP.reboot is its runtime which first interpret the script and then use a type inference/type checker algorithm to try to emit exactly the same bytecode as javac. So some parts of the language are quite fast, but not the whole language because some parts still run in interpreted mode only.
As a demo, I've taken the mandelbrot benchmark from the Computer Language benchmark[1] and write it in PHP.reboot (I hope with no mistake). Here is the result on my laptop:
[forax@localhost phpreboot]$ time bin/phpr.sh test/mandelbrot.phpr >/dev/null
real 0m34.189s user 0m34.087s sys 0m0.088s
You can compare with your favourite dynamic language :)
cheers, Rémi
[1] http://shootout.alioth.debian.org/u64/performance.php?test=m...
Also, admittedly off of just a glance, beware the specialized syntax sinkhole. Can I easily take two XML snippets and compose them together somehow? Can I easily take two SQL snippets and compose them together? A lot of times these specialized syntaxes make for cute-looking demos but in practice work out worse than just using language constructs because they are so highly specialized you can't do anything with them but exactly the one use case the author had in mind. I'd submit there's a reason that basically no large-scale successful language has this sort of specialized syntax built into it, and you may want to ponder on those reasons until you understand them. It isn't because it's hard to write the grammar or anything implementation-related like that. (And I'm not saying don't do it. Personally, I think it's a solvable problem. Look to LINQ for what is probably the closest to date. I'm suggesting you try to spend some time understanding why the obvious solutions haven't worked before you go too far down what can be a language-killing rathole.)
That's why I think I own the right to call this language PHP.reboot.
Rémi
Php reboot has less to do with php being broken and more to do with your ego refusing to accept that you're not the worlds nest programmer.
Rémi
As for "Secure by default". PHP can be perfectly secure. PDO supports parameterised queries, and was first available in PHP 5.1, which shipped just short of SIX YEARS AGO. Even mysqli supports parameterised queries, and that shipped more than SEVEN YEARS AGO.
If you're using the ancient mysql extension (i.e. the mysql* functions) that is YOUR FAULT, not the fault of the language.
Of course, the real reason is that no, you don't own the right to the name, in any sense, but hey hoo, carry on, whatever.
I'm not able to write a correct PHP script.
That's why I think I own the right to call this language PHP.reboot.
If you think you can hijack the name of a programming language name like this you will probably have to come up with a better reason than this. I have a Phd in Computer Science, I study computer
languages, compilers and runtimes
No, that's not a good enough reason.But your argument for the name is so utterly broken.
First of all, having a PhD in CS and introducing 3 security holes is no reason to blame the language. It's not even necessarily a reason to blame yourself. Since when is a PhD in CS supposed to make you a good software engineer? If it is, I know a lot of PhDs who got a raw deal.
Second, how does your language fix the three security bugs you introduced? The only security feature I see in your highlights list is "secure by default: no eval, no magic quotes/string interpolation". 99 out of 100 competent PHP programmers force magic quotes off (so if your brother didn't, he can shut up), and most bugs that can be introduced with string interpolation can be (and usually are) introduced with string concatenation (which I assume you can still do).
Third, the main thing you demonstrated with this story (as others have said) is that you aren't very good with PHP. That's no big shame, but it's also not a reason you "own the right to call this language PHP.reboot". This reasoning is crazyface.
Fourth, as others have said, calling it "PHP.reboot" just confines it to the ghetto. If it were to grow, people wouldn't be able to search for articles/blogs/forums/help/mail/etc about it without getting lost in the PHP (even admitting that for me googling "php reboot" does return your google-code repo). And right in the name it says "I'm the wanna-be little brother of the big successful language". Although I don't think this last criticism is a problem, because I assume the goal was not to actually replace PHP, because that's impossible for reasons others have mentioned. So, no big deal.
The GOOD argument for the name is "It's just a toy language, so it doesn't matter what it's called, and rebooting PHP was my motivator when I started this particular project."
Oh, and as an aside, if one page of PHP is your web programming experience, then you really should probably not be shipping an HTTP server.
Now, the main point of this toy language as you call it is to demonstrate that a dynamic language can be fast if you don't design it with an interpreter in mind. BTW, I really hope that this is what Dart is.
Rémi
I disagree. How are webprogramming skills applicable to writing a HTTP server? Seems to me the relevant skill would be network programming and my (admittedly limited) web developing experience leads me to believe the skills are mostly if not completely disjoint...
Writing robust high-load network servers is actually a little tougher than it seems, and the skillset has very little overlap with the "designing a nice language" skillset, or the "making an efficient compiler" skillset. And not only is robustness is important, but to be useful it probably needs a lot of auxiliary features like HTTPS and authentication and logging and FSM-knows-what-all (this point, on which features matter, is the only place that web-programming experience might actually be relevant). And so tacking a half-assed HTTP server onto your new-language project is, well, half-assed. And IMO, there are enough shitty toy web-servers out there already.
Sometimes I even think it would be a good idea to half-ass it and just create a "wrapper" type library to map built-in PHP functions to namespaced and standardized (naming, parameter order, etc.) functions.
Then I usually wake up in the morning with a bad hangover and a deep sense of sadness.
Right now it looks like a completely different language, and you might as well just give it an original name. I'm having a bit of a hard time seeing the connection to PHP here.
- Embedded sql in the fashion of php.reboot is dirty.
- No open/close tags and using brackets sounds error prone.
- I'm also personally a fan of the dollar sign.
It appears as though what you really want is Ruby.
That being said, my initial reaction is to wonder why, when designing a new language, one would model after PHP of all things.
I think something like underscore.js[1] would be much more in the style of PHP - I always thought PHP and JS were similary in their wackiness - and I would much prefer it to LINQ.
As far as modeling after PHP, there are things I'd leave/take, but really the biggest issue is the standard library.
May i ask why? i think that this makes the languaje very ugly.
/* in version x of SFL (Sigil-Free Language) */
school = get_school("Saint Fred's School For Girls");
class = get_class(school, "Agricultural Studies", 12);
yield = get_agricultural_yield(class, "Turnips", 2011);
printf("The Year 12 Ag Studies class produced %d turnips in 2011", yield);
Now we try upgrading to version x+1 of SFL, which adds object-orientation and concurrency (it was a BIG upgrade!). Now three of the lines in that four-line program contain errors, because "class" and "yield" are no longer valid variable names, having been turned into keywords.In a language with sigils, that's no problem. It also makes it easier (therefore faster) for syntax highlighting to spot where variables are used, without needing a full dictionary and an exact version number - that makes a difference for me as an Emacs user especially.
- Happens very rarely - Is trivially solved, even in a large codebase
For me, it makes a big difference in languages like ruby where you could either be calling a method, a monkey-patched method_missing callable, or a property in some scope.
Additionally if your language has first class functions, it would feel kind of strange if names of some functions started with $ and others without it.
Take a look at the Linq implementation for a good example. Or, look at something like JSON in javascript.
I thought it was all kind of weird and wrong at first too but now it's probably my favorite c# feature next to the (very much related) lambda expressions, especially for non-SQL collection queries. Of course this doesn't mean PHP needs integrated queries or anything, but it is a very nice feature to have if done right. XML/json literals, on the other hand, do feel kind of wrong to me though (although I bet they are handy still, as many vb.net devs will probably attest to).
[Edited for spelling - damn ipad keyboard!]
Basing a reboot on the JVM makes little sense in this context.
That said, you lost me at "less ';' like in javascript".
As horrible as PHP is, it is really easy to sit down with PHP and a tutorial or a book and start banging out code that gives you instant results. PHP is like the MS Basic 2.0 of the web era -- people who aren't really programmers (yet?) can sit down with it and GTD right away -- their code may be ugly but they can see it working as they go. They don't have to learn what a 'WAR' directory is and how it is structured, they don't have to mess around with xml configurations, etc. The ubiquity helps, certainly, but IMO the reason it got ubiquitous is how easy it is to go from nothing to "hello web world".
I think a project that maintains this instant GTD environment but improves the language is actually quite a good idea, though I also think cutting ties with PHP by giving it a new name makes more sense than calling it phpreboot and once you involve Java it seems less likely PHP's context-free easy start-up will be maintained.
It lacks a coherent design philosophy; it's a collection of hacks; a house of cards with no style. It's full of idiosyncrasies that must be memorized because they make no logical sense. Put simply, it completely lacks taste.
Which at the end of the day is the most common benchmark of utility.
If the answer to all of the above is PHP, then you're going to get projects done faster there than you would in Python or Ruby.
You could say the same thing about ASP, or even ColdFusion.
I'd argue that those instant results had more to do with the higher availability of PHP on cheap web hosts, than the accessibility of the language itself.
When I see special functions which exist to do basic array-as-list operations, like his `add()` function, my eyes roll. Then I see arbitrary, inconsistent use of the dollar sign to indicate variables and they start to bleed -- you either have a dollar sign or not, but pick one and make it work.
When the language designer adds features at whim, without considering whether or not his implementation is keeping consistency or breaking it, well that's how you get a language like PHP in the first place!
He's got a blog post here with some initial performance tests:
http://weblogs.java.net/blog/forax/archive/2011/09/04/hotspo...
Looks really fast when using type annotation (edit: faster than Java?!). Interestingly he is using the upcoming -hsx Hotspot server flag which makes a big difference in speed.
Just convert and bingo, instantly deployable on 100% of php hosts. For local development, a script with --watch a la sass, or maybe a single index.php for converting things on the fly...
If I was starting a green field project and had mostly PHP talent around I'd definitely consider using this.
Native parsing of markup and SQL looks like a neat idea (reminds me of Facebook's XHP plus LINQ) but I'm concerned about using the JVM. Does this use a .NET style multithreading model instead of using one process per request? If not, I can't see the benefit of using a JVM given its best features (GC and JIT) would be rendered not only useless, but a bit of a drag.
My personal PHP wishlist is:
* Better interfaces for the core libraries. Ideally replacing them all with namespaced and object-oriented ones with none of this needle-hackstack mixup
* A standard autoloader
* Removing the concept of 'PHP errors' and replacing them all with exceptions
The people that don't like PHP's syntax already use other tools when they can, and when they can't, because they need to use PHP, it's likely going to be because they're using some existing PHP library or platform already (wordpress, drupal, etc).
I'm all for people experimenting and trying to make things better, but you're probably better off just making a new language than trying to make something that's sort of like php, but different enough that existing code libraries won't work with it.
"What's missing ? ... - ports of all useful PHP functions"
Seems a bit premature to call it "phpreboot". In the present factor, the programmatic constructs identified have equivalents in nearly every language I can think of.
Maybe once it has some PHP functionality incorporated, it could be called phpreboot.
Understand the cleaner syntax hopes... and using JVM 7 features...
I do also see http://www.phpforandroid.net/ but it doesn't look as ambitious as phpreboot.
(To some extent it owes more to rebol than to php - it has a large grammar and a notable amount of literals.)
It makes first class what other languages embed in strings - sql, urls, html, etc. In doing so it can solve a large class of security problems that plague many php projects - you don't need to worry about sql injection when the language handles the query parsing.
PHP was successful for a number of reasons, one of which was that it was embedded and exposed a number of cgi specific features into the language ($GET, $POST, etc), this continues in this vein to embrace urls, sql and html as part of the language. The programmer no longer has to deal with escaping or transforming or sanitising strings. This is cool.
Given it runs on the jvm - it should be possible to layer this atop of heroku or google app engine without worrying too much either.
This approach isn't new either - philip wadler tried in a similar way with the functional language 'links'.
(disclaimer: I think php is a terrible, terrible implementation of some good ideas - the library, language and implementation are notable examples of bad ideas in programming)
Like Facebook. And Flickr. And StumbleUpon. And...
Wait a minute, are we not past this "PHP only works a small sites" thing yet?
you are reading between the lines to find an argument that isn't there.
It apparently "auto-protects" braces inside a script tag, but it's not clear how one would then embed phpr inside the javascript.
Also, design a language with features, then think about the runtime. A language is not it's runtime.
Perl is older than PHP!