17 ms·
Lisphp is a Lisp dialect written in PHP.
- arnorhs 16y agoThis is maybe not so useless but definitely awesome! At least this would solve the whole "which server should I use for lisp" problem...
- jacquesm 16y agoThat was exactly my thought, the lisp deployment problem can be checked off the list. This also significantly lowers the barrier to entry for people that want to try lisp. He seems to have done (much) more than a half baked job of it judging by the rest of the page.
- Scriptor 16y agoThe fact that it's interpreted makes it a little unrealistic to directly deploy a whole web application with it. However, the sandboxing and embedding features look really cool.
- jules 16y agoThere is lisp and there is lisp. The libraries and the speed do matter. While this is an interesting project it's not comparable to SBCL, Racket or Clojure.
- jimbokun 16y ago"The libraries and the speed do matter." Does PHP lack for good libraries? That was the trick Clojure used with Java to get bootstrapped.
- Turing_Machine 16y agoHmm... maybe in conjunction with HipHop for PHP? http://github.com/facebook/hiphop-php http://github.com/facebook/hiphop-php I guess if you were allowed to run compiled binaries you could just as easily use another Lisp, though -- except maybe if you needed to integrate with existing PHP applications. That might be a good use case.
- jules 16y ago> Does PHP lack for libraries? No. > Does PHP lack for good libraries? Yes. PHP's libraries are one of the ugliest and non lispy in existence :(
- jacquesm 16y agoSince they were not made with 'lisp' or anything 'lispy' in mind that should come as no surprise. PHP is about as declarative as you get, assignments are the norm, not the exception and side-effects are how just about everything is done. It's not exactly elegant, but it fills a niche and apparently fills it quite well. Though python is catching up, and even if it isn't quite as easy to deploy a large scale python web application as it is to deploy PHP the difference is getting smaller all the time.
- jacquesm 16y agoI'm curious how fast it actually is for 'real life' examples.
- mahmud 16y agoIt's a working Lisp-1 with proper support for lambda conversion/reduction rules. It's a long way from being a usable Lisp, but it's theoretically feasible to take it there. It says a lot about about his work that I am very excited to hack on it for the rest of the day, and I am not easily impressed by toy Lisps :-) Tip of the hat to the author for doing the right thing, imo.
- jacquesm 16y agoAnd under a very permissive license to boot. Also it's actual code, as opposed to most 'hacker news 'news''.
- deleted 16y ago[deleted]
- d0m 16y agoPlease, don't ever try to be funny on hacker news. People are too smart for this kind of shit.
- d0m 16y agoSo, I knew that I would be downed for saying that (of course). However, I had fun looking how the score oscillated from -2 to +2 all the day. But I guess, at the end, too-smart-people won.
- andrewvc 16y agoThis is analagous to McDonalds serving duck confit (and it actually tasting kind of good).
- mcs 16y agoIt's kind of funny that people see PHP related to anything other than serving websites and they cringe. As of 5.3 (and I won't say prior to that because even I don't believe it), PHP has become a nice utility language for just more than serving out wordpress. Closures and the reference sweep GC level the playing field.
- robryan 16y agoYeah, this code actually really illustrates the difference between writing crappy code in PHP and writing something elegantly using everything the has come in in the past few versions. I have seen quiet a few PHP bashing comments recently that while true of older versions are much less true of 5.3, I mean there is still the same old nitpicks about the parameter orders and the amount of built in functions in the standard namespace but it is defiantly heading in the right direction.
- cageface 16y agoWhat features specifically have made the difference? I've tried a few times to buckle down and learn PHP and I never seem to get farther than the mixed value/reference semantics, which I remember highly unfondly from my perl days.
- jimbokun 16y agoI just finished reading "Javascript the Good Parts" recently. It's probably also the case for PHP that if you pretend that certain parts of the language just don't exist, you end up with a pretty good language. (I have never programmed anything in PHP.) Building a Lisp on top of PHP strikes me as a vehicle for helping developers to adhere to the "good parts." I'm not sure whether that was the intent here, but it could turn out to be a useful side effect. A note on the language itself: It appears that you can choose any set of matching braces that you want anywhere in your program. I think this is the convention Scheme uses. Common Lisp reserves braces other than () for reader macros. I personally, however, favor Clojure's approach of defining distinct behavior for each brace type. There are only three pairs of matched characters on the keyboard. It seems to me that this makes them too valuable to not leverage them as a core part of the language. Immediately knowing the meaning of a specific brace type makes it much easier to read someone else's code.
- jacquesm 16y agoMinor nitpick, the cdr implementation is (out of need, as far as I can see) terribly slow for larger datasets, it uses array_slice($this->getArrayCopy(), 1) .
- jimbokun 16y agoIs there a way to implement cdr more efficiently? (I don't know PHP.)
- koenigdavidmj 16y agoIn more traditional lists, the main data structure over which car and cdr munched was a linked list. car and cdr were just accessors for the two fields (usually used as a data container and a 'next' pointer).
- jimbokun 16y agoI mean, is there any way to get that efficiency from PHP data structures? I guess you could implement a linked list data structure from scratch, but that would likely limit inter-operability with the rest of PHP.
- tiles 16y agocdr could return an array "object" where it references the entire array, and a pointer where it should start indexing. Instead of using linked-lists as the fundamental datatype, it could use array subsets.
- Scriptor 16y agoSomething like this could be very feasible, especially when combined with the array interfaces so that the fact it's an object with a moving pointer isn't even noticed.
- koenigdavidmj 16y ago
- asimjalis 16y agoSimilar to Lisp2Perl http://www.hhdave.pwp.blueyonder.co.uk/ http://www.hhdave.pwp.blueyonder.co.uk/ Which implements Lisp on Perl.
- stcredzero 16y agoCounter-intuitively, it's often easier to implement a more powerful, more elegant language in a less powerful one than the other way around. Often, good language design is correlated with elegant syntax, which contributes to this.
- eru 16y agoMaybe. Though it is relatively easy to implement an ancient BASIC in Haskell. The other way around is harder.
- leftnode 16y agoHappy to see PHP be taken more seriously around here. Trust me, we're not all moronic programmers using register globals, magic quotes, and other abominations originally available in PHP. This is a pretty cool project.
- eru 16y agoI guess PHP parallels C++ in this respect.
- jacquesm 16y agoI'd argue the situation with PHP was in fact much worse than it ever was with C++, but there are some parallels. The bigger problem with PHP is that there is no consistency and C++ always had some of that. The naming of library functions alone can drive you bonkers. It's rare that I have to look up the names of functions in languages that I've used for a decade or more, with PHP it still happens with some regularity. I know I could use an IDE to mitigate that but for some reason IDEs and me don't get along, with the exception of Borlands C Builder, which was really pretty good.
- mattew 16y agoI think PHP suffers from some of the same issues that VB6 suffered from in terms of inexperienced programmers. With VB6, someone who was not as much of a programmer as we all are could write themselves into a massive mess. I have found when writing PHP code if you are careful, you can build things with decent design patterns and consistency. Sure, its not as clean as a lot of languages, but it sure is easier for me to figure out what is going on with PHP code someone else wrote compared to Perl or Ruby code.
- jacquesm 16y agoThis single biggest issue I've found when working with PHP for larger projects is that even if you are a disciplined programmer you get to the point where the includes will eat up your performance and your memory requirements will become larger. See drupal as an example of this. You can get around some of that by using a php accelerator but it would seem to me that something like that ought to be part of the basic distribution.
- dahlia 16y agoI'm the author of this, I made the web REPL also. http://dahlia.ruree.net/try-lisphp/ http://dahlia.ruree.net/try-lisphp/ Well, of course, it uses a sandbox environment.
- mahmud 16y agoFrom a quick look, you managed to get one thing right, even though it baffles even respected language implementers: a proper stack trace on error. Most people who write a HLL interpreter in another HLL tend to cheat and implement a half-baked source to source translator. [Edit: Question: Why does it have T, NIL, #T and #F? what roles do these symbols play in the language; which ones are canonical truth values, which ones signify list termination, and which ones signify the empty value? This is the perennial Lisp question.]
- deleted 16y ago[deleted]
- jcw 16y agoHas anyone tried running code with this yet? This results in errors: <?php require_once('Lisphp.php'); $env = Lisphp_Environment::full(); $program = new Lisphp_Program("(echo 1)"); $program->execute($env); ?>
- mkramlich 16y agougly language meets pretty language have a few drinks nine months later, baby arrives and uploaded to GitHub! :)
- oneofamillion 16y agoA related project is clpython. I think lisphp can be a funny way for people using php to learn some dialect of Lisp. But in the end, there is glue with C code for example FFI to get speed.
- prodigal_erik 16y agoI hope he finds workarounds for some of PHP's more serious defects, like "pass by value or maybe reference" semantics, no user-defined types as indices (even most primitive types get silently mangled), and == being just blatantly wrong. Part of what makes a language pleasant to use is that it doesn't keep surprising you--stuff you'd expect to work, does.
- shaunxcode 16y agoI think I need to change the name of my repository now. I am now the author of "phlisp" http://github.com/shaunxcode/phlisp http://github.com/shaunxcode/phlisp to avoid confusion. hah. It is cool to see a different approach to the same problem! I am going more for source -> source, quasiquote macros, TCO, some arc-esque syntactic sugar etc. and back to php4 compat. Definitely a kick in the ass to release it now as I have stalled since april due to "work".
- dahlia 16y agoI made the mailing list (Google Groups) which is the place for discussion about Lisphp: lisphp@googlegroups.com http://groups.google.com/group/lisphp http://groups.google.com/group/lisphp Join us if you are interested in this project!
- c00p3r 16y agohttp://news.ycombinator.com/item?id=1467067 http://news.ycombinator.com/item?id=1467067
- c00p3r 16y agoSmartguys should write a lisp dialect for erlang VM. ^_^
- c00p3r 16y agoLet me guess - \(get_global_var "HTTP_SERVER", $MyServer, $ENV\)