This is a read-only archive!

Practicality: PHP vs. Lisp?

Eric at LispCast wrote an article about why PHP is so ridiculously dominant as a web language, when arguably more powerful languages like Common Lisp linger in obscurity.

I think the answer is pretty easy. In real life, practicality usually trumps everything else. Most 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. The code is a tool to help people do a job. The code is not an end in itself.

In real life, here's a typical situation. You have to make a website for your employer that collects survey data from various people out in the world, in a way that no current off-the-shelf program quite does correctly. If you could buy a program to do it that'd be ideal, but you can't find a good one, so you decide to write one from scratch. The data collection is time-sensitive and absolutely must start by X date. The interface is a web page, and people are going to pointy-clicky their way through, and type some numbers, that's it; the backend just doesn't matter. For your server, someone dug an old dusty desktop machine out of a closet and threw Linux on there for you and gave you an SSH account. Oh right, and this project isn't your only job. It's one of many things you're trying to juggle in a 40-hour work week.

One option is to write it in Common Lisp. You can start by going on a quest for a web server. Don't even think about mod_lisp, would be my advice, based on past experience. Hunchentoot is good, or you can pay a fortune for one of the commercial Lisps. If you want you could also look for a web framework; there are many to choose from, each more esoteric, poorly documented and nearly impossible to install than the last. Then you get to hunt for a Lisp implementation that actually runs those frameworks. Then you get to try to install it and all of your libraries on your Linux server, and on the Windows desktop machine you have to use as a workstation. Good luck.

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) you get to start writing your app. Collecting data and moving it around and putting it into a database and exporting it to various statistics packages is common, so you'd do well to start looking for some libraries to help you out with such things. In the Common Lisp world you're likely not to find what you need, or if you're lucky, you'll find what you need in the form of undocumented abandonware. So you can just fix or write those libraries yourself, because Lisp makes writing libraries from scratch easy! Not as easy as downloading one that's already been written and debugged and matured, but anyways. Then you can also roll your own method of deploying your app to your server and keeping it running 24/7, which isn't quite so easy. If you like, you can try explaining your hand-rolled system to the team of sysadmins in another department who keep your server machine running.

Don't bet on anyone in your office being able to help you with writing code, because no one knows Lisp. Might not want to mention to your boss that if you're run over by a bus tomorrow, it's going to be impossible to hire someone to replace you, because no one will be able to read what you wrote. When your boss asks why it's taking you so long, you can mention that the YAML parser you had to write from scratch to interact with a bunch of legacy stuff is super cool and a lovely piece of Lisp code, even if it did take you a week to write and debug given your other workload.

Be sure to wave to your deadline as it goes whooshing by. If you're a genius, maybe you managed to do all of the above and still had time to roll out a 5-layer-deep Domain Specific Language to solve all of your problems so well it brings tears to your eye. But most of us aren't geniuses, especially on a tight deadline.

Another option is to use PHP. Apache is everywhere. MySQL is one simple apt-get away. PHP works with no effort. You can download a single-click-install WAMP stack nowadays. PHP libraries for everything are everywhere and free and mature because thousands of people already use them. The PHP official documentation is ridiculously thorough, with community participation at the bottom of every page. Google any question you can imagine and you come up with a million answers because the community is huge. Or walk down the hall and ask anyone who's ever done web programming.

The language is stupid, but stupid means easy to learn. You can learn PHP in a day or two if you're familiar with any other language. You can write PHP code in any editor or environment you want. Emacs? Vim? Notepad? nano? Who cares? Whatever floats your boat. Being a stupid language also means that everyone knows it. If you jump ship, your boss can throw together a "PHP coder wanted" ad and replace you in short order.

And what do you lose? You have to use a butt-ugly horrid language, but the price you pay in headaches and swallowed bile is more than offset by the practical gains. PHP is overly verbose and terribly inconsistent and lacks powerful methods of abstraction and proper closures and easy-to-use meta-programming goodness and Lisp-macro syntactic wonders; in that sense it's not a very powerful language. 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.

But PHP is probably the most powerful language around for many jobs if you judge by the one and only measure that counts for many people: wall clock time from "Here, do this" to "Yay, I'm done, it's not the prettiest thing in the world but it works".

The above situation was one I experienced at work, and I did choose PHP right from the start, and I did get it done quickly, and it was apparently not too bad because everyone likes the website. No one witnessed the pain of writing all that PHP code, but that pain doesn't matter to anyone but the code monkey.

If I had to do it over again I might pick Ruby, but certainly never Lisp. I hate PHP more than almost anything (maybe with the exception of Java) but I still use it when it's called for. An old rusty wobbly-headed crooked-handled hammer is the best tool for the job if it's right next to you and you only need to pound in a couple of nails.

September 21, 2008 @ 6:17 PM PDT
Cateogory: Programming
Tags: Lisp, PHP, Ruby, Rant

56 Comments

Victor
Quoth Victor on September 21, 2008 @ 11:17 PM PDT

The PHP might be easy to learn but I find it really ugly and hard to use.

I have got a different situation: started writing a web site in PHP and then found out that it is much more easier to program certain things in Common Lisp. As a result, the site is mainly PHP with a major toolset in Common Lisp used to process data for that site.

And in the future I would like to have the whole site written in Common Lisp, because it is much more easier and straightforward to express common algorithms in Common Lisp than PHP. (that array() thingy drives me mad)

wvd
Quoth wvd on September 21, 2008 @ 11:19 PM PDT

You forgot to mention how PHP is practically ubiquitous in many shared hosting environments.

w-g
Quoth w-g on September 21, 2008 @ 11:20 PM PDT

> I think the answer is pretty easy. In real life, practicality usually trumps everything else. Most 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. The code is a tool to help people do a job. The code is not an end in itself.

And for large projects, Common Lisp will let you get it done with less pain than PHP.

> 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)

It takes time to get yourself trained in good technology.

> undocumented abandonware

Really? Which library exactly are you referring to? This smells like FUD.

> Don't bet on anyone in your office being able to help you with writing code, because no one knows Lisp

More FUD...

> Another option is to use PHP.

Sure. Or several other programming languages: Java, Python, Ruby and others.

> Apache is everywhere.

Yes.

> MySQL is one simple apt-get away.

Yes.

> PHP works with no effort.

Hm. In a large environment, you may have problems.

Maintaining PHP code is painful, unless you've been trained in good design and programming practices (which most people familiar with Lisp and Smalltalk are familiar with).

Migrating to a new version of PHP (for example, 4 to 5) can be HELL. I've seen this is a big company. Big effort. Stop several engineers, tell them to start "migrating code". (Does that happen with Common Lisp?)

markus
Quoth markus on September 22, 2008 @ 12:13 AM PDT

I agree with this article. PHP is from a practical point of view dominant for the www.

Lisp has faded because for too long it has not given the www the practical importance it required.

The www is very important. EVERY language that wants to compete with php needs to understand that.

The www IS IMPORTANT.

Or does anyone see many webshops in lisp, or in php?

Last but not least, to the guy

who commented before me:

"And for large projects, Common Lisp will let you get it done with less pain than PHP."

And this is valid for many other languages like Ruby too. So what is your point? I also do not like PHP but we have to be realistic - PHP was a big success.

> It takes time to get yourself trained in good technology.

Experience makes many things easier, better etc... but a bad language will help you less than a good language. I had quite some trouble to write an IRC bot in php but it was really easy in Ruby. (Mind you, i have not touched that old code anymore but my point is that after some time the BETTER language will help you more than a worse language. It helps you achieve MORE.)

> More FUD?

Lisp is still there, jobs in lisp still exist, but from a practical point of view perl/php/python/ruby are a MUCH closer "family" of programming languages than lisp. If you can not understand this, I have a simple suggestion - visit the websites of these languages. Especially ruby and python have nice websites. PHP has a rather practical website, with good online docu. Perl is showing its age on its website, but please compare that with lisp websites... they are so 1990. (Perl website is 1992...)

> Maintaining PHP code is painful

Wait a second! The author said himself that php is a horrible language! I agree with him. There is no point in listing all of php problems. Years ago I jumped the boat away from php. These days I recommend ruby or python to people (personally I clearly favour ruby but I have no real problem with python.)

Stephan Schmidt
Quoth Stephan Schmidt on September 22, 2008 @ 12:16 AM PDT

Excellent post. Exactly the problem with Lisp.

When Java has teached us one thing - and I guess PHP is the same : Since the mid-90s we don't develop software but we assemble software from existing libraries. As with Java in PHP there are lots of excellent libraries for all tasks. Development is a minor point.

So at least for us developers who need to earn money and don't have a vendor lock-in with airplane carriers or work at NASA with an - former -unlimited flow of money, we best stick to Java, PHP or other ready to use and assemble languages

"Maintaining PHP code is painful, [...]"

And Lisp isn't, why? Or do you propose the standard Lisp answer: Because all Lisp developers are geniuses so they don't make errors and always write beautifully architectured code.

Peace -stephan

Eric Normand
Quoth Eric Normand on September 22, 2008 @ 12:23 AM PDT

This is all so true.

For small, simple, dynamic web sites, nothing beats LAMP. It has -- to quote Larry Wall -- on-ramps.

I don't think this applies so much to more complicated sites, where the simplicity of PHP means you have to do more work.

For a long-term project, I would choose Lisp. I think, in the end, I would come out ahead in terms of frustration.

Victor
Quoth Victor on September 22, 2008 @ 12:38 AM PDT

Java here, Java there, Java everywhere...

Use ABCL (or Clojure) and you get the Java "batteries" available on [Common] Lisp.

Stephan Schmidt
Quoth Stephan Schmidt on September 22, 2008 @ 2:02 AM PDT

"For a long-term project, I would choose Lisp. I think, in the end, I would come out ahead in terms of frustration."

Where do you recruit 50 Lisp developers?

Peace -stephan

sumfageshwa haraneshilupumulunasopsewahtirulashu
Quoth sumfageshwa haraneshilupumulunasopsewahtirulashu on September 22, 2008 @ 2:36 AM PDT

You can download a single-click-install LAMP stack for Windows nowadays.

Lispbox includes a AllegroServe, which means you cat get the whole set (Lisp/Emacs+Slime/webserver) in one package, too.

a programmer
Quoth a programmer on September 22, 2008 @ 3:03 AM PDT

@Stephan Schmidt:

off-the-top-of-head-response: comp.lang.lisp? #lisp (IRC)?

after-more-thought-response: I am a developer with over 12 years of work experience (I was into computers way before I ever was employed to write software for them). I have worked for multiple businesses and have a lot of friends who are developers also. I have never once known anyone who worked for a company that was recruiting 50 developers at the same time (and I've worked mostly with very popular languages -- C, C++, perl, and yes, a little PHP). I have worked on desktop applications, web applications, and applications for handheld devices). All the recruiting efforts I can think of were for 5 or less developers (many, perhaps most, were for 1 or 2 developers). I'm not saying that there aren't teams out there with larger numbers (I know there are), but in my estimation, those teams are the minority. I would guess that most groups in a company that actually work together on projects consist of a team of 10 or less individuals -- with a large percentage of those being teams of 5 or less). Yes, I have worked for small businesses, but I have also worked for large million-dollar and even billion-dollar corporations.

No, it will not be as easy to find Lisp developers as it will be to find Java or C++ developers. However, I doubt very seriously that most people will ever be recruiting for 50 developers at the same time.

One solution to the recruiting problem is this: Hire good programmers who are willing to learn, pay them well, and give them the time to learn Lisp from more experienced developers who already know it (small projects, or small new features on existing projects). Companies do this every day with Java and C++ developers. There is no reason it can't be done with Lisp programmers. In fact, from what I've read, this is exactly what companies like ITA software do all the time (http://itasoftware.com).

I will not argue against the fact that many Lisp libraries need better documentation. That is true. It is also true that it will probably take many developers a longer time to get the hang of Lisp. No argument there. If you are just wanting to create a single one-off application, and are not willing to invest a significant amount of time in learning to use Lisp, then by all means use a more popular language that you already know. However, I have never known of anyone who spent a significant amount of time learning and using Lisp (and yes, I do know quite a few) who did not find it extremely productive and useful for everyday projects -- this is despite the difficulties one might have with library documentation, etc. The key is that you have to invest the time, which most people appear to not be willing to do (or they are not given the opportunity to do it in a work setting). It is not much different than spending the time to learn a powerful text editor, like vim or emacs (I've personally been using vim for about 10 years). Yes, they operate differently than most other applications. Yes, they both feel "weird" and "unconventional" to new users. However, if you spend 6-8 hours a day, 5 days a week (or more) using one of these editors, you can become "fluent" in either of them fairly quickly, and you will probably soon find that you are able perform complex editing tasks in them faster and easier than you could in a more "standard" type text editor. I am very fast with vim and I have close friends who are very fast in emacs (and all of us work or have worked with multiple languages in multiple environments -- including Windows, Linux, Solaris, etc). Both editors are powerful, but both have a steep learning curve (with vim's curve being perhaps a bit steeper, but others might disagree with that). The situation is the same with Lisp. Powerful tools often require an investment in time to learn to use well. The situation with Lisp requires a very significant investment, and a good deal of patience, but I know of many people who would argue that the payout is big enough to be more than enough to make up for the required investment to get to that payout.

August
Quoth August on September 22, 2008 @ 3:09 AM PDT

true. It is like whether or not accept lesser evil. If one wants to marry wrong woman and live with her his entire life - you can't argue with that.

I program in Common Lisp, because this is what I want to do. I like programming, I like Common Lisp - and I would never code in language I don't like unless forced to. At the moment, I have the freedom to choose.

luxury, eh? Well - OK, maybe, dunno.

Jeff Horn
Quoth Jeff Horn on September 22, 2008 @ 3:10 AM PDT

I think PHP is fine for what it is... a tool to put together a reasonably functional website quickly. I like your comment: "An old rusty wobbly-headed crooked-handled hammer is the best tool for the job if it's right next to you and you only need to pound in a couple of nails.". What I see far too often though is application developers seeing everything and anything as a nail just because they have this "wobbly-headed-crooked-handled hammer" nearby. I see this all the time... we hired this guy to build a series of complicated business transactions to be executed as cron jobs... AND HE DID IT IN PHP! We hire a person to do memory caching as a service... AND HE DID IT IN PHP! We wanted to build a domain specific language parser... AND DID IT IN PHP!!! YIKES! Right tool for the job people... yes, take proximity and availability and cost into consideration, but hey, let's not be stupid!

August
Quoth August on September 22, 2008 @ 3:11 AM PDT

Also worth noting - it is not the speed or practicality or getting the job done, it is cost of maintenance and time-to-response for change requests ten years from now that matters. At least, for some applications

Stephan Schmidt
Quoth Stephan Schmidt on September 22, 2008 @ 3:20 AM PDT

@a programmer: Not 50 at one time, but it's difficult even over serveral years to recruit 50 lisp developers in one city I guess.

"All the recruiting efforts I can think of were for 5 or less developers (many, perhaps most, were for 1 or 2 developers)."

We're a small website with 50 developers and - when looking at our jobs page - we currently search for 5 more Java developers. Perhaps we're just in two different industries.

Peace -stephan

John Haugeland
Quoth John Haugeland on September 22, 2008 @ 3:54 AM PDT

Lal, a LAMP stack in Windows. The problem with using buzzwords and buzz-acronyms instead of actually naming the technologies is that you start forgetting what they mean and start attaching other, largely incorrect connotational meanings to them.

You can never have a LAMP stack under anything but Linux. By definition. Try to remember that those letters mean things.

Craig
Quoth Craig on September 22, 2008 @ 4:10 AM PDT

Clojure is an interesting hybrid that may give a best-of-both-worlds approach. It will be interesting to see how the experiment plays out.

a programmer
Quoth a programmer on September 22, 2008 @ 4:19 AM PDT

@Stephan Schmidt: Fair enough. I would suggest that you should be able over several years to recruit enough good programmers who will learn whatever technology you ask them to. You can be more picky about who you hire if you pay a good wage. Some companies are either unwilling or unable to do so (but given the waste I've seen at many companies, the real problem is that they put their money in the wrong places). Even when money-constrained, it is better to hire fewer good programmers who get real work done than to fill the quota with mediocre ones -- which is all too common. And I think you can invest the money in training different technologies (just like companies do with Java/C++). If developers aren't willing to learn on the job, you're hiring the wrong ones. I can appreciate that this is more difficult to do for smaller operations, however. Bigger companies have the resources to do so, but are often too blind to see any possible benefits of making the investment.

We are at least in different niches, most likely. Some of my web application work has been for intranet web applications, rather than public internet ones. Much of the public internet web applications were for small companies with 10 or less total developers. The larger corporations I have worked for may have had 50 or more developers total, but most of the teams were broken down into groups of 10 or less that worked largely in isolation with limited joint projects.

Of course, most of the Lisp developers I know would argue that if you hire good programmers and train them to know Lisp well, you would never need 50 developers for a small site. I can, however, appreciate the difficulties in making that investment in a small company, where you may not have the time to invest up front -- especially when the technology goes against what many will call "conventional wisdom", whether or not the term "wisdom" is really appropriate in that instance.

Why did you bother
Quoth Why did you bother on September 22, 2008 @ 4:30 AM PDT

adoption!=practicality

Robert Virding
Quoth Robert Virding on September 22, 2008 @ 6:49 AM PDT

@John Haugeland: That would mean that on Windows you would have a WAMP stack, or perhaps a WIMP stack if you use IIS. Sorry I couldn't help myself.

Thr4wn
Quoth Thr4wn on September 22, 2008 @ 7:44 AM PDT

Is Arc making server-side lisp easier?

Brian
Quoth Brian on September 22, 2008 @ 8:03 AM PDT

Arc is largely vaporware. :(

Anonymous Cow
Quoth Anonymous Cow on September 22, 2008 @ 8:16 AM PDT

my god this is so interesting

Mark Dionne
Quoth Mark Dionne on September 22, 2008 @ 9:12 AM PDT

I wrote my thesis on LISP.

I helped start a company, Interleaf, that based its product on LISP.

These days I use PHP and JavaScript.

Robert Synnott
Quoth Robert Synnott on September 22, 2008 @ 9:18 AM PDT

The thing about abandonware libraries is simply untrue, and unfair.

Friedrich
Quoth Friedrich on September 22, 2008 @ 2:33 PM PDT

I once had some software wrote in PHP and I disliked it. The meshing up of things is "terrible", I gave Lisp the "chance" but in the end I used Ruby + Rails. I wrote about APIs just be usable by thos having implemented the library. I've seen the problems with Common Lisp libraries all too often. There are still exceptions: If you'd use the stuff provided by the Common Lisp Vendors you usually can get through without too much headaches. The libraries from Edi Weitz can be seen as "standard". But my experiences with UCW, Cells, McClim etc were devastating. I wrote about my problems with ucw at http://www.cliki.net/UCW.

So you better knwo which places to go to find "useful" Lisp stuff. And you just learn that by painful try+error mode...

Feel free to flame me for that Friedirhc

evrim
Quoth evrim on September 22, 2008 @ 8:03 PM PDT

try this: http://www.cliki.net/CoreServer

P. Cabron
Quoth P. Cabron on September 23, 2008 @ 2:03 AM PDT

Sounds like there's a market for LispScript. :)

Chris
Quoth Chris on September 23, 2008 @ 2:42 PM PDT

I recently wrote an app which had to compile arbitrary oblique specifications each into a plugin for a different application on some target machine (running either PHP5, ASP.NET or JSP). That plugin would, in turn, gather user input and compile a code instance elsewhere and that instance would then gather up whatever files/data it needed and output HTML.

I wrote that app in Lisp. It is well written, easy to read, easy to maintain. It is running well, the plug-ins it compiled are running well on whatever different servers they are at, the code instances that they build are running well. I know PHP very well and have coded in it for years. But make no mistake, if I had chosen to write that app in PHP instead of Lisp, I'd still be working on it and it'd probably never be working correctly.

PHP+Apache+MySQL is convenient and great. That convenience is a big advantage. But, as far as I can tell, it is PHPs only advantage when compared to Lisp.

I've used Lisp on several projects and have never felt poor for libraries. There is a fantastic library for handling regular expressions, several choices for XML parsing, several HTTP server and client options, SOAP, Amazon S3, image handling including bindings to GD, the list goes on and on.

If I'm building a data-driven web service will I choose Lisp over PHP? Not necessarily - do I have control over the server, or is it going to be put on some client's server? As I said, that convenience aspect of PHP is a big advantage. But if the app is anything more than flour-and-water pasting of some SQL queries/XML parsing to web output (a childs task that hardly deserves to be called programming anymore) then I choose a grown up language, and PHP is not that.

aaa
Quoth aaa on September 23, 2008 @ 10:16 PM PDT

stupid lisper.

Jeff
Quoth Jeff on September 25, 2008 @ 7:12 AM PDT

Lisp is the easiest language to use, If you are a real programmer you would under stand, lisp means LISt Processing. Everything is a list. Everything uses () which makes the code easier to figure out. Everything is just a plugin within a plugin. Just little pieces that fit in other peices

simple list (list :namea "hello" :nameb "world")

getting part from list (getf yourlist :namea)

the real evaled code (getf (list :namea "hello" :nameb "world") :namea)

How difficult is it to figure out all you are playing with are strings. Once you figure this out any task is simple.

Instead of wasting time trying to figure out what premade package is out there that wastes memory every time it is loaded.

Time finding these premade functions is ridiculous.

Just know what you want your final result to be before you start working

Ali
Quoth Ali on September 26, 2008 @ 12:33 AM PDT

To avert myself from exploding at the in-accurateness of this post, I composed my reply from keywords.

windows,clisp,hunchentoo,cl-who,quicker,better,easy - genius not required,emacs not required,libraries - http://www.cliki.net/web

Yeah, any company which wants a couple of web pages and a bit of script should use PHP, everyone knows that. Its economics, not technological wisdom, stupid.

I've coded PHP websites a lot, and CL for a very short time. I can tell you hands down CL beats PHP in productivity by orders of magnitude - if you can learn it for just a minimal amount of time.

Hey I know what'll add to my post...

FUDFUDFUDFUDFUDFUDFUDFUDFUDFUDFUDFUD

Much better.

Brian
Quoth Brian on September 26, 2008 @ 2:33 AM PDT

Glad you feel better now!

Sleepy
Quoth Sleepy on November 14, 2008 @ 11:25 AM PST

An interesting, yet not really solid, post. I have been coding Common Lisp, Haskell, Ruby, PHP, Java, C,... the works. In my finding, I like lisp the most. Whenever I'm coding in another language, I feel sad because of the missed abstractions. Virtual limitation of my programming skills, solely due to the inexpressiveness of the language I was obliged to use.

Besides the fact that other languages frustrate me, I do acknowledge that there is a lack of standardized libraries in Common Lisp. This indeed makes many inferior languages quicker on the short run. It tends to be easy to write new libraries in lisp, but certainly, it is not always a welcome treat when the job needs to be done quickly.

I don't believe there is a shortage of Lisp programmers out there. It is hard to find experienced lispers, because no experience can be gained in a payed environment. Schools generally don't help either, with their overly hard emphasis on the more popular, yet feature-inferior languages (eg: Java). Yet I do know some that would do much to code in lisp, instead of php.

The conclusion of this post for youngsters or interested coders, is hopefully not one of ignorance towards Lisp. The poster makes clear that Lisp allows for greater abstractions. It is up to all of us, to use this power. To make better libraries in it. To make the language live. Therefore, I suggest newcomers to learn the language, to build in the language. Try to build libraries in Lisp, you'll never learn to build them that good in any other language.

--

Anyway, we all know chicks dig lispers.

ANSI specification revision. | keyongtech
Quoth ANSI specification revision. | keyongtech on January 18, 2009 @ 12:58 AM PST

[...] enough, what would some other drawbacks be to revising the spec for CL? The discussions around http://briancarper.net/2008/09/22/pr...y-php-vs-lisp/ and others bring into focus this question. [...]

Abdullah
Quoth Abdullah on June 15, 2009 @ 1:56 PM PDT

Learning to use emacs and coding in (emacs) lisp is really easy. Do check out my blog www.linuxandlisp.blogspot.com. Right now I have a post that summarises the way the lisp language works. Experts in lisp, your comments will be appreciated.

Johannes
Quoth Johannes on July 01, 2010 @ 9:31 PM PDT

I find that most people who complain about PHP being a terrible language are the same people who mix logic and presentation and think it's the only way to write it.

Jan Rychter
Quoth Jan Rychter on July 01, 2010 @ 10:02 PM PDT

I 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.

Emil Sedgh
Quoth Emil Sedgh on July 01, 2010 @ 11:01 PM PDT

It's odd that noone said anything to 'defend' PHP here.

Well, I have to.

As a PHP programmer, I do care about the code I write more than anything else.

Why I use PHP, you ask? Because its not as bad as you say. Here are a range of things you have to consider:

1) PHP is a language. It includes no API. It just gives you basic stuff.

2) PHP is not a 100% OO language. There are so many ugly functions, like famous str_* mess. However, it gives you all the tools you need to create a very powerful OO program.

3) There are many beautiful, good looking PHP web application frameworks which have very well thought API's. Use them and write back your experience.

What im trying to say is, PHP makes it easy to write both ugly, 'just working' code AND very well structured, powerful one. Its your decision which way you want go.

But if you write crappy code with PHP, it doesnt mean PHP is bad.

Harleqin
Quoth Harleqin on July 01, 2010 @ 11:10 PM PDT

If you have a project that is perceived to need 50 PHP developers, you do not need 50 Common Lisp developers to write it in Common Lisp instead---you need about 5.

In other news, ITA software just was acquired for 700 million dollars by Google.

Guess what most of their core software is written in.

steve
Quoth steve on July 01, 2010 @ 11:26 PM PDT

I have to agree with Emil Sedgh! If you are suck at programming then don't blame on the language. Why major websites like Facebook uses php?

John
Quoth John on July 02, 2010 @ 12:38 AM PDT

For the simple webapps, if you don't want to use PHP, and you feel like you don't want to take out the big guns (Lisp), why not use Perl/Python/Ruby? (Brian, I see you mention Ruby at the end of your article.)

Personally, I like Perl, and although deployment is a little more work than PHP (which takes no work), it's still not too bad. I'd rather deal with that bit of extra deployment work than deal with PHP, especially since I'm already using Perl daily for other sundry tasks.

Brian
Quoth Brian on July 02, 2010 @ 3:28 AM PDT

John: Yes, I do use Ruby nowadays. Phusion Passenger makes it fairly braindead to deploy.

Jesse Raleigh
Quoth Jesse Raleigh on July 02, 2010 @ 4:32 AM PDT

All this PHP bashing is rather amusing.

If it's such horrible crap, why does Wikipedia use it? They seem to be serving a heck of a lot more data than I suspect most of the posters here are with their lisp based apps.

I won't argue that the transition from php4 to php5 was rough. FIVE YEARS AGO. Who cares, it's been dead for years now!

Bad coders can write crap code in any language. Good coders can get the job done if given tools that are suitable to do so.

PHP is a niche tool, it's built for delivering data driven websites. It's not a tool for writing cron jobs, though it has that potential. If you need to automate a task that touches a database, I doubt very much you're going to do that in BASH by hand. If you already have a rich set of libraries for your specific application that you can leverage for your command line script directly via php, why re-invent half your library in perl just to use a more "systems" language?

Most of these comments seem to be arguing that apple pie would be better if made with oranges. This totally misses the point.

Ben Atkin
Quoth Ben Atkin on July 02, 2010 @ 4:33 AM PDT

Regarding the desktop machine dug out of a closet: It's sad that the client has any say over what the app runs on. It's not the way it works in a SaaS business.

gb
Quoth gb on July 02, 2010 @ 6:54 AM PDT

Reading these comments is depressing. Everybody has an opinion, and yet very few of these comments seems to go beyond "PHP is dumb, because... My favorite tool rules."

The potential for an interesting conversation is being completely ignored, even though the article makes an attempt at it: "Why is PHP so successful? What are its qualities that make it such a stand-out language, even though it's clearly not the best language out there?" There is something to be gained by understanding this question that goes far beyond how the syntax looks or how hard it to do certain things.

JL
Quoth JL on July 02, 2010 @ 8:10 AM PDT

gb above said: "something to be gained by understanding this question": absolutely. Moreover, there are problems with CL, I mean with the language as such; never mind inserting CL in a WEB page. But of course if you say this to the Lisp community you will stoned on the spot.

nickik
Quoth nickik on July 02, 2010 @ 10:29 AM PDT

Hallo,

In real life, here's a typical situation. You have to make a website for your employer that collects survey data from various people out in the world, in a way that no current off-the-shelf program quite does correctly. If you could buy a program to do it that'd be ideal, but you can't find a good one, so you decide to write one from scratch. The data collection is time-sensitive and absolutely must start by X date. The interface is a web page, and people are going to pointy-clicky their way through, and type some numbers, that's it; the backend just doesn't matter. For your server, someone dug an old dusty desktop machine out of a closet and threw Linux on there for you and gave you an SSH account. Oh right, and this project isn't your only job. It's one of many things you're trying to juggle in a 40-hour work week.

You say that sometimes you just want a website for some simple data input output. Yeah thats true. But oftentimes something happens with stuff like that. Managers come and say staff like could we add blablabla to that? Ok, hack it. Then the other guy comes and want something else. Ok, hack it. No problem.

Then somebody wants something complex then your fucked and I takes way longer.

or you have to do something almost the same for some other costumer even it that wasn't planed. <-- fucked again.

Your ignoring what we learned in 50 years of software industry

One option is to write it in Common Lisp. You can start by going on a quest for a web server. Don't even think about mod_lisp, would be my advice, based on past experience. Hunchentoot is good, or you can pay a fortune for one of the commercial Lisps. If you want you could also look for a web framework; there are many to choose from, each more esoteric, poorly documented and nearly impossible to install than the last. Then you get to hunt for a Lisp implementation that actually runs those frameworks. Then you get to try to install it and all of your libraries on your Linux server, and on the Windows desktop machine you have to use as a workstation. Good luck.

Just take one and always work with that. I admit that there are some problems there just take one thats seams to be the best for your requirements and work with that. There are many php frameworks too and you have to work with one and get to know it.

Add it to the problem list.

Don't bet on anyone in your office being able to help you with writing code, because no one knows Lisp. Might not want to mention to your boss that if you're run over by a bus tomorrow, it's going to be impossible to hire someone to replace you, because no one will be able to read what you wrote. When your boss asks why it's taking you so long, you can mention that the YAML parser you had to write from scratch to interact with a bunch of legacy stuff is super cool and a lovely piece of Lisp code, even if it did take you a week to write and debug given your other workload.

You can NEVER just take one language and do what ever you want. If your in a team that works with php you have to work with php you will have to live with that!

But if you form a new team then you can decide on a language und the frameworks ... you want to use you can take a Lisp or something other that is not really standard. If your company doesn't have rules for that stuff (witch it really should)

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) you get to start writing your app.

Why is it easier to write PHP in notepad than CL? Just because you have to count the parentheses? Thats no reason.

In the end it doesn't matter what language you take you will want tool support.

Its culture to. Lisper use emacs a lot. Java guys love big IDEs ...

You can ask in the net for help with libraries there at least one good one in there for simple SQL stuff. At least its easy do make your own if something is really missing. If something is missing in php your fucked.

But we can safely add that to the problem list.

Then you can also roll your own method of deploying your app to your server and keeping it running 24/7, which isn't quite so easy. If you like, you can try explaining your hand-rolled system to the team of sysadmins in another department who keep your server machine running.

True that and add it to the list of problems

But PHP is probably the most powerful language around for many jobs if you judge by the one and only measure that counts for many people: wall clock time from "Here, do this" to "Yay, I'm done, it's not the prettiest thing in the world but it works".

The above situation was one I experienced at work, and I did choose PHP right from the start, and I did get it done quickly, and it was apparently not too bad because everyone likes the website. No one witnessed the pain of writing all that PHP code, but that pain doesn't matter to anyone but the code monkey.

Thats what software industry is today and look whats came out. Tones of shit Java and php code that nobody wants to look at or change. Of course for a manager just hires some more code monkeys who have to work with your code and he will have a pain to.

Software is not write once and then its done. Look at stuff like Extreme Programming I think they got it right.

I have to do that at work atm work with old VB code that sucks hardcore. If they had taken the time 10 years a go the would have to pay me to go throw all that pain witch would be better for me and cheaper for them.

If I had to do it over again I might pick Ruby, but certainly never Lisp. I hate PHP more than almost anything (maybe with the exception of Java) but I still use it when it's called for. An old rusty wobbly-headed crooked-handled hammer is the best tool for the job if it's right next to you and you only need to pound in a couple of nails.

Ruby is already more then half way to Lisp. I think you would never use Commen Lisp as it is today.

You are write I would use the old hammer but only if I head the option to replace the hammer if the head breaks of.

With a hammer you can do but not with software.

So here is the problemlist: 1. libs 2. other people don't know it that well 3. libs again 4. deployment 5. libs again

Hard or impossible problems to solve. Still better that php.

So here is my solution as somebody that likes lisp. Use clojure. It was created to solve exactly these (and more problems) because its compiles to the JVM (note: JVM good, Java not good)

Its not CL or scheme its a new Lisp.

I'm really happy with it and I think its the Lisp of the future that can bring more popularity to lisp again.

What you got know is the biggest collections of libs and easy deployment. There is still the "people don't know it problem" but nobody is perfect.

The "people don't know it problem" you will encounter with everything that is somewhat not C like (Java, PHP, C++) or mainstream

Ok, ruby is easer to learn than clojure but there are also a lot of benefits.

And here something about hiring:

At the moment there are not to many people hiring Lisp/Clojure or other odd stuff Programmers and because everybody that likes [random odd thing] will want to work for you.

If there are 1000 who want PHP Coders there are ~20000 if you want [random odd thing] Coders there are may be only 10 or so but

  1. they want to work for you
  2. they LIKE work for you (<-- really imported in my book)
  3. the are more productive
  4. your System will have less scaling problems
  5. System is easier to maintain

If your only had 1 day for a website and than you deploy it php my easer but most of the time you have project that take weeks or even years.

In most cases you don't throw together a website in 1 day and never look at it. Today websites change alot because the world is changing too.

P.S. Here is a good read for you: http://www.paulgraham.com/avg.html

Ryan A.
Quoth Ryan A. on July 02, 2010 @ 12:04 PM PDT

I think a good sensible choice these days would be something like Scala. It has access to all the battle-tested Java libraries, has a very decent syntax (very ruby like), has type inference, performs quite well, there are plenty of managed hosting options if your business requires it.

PHP is popular because it's commodity and has such a low barrier to entry. Someone who has rudimentary HTML knowledge can pick up some simple PHP and plug it into a database without too much trouble, the same person couldn't design and construct and deploy a JVM application, though.

I don't think you can compare PHP to LISP, let alone anything, as PHP is a truly horrible yet initially accessible commodity web programming language with about a much design sense as a rabid monkey.

Vsevolod Dyomkin
Quoth Vsevolod Dyomkin on July 02, 2010 @ 8:28 PM PDT

Another article re-framing the old stupid FAD. In my experience there are no problems with Lisp libraries and environment, that you mention. The same concerns the mythical impossibility of finding Lisp coders or people able to understand Lisp code, even if they didn't work with it before. Not to mention, that the relative accessibility of PHP comes at a cost of security problems and other unpleasant things.

The real reasons for PHP ubiquity in web-development are mentioned elsewhere (for example by Jeff Atwood): - the simple shared-nothing execution model - good targeting of the market (after all, PHP is a DSL for web-development) - historical reasons

It can be understood from the comparison not to Lisp, but to Perl and Python/Ruby: - Perl also is on every shared hosting, but it has much worse market-targeting (after all, PHP originated from Perl to solve this concrete problem) - Python/Ruby are even more accessible, than PHP (at least, if you tale Django or RoR), but they're not on every shared hosting out there, that's why they loose (relatively)

screw php
Quoth screw php on July 03, 2010 @ 2:58 AM PDT

I'm a Lisp programmer who currently works in a PHP shop.

I really can't take someone seriously if they claim that the comments section on PHP's website is useful. It's absolutely crawling with useless, usually broken code.

PHP's 'simplicity' also goes flying out the window the moment you try to develop anything more complex than your damn little side nav. I work on a very large (in the MLOCs), 10-year-old PHP codebase, and the horrors I have seen, and the facepalms I have faced, are more than I think anyone here would be willing to deal with (considering the rest of their bitching and moaning). Architecture-dependent integer overflows in a high level language? Seriously?

Someone else mentioned the incredible pain of having to go from one version of PHP to another. I don't even have to go into that. You can imagine the troubles of updating a several-million-loc web application to the Next Great Version of PHP. It's troublesome, expensive, and even when you think you're 'done', you'll continue to suffer from obscure errors or old, ugly, crusty code that you couldn't be arsed to update.

And don't even get me started on all the security bullshit that PHP makes you waste your time on (unless you feel like having your life hijacked by l33thax0rs that bothered to spend 10 seconds googling all the major attack strategies).

Easy to set up? Seriously, it's like no one but me has had to deal with tweaking php.ini.

Now to Lisp:

  • A lot of lisp libraries look better from the outside than they really are.

  • The barrier of entry for Lisp is higher. This isn't to say that support is worse -- #lisp has always been incredibly helpful, and #php seems to be full of bumbling idiots that aren't even remotely interested in helping.

  • You don't need emacs+slime. That happens to be a fantastic environment that no other language really has. When PG was working at Viaweb, he was using clisp and vim. This is still perfectly reasonable, you just don't get the supersexy environment, and you still get more than what PHP provides.

  • Lisp is a lot more stable, as a language. You're not going to have to spend thousands of dollars completely rewriting your application just because they finally decided to add objects (or closures).

  • The productivity gains I see with Lisp completely dwarf any issues I've had with Lisp libraries. It's more productive for me to use Lisp and patch a library that doesn't do things the way I want than it is to use PHP and forever be stuck with its warts (and crappy development process)

  • Hiring lispers - If you're a company that really just wants to hire Java or PHP programmers based on them having it in their resume, I don't want to work for you. Competent programmers are going to be able to learn whatever language you throw their way. It's not even going to take them that long. Perhaps you should focus more on hiring good programmers, and less on hiring inexperienced kids fresh out of a diploma mill with a bunch of buzzwords in their resume. ITA is full of brilliant hackers. They don't hire Lisp programmers. They hire good programmers, and then teach them Lisp. The shop I work at doesn't hire PHP programmers. It hires good programmers, then hands them some books on PHP and throws them into a very large codebase. Knowing PHP already just happens to be a plus.

That said, I don't care about Lisp being popular. It doesn't need to be. There's something to be said about a language with so many warts that still manages to blow its counterparts out of the water when it comes to productivity. You're not going to find what you expect in Common Lisp.

Anthony G
Quoth Anthony G on July 03, 2010 @ 4:21 AM PDT

Lisp is my favorite language. But this PHP bashing has got out of hand.

I wrote my doctoral dissertation project in CL. My lab was contracted on this project to deliver a product for DARPA. We used Allegro CL, an "industrial-strength" version of CL for which you pay through the nose. Despite that, the garbage collector is terrible - our whole application would stop dead when it run, which was bad, because it was a time-sensitive application. My overall impression was that while it was a joy to code in CL, problems that had long been solved in other languages where still open in CL. Libraries are immature, buggy, and incomplete, and the time you save in programming, you spend in writing stuff that would be available immediately in Python, Ruby, etc.

I work with PHP during in my daily job, and I find the language acceptable. I think that the main problem that PHP has is one of perception. PHP now is a 'corporate' language. This means that it is rock-solid, but it is no longer cool. The "cool" kids want to use something else so they can feel like rebels. So PHP-bashing is in.

The perception is also not helped by the PHP community containing lots of inexperienced programmers and non-programmers that just dabble here and there. So you see a lot of horrid code floating around, and instead of concluding that the programming is faulty, the "horridness" rubs off on PHP.

And because so many PHP programmers are on the inexperienced end, most don't know that PHP provides a really impressive set of power-features that allow you to make additions to the language that most people do not even know about. And some perceptions in the PHP community itself seem rather bizarre to me. For example, if you visit PHP forums, people will state as an article of faith that 'eval' is evil and should be avoided. If you press them to give you a reason, most can't. They just heard it from somebody else, and blindly repeat it as a mantra.

The only two valid reasons that I have heard against the PHP eval are 'security' and 'speed'. On security: if you execute unsanitized user-given input in your eval, then that's bad. Don't do that. If you must allow your users to give you something to eval at all, then you better sanitize your input well. But for the case where you are in control of what goes into the eval, this is a non-issue. Which leads to the speed problem. Yes, eval'ed code is slower, about 3-4x so. That however is many times a price worth paying.

I'd like to remind Lispers that Lisp came out of a math theorem on eval, so languages that give you access to such a feature allow you to do very powerful things. Here is a library that I wrote called ClassMixer: http://github.com/wellspringworldwide/PHP-ClassMixer. Thanks to the PHP eval, in my company we are using multiple inheritance and have access to 'before' and 'after' methods a-la CLOS. All in pure PHP.

Building on ClassMixer, I have recently written a PHP mixin that dynamically changes PHP objects to use property access (e.g. $foo->var is rerouted to get_var() and set_var() methods). Thanks to _get and _set magic methods.

Just yesterday I finished a fluent interface for database access that allows us to do sql queries from our ORM in a single statement a-la jQuery. All thanks to the __call magic method.

To recapitulate: PHP is not only not horrible, in my opinion, it is a better language than Python, one of the cool kids darling. Python's multiple inheritance is a mess, the GIL is broken, and don't get me started on its package manager. I had a lot of fun debugging a problem caused by sys.modules hashing the same file under two different entries when you import them using relative and absolute paths. Please play some more with the PHP language from an unbiased perspective, you may form a different opinion.

screw php
Quoth screw php on July 03, 2010 @ 5:48 AM PDT

Anthony: I stopped reading your post the moment you claimed that the garbage collector stopped the world. Anything else you could say after that is nothing but FUD.

... actually, I also read the very end of your post. Are you seriously griping about Python's GIL when trying to prop up a language that has absolutely no concurrency support?

Get out of the internet.

Anthony G
Quoth Anthony G on July 03, 2010 @ 6:49 AM PDT

That's the point. PHP doesn't claim to support everything. But what it supports, it supports well. Python wants to be the jack of all trades, but is the master of none. And Guido's answer to the multithreading debacle? Not fixing the GIL, use multiprocessing instead. If you'd like to be taken seriously, as a mature person, it would behoove you to be civil in your responses. And yes, the Allegro CL GC stops the world. No need to FUD when the truth is horrible enough.

Anthony G
Quoth Anthony G on July 03, 2010 @ 6:56 AM PDT

Here is the documentation for the Allegro CL GC. We spent a good amount of time trying to tune it so that it would not stop of dead to no avail. If you know of a way to accomplish this, would sure love to hear: http://cse.unl.edu/cl/gc.htm#global-gc-1

Anthony G
Quoth Anthony G on July 03, 2010 @ 6:59 AM PDT

And if you are serious about doing concurrency in PHP, you use this: http://gearman.org/

Alpheus
Quoth Alpheus on September 12, 2011 @ 3:17 AM PDT

I hate PHP. I'm using it at work right now, and it reminds me why I hate it. I'm just beginning to learn Common Lisp, and I really like it so far...but I don't use it too much at work, even though I'm more free than others to choose my languages. Instead, I typically reach for Python.

Why Python? Or even PHP, for that matter? Because when I have these tools, I generally have two things: lots of mostly-well-tested libraries to reach for; and cross-platform compatibility that typically includes those libraries.

Oh, it's not perfect, by any means! Trying to figure out how to install "lxml" on Windows, after using "apt-get" to get it onto Linux, can be a surprisingly difficult task. But it's nonetheless there, and you can do it, and your scripts will work.

Oh, I yearn for a single Common Lisp that works on Linux, Mac OSX (and I hate Macs!), and Windows--along with a core repository of libraries that work on all three systems! Oh, how I yearn to write such a system--but don't have the time.

Lisp apologists need to stop apologizing for things like lack of libraries and lack of cross-platform compatibility. The community needs to rally around a single project whose goal is to write lots of useful libraries on an implementation that will work on all three systems! (And no, running under CygWin doesn't count.) And all this needs to be relatively easy to install, too.

Is this too much to ask? No, because Python, Ruby, PHP, and so many other languages, already do this.