14 ms·
Practicality: PHP vs Lisp
- norswap 16y agoThis is so true, and it's also valid for non-web uses of common lisp. Except Racket they are no user friendly lisp/scheme package. And heck, even Racket is far from ideal. Lisp may be a superior langage, but setting it up is impractical for anybody who isn't used to hack emacs and bash scripts all day.
- deleted 16y ago[deleted]
- swannodette 16y agoWow people are upvoting this FUD? > but setting it up is impractical for anybody who > isn't used to hack emacs and bash scripts all day This is Hacker News right? Having built websites in PHP, Python, Ruby, and Clojure ... guess what? They all present you with equal challenges if you're not building trivial small websites on shared hosting. Getting a website up and running in Clojure is as simple as it gets. Compojure ships with a good webserver baked right in.
- Raphael_Amiard 16y ago> Getting a website up and running in Clojure is as simple as it gets. Well you first have to get clojure running. And that's not as simple as it gets
- masomenos 16y agoYou piqued my curiosity, never having tried Clojure. My time from 0 to getting (the correct!) result of (+2 2) from Clojure's REPL was approximately 60 seconds. Pretty simple.
- randallsquared 16y agoIt took you less than 60 seconds to install Java, compile Clojure, and start the REPL? :) I haven't actually used (or installed) Clojure, but most of the complaints (here and on proggit) appear to be by people who don't already know Java, and so have to figure out enough of the Java build process to build Clojure in the first place, even though a touted advantage of Clojure is that you don't have to deal with Java.
- babblefrog 16y agoProbably already had a JRE installed (just about everybody does, I would expect), downloaded a pre-compiled clojure.jar, and ran it.
- francoisdevlin 16y agoThe advantage should be more properly stated that you don't have to deal with Java the language, but you still get Java the ecosystem. Using all of the supporting build & deployment stuff is actually seen as advantage with experienced Clojure guys.
- golwengaud 16y agoI have no java (programming) experience, and it took me ~45 s: #apt-get install closure #closure user=> (+ 2 2) 4 Most of that 45 s was waiting for apt-get. Now it's not going to be this easy on platforms that don't have such nice package management (e.g. Windows). Furthermore, Raphael_Amiard makes a good point that there's a lot more infrastructure that has to go into web application development (or any other kind of application development, for that matter) than computing the sum of 2 and 2. Nonetheless, it just doesn't seem that hard. At worst, put a "clojure /path/to/project.lisp" in rc.local or equivalent. (Caveat: my web development experience consists entirely of a couple of toy projects I ran on my laptop for my own amusement. Take all this with a grain of salt.) EDITed for formatting.
- 3d3mon 16y agoJust as easy for Windows. Use clojurebox. Double click the .exe file. http://clojure.bighugh.com/ http://clojure.bighugh.com/
- randallsquared 16y agoHaving built websites in PHP, Python, Ruby, and Clojure ... guess what? They all present you with equal challenges if you're not building trivial small websites on shared hosting. I've built websites in PHP, Python, Common Lisp, and RXML/Pike. Some have been very small, and some have been medium-sized. I currently work on a several-hundred-thousand-line PHP codebase, and I don't think being in PHP has been a serious problem for it. I do agree that language infrastructure is more important for small projects, and language power is more important for large projects. I think it's critical to provide good language infrastructure precisely because of this, though, since virtually everyone starts out learning a language with a small project! It's really easy to bounce off of CL, when you're first starting out, as easily demonstrated by a survey of c.l.l (at least, when I paid attention there 2003-2007), and it's not because of the language itself; it's because the infrastructure is (was?) severely lacking. I think it's harder to build a good infrastructure with a more powerful language, ironically, because the power substitutes for things that would otherwise be infrastructure-related, and once you've learned enough of the language to work on infrastructure, you no longer care so much.
- ulf 16y agoThis illustrates a far greater point that every once in a while returns to the surface of HN as well: A tool is seldom more than a tool. In regard to languages, for most projects there are more than enough constraints to begin with, so you can pick a language of your choice in no time. Sure there are languages that suck and languages that are awesome. But most of these comparisons only work in a vacuum. And in practice, no project ever starts in a vacuum.
- billswift 16y agoOne of the first posts I wrote on my blog last year was about tools - the first lines were: Use tools appropriate to your skills and to the job you are trying to get done. Learning to use more powerful tools is one of the best ways to increase your effectiveness. That is the best tool depends on both the job and your skills. (Most of the post was about my main illustration though, which was drafting versus CAD.)
- Tichy 16y agoBut why is it so - why is there no user friendly LISP, why did PHP win instead?
- sigzero 16y agoPHP won for two reasons. PHP is easy to pick up and ISPs installed mod_php which gave it good performance.
- ramy_d 16y agovery true. Also, this "Once you manage to get Emacs and SLIME going (I'm assuming you already know Emacs intimately, because if you don't, you already lose)" sometimes i feel lisp is like an exercise in barrier of entry. "Let's make an awesome language that is as inaccessible out of the box as possible" not just application wise. knowledge wise too.
- aerique 16y agoI've replied to these arguments before on HN but it bears repeating: You really do not have to use Emacs and Slime to get going with Common Lisp. There are many options including using whatever you're already familiar with or just plain Notepad. It's unfortunate that people advocating Lisp also advocate Emacs+Slime as the only option (although it is a good option).
- asciilifeform 16y ago> using whatever you're already familiar with or just plain Notepad. This is disastrously bad advice. This is how to create parentheses-phobia.
- aerique 16y agoOh please. Most programmers already somewhat decent editors like Textmate, Notepad++ or Vim.
- deleted 16y ago
- rubinelli 16y agoI only see a "File not found" now. Did we break it?
- bonaldi 16y agoSo the comparison is between starting from absolute scratch with Lisp -- having to choose a framework, get a dev environment set up, choosing your libraries etc vs an experienced PHP person just using PHP? This article could easily be turned around to something like "use emacs, lisp and the trusted framework you already know, or try to learn PHP with its inconsistent naming and verbose syntax and ..." Essentially he's judging languages by "wall-clock time", but only including time-to-learn in one of them.
- bad_user 16y ago> use emacs, lisp and the trusted framework you already know It took me 2 years to finally get comfortable with Emacs to the point I trust doing stuff in it, and I still don't know what I'm going to do if I ever start working in a language that doesn't have an editing mode available (it's not Textmate where you can define a syntax file in an hour). For a whole month I studied Clojure, trying to wrap my head around it. I still have problems. And now if I'd want to do stuff in Clojure, all web frameworks available suck for me (no, I don't like Compojure) ... which would mean I'd have to write my own ... or use Django, Rails 3, or even asp.net mvc 2 (even that is preferable). Of course, being the yak-shaver that I am, I'll probably attempt to write a web-framework for Clojure of my own, but not when the clock is ticking. On PHP ... doing PHP programming / copying popular websites was my first job. It took me exactly 1 week for going from a complete zero to someone that could get the job done. I don't love PHP as there are truly better options out there, but libraries/frameworks are more important than languages. If Java frameworks would've been designed with an eye towards their users and not to please managers, it would've crushed all other high-level languages by now (and it did in many ways).
- joubert 16y agoWhy not just write servlets in Clojure?
- bad_user 16y agoBecause I just don't need dumb request dispatch. There are a couple of things a web-developer needs ... data-models, with validations, form/request handling with validations (forms that render themselves are a plus), authentication/authorization (OpenID/Facebook/whatever support should be available of course), CRUD generating (I don't want to work on stupid admin interfaces that show tables of existing items more than 10 minutes), session handling, caching support backed in, a nice templating language that doesn't suck ... and a (lazy) ORM querying language would be nice (bonus points if it has integration with NoSQL databases). And all of them nicely integrated of course, as I don't want to lose time trying to figure out how to blend them in. That's not much to ask, and these are problems devs have struggled with in the last 10 years ... it is unacceptable to work just with servlets.
- swannodette 16y agoBefore people go around upvoting this article mindlessly. This article is from 2008, before Brian rewrote this blog twice in Clojure and got the hell off WordPress. I'd be interested to hear what he has to say now about this article (though it may be that his opinion has remained largely the same).
- mechanical_fish 16y agoThis remains a big problem with the web: Timelessness. It turns out that the ephemeral nature of offline commentary is a big feature. If I say something offhand in a bar I don't have to curate that statement forever, going back every few months to add some editorial comment about how my opinion has changed. It struck me the other day that this is why archivists have trouble with the web. Old links go dead all the time. Various people have tried to convince web publishers that they should take the preservation of old links seriously - we are destroying history! But it isn't just that preserving old links is hard work - which it is - but that history is a terrible burden for the living. You are forced to curate and disclaim it, or risk having it held against you. It's much more comfortable to just walk away from your history and hope that it biodegrades. Forgetfulness is a blessing, and few online systems provide it in any well-thought-out fashion. Users are forced to use hacks to achieve it.
- deleted 16y ago[deleted]
- jherdman 16y agoHow is this a problem with the web any more than anything? As soon as a thought leaves your mind and is engraved on some sort of medium (be it someone's memory, paper, or a webpage) it's out there for good. Publishing thoughts on web, like print, demands rigour from the author and the reader. Read actively, write like you have an audience, and be skeptical.
- mechanical_fish 16y agoAs soon as a thought leaves your mind... it's out there for good. This is another mindset endemic to engineers like myself: First-order thinking. The notion that, because a bit in a piece of flash RAM, a memory in someone's brain, and an etching on the wall of a thousand-year-old church are all the same to first order -- "persistent" storage of information -- they can therefore safely be treated as the same thing. The second-order differences are pretty important. To pick just one particular example: Human memory is not just an incredibly fallable medium (you remember events that never happened, and your memory of events that did happen gets distorted over time and is situational, dependent on your current mood) but it is inevitably filtered through the personality of the rememberer. The only way to learn what a World War II veteran remembers about the war is to listen to what the veteran tells you. If the veteran happens to have been a personal friend of General Patton, they will tell you certain things about Patton. If the veteran was a sworn enemy of Patton, they will tell you other things about Patton. If you strive to prevent them from doing this consciously, they will do so unconsciously. Such is the nature of human memory and communication. A photograph of Patton, or a written memoir, is an entirely different beast. And, similarly, there is a big qualitative difference between a third-hand account of a conversation in a bar, an entry in a handwritten diary that is stored in your basement someplace, and a popular web page that has been downloaded a thousand times and is available on Bittorrent in case the original is taken down.
- thejay 16y agoMost programmers aren't paid to revolutionize the world of computer science. Most programmers are code monkeys, or to put it more nicely, they're craftsmen who build things that other people pay them to create. To say most programmers are craftsmen is a huge overstatement. Most programmers have no sense of craftsmenship.
- adamc 16y agoAnother way to put it is that people don't learn lisp because it is never the local maxiumum, the nearest, easiest hill to climb. That's probably true, but always settling for local maximums has bad consequences over the long term. Periodically you should invest in figuring out how to do things better overall.
- _ivan 16y agoLisply upvoted
- tsally 16y agoMahmud is one of the few HNers that actually has practicle experience deploying Lisp in the real world. You might be interested in what he has to say on the issue of practicality: "Today, Lisp is nothing like what it was 8,7,6, even 2 years ago. It's not just "good" in the well-explored text book fashion; no, it's _good shit_. Get work done good. Think, hack, ship, bill for it good. 2-3 products per month good. You still have to know where things are, who is working on what, what's maintained and what's obsoleted by what. Sure. But there is absolutely no lack of libraries." (http://news.ycombinator.com/item?id=972423 http://news.ycombinator.com/item?id=972423). I'm curious if the author of the article has similar experience deploying CL or if this article is just theorycrafting. I notice some experience with Clojure, but this article was written in 2008.
- jwr 16y agoI think many people who defend Common Lisp in this thread never actually deployed web applications written in CL. I have. I had to seriously hack on Weblocks just to get things to work they way they should. I had to work around various bugs and omissions. And worst of all, every once in a while I discovered that I am clearly the only user of said software. A good example is when I discovered that the database interface (to CLSQL) isn't thread-safe. It was a quick hack intended for a single thread only. Obviously you'd never notice it in a demo setup. Turns out I noticed it just when somebody else had that problem and wrote CLSQL-FLUID. But there is more — after running the application for several months I discovered two things: a) there are obscure bugs related to caching in CLSQL, which I don't have time to hunt down (stale content is being served), b) there are bugs somewhere either in CLSQL or Weblocks that blocked part of my admin interface and they are obscure enough that I don't even know where to start looking, c) every once in a while SBCL will crash on me and land me in the LDB. Don't get me wrong — I like CL and I invested a significant amount of work in to Weblocks — but I agree with Brian here: I don't want to discovere somewhere along the way that I'm the first real user. At least not when I am on a deadline. I do most of my work in Clojure now, but when there is a simple web application to write — hey, we get our hands dirty and we do it using PHP. Because life is too short.
- Ixiaus 16y ago
- IgorPartola 16y agoBuyer beware: PHP documentation is not always as extensive as is boasted and the user comments often times are very dangerously wrong. For an example of this see the comments to json_encode where many wrong PHP implementations are suggested (they don't take care of escaping non-ASCII data), or the read/write/socket functions where bizarre timeout behavior is suggested, or the microtime and usleep functions where even more bizarre things are suggested.
- robryan 16y agoAs with most comments on the internet, you have to be careful not to take it all as stated fact, they are moderated which is good but I doubt they go into the implications of code snippets on edge cases when approving. I haven't found anything misleading enough in the actual documentation to remember.
- mifrai 16y agoI fully agree. For instance, PHP implements it's own round function. Now there very well may be a good reason they don't just use/implement the C99 round - but one can at least expect it not to change. This isn't true, in some version (I forget which), they changed their implementation and that caused all sorts of headaches to us and our users that depend on these numbers. Moral of the story? Don't use PHP for stats.
- c00p3r 16y agoYes, it is that simple - you need some prepackaged basic stuff, like mysql connector, xml, json parser and other commonly used modules. You need dumb-easy install and integration with web server, and you need a quite large and active community. In that case all cheap hostings will support it. PHP is coming with all distros nowadays, so newbies and managers makes a choice without thinking at all. sudo yum install php-* - that is why. btw, take the arc, add a buzzword (llvm) and easy api to write extensions with fast FFI, and it will get as much hype as clojure - llvm is better buzzword than jvm ^_^
- adamilardi 16y agoDespite the claims PHP is ugly. It's very easy to use. I've seen newb programmers able to do simple if statements and read data from a database with little coaching. It's really a delight to use for simple websites. The other factor is it's standard on ALL shared hosting. If they started to make rails or django standard I would have started with that instead.
- michaelfairley 16y ago"LAMP stack on Windows"?
- invisible 16y agoE.g. http://www.apachefriends.org/en/xampp-windows.html http://www.apachefriends.org/en/xampp-windows.html
- ww520 16y agoIn a Linux VM I guess?
- briancarper 16y agoA perverse case of http://en.wikipedia.org/wiki/RAS_syndrome http://en.wikipedia.org/wiki/RAS_syndrome. Please forgive me.
- jff 16y agoOver here, I wanted to try doing some web dev with Lisp, but couldn't find a CL implementation that would compile on FreeBSD/sparc64, so I guess I'm boned.
- scottjad 16y agoThe biggest strength of PHP has always been that a non-programmer who already has an HTML page can start adding dynamic code by inserting a simple tag into their HTML file and continue working as they have been (edit the HTML file, reload page, repeat). That's the lowest barrier to entry of any language except maybe javascript.
- asnyder 16y agoReading that article was pretty frustrating for me. Sure, if somebody decides to sit down and start writing a complex WebApp or program in direct PHP it can be a hodge-podge, however, if you were to use many of the frameworks out there you can get a very positive, and consistent experience, while also enjoying all the benefits of PHP's widespread adoption and support. For example NOLOH (http://www.noloh.com http://www.noloh.com), which provides just that sort of abstraction. NOLOH devs never even need to really know that they're in PHP. You would never know it from the consistent and elegant code, or the numerous syntactic sugars that make coding in it a joy. While none of this is out of the box in PHP, once you add NOLOH, poof, wonderful, clean, and consistent language, with language features that rival many others. Furthermore, any PHP environment can benefit from this, including all shared hosting users. Thus in my opinion it's never that clear cut to suggest, oh PHP is crap, it's terrible, I hate working with it, because the language is flexible enough that you can write a framework that makes programming in it a joy. Now, if you were to ask me if I would use PHP without NOLOH that would be difficult. I've done it before, and it isn't so bad, but I would likely only go so far to a small script, or a small WebApp. Disclaimer: I'm a co-founder of NOLOH
- jacquesm 16y agoNOLOH looks great by the specs, I'd probably put some time in to evaluating it if it were open source.
- asnyder 16y agoWe do offer open-source projects license, and have an open-source guarantee. Meaning that if anything should happen to us the source-code would be opened. We're currently designing a clearer product section that details the guarantee along with clearer descriptions of the free and commercial license options.
- wvenable 16y ago"PHP is overly verbose and terribly inconsistent and lacks powerful methods of abstraction and proper closures and easy-to-use meta-programming goodness" Sometimes I wonder how much closures and meta-programming is just code for coding sake. I've seen lots of examples of 5 line LISP code that does something totally amazing but you don't really know what it means but it's so abstract. If you have a quick job to do, I don't see that it's a limitation in using a language that requires to build the most straight forward solution. PHP is ugly, but for the most part it isn't horrible -- these days you can easily avoid some of the worst parts and concentrate on making code that would be very equivalent to the same code in, say, Java. PHP is very straight forward -- it means what it says. "Your web framework in PHP probably isn't continuation-based, it probably doesn't compile your s-expression HTML tree into assembler code before rendering it." This just sounds like over-engineering the problem.
- sedachv 16y ago"This just sounds like over-engineering the problem." Except the problem was never defined. Of the five commercial Lisp applications I've worked on, two are addressing domains (large-scale financial calculations, and a web platform/OS) where using PHP makes absolutely no sense, and the current one (ERP) where PHP was previously attempted and found not to make any sense. All three use basic techniques like closures, markup generation and metaprogramming, and one of them is continuation-based (which I think is a mistake, but opinions differ).
- eru 16y agoI find e.g. closures in Lisp overly verbose. The ML family of languages has a much lighter weight syntax for functions. This makes amazing stuff look less like code for code's sake. (Though I do admit that I immensely like Lisp's macros.) In e.g. Haskell abstractions are the straightforward way to solve a problem. Abstractions are cheap.
- Zak 16y agoClosures in most Lisps are a bit verbose, but it's easy to create an alternate syntax using a macro. Arc and Clojure provide built-in shorthand for function literals that makes them much more convenient to use.
- mahmud 16y agoXach has a new toy under-wraps that's gonna revolutionize the state of Lisp deployment. Really awesome stuff. Stay tuned ;-) http://quicklisp.org/ http://quicklisp.org/
- neovive 16y agoUsing a good PHP MVC framework such as CodeIgniter or KohanaPHP can go a long way towards making your PHP code cleaner and more maintainable. PHP clearly does not match the expressiveness and elegance of Ruby or Python nor does it match the power of Lisp, but as the author points out, it does "get the job done". Using a good framework will help you avoid reinventing the "well written" PHP code wheel.
- shaunxcode 16y agoSolution? A framework which allows you to write lisp which turns into php written in php? Below is how I would do this in what I am calling "lisphp" http://github.com/shaunxcode/lisphp http://github.com/shaunxcode/lisphp (map-dict [k v | tag :li (tag :strong k) (join "," (map [get :name _] v))] (group-by :color (sql-query "select * from favcolor order by color, name")))
- code_duck 16y agoWhy is PHP offered as the only other solution? I've used PHP in plenty of projects, and after years of experience with that, it would absolutely not be my first choice to solve what the author describes. How about Ruby/ + Sinatra or Rails, or Python + Django or Pylons?