9 ms·
A reboot of PHP: keep the philosophy, improve the syntax with the jvm
- garyrichardson 15y agoI hear perl tried this a decade ago. I don't think it worked out too well. Also, design a language with features, then think about the runtime. A language is not it's runtime.
- josegonzalez 15y agoAs a PHP developer, I'm less than enamored by this because it seems as though it increases spaghetti code. - 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.
- notJim 15y agoThey didn't make it very clear, but I think the embedded SQL idea is meant to be for things like querying against collections, similar to LINQ[1]. Even it's meant for databases, it's still up to you where in the app you put it. That being said, my initial reaction is to wonder why, when designing a new language, one would model after PHP of all things. 1: http://en.wikipedia.org/wiki/Language_Integrated_Query http://en.wikipedia.org/wiki/Language_Integrated_Query
- josegonzalez 15y agoYeah I'm also not a fan of linq. Or at least not in my PHP. 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. 1: http://brianhaveri.github.com/Underscore.php/ http://brianhaveri.github.com/Underscore.php/
- jond3k 15y ago+1. wish I'd seen underscore.php sooner!
- gbaygon 15y ago"- I'm also personally a fan of the dollar sign." May i ask why? i think that this makes the languaje very ugly.
- gburt 15y agoI like it as well, it makes it very clear what is a variable and what is some other sort of identifier.
- etfb 15y agoHere's a contrived example to demonstrate the value of sigils: /* 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.
- josegonzalez 15y agoetfb is on the right path, but for me it just feels right. I guess that's just a personal preference, but the dollar sign is a visual indicator that a particular string is a variable, and not a function call. 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.
- encoderer 15y agoReally? It's cleaner to have queries represented as strings than as a language-integrated syntax that can throw errors at compile time? To each their own, but if I had to guess, I'd say you've got a minority opinion there.
- ceejayoz 15y agoI doubt it's a minority opinion, at the very least amongst PHP devs. Having it as a string allows me to pass it to a logging function, or output it in a debug console, or send it to a query pre-processor that adds the right database prefix for the current app, etc.
- encoderer 15y agoYou're making the assumption that you'd lose that functionality if you moved to a language integrated query? Not so. Take a look at the Linq implementation for a good example. Or, look at something like JSON in javascript.
- dbattaglia 15y agoAs encoderer said, you can definitely do that in Linq. The query operators basically just map to methods, which are overridden by the different providers... The SQL ones basically create SQL statements for you behind the scenes (as log gable strings). 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!]
- scott_s 15y agoYou never lose capabilities by adding semantic structure. It's trivial to flatten that out with a toString of some kind.
- TheMoonMaster 15y agoWhile I'd agree that PHP needs a "reboot", I don't think this is the right way to do it.
- janeklb 15y agoNative JSON is a nice step, but for the most part I would have to agree with the other commenters. Especially embedding SQL as a literal as seems more convoluted than clarifying.
- glassx 15y agoI think it might be elegant in small doses - just look at C#'s LINQ. Also, it's a nice strategy to lure newbies away from string concatenation and give security for free...
- acabal 15y agoSometimes on rainy nights when I've had a few too many glasses of wine, I dream of doing a PHP "reboot": something with syntax and features like C#, which I personally love, but without the sometimes deceptive magic that goes on behind the scenes of stuff on the .NET stack. Just output HTML to the browser, no compilation required, arrays like PHP, and sane and useful built-in libraries. FOSS. 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.
- dguaraglia 15y agoI just wonder: how are you supposed to escape braces in embedded JavaScript? If the language 'intelligently' finds braces inside <script> tags, then I'd recommend everyone to run as fast as possible in the opposite direction.
- runfast 15y agohttp://code.google.com/p/phpreboot/source/browse/trunk/phpreboot/test/testxmljavascript.phpr http://code.google.com/p/phpreboot/source/browse/trunk/phpre... It apparently "auto-protects" braces inside a script tag, but it's not clear how one would then embed phpr inside the javascript.
- andypants 15y agoWhat exactly is the philosophy of PHP? You should write a bit about it on the project page. 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.
- chow 15y agoWhen will people realize that the main reason PHP was/is so successful has nothing to do with the language? PHP got huge because it's free and super easy to deploy on commodity-level hosting. Ubiquity breeds popularity. Basing a reboot on the JVM makes little sense in this context. That said, you lost me at "less ';' like in javascript".
- georgemcbay 15y agoIMO you are only partially right and some of PHP's success does have to do with the language and not just availability. 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.
- OstiaAntica 15y agoThat's exactly right. I learned to code from a PHP book a decade ago, and now I am using the excellent OOP Symfony2 PHP Framework. The full spectrum of options are already available with PHP, the language and its frameworks lack nothing.
- gnaritas 15y ago> the language and its frameworks lack nothing. 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.
- mgkimsal 15y agoBasing this on the JVM may afford some benefits, but widespread adoption will not be one of them. I'm a big Groovy fan, and love Grails, but it's never going to challenge PHP in uptake. I get a lot of JVM benefits by using Grails, but I still do a lot of PHP too, and each have their place. I suspect others would chime in with their own non-PHP loves (ruby, c#, python, etc) but PHP's massive adoption has a lot more to do with availability than syntax. 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.
- jsmcgd 15y agoI'll voice a minority opinion: Well done! If I was starting a green field project and had mostly PHP talent around I'd definitely consider using this.
- z92 15y agoSeconded.
- mgkimsal 15y agoOne extra comment different from my last - easier Android app development could make this a very interesting project. That's assuming this as a JVM language will work on Android (groovy doesn't right now because of too much AST stuff, fwict). I do also see http://www.phpforandroid.net/ http://www.phpforandroid.net/ but it doesn't look as ambitious as phpreboot.
- andrewnez 15y agoWould a coffeescript-like language that generates php be something of interest to people? Improving the syntax whilst maintaining the ability to just drop onto an apache server.
- mgkimsal 15y agoProbably to some people, sure. For totally 100% from scratch projects, it might be nice - may be harder to deal with existing code bases that you want to extend or integrate with, no?
- glassx 15y agoWell, I believe it would work seamlessly if it's just a code-translator like coffescript.
- glassx 15y agoIt would be really cool. In fact, I was thinking about that right now. 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...
- bgarbiak 15y agoYes, that would be something huge (or maybe I'm thinking that because I have this idea for a long time and really wish someone would do this). Obviously, the quality of the output php code would matter a lot. Actually, by quality I mean mostly the performance.
- martin_rusev 15y agoI've started something like that a year ago. It's called purplescript( https://github.com/martinrusev/purplescript https://github.com/martinrusev/purplescript ) and it's a ruby like language written in Python ( with PLY ) and it compiles directly to PHP, so there is no need to rewrite PHP functions - they just work.
- 15y ago
- plq 15y agoi wonder how the embedded sql syntax would handle multiple database connections.
- 46Bit 15y agoMy PHP reboot is simple: drop it for more versatile interpreted languages like Ruby & Python, and their respective web frameworks. Loving it, personally.
- 46Bit 15y agoNot surprised at this getting negged, nor at nobody actually writing why.
- pbreit 15y agoI didn't neg but would agree that the comment adds little to the discussion. Comes off as snark and not much else.
- 46Bit 15y agoIt's not though. If you're going to upend PHP in order to make it more like something else, maybe just use something else.
- driverdan 15y agoNegged for an elitist snob comment that adds absolutely nothing to the conversation.
- voidfiles 15y agoPHP is widely used because of deployment, not because the language is awesome. If you reboot PHP you need to keep the deployment easy as well.
- lachenmayer 15y agoI hope the "less ';' like javascript" isn't implemented in the same way it is in JavaScript...
- nphase 15y agoThe embedded XML reminds me of Facebook's XHP: https://www.facebook.com/notes/facebook-engineering/xhp-a-new-way-to-write-php/294003943919 https://www.facebook.com/notes/facebook-engineering/xhp-a-ne...
- jessedhillon 15y agoWhy, when "rebooting" PHP, do you still keep the inane non-object arrays? Why not either/both create a syntax for manipulating arrays, or promote arrays to objects with their own methods. 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!
- deleted 15y ago[deleted]
- mgkimsal 15y agowhat might make sense is to only implement the SPL stuff, and force all array access to be objects implementing the SPL interfaces. it would hurt 'ease of use' compatibility, but would enforce as a standard something that's already defined in PHP.
- kikito 15y agoI think this problem solves the wrong problems.
- sandeepshetty 15y agoA better approach might be to go the CoffeeScript way or better still, contribute to php itself. Sure it might take longer but languages take years to catch on...
- deedorgreed 15y agophp is fine the way it is. the updates you'd like to make would just turn it into python or ruby as others have alluded to
- jond3k 15y agoIt looks like someone had fun! 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
- bodski 15y agoInteresting, this is by Rémi Forax who is involved in the Asm Java bytecode manipulation library[1] as well as hacking on all kinds of other Java related stuff. He's got a blog post here with some initial performance tests: http://weblogs.java.net/blog/forax/archive/2011/09/04/hotspot-loves-phpreboot 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. [1] http://asm.ow2.org/ http://asm.ow2.org/
- jrockway 15y agoPHP has only one feature going for it: it already exists. As soon as you introduce a new programming language, you lose what PHP has to offer. Another success is the lack of a library culture -- just copy-and-paste code into your app, and you never have to worry about installing dependencies on your shared host. 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.
- blantonl 15y agoWriting 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.
- ra 15y agoThe stated goals of this project aren't the ones I would have picked, but I'm sympathetic to the motivation behind it. 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.
- raffi 15y agoWriting a programming language in this day and age and posting about it on HN is like visiting each denomination of your favorite religion and announcing that you're starting a new cult. Personally, I think it's a lot of fun, just don't expect a positive or welcoming reaction. Best of luck to you.
- drivingmenuts 15y agoIf we're going to rewrite PHP, lets make it look and act like Objective-C.
- ceejayoz 15y agoFor the love of all that is holy, no.
- LarryMade 15y agoI don't like the reduction of brackets, one thing I like in php is the readability of the symbols: if(){ }else{ } I know when things start and stop, with the conditionals presented there are no indication of start/stop except possibly indentation... lack of closure symbols is one of the reasons I am not comfortable with python as much, I gain comfort in being able to visibly close my sections, and I think for learning a language it makes it way more readable/understandable too.
- LarryMade 15y agoMy second thought is it needs a seamless transition path where you can run both old and new PHP without error, there is a lot of code out there and I don't think everything would be rewritten in one fail swoop in many applications.
- haddr 15y agoisn't it in fact a Java reload? (i mean java for web by mimicking PHP syntax)
- tef____ 15y agoI think this is a good idea. PHP solves a niche of small sites with slightly dynamic templates. (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)
- j_col 15y ago> PHP solves a niche of small sites with slightly dynamic templates. Like Facebook. And Flickr. And StumbleUpon. And... Wait a minute, are we not past this "PHP only works a small sites" thing yet?
- tef____ 15y agoit turns out a tempting language can be useful for more than one thing, but for small sites, it works very well. you are reading between the lines to find an argument that isn't there.
- jroseattle 15y agoFrom the phpreboot code.google.com site page: "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.
- remi_forax 15y agoHi guys, I'm the author of PHP.reboot and also one of the guys that worked on JSR 292 (invokedynamic in Java). First, I don't know based2 and please don't be too serious, PHP.reboot was written as a small prototype to see what can be done on top of invokedynamic. It was also used to debug the hotspot implementation of JSR 292. 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=mandelbrot http://shootout.alioth.debian.org/u64/performance.php?test=m...
- catch23 15y agoIt's cool to do it as a prototype language, but I doubt someone would make use of it over php. Until someone ports drupal or wordpress to "the next php language", php in the current form probably isn't going anywhere.
- jerf 15y agoIf you're serious about this moving forward, I very strongly suggest renaming it. PHP.reboot is a very hostile, aggressive name that is clearly trying to steal thunder. Call it a reboot of PHP informally, playfully base the name off of PHP somehow, but don't outright call your language "PHP.something that Google won't correctly parse as part of the same word so the search will still pull up nothing but PHP results". In addition to the hostile nature of the name, being effectively Google-blacklisted isn't a great way to start. 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.)
- EGreg 15y agoI would recommend a reboot of javascript instead: http://news.ycombinator.com/item?id=2044752 http://news.ycombinator.com/item?id=2044752
- hendler 15y agoA little confused about why this project is starting when there is already a fully supported PHP for the JVM in Quercus. http://www.caucho.com/resin-3.0/quercus/ http://www.caucho.com/resin-3.0/quercus/ Understand the cleaner syntax hopes... and using JVM 7 features...
- InclinedPlane 15y agoPHP (and Perl, and Rails, and even Erlang) were all created to fulfill an immediate need. That's one of the reasons why they are so successful. They aren't like, say, Pascal in that they were created with abstract goals in mind. If you want to replace PHP you have to do so on PHP's turf and PHP's terms, you need to make something even MORE practical and even EASIER to go from zero to functional dynamic website.
- jrockway 15y agoJava wasn't created to fulfill an immediate need (other than to make money for Sun), and it's more popular than Perl, Rails, or Erlang.
- schiptsov 15y ago1. Too late. 2. Who needs "PHP" which cannot run old crap? 3. move to JVM is ridiculous. (Lua's way is better)
- maxpert 15y agoI have a been in a love affair with PHP and also have been FRUSTRATED for its lack of few things. Despite the fact that PHP lived as a royal king of its era, few new comers like Rails, NodeJS are really taking the attention away; I've been always wondering and why wasn't community really taking the great examples of nifty syntax from ruby and evented model from Node to create the same beast again? I've been waiting 3 years for getting myself out of crappy array('foo' => 'bar') syntax to something neat like {'foo': 'bar'}. I really appreciate your move to create something where we would be able to fix these issues. Keep up the good work!
- billpg 15y agoCall it PHP version 6 instead.
- Kwpolska 15y agoPretty much, python.
- Kwpolska 15y agoPretty much, python sans tabs and coolness. Use it or ruby if you want such stuff.