6 ms·
Reboot PHP: keep the philosophy, improve the syntax (PHP on the JVM)
- balding_n_tired 16y agowhy?
- cemerick 16y agoLooks like an experiment, someone attempting to innovate. From Rémi Forax's announcement on the JVM Languages Group (http://groups.google.com/group/jvm-languages/browse_frm/thread/91a069b78fb509ac http://groups.google.com/group/jvm-languages/browse_frm/thre...): It's as far as I know the first reboot of an existing language :) The idea is to keep the spirit of PHP but change its syntax to natively support XML, SQL, JSON, XPath/XQuery, Perl5 regex, etc. Embedding those DSL provides several benefits: - better readability - variable values are correctly escaped by default (no SQL injection, etc) - integration into a common runtime type system which avoid runtime conversions Unlike PHP wich is based on C runtime, PHP.reboot is based on the JVM which natively supports unicode, exceptions and provides a runtime optimizing environment. PHP.reboot uses a gradual type system (not yet finished) and will soon get a runtime compiler thanks to JSR 292 API. The interpreter already use this API to speed up method calls and member access.
- jacquesm 16y ago> It's as far as I know the first reboot of an existing language :) What an absolute nonsense. As if nobody has ever re-implemented a language that already existed, it's maybe a first for PHP but it's more the rule than the exception that there are dialects of programming languages.
- jrockway 16y agoSee also, Ruby and Perl.
- derefr 16y agoCan you provide examples? Besides Lisp (which isn't considered "a language" so much as a taxonomical classification to them), what language has 2+ dialects where both are in active development and use? (Not to suggest JPHP is in active use.) I think the only good example I can come up with is Visual Basic vs. Visual Basic for Applicaions.
- jacquesm 16y agoI have a harder time finding languages that only have a single implementation. C++, C, Basic (numerous implementations), Python, Cobol, you already mentioned lisp. There's lots more but I think that suffices.
- cjoh 16y agoPHP is a language a bunch of people are familiar with-- and a "first language" for a lot of people. This could mean a great deal to some of those kids who started out as "Drupal Developers" and never expanded their skills past the platform.
- randallsquared 16y agoBut it really has little to do with PHP at all. Besides the name, I guess.
- grumpycanuck 16y agoAs a long-time PHP developer (12+ years, yuck it up PHP haters) I look at this with a combination of awe and disappointment. Awe that someone would be willing to take on implementing a version of PHP that can run on the JVM much like Quercus. Disappointment because what they are doing is not PHP. If the goal is to recreate the "let's build a better runtime" situation that exists in Ruby but in the PHP world, that is admirable. But if you really want the project to get any sort of traction, creating almost-PHP isn't the way to go. If you can't run your existing PHP code in this thing, then what's the point?
- chewbranca 16y agoIf you're just looking to run existing php faster, then check out facebook's HipHop: http://developers.facebook.com/blog/post/358 http://developers.facebook.com/blog/post/358
- hendler 16y agoAgree with the above. I've used Quercus in several projects - porting existing code to the JVM seems like a different use case than re-designing PHP. http://www.caucho.com/resin-3.0/quercus/ http://www.caucho.com/resin-3.0/quercus/
- leftnode 16y agoI'm in your boat as a PHPer (11 years :)), but I like projects like this. I know you can't use your existing projects in it, but if it gains PHP some more respect from the general programming community, I'm all for it.
- petercooper 16y agoConsidering one of the examples demonstrates running a SQL query in the middle of some HTML, I doubt much respect will be gained here.
- jfarmer 16y agoIt reminds me of ColdFusion, e.g., CFQUERY. That is never a good thing.
- catalinist 16y agoI wonder if google will ever include PHP into Google App Engine ..
- invisible 16y agoIt seems more like JavaScript changing more towards PHP than anything else. If that is the goal, then perhaps nodeJS is the solution. I've been considering using nodeJS for more and more logic as time progresses, but truthfully PHP works 99.9% of the time.
- RossM 16y agoIt's definitely interesting, but I think they should develop this as a separate language - specialised for the web. Inline HTML, JSON and SQL look excellent but to me this should be developed as a "new" language, so it is not bound by restrictions of trying to look like PHP.
- apgwoz 16y agoSee also links (http://groups.inf.ed.ac.uk/links/ http://groups.inf.ed.ac.uk/links/) which has lots of these things, but hasn't gained any traction probably due to it's academic origin. But, I agree with your statement. Saying it's similar to PHP, or PHP++, or PHPReboot is just hype.
- DrSprout 16y ago>This is a reboot of PHP, like the reboot of Star Trek. So it's going to be a cotton-candy superficial take on a language with a deep and active user base that basically ends up making it no different from every other language of the month that people promptly forget about?
- AndrewO 16y agoI dunno—the Star Trek reboot reinvigorated the series after lackluster box office performance. If you're looking for things ignored by the active user base and promptly forgotten, I think a better comparison would be the Ewoks movie... :-)
- thasmin 16y agoI don't think this project is properly leveraging PHP's advantages. PHP code's ability to be run on almost any server with Apache is a big plus, but this project requires a JVM. It's different enough from PHP that the plethora of PHP programmers will need to learn a new language, which is another hurdle. It's not backwards compatible so existing PHP code will need to be rewritten. In fact, it looks very different from PHP except for the intended use of the PHP library, which is one of PHP's weakest points. The project has a lot of great ideas but I don't think branding it as a PHP derivative is one of them.
- code_duck 16y agoWait, less ';'? The semicolons are only optional in JavaScript if you are okay with being incompetent. Or, well, slowing down your programs a bit and risking errors through ambiguity. The JSON style syntax is nice, PHP really needs that. I'd be pleased to never see or type => ever again. I have no idea what to think about the rest. Inline SQL? Isn't some heinous mixture of PHP, SQL, JavaScript and XML all in the same file something that normal people would seek to avoid?
- benwerd 16y agoWhoa. I admire the chutzpah, and I definitely think aspects of PHP could use a Star Trek style reboot (albeit with less lens flare), but I also think the proposed syntax here actually makes PHP less clear. My specific issues: As others have commented, fewer semicolons equals potential ambiguity. I'm totally not okay with the inline XML or SQL syntax presented here - clearly demarcated, storage-agnostic code makes me sleep soundly at night. That said, the duck typing and inline JSON structures are neat.
- WilliamLP 16y agoI think this shows a remarkable misunderstanding of what PHP users actually like about PHP: * We like semicolons. The culture who thinks saving this one character is valuable tends toward a non-pragmatic purity that is completely missing the point of PHP. We like to know when the line ends and to break up lines easily. * The $ before all variables is a feature, we like this too. It's jarring coming from other languages but we think it adds readability. * Inline SQL with no special syntax to denote that it is special? This seems way too far off the deep end of preventing an extra character at all costs. Give me a key word or a syntax if you like but don't make it look just like a variable, please. * No from/to string auto-conversion. We like this too. Having the sense to not overload "+" for strings goes a long way here. 1 . 1 == "1" . 1 == "1" . "1" == 11 == "11" 1 + 1 == "1" + 1 == "1" + "1" == 2 == "2" Yes there are warts and some paradoxes but we deal with it, and we have to be very conscious of what data could be provided by users, but our web apps work fine provided we know the language. (Yes, there are very many PHP programmers who don't.)
- goodmitton 16y agothe $ is perhaps my favorite feature. I love being able to easily scan the code which parts are variables, and which parts are strings. This comes in really handy when your page has php, js, and html hacked together because you can more easily tell what language the code you are reading is in.
- jacquesm 16y agoI'd like to add 'we like braces'. Braces are explicit, and guard against dropped lines.
- mcantelon 16y agoAny decent editor can use color coding to contextualize variables and such: no need for syntax cruft. I'm a longtime PHP user and much prefer working in languages with less visual noise.
- KrisJordan 16y agoRe: "The $ before all variables is a feature [...] but we think it adds readability." The argument for the $ sign is not readability. If it were you'd see JavaScripter's prefixing all of their variables with a dollar sign, too. var $foo = 'bar'; is completely valid JavaScript. (Aside: $ prefix is handy in JS when holding references to jQuery objects ie $container = $('#container');) The argument is for simplified string manipulation with magic quotes and is an homage to unix shell scripting. Without the $ prefix string manipulation would be reserved to concatenation/printf/replacement/etc. With the $prefix you can do things like: $base = __DIR__; $user = (object)array('name'=>'Foo','dir'=>"foo"); $size = "lg"; $image = "$base/users/$user->dir/images/$size.jpg"; vs: image = base + "/users/" + user.dir + "/images/" + size + ".jpg" When doing a lot of string manipulation and scripting the $ is quite handy. The dollar sign also enables variable variables and dynamic property access. i.e. $foo = 'Hello, world.'; $bar = 'foo'; echo ${$bar}; // 'Hello, world.' - and - $user = (object)array('name'=>'Foo','dir'=>"foo"); $prop = 'name'; echo $user->{$prop}; // 'Foo' The dollar sign for variable variables is weak because variable variables is usually an indication of code gone awry. Dynamic property access, on the other hand, is much more useful in a dynamic language like PHP/JavaScript. That said, I believe JavaScript's solution is much more elegant. i.e.: var user = {name: "Foo", dir: "foo"}; var prop = "name"; alert(user[prop]); // 'Foo' By overloading the index operator on objects to accept a string that dereferences to an object's property you get the same benefit in a much more elegant way. Thus the $'s primary justification is magic strings and string manipulation.
- michaelbuckbee 16y agoI'd be curious to hear how PHP devs would contrast this with something like HipHop from Facebook (which requires a specific coding style and some restriction of PHP features).
- jrockway 16y agoThis project has nothing to do with PHP, except that the letters P, H, and P are in the name and that it's a bad implementation of a bad idea.
- rbanffy 16y agoI don't really like the SQL integration. I would prefer an object layer on top of it. Making assumptions about an underlying database is a sure way to get burned when you switch to another. And assuming SQL to be the "official" persistence engine makes it hard to migrate to non-relational platforms in case you want to.
- regularfry 16y agoI was about to make the classic "but how often do you switch to another" comment when I realised that every single one of my active projects uses both (MySQL or PostgreSQL) and SQLite.
- FlorinAndrei 16y agoupvoted for sincerity
- tszming 16y ago>> less ';' like in javascript You should read the book by Douglas Crockford - JavaScript: The Good Parts, p102 (Appendix A: Awful Parts), this is not fun.
- jrockway 16y agoIf only there was a programming language where you could write something like: do { foo; bar; baz } or: do foo bar baz and they would both be equivalent.
- Judson 16y agoI like my ';' - Even in javascript
- jrockway 16y agoIf you really want inline XML and SQL, why not have some sort of quoting operator so that this is actually possible to implement sanely? Programming languages designed by PHP programmers... the goggles do nothing.
- misuba 16y agoAwesome. If it had first-class functions I'd be downloading it now.
- jrockway 16y agoBut it has first-class SQL statements! Rock on!