19 ms·
Why Racket? Why Lisp?
- aaronbrethorst 12y agoFrom what I've seen out of the Clojure community over the past few years, it seems like they're far more likely (and able) to offer up concrete examples of how Clojure makes their businesses and products successful in a way that an imperative language could not. So, yay Clojure community, and boo on hand-wavy Lisp people. e.g.: http://www.kreuzwerker.de/en/blog/posts/why-clojure-rocks-2/ http://www.kreuzwerker.de/en/blog/posts/why-clojure-rocks-2/ https://news.ycombinator.com/item?id=5113060 https://news.ycombinator.com/item?id=5113060
- pjmlp 12y agoThat is also a sore point from the Lisp community in regard to Clojure. Clojure devs are willing to compromise a bit to allow a good integration within the JVM and other implementations, thus allowing some shops to buy into Clojure. Whereas many in the Common Lisp community will not, no matter what.
- deleted 12y ago[deleted]
- bad_user 12y agoWhat kind of compromises are you talking about? My impression (based on limited exposure) is that Common Lisp suffers from a lack of clear guidance on how to do things. It's common in Clojure for example to use immutable data-structures and in case of mutation to use atoms and STM. Compromising on issues is seen as reasonable, but not a best practice and often there's a clear path you can take for certain problems. It's an opinionated language without being obnoxious. To me the attitude exposed by Clojure (and Scala) is a breath of fresh air. Some people tend to focus on how pieces of code look, or on using certain abstractions and optimizations, forgetting that the most important thing for users is a working app. For example, surely things like TCO and continuations have value, but that value is being trumped by a huge ecosystem of libraries and tools that, while not beautiful, are decent.
- mark_l_watson 12y agoA long time ago, the inventor of the Clojure language Rich Hickey wrote a Java bridge for one Common Lisp implementation that was very good - I used it a lot for a while. So, Rich has been thinking of the practicalities of Java interop for a long time.
- _delirium 12y agoI don't see CLers as having a problem with JVM interop per se. ABCL is often recommended as a perfectly respectable implementation for people who need Lisp on the JVM. But it's true that Clojure and ABCL take different approaches to it.
- eudox 12y ago>Whereas many in the Common Lisp community will not, no matter what. Common Lisp on the JVM: http://abcl.org/ http://abcl.org/ Common Lisp/Java bridge: http://foil.sourceforge.net/ http://foil.sourceforge.net/
- pron 12y ago> ... in a way that an imperative language could not Perhaps a nitpick, but sometimes nomenclature is important. Clojure (like all Lisps) is an imperative programming language. "Imperative" languages are contrasted with "declarative" languages[1]. Where does functional fit in and what is the name for "non-functional"? Well, that's not clear, as "functional" (in the PL sense) doesn't even have an agreed upon definition. Is Clojure "functional", then? Well, it's certainly not pure like Haskell is (and it has explicit loops etc.), but it does encourage more uses of function composition than, say, Java, it's more declarative, and it also isn't object-oriented, but that doesn't make it not imperative. Actually, I think even Haskell still qualifies as imperative. But Clojure can certainly be contrasted with OO and procedural languages (even though at least one of its core abstractions -- protocols -- is borrowed from OO). [1]: http://en.wikipedia.org/wiki/Imperative_programming http://en.wikipedia.org/wiki/Imperative_programming
- andreasvc 12y agoI think declarative should be contrasted with procedural, not imperative. Also, your reference/footnote [1] is missing.
- wtetzner 12y agoActually, I would say that protocols are more influenced by Haskell type classes than OO interfaces.
- eru 12y ago> Actually, I think even Haskell still qualifies as imperative. How so?
- LesZedCB 12y agoTechnically, if a language can produce side effects, it's considered imperative. However, nobody really is going to say that Haskell is imperative.
- Tyr42 12y agoThough there are some claiming that Haskell is the best imperative language because of having to state upfront what effects each bit of code can have. Since evaluation order is not very straight forward in Haskell, effectful code has to be explicitly ordered, which makes is very clear.
- fnbr 12y agoI tried Clojure, and I quite like it as a language (especially the thread-first & thread-last macros [1, 2]). I don't, however, like the ecosystem surrounding it. I find Leiningen (while an excellent tool) far too heavy for the majority of my purposes. I much prefer other functional languages (e.g. OCaml, Haskell) that don't need such an intricate project structure. With OCaml & Haskell, I can start with one source file in one directory and gradually build up to a more sophisticated layout as needed, rather than have a complicated layout imposed upon me by the project. [1] http://clojuredocs.org/clojure_core/clojure.core/-%3E http://clojuredocs.org/clojure_core/clojure.core/-%3E [2] http://clojuredocs.org/clojure_core/clojure.core/-%3E%3E http://clojuredocs.org/clojure_core/clojure.core/-%3E%3E
- bad_user 12y agoYou can get started with Clojure without Leiningen. You can get started with Scala without SBT. These are build tools for serious projects, with lots of options and lots of things they do for you. Some people recommend them to beginners and while that's not necessarily wise, it goes to show that they are mature and OK enough that some beginners cope with it. Yes, you can get started easily with Haskell - but then Cabal is such a complete piece of shit that people felt the need for a Haskell distribution with batteries included. And it is my feeling that you're mixing the cause and the effect here.
- leishulang 12y agoI agree. If Cabal was as good as Leiningen, then Haskell would has been way more popular than today.
- pjmlp 12y agoAvoid success at all cost. :)
- leishulang 12y agoLeiningen prevents clojure from having the dependency hell problem from the beginning, which haskell was prone to but eventually fixed by sandboxing. Then would you say sandboxing is too heavy for haskell? Now if by heavy, you mean the folders structure lein generates, then I disagree. Those folders actually keep the task of understanding any lein project easy. If by heavy, you mean the JVM: You can compile the thing into a jar that runs on any jvm, or a js file using clojurescript. JVM, web browsers and Node.JS are very likable cross-platform layers, and I don't see why binary executable that are OS dependent compares.
- cturner 12y agoThe top reason here could been written - lisp is more expressive. You can find ways to express an idea that make sense now, and which are readable. Macros is a different part of the same idea. -- Maybe I'm doing it wrong, but a problem I've had with racket is as you begin to build larger projects, when something breaks it can be quite difficult to find out exactly where the break happened. When you compile Java or run Python, it's almost always immediately obvious what broke. The way I got around this was to use a methodical TDD approach. Would be a shame if that turns out to be as good as it gets for lisp. Something I haven't done yet but am interested to get to is attaching a repl console to a running process.
- calibraxis 12y agoYes, that is very important. When I watch experienced programmers learn Lisp, they write a couple functions, then go through the pain of debugging that. They should unlearn that. And put tiny fragments in the REPL. (Or whatever interactive tool you have.) Playing with it.
- cturner 12y agoSince lisp is homoiconic (refreshed on this, see downvotes below) it would be nice if you could type things into a repl and then run a function like this: (persist function-i-just-wrote). And then it would save to a text file. Then you wouldn't need to stuff around with the mouse copying from one buffer to another and the like. (I expect something similar is possible in emacs, but emacs is not my thing.) Hmm. I suppose I could just write the persist function myself. Watch this space.
- dedward 12y agoWhat you just described is pretty much universally handled by editor integration.... I can't imagine anyone actually develops lisp without this. The editor is hooked directly up to a running image.. a keypress (or two) causes an expression to be executed in the running image... you can flip to the REPL and goof around directly and/or at the same time work from one or more editor buffers and selectively execute code as you desire. You can bust into the debugger whenever you feel like it, etc etc. Someone else described it better above I think - but this image-based interaction is one of the most attractive things for many - it goes well beyond just having a REPL where you can evaluate code... lisp was basically designed around the idea of interactive development. If you think this through to a large, complex project - you can have a giant running application, working in production, and still attach to it with an editor/environment and debug it live... that's hard to do with anything else.
- qewrffewqwfqew 12y agoThat's some pretty ugly text for a site called 'practical typography'.
- arm 12y agoOh? What makes you say that? On my OS X computer at least, it honestly looks gorgeous: http://f.cl.ly/items/3o2r3E2T2y3v3M3T291i/Screen%20Shot%202014-08-21%20at%203.10.46%20AM.png http://f.cl.ly/items/3o2r3E2T2y3v3M3T291i/Screen%20Shot%2020...
- fake-name 12y agoYeah, except the obnoxious diamond symbols used to denote each link, rather then underlining them, like has been standard for 20 years now.
- chipotle_coyote 12y agoUnderlining isn't very attractive, either, even if it's standard. I don't mind the diamond, but I'm not very enthused by it, either.
- _delirium 12y agoThe manual to this publishing system, discussing how its markup/programming language is implemented as a custom Racket language, is pretty interesting: http://mbutterick.github.io/pollen/doc/ http://mbutterick.github.io/pollen/doc/
- na85 12y agoI sure hope the giant, hideous, obtrusive diamonds inserted into the text to denote a hyperlink doesn't catch on as a trend. It's a great way to break the flow of the text and irritate your readers. As for the idea of Lisps, well, it sure seems neat. But I've literally never run across a situation where I needed my code to edit itself. I've never run across a situation where the lack of an everything-is-an-expression-is-a-list feature prevented me from doing what I wanted to do. So I just don't really feel the need to get repetitive strain injuries in my pinky from reaching for the parentheses all the time.
- cespare 12y agoAs someone who writes Lisp (well, Clojure) every day and does not particularly enjoy it, I find the common complaint about parentheses to be a non-issue. In fact, I'm not sure I've heard of anyone who wrote any significant amount of lisp code and came away talking about parentheses. This seems to be mostly a reaction from people who've read a bit of Lisp without using it. Then again, I just noticed that I type ( and ) with my third and fourth fingers, so maybe it would be worse if I typed properly :)
- jsmeaton 12y agoI would assume it'd be the same as people complaining about significant whitespace in python. No one who actually programs in python complains about the whitespace.
- lutusp 12y ago> No one who actually programs in python complains about the whitespace. I wouldn't say "no one." I read comments regularly from people, usually students, who get into trouble with whitespace in Python, especially if they mix tabs and spaces in the same source file.
- jsmeaton 12y agoIf you're mixing tabs and spaces in the same source file, chances are that you're not a very seasoned python programmer. I would imagine a large segment of students also complain about parens in lisp. Though to be fair, there would be some people that use python day-to-day that don't like significant whitespace. I'd bet there'd be at least a few lispers that don't enjoy wrangling parens.
- hyp0 12y agoRe 1. everything is an expression benefit, condition example: C-like languages often have the ternary operator, cond?exp1:exp2, that is exactly this. I feel clever using it, but I consider it a hack, because it's (usually) less clear. A microcosm of lisp, clever but unclear.
- wtetzner 12y agoI think it mostly seems unclear in C because of the syntax. If you could write this in C, would it still seem unclear? int x = if (y == 0) then 7 else 10; As opposed to one of these: int x; if (y == 0) x = 7; else x = 10; or int x = 10; if (y == 0) x = 7; It makes everything local, and in my opinion reduces cognitive load.
- hyp0 12y ago(speaking for myself only): I find the ?: syntax clearer... probably because I've known it for so many years. It's the doing several things at once that, for me, makes it unclear. Of your examples, I find the very last one the clearest. Arguably, it's a hack, because it assigns values twice to x - but it feels like the syntax embodies the semantic truth of y==0 being an exception. A pattern matching solution (with a specific and then a general rule) would also embody this, but to me, having the general rule first, with a following exception, seems more intuitive. Disclaimer: "intuitive" is all very subjective, and it's certainly possible that with experience, my intuition could change. But for better or worse, the above is my opinion today! PS: I do think your first example is cool, neat and clever. I understand and feel that aspect of the appeal.
- jstoja 12y agoPlease.... text-align: justify; ...
- Tomte 12y agoPlease... see http://practicaltypography.com/justified-text.html http://practicaltypography.com/justified-text.html for the author's opinion. Personally I believe that Matthew is wrong there. There's no justification for justification. :-)
- pera 12y agoJustification is terrible for people with dyslexia.
- happywolf 12y agoAgree with some of the earlier comments: the diamond-shaped thingies inserted are really a nuisance and breaks the reading flow.
- jey 12y agoMaybe only because it's unfamiliar. After all, other punctuation doesn't break your flow. And trying to figure out whether something is a link or not also breaks flow.
- happywolf 12y agoThe real question is why someone would change something most people already getting used to. I don't see any compelling reason to change the link in this way, do you?
- Illotus 12y agoIndeed. Whenever you break convention like underlined and colored text for links you in general need to have a good reason.
- mapcar 12y ago> If Lisp languages are so great, then it should be possible to summarize their benefits in concise, practical terms. His list is concise but man did he take a while to get to it! Seriously though. The introduction was super relevant as I have wondered the exact same question about Lisp myself. What features make it so praise-worthy? Maybe X-expressions isn't a core feature for everyone to appreciate, but the fact that everything is an S-expression is an understated value. People complain about its syntax, but alternate versions (so many reincarnations of parentheses-less Lisps) have never caught on. The thing is, Lisp is no longer unique in its feature set, and languages with more standard forms of syntax have incorporated some of its features. But it is uncommon to find all of these listed features in one language. In the domain of data analysis where I do most of my work, it still makes me sad that XLISP-STAT has been supplanted by other languages which leave the user wanting.
- agumonkey 12y agoBy feature set you mean sequences, map/filter/reduce and such ? I felt there was more to Lisp than that. It was the root of the ML/function-based family, which deepened the recursive typed logic McCarthy talked about in his early papers. The first-class function and functions as modeling unit, giving composability, and domain embedding as first class.
- guilloche 12y agoWhen visited with w3m I got spaces breaking words frequently. Is there any justification to use complex html to control intra-word spacing for a web page?
- sjy 12y agoThose are soft hyphens, which supplement the crappy hyphenation support built in to most browsers. w3m should probably just ignore them, but it looks like your version is broken[1]. [1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=441934 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=441934
- TheMagicHorsey 12y agoWhy does Racket perform so slowly on benchmarks compared to Clojure and SBCL?
- LeonidasXIV 12y ago> Why does Racket perform so slowly on benchmarks compared to Clojure and SBCL? Clojure benefits from the optimization of the JVM and SBCL has a couple of pretty bad-ass hackers working on the compiler. Racket on the other hand uses a pretty of the shelf JIT compiler which might not be as specialized as the other two. Language-wise, there is hardly anything that would make Racket inherently slower than Clojure. Maybe continuations.
- alvatar 12y agoMany of the last items in the list should be in the category "Scheme". Racket is a dialect from Scheme, but it still is a Scheme. The syntax-case macro transformations are available in most Scheme systems.
- dragonwriter 12y ago> Many of the last items in the list should be in the category "Scheme". Racket is a dialect from Scheme, but it still is a Scheme. The name was changed to Racket from a name with "Scheme" in it because its not a Scheme in the strict sense; Racket does not conform to any of the Scheme reports (though its bundled with language definitions that do, as well as lots of others, but the Racket language, while near Scheme, is not.)
- pflanze 12y ago> because its not a Scheme in the strict sense; Racket does not conform to any of the Scheme reports The same could be said for many, if not most "Scheme" implementations. Scheme didn't standardize stronger language abstraction features, otherwise what Racket offers aside its core implementation (unless they would deviate just for the purpose of lock-in) would just be Scheme libraries, and it would be fair to call it "the Racket implementation of the Scheme language, which comes bundled with more involved language libraries than most". From a marketing standpoint, their move is good for them and bad for the Scheme community because they imply that "Scheme" as a brand or community isn't able to support the languages that they are implementing. They may have the finances and manpower to make it work for them, but it leaves out the community from which they have grown. I'm not deep enough inside the community to know all the factors that lead to this but as a fringe participant it seems (more than?) somewhat untruthful and disappointing.
- georgegeorges 12y ago> but the Racket language, while near Scheme, is not. You've described 99% of Scheme systems. The only exception I know of is Scheme48, which is pretty much the Third Reich of Scheme systems. Portability between Scheme systems is tedious and, in some cases, close to impossible. Even moreso when you start using some combination of SRFIs.
- DCKing 12y agoWhy Lisp? That is understood. Why Racket? From an ignorant outsider's perspective, all Lisps seem to be more or less interchangeable when it comes to the language. They only differ in the details, and each seems to be about as difficult to learn as the other. Although this article does make somewhat of a case for specifically Racket, it seems to be a rather weak one - tools are nice and some language details are nice. But the same general arguments can be made for other Lisps, most notably Clojure. It seems to me that Clojure is a lot more practical: it has many good libraries in both Clojure and Java, it has some great tools, there's a lot of momentum, and it can be deployed everywhere (including the browser). So, being an ignorant outsider, is there any reason the Lisp I should learn isn't Clojure?
- pervycreeper 12y agoSICP
- klibertp 12y agoStructure and Interpretation of Computer Programs by Abelson and Sussman, for the uninitiated. It's one of the best introductions to basic and advanced (and then even more advanced) programming there is. This book, along with a series of "The Little Schemer", "The Seasoned Schemer" and "How to design programs" use Scheme as a language, and Racket makes it particularly easy to follow them by providing special environments (#langs) crafted for them.
- cipher0 12y agoOnline interactive version of SICP http://xuanji.appspot.com/isicp/ http://xuanji.appspot.com/isicp/ for great win.
- densh 12y agoRacket has probably the best macro system out of all existing lisps available to date. Plus it has concept of extensible languages via #lang. If you care about lisp-style macros and meta-programming that's probably the main reason why I would recommend Racket. Clojure macros in comparison are very ascetic. You can get stuff done in them but it's not a strong feature of the language in my opinion.
- sanatgersappa 12y agoMy personal experience with Clojure has been that it 'bends' the brain - in a good way, and it forever changes the way you program. It is extremely difficult to go back to the style of coding I did before my exposure to Clojure. I guess other Lisps would provide a similar experience.
- theRhino 12y agoNot sure how closely you have read Siebel - your 1st few points are covered pretty comprehensively at the start of his book
- jimbokun 12y agoIf you took a Common Lisp programmer from the early to mid 90s in a time machine to today, very little about current programming languages would seem novel or an advance over what he or she was using then. I think this is a reason for much of the smugness of Lisp programmers. Whatever features you think are new or cool or advanced about your programming language, Lisp probably got there first.
- lmm 12y agoNonsense. We've figured out how to do type systems. We can even fully infer types if you're willing to accept some quite reasonable restrictions on how polymorphic your code is. We have a bunch of reasonable approaches to effect tracking, which Lisp folk used to have to do by hand (that story about the T garbage collector sounds like the most unmaintainable piece of code I've ever heard of). We know how to solve the expression problem. Modern "pragmatic"-oriented languages have little that wasn't in Lisp - or in Algol. Which is fine! The innovation is about the wider ecosystem (a lisp programmer from the '90s would be amazed by CPAN, never mind maven), or about making common tasks easy (a lisp programmer might eventually put together a collection of idiosyncratic macros with much of the functionality of Rails, but that wouldn't be a project you could hire someone else to maintain). OTOH modern "researchey" languages, like Coq or even Haskell, are far far ahead of Lisp.
- masklinn 12y ago> Nonsense. We've figured out how to do type systems. We can even fully infer types if you're willing to accept some quite reasonable restrictions on how polymorphic your code is. That dates back to the 70s: http://en.wikipedia.org/wiki/ML_(programming_language) http://en.wikipedia.org/wiki/ML_(programming_language)
- eudox 12y ago>a lisp programmer might eventually put together a collection of idiosyncratic macros with much of the functionality of Rails, but that wouldn't be a project you could hire someone else to maintain There is, in fact, such a thing as Common Lisp libraries. See https://github.com/quicklisp/quicklisp-projects https://github.com/quicklisp/quicklisp-projects 1034 projects with ~48 waiting to be added.
- colig 12y agoDoes anyone else find it difficult to highlight things on this page? Specifically, 'kvetchery' which is found in the third paragraph. I believe the author is the one responsible for the facelift of Racket's documentation. He may belittle his own lack of formal programming education but I am thankful for his design chops.
- amirouche 12y agoI tried somewhat Pollen and it's kind of fantastic, the only thing is getting to work with a new project in a language that I don't know very well is difficult for me. That's why I started a similar project in Python, watch https://warehouse.python.org/project https://warehouse.python.org/project if you interested /azoufzouf/
- amirouche 12y agoI just pushed the code. You can have a look at it @ http://amirouche.github.io/azoufzouf/ http://amirouche.github.io/azoufzouf/ there is all you need to know and ⵣcode{pip install azoufzouf}. With that markup, it's easy to plug any function you want. That's right. It's not nested and is inspired from unix philosophy, I dare to say. I tried several time Sphinx, docutils alone and other markups they don't deliver as much as this one (sofar).
- CMCDragonkai 12y agoMany of the reasons you wrote are the same that got me attracted to Elixir. That and of course erlang interop and OTP.
- mrottenkolber 12y agoCan not resist... This article is fairly misguided. I find it painful that everybody who writes about a Lisp offshoot (Scheme, Clojure, ...) ends up misrepresenting Common Lisp. To sum up "Why Lisp?" from a CL perspective: CL has pretty much every feature of every programming language around, only that its better designed, implemented and generally more powerful. It's just a poweruser language. Its not just macros, sexps and lambdas. Its also number types, arrays, OOP, symbols, strings, structs, dynamic/lexical variables, lambda lists, multiple return values, on-line disassemble, exceptions, restarts, MOP, metacircular definition, great implementations, great libraries...... the list goes on and on... I surely forgot a ton of great stuff. TL;DR: CL got everything. And this "everything" is designed so well that its extensible and no CL programmer ever needs to doubt that any new feature can be implemented easily in CL. To correct a few of the wrong statements of OP: > “Wait—I love state and data mutation. Why would you take them away?” Because they’re false friends. CL is NOT particularily functional. Just because we know how to write good side-effect free code, doesn't mean its a functional language. (We jave SETF after all, failed to mention that aove). > a syntax transformation in Racket can be far more sophisticated than the usual Common Lisp macro. Outright wrong. The only reason Scheme has weird macro systems is because its a Lisp 1. CL is designed well (thus being a Lisp 2), and thats why its simple but ultimately more powerful macro system can work. > A macro in Common Lisp is a function that runs at compile-time, accepting symbols as input and injecting them into a template to produce new code. This is so wrong I had to write this comment. A macro in Common Lisp is a COMPILER, it accepts arguments and returns an SEXP. It is infinitely powerful, it can do EVERYTHING.
- deleted 12y ago[deleted]
- pivo 12y ago> More generally Common Lisp lacks a coherent web based module repository infrastructure like those of other dynamic languages such as CPAN or RubyGem. What about ASDF and/or Quicklisp (http://www.quicklisp.org http://www.quicklisp.org). They work well for me.
- dschiptsov 12y ago"Clarity is an evidence" as the saying goes. This post only proves its correctness.) The distinct feature of Lisps and good lispers is clarity of thought and conscience of writing.
- ColinDabritz 12y agoA good list of some interesting 'day to day' benefits of Lisp. Maybe that is something that would appeal to beginners especially. From my perspective Lisp is a powerful language because of its genesis in research. The question wasn't "How do we make a tool to make this hardware do what want?" but rather for a research goal. If you want to read the actual original Lisp paper look up: Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I John McCarthy April 1960 Paul Graham covers it nicely in this essay, especially the "What made Lisp different" list about 1/3 in http://www.paulgraham.com/icad.html http://www.paulgraham.com/icad.html Lisp has had expressiveness we're only recently seeing in popular mainstream languages now. It has to do with the design, the simplicity, and how Lisp expresses problems. I've often heard it described as "the language gets out of your way." That's why Lisp.
- smeyer 12y agoThanks for the link (it's one of PG's I hadn't read yet.) That being said, I really didn't like the part where he implied that if 1 line of Lisp can replace 20 lines of C that it also means that a feature can be developed 20 times faster in Lisp than C. Are you a Lisp programmer? I've only used it a bit, but I didn't get the impression things would scale that way for feature development.
- BugBrother 12y agoIf you check the research on the subject of development speed, it suggests a given programmer generates around a certain number of pages of code in any language he/she is proficient in. And if the programmer learns another language, they will write about the same number of pages when they get proficient. (Apply NaCl. I assume the real statement is that a given programmer generates a given amount of complexity in a work day.) [This paragraph of background was not needed, you seem aware of this point.] You can, simplified, see Lisp as the grandfathers of the scripting languages. (But with parse trees as syntax, efficient compiler decades ago and so on.) The point with the scripting languages is that development speed is so much quicker than e.g. C, for many cases. Lots of less code is needed. Personally, I went to scripting languages from C originally because of that the sheer productivity is so fun. I would have gone Lisp if there were jobs.
- wes-exp 12y agoAuthor is wrong about hygienic macros – they are not more powerful. They are less powerful, and more complicated, in order to enforce safety. Whether this is preferable or not is a matter of debate.
- deleted 12y ago[deleted]
- samth 12y agoNo, the article is correct. Hygienic macros give you strictly more information to work with, enabling them to be more expressive. It's possible to implement unhygienic macros, either at an individual macro level or a whole new macro syso, using Racket's macro system.
- wes-exp 12y agoI'm thinking you're right in the theoretical sense, but I'm right in the practical sense. Every time I've looked at hygienic macro systems, it just seems like now I'm jumping through extra hoops to overcome a more restrictive way of doing things. Is that extra information you cite typically useful for anything besides safety? Can you give an example?
- NotAtWork 12y agoMost of my development time is spent on correctness, safety, and refactorings. If the extra information helps those at the cost of not one of those, it's almost always the right choice for me to use.
- samth 12y agoYes, the information is useful for lots of things. For example, tracking the binding information in the data is how DrRacket manages renaming, how Scribble (the Racket docs tool) hyperlinks every identifier in every example to the correct documentation for the identifier, how Typed Racket tracks type metadata for identifiers, ...
- deleted 12y ago
- agentultra 12y agoSome practical features I enjoy in CL: 1. Conditions and restarts: As far as error handling in programs go this is the most rock-solid system I've encountered. You can tell the system which bits of code, called restarts, are able to handle a given error condition in your code. The nice thing about that is you can choose the appropriate restart based on what you know at a higher-level in the program and continue that computation without losing state and restarting from the beginning. This plays well with well structured programs because the rest of your system can continue running. Watching for conditions and signalling errors to invoke restarts... it's really much better than just returning an integer. As a CL programmer using SLIME or any suitable IDE, this error system can throw up a list of appropriate restarts to handle an error it encounters. I can just choose one... or I can zoom through the backtrace, inspect objects, change values in instance slots, recompile code to fix the bug, and choose the "continue" restart... voila the computation continues, my system never stopped doing all of the other tasks it was in the middle of doing, and my original error was fixed and I didn't lose anything. That is really one of my favorite features. 2. CLOS -- it's CL's OO system. Completely optional. But it's very, very powerful. The notion of "class" is very different than the C++ sense of struct-with-vtable-to-function-pointers-with-implicit-reference-to-this. Specifically I enjoy parametric dispatch to generic functions. C++ has this but only to the implicit first argument, this. Whereas CLOS allows me to dispatch based on the types of all of the arguments. As a benign example: (defclass animal () ()) (defclass dog (animal) ()) (defgeneric make-sound (animal)) (defmethod make-sound ((animal animal)) (format t "...")) (defmethod make-sound ((dog dog)) (format t "Bark!")) (make-sound (make-instance 'animal)) (make-sound (make-instance 'dog)) Will print "..." and "Bark!" But the trivial example doesn't show that I can dispatch based on all of the arguments to a method: (defclass entity () ()) ;; some high-level data about entities in a video game (defclass ship (entity) ()) ;; some ship-specific stuff... you get the idea. (defclass bullet (entity) ()) ;; ... more code (defmethod collide ((player ship) (bullet bullet))) ;; some collision-handling code for those types of entities... (defmethod collide ((player ship) (enemy ship))) ;;; and so on... Conversely... Ship::collide(const Bullet& bullet) {} Ship::collide(const Ship& ship) {} Where collide is a virtual function of the Entity class requiring all sub-classes to implement it. In the CLOS system a method is free from the association to a class and is only implemented for anyone who cares about colliding with other things. The super-powerful thing about this though is that... I can redefine the class while the program is running. I can compile a new definition and all of the live instances in my running program will be updated. I don't have to stop my game. If I encounter an error in my collision code I can inspect the objects in the stack trace, recompile the new method, and continue without stopping. 3. Macros are awesome. They're like little mini-compilers and their usefulness is difficult to appreciate but beautiful to behold. For a good example look at [0] where baggers has implemented a Lisp-like language that actually compiles to an OpenGL shader program. Or read Let Over Lambda. One of the most common complaint I hear about macros (and programmable programming languages in general) is that it opens the gate for every developer to build their own personal fiefdom and isolate themselves from other developers: ie -- create their own language that nobody else understands. Examples like baggers' shader language demonstrate that it's not about creating a cambrian explosion of incompatible DSLs... it's about taming complexity; taking complex ideas and turning them into smaller, embedded programs. A CL programmer isn't satisfied writing their game in one language and then writing their shaders in another language. And then having to learn a third language for hooking them all up and running them. They embody those things using CL itself and leverage the powerful compiler under the floorboards that's right at their finger tips. Need to read an alternate syntax from a language that died out decades ago but left no open source compilers about? Write a reader-macro that transforms it into lisp. Write a runtime in lisp to execute it. I've done it for little toy assemblers. It's lots of fun. ... this has turned into a long post. Sorry. I just miss some of the awesome features CL has when I work in other languages which is most of the time. [0] https://www.youtube.com/watch?v=2Z4GfOUWEuA&list=PL2VAYZE_4wRKKr5pJzfYD1w4tKCXARs5y https://www.youtube.com/watch?v=2Z4GfOUWEuA&list=PL2VAYZE_4w...
- reikonomusha 12y agoI dislike this notion that Lisp (or Haskell or OCaml or ...) owe it to everyone else to explain and enunciate why it can be more productive to use Lisp. """ That’s asking too much. If Lisp languages are so great, then it should be possible to summarize their benefits in concise, practical terms. If Lisp advocates refuse to do this, then we shouldn’t be surprised when these languages remain stuck near the bottom of the charts. """ What?? Why? The problem is not and has never been communication of Lisp features. No one made a concise list of why C and Java are so great that people rushed to use them. Instead, they were pervasively used and taught in universities, and they are pervasively used in the development of most applications for e.g. Windows and Linux, and they are relatively simple languages (in theory) whose semantics most people "get". No wacko high order crap, no weight curried things, no arrows or morphisms or monads or macros. Programmers of such languages don't owe the rest of the world anything. Everyone has a choice about what to use, and it's each individual programmer's responsibility to choose them wisely. There is plenty of material about Lisp and Scheme out there. Unfortunately, we are in this TL;DR culture where no one has the time to spend a few hours every week to learn something new, since somehow that's too big a risk on their precious time. Now, for some comments: 1. Everything is an expression. He says this is a boon, but it's also confusing for "expressions" which are side effectful. Too bad he did not talk about that, nor did he talk about how the expression-oriented way of thinking is really best for purely functional languages that allow for substitution semantics. 2. Every expression is either a single value or a list. This is wrong, unless we devolve "single value" into the 1950's idea of an "atom". What about vectors or other literal composite representations of things? What about read-time things that aren't really lists or values? 3. Functional programming. Functional programming is indeed great, but why don't we talk about how in Lisps, we don't get efficient functional programming? Lisp has tended to prefer non-functional ways of doing things because Lisp will allocate so much memory during functional programming tasks that for many objectives, FP is far to inefficient. Haskell solves this to some extent with things like efficient persistent structures and compilation algorithms such as loop fusion. Lisp doesn't really have any of this, and the data structures that do exist, many people don't know about or use. 4 and 5 don't really have to do with Lisp but particular implementations. That's fine I guess. 6. X-pressions. What the hell is an X-pression? 7. Racket documentation tools. Okay. 8. Syntax transformations. He made the same mistake as he so baroquely outlined at the start. What in the world are these "macros" and "syntax transformations" good for? You're just telling me they're more powerful C preprocessor macros that can call arbitrary functions. But I was taught that fancy CPP code is a Bad Idea, so boosting them is a Worse Idea. 9. New languages. Same problem as 8. You say it's useful but you don't say why. Just that it's "easier". 10. Opportunities to participate. Nothing to do with Lisp again. * * * Instead of all this glorifying of Lisp and etc, why don't we spend time increasing that library count from 2727 to 2728? Or do we need to go through an entire exercise about whether that time spent is worth it or not? """ Rather, you are—because a Lisp language offers you the chance to discover your potential as a programmer and a thinker, and thereby raise your expectations for what you can accomplish. """ You're repeating everyone else. Notice how difficult it is to convey such things without being hugely abstract and unhelpful? Why don't other programmers see this huge productivity benefit from these Lisp wizards in their day-to-day life? Where are the huge, useful applications? They all seem to be written in C or C++. """ It’s mind-bendingly great, and accessible to anyone with a mild curiosity about software. """ It is accessible to those who are intently curious about theoretical aspects of software development, especially abstraction, and who can take exercises which require mathematical reasoning. A "mild curiosity" in my experience with others will not suffice. * * * This post may sound somewhat cynical and negative, but Lisp enlightenment articles are almost as bad as Haskell monad tutorials. They're everywhere and by the end, still no one gets it. And I don't like the attitude that because a group G doesn't understand it, and group H does, that H owes it to G to spoonfeed the information. That's not the case.
- michaelsbradley 12y agoRacketCon is being held in Saint Louis, Missouri, USA the day following the Strange Loop 2014 conference (also in Saint Louis): http://con.racket-lang.org/ http://con.racket-lang.org/ I hope to see some of you there!
- bad_login 12y agoIt seems most people here have never used (and not tried) racket. I decided to use racket for my little sides projects, as replacement for scala and clojure. I choose it because it was clear for me i can't stand limitations other language impose to me in way of style and boilerplate, the racket macro (aka syntax transformer) system is the most advanced i know to reduce the boilerplate to a minimum and so just write what i want to express. In facts i rarely write macro because writing a good macro demand you take care of errors syntax, i am lazy in the bad meaning of the term. I choose it because it's dynamic typed and i get more convinced that type go on your way most of the time (expect complex algorithms)(i write little projects, so refactoring argument is out). It enable me to write code and eval it on the fly with geiser (using enter! on the back), after eval the new function i test it in the repl, hack until the function meet the requirement copy paste from repl and boom i get a unit test. Because it as eval and it will become handy one time in your programmer life for sure. I choose it because of it's sexpr syntax, as a heavy user of emacs i know that other syntax is a pity. Also because it has (and i use): 1. llar parser (implemented through a macro). 2. A pattern matching nothing to envy scala or clojure deconstructs. 3. An optional type system. 4. A contract system. What i find hard as a new comer (to racket, not as a programmer already now scala, clojure, half of c++ :), php) is 1. The broadness of the features the language offer, which feature to use e.g.: class or generics. 2. The documentation is rich but lack of examples for the common cases, so you need to read the doc of the function (sometime it's huge). 3. Understanding how racket module works is quite hard and you have the documentation, if you don't plan to play with the macro expander (the stuff that run your macro) and some dynamic features you don't really need to. 4. You need to 'register' the errortrace library if you want a stacktrace, quite a surprising behaviours for me. My opinionated conclusion: Racket is the best language design i ever see, it's hard to learn but make you feel learning an other language will just become to learn a new sub-optimal syntax. Sadly the ecosystem is lacking libraries and peoples and i am not helping in this way.
- samth 12y agoI'm glad you like Racket, and you're right about some of the weaknesses, especially in providing guidance and examples for how to do things. I have questions about points 3 and 4. For 3, do you mean it's hard to figure out how the implementation of something works, especially when that something is a complex macro? If so, I can't disagree. For 4, if you just run Racket programs at the command line, you should get stack traces (although less nice than the ones errortrace provides). Do you not get those?
- kazinator 12y agoCheck it out. For five years I have been developing a tool called TXR. It's a "Unixy" data munging language that is ideally suited for programmers who know something about Lisp and would like to move away from reaching for the traditional stand-bys like awk, sed, perl, ... You do not have to know any Lisp to do basic things in TXR, like extracting data (in fairly complicated ways) and reformatting it, but the power is there to tap into. In TXR's embedded Lisp dialect, ("TXR Lisp"), you can express yourself in ways that can resemble Common Lisp, Racket or Clojure. You can see a glimpse of this in this Rosetta Code task, which is solved in three ways that are almost expression-for-expression translations of the CL, Racket and Clojure solutions: http://rosettacode.org/wiki/Self-referential_sequence#TXR http://rosettacode.org/wiki/Self-referential_sequence#TXR Or here, with syntax coloring: http://www.nongnu.org/txr/rosetta-solutions-main.html#Self-referential%20sequence http://www.nongnu.org/txr/rosetta-solutions-main.html#Self-r... If you closely compare the original solutions, you will see that certain things are done more glibly in TXR Lisp.
- deleted 12y ago[deleted]
- picardo 12y agoIs it just me or is this page entirely blank? I poked through the source for quite a long time, but couldn't undo it. The text is there. There is something in the CSS that obscures it in Chrome. So annoying.
- einhverfr 12y agoI am learning Perl's FP features and really liking it, and teaching myself common lisp. I enjoyed the article quite a lot actually. I find it is very hard to define functional programming for many people but this is what I have come to explain to people: Functional programming means thinking in terms of mathematical functions in the f(x) sense. Once you get that basic promise, that for any given input you have a single correct output, then it transforms the whole way you think about and designing your software. The better I get with lisp, the more everything else changes. I may have to try Racket.
- innguest 12y agoI think your explanation is excellent for getting the point across. All other nice things that we get in FP derive from the "mathematical functions" fact you stated. It's also good in the sense someone can then ask you "how is it that using mathematical functions transform the way you think" and now you have their attention and interest. :)
- raiph 12y agoWhat about spending a few minutes exploring P6 and providing feedback about it to Larry Wall et al on #perl6? One easy way follows (for you or anyone else reading this who is curious about P6). Preferably between about noon and midnight GMT (so you're more likely to catch Larry Wall, nick TimToady) visit the freenode IRC channel #perl6 (eg go to https://kiwiirc.com/client/irc.freenode.net/perl6 https://kiwiirc.com/client/irc.freenode.net/perl6 and enter a nick) and enter 'hi'. There are on channel evalbots and folk who will be happy to show you a well designed and continuously improving Perly blend of FP, OO, etc. Yesterday's log is at http://irclog.perlgeek.de/perl6/yesterday http://irclog.perlgeek.de/perl6/yesterday. Hope to see you in the log. :)
- rodrigosetti 12y agoNice write-up. I really like Racket, but never had a chance to use it in a professional project so far. By the way, Scribble (item 7) is an implementation of Literate Programming - a feature is some other languages too. In Haskell, for example, you can write programs in Latex with embedded code.
- 59nadir 12y agoI think it's kind of sad that most of the comments in this thread are about other languages than Racket and only barely touch on the articles points (mostly the stuff you don't need to actually try the language (or any lisp) to comment on). I think it says a lot about what the crowd on HN is really all about.
- GFK_of_xmaspast 12y agoIt's kind of interesting that the author's examples of 'woah! look at all these cool packages' include plotting, unit testing, and a gui. Those standards feel a little low to me.