382 points · by smartial_arts · 13y ago · 229 comments
I'd ask you to mention a lisp library which you use but find under-documented (as another reply already has), but I don't think anyone with actual first-hand knowledge of the CL ecosystem would make this comment (even though I'm sure it recieved many enthusiastic if uninformed upvotes).
Lets look at some popular libraries with documentation. - Alexandria http://common-lisp.net/project/alexandria/draft/alexandria.h... - CL-PPCRE http://weitz.de/cl-ppcre/ - metabang-bind http://common-lisp.net/project/metabang-bind/ - not to mention the standard by which all other language documentation should be judged, the CL hyperspec http://www.lispworks.com/documentation/HyperSpec/Front/
And with sites like http://www.cliki.net/, http://common-lisp.net/ and http://www.gigamonkeys.com/book/ and many other full length books, if you can't find lisp documentation you're not looking very hard.
Let's take a look at HyperSpec, I follow your link and I'm greeted with a mostly blank (and very ugly) page. Ok there is something called starting points, I guess I'll start there. That page just lists all the indexes. Ok let's try chapters, that sounds like a place to start. Oh yay, another page with nothing but links. Ok, let's try introduction. Again, just a mostly empty page with links. Most people would have given up by now. But lets keep going. Let's try 1.1, which takes us to ANOTHER page of links. I'm feel like I'm getting the run around here. Lets click 1.1.1 and see what happens. Finally I get a page that isn't all links, and it's a single paragraph. What a waste of time.
Let's try another language, how about JavaScript? Google gives me this link: https://developer.mozilla.org/en-US/docs/JavaScript Some helpful information on the first page! Do I want a reference? Do I want a guide? Do I want a re-introduction? Maybe some sites with courses on JavaScript! Wow, that's really useful. Lets just start with the guide because it's "Our primary guide about how to program with JavaScript" and that sounds about right. It takes me to a list of links, Yuck, let's try the fist one called "JavaScript Guide" (Isn't that what I clicked on to get here?). Yup, that link just refreshes the page. That sucks, let's try the second link "About this Guide". A page that describes what I should already know, how to find my way around the guide, and tips for diving into JavaScript.
This is the problem with LISP documentation. At best, if I know exactly what I am looking for I find a giant index. At worst I have no idea what I'm looking for and I get snooty comments from LISPers.
The point is you shouldn't make people look really hard to find information. Good documentation should be easy to find and navigate.
Learning lisp wasn't any more difficult for me than learning any other language. "Practical common lisp" is well written. "Object oriented programming in common lisp" is a well written book as well, "Land of lisp" was fun, and not too bad either.
The core language is extremely well documented and understood. As for the libraries, some of them are well documented, some of them aren't. After the docs for RESTAS started going slightly out of date, I just opened the source and read it all in an afternoon(~600loc), and mostly understood it. I prefer not to have to do that, but claiming it makes it extremely difficult to learn, I don't know, to me it's just an inconvenience, and I have a much better understanding of the framework now, which I couldn't get from just reading docs. And some libraries are so small, I can just figure them all by inspecting the package in slime, and reading the docstrings. Usually there is at least example code. The situation isn't perfect, but it is more than possible to use lisp libraries with great success. Most authors are also pretty approachable on irc or the mailing lists. In other words, I'm a young amateur programmer, who picked common lisp less than two years ago, I'm barely competent as a programmer, and I could figure this all out, why can't expert programmers with years of hacking behind them do the same, I can't understand.
PS as for the ugliness of the hyperspec, I'm happy if it scares away people who get impressed by "modern" design, more than substance and content. I usually read it in text only browsers, and curse docs I can't read well from within emacs. Alt-tabbing to a browser and having to use the mouse while hacking ruins my day :)
I'll make that statement, but only in a somewhat pedantic sense about the language standard itself. Yes, I know CLTL2 is over a thousand pages long, but the one thing about programming languages that always bothers me is undefined behavior. Sadly, even Common Lisp has undefined behavior; Paul Graham's book On Lisp actually relies on undefined behavior being implemented in a particular way e.g. using setq on an unbound variable.
Good documentation should not leave anything undefined; good documentation should leave no questions about the semantics of a system/API/language. Given source code and documentation, it should be possible (perhaps difficult, but possible) for a person to figure out what will happen if the program is run.
Using SETQ on an undefined variable may be undefined in the Common Lisp standard, but every implementation deals with that and allows it. That's a non-issue. There are a lot of other things which isn't defined in the standard and which all implementations deal with. Garbage Collection. Also not in the standard, but every user expects garbge to be collected.
It would be nice to have less undefined behavior, but it has nothing to do with good or bad. It was useful in a time of experimenting.
Even worse for Common Lisp was that in 1981 there wasn't yet an OOP system for Lisp that was explored and accepted. This way CLtL1 was defined without an object system and it had later to be added (CLOS).
Also, if you're (or anyone else is) interested in working on a Common Lisp environment tutorial, shoot me an email. I've been working on one but haven't launched it yet.
I was talking as a long time member of a different programming community with similar attributes. (Smalltalk - since 1998)
Here's a racket guide, which provides detailed documentation for every facet of the language: http://docs.racket-lang.org/
=how do I do X?=
java: something similar to X is already done in Y. add abstract class and redo X and write Y. +200 LOC
lisp: something similar to X is already done in Y. realize you can generalize X and Y into a new pattern and use it for ABC too. -70 LOC
=there is a bug in function X=
java: open X.java. edit line. restart program. X seems to be working correctly.
lisp: two hours later, ah ha! I understand this code. fix X. write unit test. eval unit test. X works correctly.
[1] demo: https://a.keeptherecords.com/demo, source: https://github.com/ThomasHintz/keep-the-records
And your first example is something that most modern languages are sold on. The truthiness of those statements can be debated, but your examples are flawed to say the least.
Point is: you can generalize and write unit tests in any language.
(define (println . args)
(for-each (lambda (arg)
(display arg)
(display " "))
args)
(newline))Remember that movie "Boy in the Plastic Bubble," about a boy with an immune system deficiency who lives instead a hermetically-sealed, sterile bubble? That's not the answer. We instead need to create immune systems (read: robust systems) rather than simply avoiding them.
[I know I'm simplifying things, and this is not meant to be a slight.]
In other words: functional programming and Lisp does not translate to ignoring state.
It was _really_ good, you should definitely check it out :)
Same is true for I/O. You must start from a protocol.
Most of people probably underestimate how many brilliant people contribute to what we could call a modern Lisp.
With all respect, Clojure is nowhere near in terms of sanity, consistency and uniformity.
I don't event want to argue about Haskell. Seems like words "monad" is the same as words "chakra" or "dharma" in a popular culture.))
Are there any more interesting concepts you stubbornly dismiss?
It's Clojure http://clojure.org/
Closure is Google's js library and tools https://developers.google.com/closure/
Although I agree that clojure has is warts. For example clojurescript uses the numerical stack of JavaScript. So you get different and unexpected results than when running on the JVM
The real issue is whether you think it's worth separating out code that can be reasoned about in a mathematical fashion from stateful code that has to deal with mutating concerns. Functional programming is where research on improving abstractions to better allow this separation of concerns, which is pretty much the opposite of a clumsy hermetically-sealed bubble rolling around and knocking lamps over, etc.
Mutable state in software is like moving parts in hardware. It's often necessary, but it makes everything a bit more fragile.
Common Lisp has a better object system then any other in the world. Clojure has a time and state managment system.
However saying these are the best OOP systems in the world is still very subjective because I do have a fondness for the simplicity and elegance of Prototype based OO especially as implemented in languages like in Io, Rebol & Self.
What does this mean in practical terms? What are you specifically criticizing? It's obvious that you're taking some kind of dig at functional programming, but what is the actual critique or logical argument you're attempting to make here? It is very unclear.
The problem is not state. The problem is being able to recreate the state: both for testing and for business purposes.
The bigger problem is that most programmers, like you, are knee-jerking before the issue of "recreating the state" and declaring that "It cannot be done, because it's all state".
And hence we have both languages who are build by considering mutability to be a virtue and back-end databases (your typical CRUD SQL DB) build upon the same false premises.
I'll give you one example: monday morning the service desk calls because one user of your app, at 3:07pm on friday, experienced a bug.
Can you "recreate the state" your application was in at that time as to be able to figure out what triggered the bug?
You probably can't. Because your DB has changed meanwhile: you're SOL because the 'U' and the 'D' in CRUD are destructive. It's mutability. It's the ennemy of determinism.
So now you're stuck calling your DB admin asking for a dump of the prod DB on last thursday evening and a dump of the log of the transactions that happened on friday... And you're spending hours and hours trying to recreate the state the environment was in when the sht hit the fan. And you may or may not be able to do it.
It's just one hypotethical scenario but things like that is the daily lot of
many* programmers.But software development, in many cases, shouldn't be that painful. If you were to use a CRA DB (Create Read Append) and languages favoring immutability and a more functional approach overall, you'd have a much much easier time recreating the state.
If you think of it, it's all a gigantic determistic machine.
So why can't we accept that the notion of time is an important one?
Why can't you realize that the battle the likes of Rich Hickey are fighting are worth it?
It is possible to use programming languages and DBs (or wrappers like Datomic in front of SQL DBs) that do definitely make it easier to reason about programs and that make it just so much easier to recreate the state and to query the past (which has a lot of business value).
Why do you react like this: "The truth is, it's all state". Saying that as if nothing could be done and as if every single programmer's life should be Java/C# + ORM + XML + SQL hell?
There are people trying to make our life as devs easier. Why not try to listen to what their saying?
Is Rich Hickey "seeing things" with Clojure + Datomic?
To me the combination of a functional language (or at least a language that can be used in a mostly functional way) and a CRA DB (Create Read Append) which incorporates the notion of time from the start is a godsend to our industry.
Why do you close your eyes?
Even if you have perfect time-warping capabilities, there are still big challenges to solving bugs with that kind of analysis. The time the bug is noticed may be long after the root cause, and working backward could be a very slow process.
That's why SQL has declarative constraints, to try to make the error noticed at a time closer to the root cause.
Would I like full time-warping capabilities sometimes? Of course. But it's just one more option, and a very expensive one at that. To be any use at all, we'd need to be able to warp backwards through the entire OS and its scheduling decisions (not just a single process), because many difficult bugs involve race conditions.
Really, we need better temporal capabilities, and more declarative constraints (that are immune from race conditions, like a UNIQUE constraint), better ways of avoiding race conditions, etc.; and they all need to work together.
That's why I have worked on temporal capabilities[1] as well as declarative constraints [2] (immune from races) in Postgres. Also, you might be interested in truly serializable transactions in postgres, which eliminate race conditions between transactions without blocking[3].
I feel like the programming language community should work more with the database community. From the article, they mention how restarts can help recover from errors encountered after part of the state has already been changed. But that kind of recovery is taken for granted with the atomic nature of transactions in a database. Database theory is largely about detecting, containing, mitigating, recovering from, and preventing errors[4].
[1] http://www.postgresql.org/docs/9.2/static/rangetypes.html [2] http://www.postgresql.org/docs/current/static/sql-createtabl... [3] http://drkp.net/drkp/papers/ssi-vldb12.pdf [4] http://thoughts.davisjeff.com/2009/12/23/good-error-recovery...
All it takes is to swap "write" operation with "event" entity (all is state). Combine that with intention revealing commands (customer_died instead of delete from customers where id=1) and you hit jackpot.
End result is nice stream of events which is ultimate source of truth and enables crazy queries you never thought you would ever need http://abdullin.com/journal/2010/6/3/time-machines-should-su...
Lisp puts a heavy burden on the individual programmer, and its benefits can be achieved with better planning and engineering with the standard C++ toolkit. Yet, it is not easy to achieve the advantages of C++, such as performance, parallel execution, low level with lisp.
Lisp is nice for the few who have small projects, big brains, and little time, but by tightly coupling the problem to the code (with no performance benefit) it creates a unstructured nonsense that nobody but the author can understand.
I'm not familiar withe the concept and google and wikipedia haven't helped.
Thanks.
Lisp represents mutable state the same way Python and C++ do.
I guess I just wanted to see how many points it collects. So far it has exceeded my wildest expectations, although that is mainly due to the content, not the title.
I tried Clojure some week ago through the Clojure koans that were posted here. Compared to Haskell I found the syntax very obtuse and it was not obvious why Lisp would be more powerful than Haskell. The bare-bones syntax felt more like a "proof of concept" than an actual strength.
(of course, the koans took less than a day to do so I'm not dismissing Clojure because they didn't impress me, but I got the idea that the koans were an attempt to showcase Clojure's strengths)
The answer is that Lisp code is written with Lisp data (the property known as homoiconicity). Why is this an advantage? Because it greatly simplifies metaprogramming; Lisp macros are simply functions that operate on Lisp data structures.
Language "power" is ill-defined, and basically means "good".
If you think that homoiconicity is good, then you probably like lisp. If you think that referential transparency is good, then you probably like haskell. Those are mutually exclusive, so one language can't really have both. But either one could be considered "powerful" and either one could be said to help prevent bugs.
What homoiconicity offers is the macro system, the ability to operate on the syntax tree as a regular language data structure.
The difference is a language like Haskell enforces referential transparency where in a lisp it is up to the developer whether or not a function will be referentially transparent.
That was incorrect, I meant: "the kinds of metaprogramming associated with homoiconicity are mutually exclusive with referential transparency".
A macro could not, for instance, take a variable name as an argument and return a result that's based on the value of that variable and maintain referential transparency. So that would be a pretty weak macro system.
I suppose there may be other uses for homoiconicity, but I don't know enough about lisp to comment on that.
Although that may compromise the ability of the compiler to detect mistakes even when the developer writes all referentially-transparent functions. Not sure about that, but I suspect that it does in practice (currently) even if not theoretically inherent.
There are Lisp computer algebra systems like Maxima and Axiom that can be used for advanced term rewriting operations. Referential transparency, which is replacing terms with their definition, is just a very simple term rewriting operation.
This mutual exclusivity is a strange claim that I have never encountered before (but I'm not a computer scientist). Could you explain it?
Really, what I meant was the metaprogramming associated with homoiconicity can't be done in a useful and referentially transparent way. That's because "eval"-like things are not referentially transparent.
However, there are other uses for homoiconicity aside from executing the code in an eval-like way. For instance, a text editor might use that property to inspect and transform the code being edited more easily. Also, I'm sure there are plenty of times it just makes things easier.
I think metaprogramming is also at odds with static analysis (e.g. a good type system), simply because the code itself is not static enough to analyze.
What do you mean by "obtuse"? If by that you mean difficult to understand, Haskell's syntax is far harder to understand because it has operator precedence tables. Even if you manage to memorize the language's built in operator precedence levels developers can define their own operators with custom associativity and precedence.
I will take the uniformity of Lisp syntax rather then the complicated, incomprehensible, and hard to parse syntax of Haskell any day. Lisp syntax is so much simpler then syntactic languages like Haskell that you can even build a simple reversible parser that converts textual code to and from list structures with whitespace metadata: http://lisp-ai.blogspot.com/2012/09/reversible-lisp-reader.h....
The easiest answer to that is, there's no syntax, which makes reimplementing your own Lisp parser trivial (one single function call, in fact). This in turn makes reimplementing your own Lisp, inline in Lisp, similarly trivial.
That sounds like something out of an SICP exercise - and it is - but the same properties make it easier to reason about your code in a way that's far more abstract than other languages let you. Once you start treating your code as data that other parts of your code can manipulate, you can start refactoring in ways that simply aren't possible in other languages. This explanation by a well-known Perl programmer explains it very well: http://lists.warhead.org.uk/pipermail/iwe/2005-July/000130.h...
Another way I've heard it (this may have been pg, but I can't remember), is that, when writing idiomatic Lisp, you first think, "What language would make solving this problem really easy?" and then proceed to implement that language.
I've done some compiler work in Haskell like writing programs (semantic actions) as algebraic data structures and then transforming or interpreting the tree. Would I gain something by using Lisp macros in this instance?
http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/m...
That's close, but not quite the wording I remember, so I must have seen it somewhere else as well. That's a pretty good description of what I was referring to, though.
Everywhere I read about the power of lisp and really want to use it. If it is so good why ain't it is used more?
It is very easy to get sites running using ASP .NET, wordpress, RoR or Django. I have worked on production sites using the first two. And personally tried on small projects on the last two.
Is there a way to use Lisp professionally?
* Weird syntax (for most people).
* No free implementations existed during a key period (80s, 90s) so no initial traction, no useful libraries and killer apps which would pull the whole ecosystem. Implementations didnt even exist for commodity hardware.
* The commercial implementations cost too much, so they suffocated the ecosystem. People preferred coding for free in C or Perl, than paying an arm and a leg for Lisp. So they wrote all the useful libs in C, Perl, Java and Python instead of Lisp.
* No canonical implementation, late and incomplete standardisation, which led to extreme fragmentation, which further killed off the growth of the ecosystem. Instead of writing useful libraries, Lispers wasted effort writing 1001 incompatible implementations of the same basic system.
So to summarize, I'd say the Lisp ecosystem is _still_ suffering the consequences of the bad strategic decisions made 30-40 years ago.
But it is slowly but steadily healing and improving, especially the last few years. It has a high-quality free implementation with SBCL [1], consolidated CPAN-like library management with Quicklisp [2] and a IDE with Emacs-based SLIME [3]. Everything is getting better.
Emacs LISP (OK, a limited dialect) was available and so was CMUCL (full implementation), which I believe was used for teaching in 1992 when I first got in contact with LISP at our uni ...
Also, back then (80's and 90's) most people still paid an arm and a leg for C, Modula and Pascal on their platforms, so that can't have been an issue. My take is that LISP implementations were too slow to justify their use for most people over faster compiled languages. Whether you paid for the language or not, you expected to be able to get the most out of your hardware.
Lisp is a compiled language.
For that matter, it's a damn fast one, too. The Lisp implementation of PCREs are actually faster than Perl's, by some benchmarks.
I don't want to start a tangent about benchmarks and their relevance, but it's clear that Lisp performance isn't a limiting factor.
That's also not new. Common Lisp has an Emacs IDE since before the dark ages. It was called ILISP. Every Lisp + Emacs user was using it. Well, Franz had/has their own Emacs interface called ELI.
BS.
CMUCL. AKCL. CLISP.
I did not intend to imply that nothing. existed. whatsoever. cmucl, gcl (akcl) and clisp even today are insignificant also-rans and basically unmaintained abandonware.
> If it is so good why ain't it is used more?
My guess is that it's hard to create well-gelled lisp programming teams.If you're using Java or C#, there are certain ways of going about things, and there's general consensus about this. You can pick up Java code that is written by someone you've never met and have a pretty good idea of being able to work out what's going on.
Something similar with python: whitespace forces a lot of style, and it's backed up by the style guide.
Whereas lisp is completely open-ended. Want to run a large system built entirely from lists? Fine. Want to build an object system tinted by your weird philosophies? Fine. Want to create sophisticated self-modifying code? Fine.
It's a worse version of a problem you have with C++, finding a common subset of things that the team will stick to (or only hiring gurus who are interested in all the quirks and who know the history).
Style arguments within teams are draining, but you need to have commonality to be able to work as a team.
Clojure has some edge here for weird reasons. It discourages recursive techniques because of limitations in the JVM. And, if you're going to be interacting with libraries from other parts of Java, you probably don't want to be acting as funky as you might be tempted to otherwise.
I've read a decent amount of Clojure source, since documentation is admittedly a problem with a lot of libraries, but it's the language I've found actually easiest to read. The Clojure way of going about things is to pass around and manipulate simple immutable data structures, which I find easier to understand than large class hierarchies. Macros are usually used for creating DSLs or removing simple boilerplate, which leads to smaller, easier to understand code bases in my experience, rather than implementing custom object systems or something like that.
I don't think Clojure really discourages recursion so much as it lets you avoid using it explicitly by providing a good standard library, but many of the standard lib functions are themselves written recursively.
Anyway this was all in response to why isn't it used more. I don't really have a good answer for that, but a lot of it comes to from people being weirded out from its simple syntax, and also not wanting to learn to think functionally. It is being used though, the most successful Clojure example I can think of off the top of my head is Storm, which is usually billed as a Hadoop for realtime processing, and it's being used at a lot of large companies: http://storm-project.net/
So merely through the absence of this emphasis on expressive power, Clojure is a bit different. And I think that's great. I might be using Clojure at the moment, except I need to be able to make native builds for the project I'm working on, and so I went with Racket.
Yeah, people are weirded out by the syntax as well. Which is sad, because people who are used to it tend to love it. But if this was the only problem, it could have been easily bypassed decades ago with a whitespace alternative. That is, where developers would be able to denote blocks with python-style whitespace and colons as an alternative to parens. Last time I mentioned this someone pointed me to a distribution of arc that already did it.
> many of the standard lib functions are themselves
> written recursively
Maybe the JVM has been updated while I wasn't looking and no longer has a problem with deep recursion. What are some stdlib functions that are recursive?It is used in a few places, but its not common. The reason it isn't used often is because no one bothered to build anything with it. So, if Clojure / Lisp / etc want to make the language popular, you should build something that makes money and tell the world about it. This is what happened with RoR and Django.
I have a CRUD site written in Clojure. All total is around 1,500 LOC. I only have to add in a mailing feature and and one other small operation and take it off the now-deprecated Noir framework. All told, it will still be 1,500 LOC, I think. It takes in quite a bit of information, has multiple "views," dynamically generates HTML, connects to a database, and allows quite a few unique operations, so it's actually very easy to create a website in Clojure, and it can be highly elegant once you get used to the data structures and how to destructure.
The Clojure community has done an excellent job to make the process of building -> deployment very easy, it's just that no one has stepped up to the plate and did anything with the tools, and unfortunately, I fear Lisp will always be a Land of Toys and No Product Shipped.
In a sense, people are using it more. A lot of features that Lisp pioneered and that used to be radical back in the day (like built-in garbage collection, lambdas, first-class functions, etc) have now been assimilated in to other languages.
As a result, many Lispish things are now pretty mainstream. Not everything about Lisp has caught on, though (yet). In particular, many people are still averse to Lisp's syntax (or lack thereof), and its many parenthesis. Because of this, they're missing out on some of Lisp's most powerful features (lack of syntax and parenthesis are features, as is Lisp's very simple macro system).
Also, a lot of people have a pretty skewed, outdated view of Lisp, often based on rumors of a bad experience with some crippled Lisp they were forced to learn in school.
Very few people who have a very negative impression of Lisp have had much experience with a modern, full-featured implementation of Common Lisp (like SBCL), or Scheme (such as Chicken or Racket).
Those that have quite frequenly describe their experience with them as enlightening and often wish they could use Lisp/Scheme on their day job.
I've been getting Guile recently and find the very tight integration with C to quite nice. It's like the best of both worlds
Now extraneous syntax, even in a half-Lisp like Clojure, seems ugly to me. It's a real pity more people don't appreciate the elegant simplicity of Lisp (and especially Scheme).
Everything is to be built on top of Ring, which is the Clojure equivalent of Rack or WSGI. Compojure is pretty much the standard for routing at the moment. Korma is a very popular DSL for writing SQL. For templating, Hiccup and Enlive are popular, but there are other options as well.
I would start off by getting a decent understanding of Ring and Compojure and building from there.
--
https://github.com/ring-clojure/ring
https://github.com/weavejester/compojure
https://github.com/weavejester/hiccup
https://github.com/cgrand/enlive
http://www.clojure-toolbox.com/ is really helpful for finding appropriate libraries.
I find this setup similar to using Ruby + Sinatra.
I still keep up to speed with Rails versions, etc., but in the last year almost all of my web development has been with either Clojure or Ruby + Sinatra.
If it is so good why ain't it is used more?
pg has written about this [1], and the main reason he found was that popularity is always self-perpetuating. If one of the languages get a head start with libraries, it's usually easier to develop programs and libraries within this language than other languages. If you know a popular language, you're more likely to have more job opportunities. If you're a manager, you would prefer to be able to replace programmers easily.That's one of the reasons why Clojure started off on the JVM in the first place: It has libraries and an already thriving ecosystem. In addition, it's a nice bonus for language developers to not have to worry about performance related to GCing, threading, OS-specific differences etc, which the JVM abstracts away.
I'm too pessimistic, but there is almost no correlation between quality and frequency as far as programming languages are concerned. Reasons for that are legio.
* the first Gulf War in Iraq was won because a Lisp application took care that US soldiers had everything from toilet paper, ammunition to gasoline. Plus it took care that the troops were at the right place.
* the missions of various Telescopes, especially the Hubble Space Telescope are planned with a Lisp-based planner
* American Express has been checking complex business card transactions with a Lisp-based rule system
* many cars (Ford, Jaguar, ...) were designed using a Lisp-based design software developed by Evans & Sutherland
* turbines for various airplanes were designed in Lisp (Boeing, Airbus, ...)
Some of that stuff survived. Some not.
But still today, if you see product descriptions like this, you would not suspect that it is written mainly in Lisp, but it is:
Really? Because IIRC it was won because it was fought by superpower against a small country with 1/1000 the military resources.
I'm not talking politics in this comment. What I mean to say is it's another thing to say "Lisp was used in that system" and totally another to say "the war was won because of it".
There is a big possibility that there was absolutely no correlation between what that language that system was written on and the war being won (and is far more likely, anyway: wars have been won, before and after, without Lisp).
Lot's of NASA missions use plain old C and do just fine. Should we say that they succeeded "because of" C?
> Because IIRC it was won because it was fought by superpower against a small country with 1/1000 the military resources.
The Lisp software moved the 1000* military resources to Iraq.
Programming is a high-variance activity. It's not that some programmers are 10x faster than others -- it's that an individual programmer may have 10x variance in performance on different days/weeks.
So, the two most effective things a programmer can do to become more productive are: (1) Get enough sleep. (2) Don't write code -- use libraries.
To the extent that Lisp's meta-programming support can help with (2), it's useful, but usually the lack of discoverable, minimalist, production-tested libraries is a worse tradeoff.
Essentially, the other ecosystems are good enough, and the Lisp ecosystem is not great for the bang-out-10-features-today style of most app development.
Also, there's a Noir [1] framework build on top of it.
http://www.vijaykiran.com/2012/01/11/web-application-develop...
Once you have a Ring-based Clojure web-app, you can run it as any other Java Servlet app, eg. in Heroku.
Speaking just for myself, it's because most commonly available distributions (such as SLIME) require you to learn a new editor on top of learning a new language.
I think emacs is great, but it's not my editor of choice, and when a language distribution all but requires you to use emacs, it's going to have a hard time gaining traction with me.
This may have changed over the past few years, but it certainly stopped me from learning Lisp some 10 odd years ago.
If you read Coders At Work http://codersatwork.com/ the grown-ups don't use IDEs.
If I recall correctly, one tutorial (and several IRC lispers) even stated the following: "How do I use this with vim? Just use Emacs + SLIME, you'll be better off for it."
It's probably changed (at least I certainly hope it has), but it certainly hampered my adoption of lisp.
Take my VIM for example, which I use for Python and (Java|Coffee)Script development (along with Erlang and a few other languages for hobby projects). I have a file list/tree/browser with NERDTree. I have a list of classes and functions in currently opened files with TagBar. I have "go to definition" and "display help/docstring" through Rope, along with four different auto-completion modes (partially built in, enhanced with SuperTab and a few other plugins, including Rope). Similarly I have support for refactoring from it. I have "find in files (quickly)". I have "fuzzy file name matcher" with Command-T. I have three different linters for Python. I have access to git log, blame, status, add and everything else with fugitive and diff is pretty, side-by-side one thanks to vimdiff. I can open remote files easily (this is built in). I have a bar with snippets (with placeholders I can fill in when pasted, of course) with SnipMate. I can open command line (like bash, ipython or coffee) in a window or tab with Conque. I can easily evaluate bits of code thanks to IPython (and thanks to their recent refactor, it's really paying off!). I use zencoding when I have to write HTML structure. And these are just things I use most often.
Now, I use VIM, which, I assume, means to you that I don't use an IDE - but what is the difference between, say, Komodo IDE and my VIM (aside from my vim being able to display in the console) really? It's IDE all the way down to unix shell and all the way up to git integration... And I'm old enough to be called a "grown up". Of course, I assembled my IDE myself from pre-made and some custom components, but it's IDE nonetheless.
The thing is that IDEs are there for a reason. Every single feature I mentioned above is a timesaver to greater or lesser extent. Every one of them increases my productivity in some common situation - and we're talking about Python and back-end (mostly) web-development here, which has much less repetitive, tedious tasks than, say, writing MFC app in C++.
Anyway, if you want to program in Notepad - feel free. Just don't, really don't, try to convince anyone to do the same by saying that notepad is somehow superior to Visual Studio for programming. It isn't. You'll understand this when you have to immediately fix a bug in production code on the server with something like nano, joe or mcedit and you introduce three other errors in trying to do so due to unbalanced parens, messed up indentation and a huge number of other issues that IDEs (yes, VIM included) protect you against. Well, I guess you need to grow up first to get access to that production code, I mean afterwards ;)
You know that Hacker News was created by Paul Graham right?
You definitely do want to read Paul Graham's essays.
A blub user will think "yeah whatever", IMHO.
tl;dr: nice cartoon, "lisp means no bugs" == total BS, bugs can totally exist in Lisp code
I don't need a cartoon to sell me on something. I need to see how something can be used.
That is false.
I am aware that you can prove code is correct, from a math POV. That's about the only way you can write "bug free" code without extensive testing, and even then, I'd argue that's not good enough - code needs to be tested. Bugs don't exist just in code. They exist in CPUs. They exist in configuration. They exist in dependency version mishaps that somehow make your code work incorrectly.
There is no silver bullet here. Sorry - there just isn't.
Incidentally, the author (Conrad Barski) says in that discussion that Clojure is his favorite Lisp now and he finds it much more elegant than Common Lisp. I have a similar background (CL programming, now doing Clojure) and I agree.
For production code, I ended up abandoning Common Lisp for the most part in favor of Racket, simply because of its library support and compatible, scoped dialects, but the principles are the same in either case. I'd actually recommend starting with something less 'batteries included' if you have the patience, because it makes it easier to see the fundamental beauty of the language, without getting distracted by something as "irrelevant" as library support.
Some people say that Land of Lisp makes it hard to develop 'useful' applications afterwards, but for that, I think Practical Common Lisp is a good secondary resource, and it's easy to skim once you've completed Land of Lisp. Land of Lisp is much better as "Lisp Propaganda" - ie, for someone who's interested in giving it a shot, it does a good job of selling the Lisp paradigm as a whole philosophy, even if it doesn't have space to cover all of its practical uses[0].
[0] I won't sell it short, though - it does a good job for that too... several of the games it implements are non-trivial.
Note the implication: You don't save the world by telling it, "You're doing it wrong." You save the world by getting the world to covet your success.
Non-functional programs read like plain English. Particularly Python but I just can't get my head around the functional ones.
The Main difference is, a functional programs mainly talks about what things are, not what they do. For instance:
// C(++)
int square(int n)
{
return n * n;
}
-- Haskell
square :: Int -> Int
square n = n * n
The C code reads like a procedure to follow: "return n times n to whoever called you" (I'm anthropomorphising square(), here). The Haskell code reads like a description: "the square of n is n times n".That was the first major difficulty. Now the second one: functional code is often like reversed imperative code:
// C(++)
int compute(int n)
{
int x = foo(n);
int y = bar(x);
int z = baz(y);
return z;
}
-- Haskell
compute :: Int -> Int
compute n = baz (bar (foo n))
-- alternate definition
compute n = baz . bar . foo $ n
where g . f = \x -> g (f x) -- function composition
f $ x = f x -- function application
So, in the Haskell code, you see that the data flows from right to left, instead of top to bottom. Like Unix pipes, only reversed.The final difficulty is getting used to the fact that functions are passed around directly. In C++, Java, or Python, we often pass around objects, who may or may not hold the same methods than the others that where passed around in the same way (that's polymorphism). Subtype polymorphism is neat, but most often, you need it because you want one method to change depending on various factors. A simpler way to do this is pass around the function directly.
That leads to some powerful, though uncommon in the imperative world, idioms. For instance, you can write your own customized loops. Imagine for instance that you want to process lists in Haskell:
-- A List is either
data List a = Empty -- an empty node,
| Cons a (List a) -- or a cons cell,
-- with an element and a list.
Now let's process the list inc-all :: List Int -> List Int
inc-all Empty = Empty
inc-all (Cons e l) = Cons (foo e + 1) (inc-all l)
dbl-all :: List Int -> List Int
dbl-all Empty = Empty
dbl-all (Cons e l) = Cons (foo e * e) (inc-all l)
See how much they have in common? There's a way to factor out that, with a map: map (a -> b) -> List a -> list b
map f Empty = Empty
map f (Cons e l) = Cons (f e) (map f l)
Note that the first argument is a function, hence the (a -> b) between parentheses. Using it is very simple: inc-all l = map (λe -> e + 1) l
dbl-all l = map (λe -> e * e) l
And Haskell can make it even more concise, with what we call partial application. Haskell functions actually have only one argument. Multiple arguments are simulated by having the function return another function. Here: add :: Int -> (Int -> Int)
add x = λy -> (x + y)
Which is the same as: add :: Int -> Int -> Int
add x y = x + y
Or even add :: Int -> Int -> Int
add = λx -> (λy -> (x + y))
So, inc-all and dbl-all above can be written as: inc-all = map (λe -> e + 1)
dbl-all = map (λe -> e * e)
Without those fundamentals, one doesn't stand a chance at understanding real world functional code. It's just too different. It's no harder, though. The main difficulty here is to change your mindset.Now I haven't talked about macros…
It depends partly on what you're used to. You're used to programs specifying instructions (since that's what we think of as an algorithm), so yes, Lisp won't look like "plain English" instructions.
However, functional programs don't define instructions - just relationships. For the most part, they wash their hands off of specifying the details of the execution, in favor of looking only at the high-level, mathematical relationships.
In that sense, Lisp programs like
(define x (map (lambda (x) (* 2 x)) (sort '(2 3 2 1 4))))
is defining a relationship between x and the list '(2 3 2 1 4), the same way that
x = 2y + 3
is defining a relationship between x and y. The latter doesn't tell you how to get the value of x (for a given y value), but defining that relationship is sufficient to understand the concepts.
So, you could say that non-functional programs read like plain English instructions of actions, whereas functional programs read like plain English mathematical relationships.
this is non debugable language, it it makes it bug full. you have to follow complex ideas, and keep scores of ideas, this is not for normal humans.
when you pass the wrong type and not support it, it goes to hell, and as a programmer you start to flame.
list, is a piece of shit for the masses, its useful for handful, who didn't distribute the ideas well, and people when to the place where it was easier to write code, and less is needed for getting your path going.
It's not as easy as setting breakpoints in an IDE like Eclipse and using a visual debugger there, but it's definitely a workable command-line debugger. You just need a little patience in order learn how to use it, and also probably have a pretty good understanding of Scheme's execution model, but that would be true for debugging any programming language.
For real?
> It's not as easy as setting breakpoints in an IDE
I don't use an IDE. I'm comparing against command line tools for scripting languages, Haskell and Common Lisp. Some fail more helpfully than others.
Now seriously - in which Scheme did you "write"? Racket has excellent debugger and brilliant contract system and exceptions, not to mention a repl and powerful type system. I'm sure you didn't want to display your lack of experience and knowledge, it just happened; I won't hold it against you, just don't write anything more about the thing you know nothing about.