7 ms·
Lisp in Your Language
- codecurve 11y agoAuthor here, would be interested to hear people's take on the addition of illustrations (illustration is being generous, I know). Do you find them distracting or do they help break up the text?
- davexunit 11y agoI think they are nice. I think you made the basic ideas behind Lisp accessible and fun. Good job!
- calibraxis 11y agoI agree! Lucid approach. The illustrations work for me. I like the approach of using eval immediately, without ceremony. (Disclaimer: I’m used to Lisp so I’m not really the audience whose opinion matters. But I’m sure I would’ve benefited from reading this earlier. Skimmed it, and am now halfway through a more careful read.)
- mordocai 11y agoI like the illustrations, but I love Land of Lisp which is filled with them so... I think I'm already predisposed toward illustrations in text.
- kaoD 11y agoI didn't even realize there were illustrations until I read this comment. Had to go back and check.
- codecurve 11y agoHaha, that's a pretty clear case for them not being distracting!
- archimedespi 11y agoOr maybe they were using a reader program which didn't display images, or they were reading HN on Lynx :)
- SamBoogieNYC 11y agoCool post! I'm curious - where did you get the turtles illustration idea? I've seen it in a funny, obscure book and am wondering if you've read it too.
- Rmilb 11y agoIt's a reference to this : Turtles all the way down https://en.wikipedia.org/wiki/Turtles_all_the_way_down https://en.wikipedia.org/wiki/Turtles_all_the_way_down
- deleted 11y ago[deleted]
- jfaucett 11y agoHi sounds like you'd like some constructive criticism so here's MHO. Images can be great aids in understanding text and making abstract concepts concrete. Also, in many cases the usual metaphor/simile rules apply. For instance, in the phrase he's "fast as a bolt of lightning" we can imagine the speed of the runner and it helps us envision how he "flashes" by opponents. In this case both concepts are known i.e. lighting and fast, but new descriptive meaning is created through the use of simile. Similarly, metaphor takes two known concepts and combines them to reveal a new concept. An example of metaphor, would be "he's an emotional rollercoaster", we know what emotional is and how a rollercoaster behaves, this gives us new insight into the persons high and low spiraling personality. Essentially, I think good images interact just like simile and metaphor with a text, enhancing, extending, and clarifying concepts. If you go back now and look at your images, I think you'll see that they actually reflect rather verbatim what the text contains, only minimally extend or clarify the text, and at times might make it more confusing (how do turtles enhance our understanding of expressions?). So for these reasons, I found them to be distracting and not helpful, as nice as they actually appear graphically :) Nice post btw :)
- jaywunder 11y agoThe car illustration was both funny, and helped to show your point in a really concise way. So I'd say +1 to illustrations!
- mordocai 11y agoVery good post but ewwwww to the way you have to implement it in Javascript. Still, seems very accessible and useful to people who don't feel like going through the trouble of learning/building a "real" lisp but will read a blog post.
- zeveb 11y agoWell, once you've got this much going all you need to implement is a proper READ, and then life is just about perfect.
- undershirt 11y agoIf JS developers want a concrete example of Lisp's benefits, you only need to look at React's JSX syntax-- it lacks conditional logic and loops. To see why, you kinda have to see how React components are created in ClojureScript's lisp syntax, it's really elegant: https://github.com/shaunlebron/jumping-from-html-to-clojurescript https://github.com/shaunlebron/jumping-from-html-to-clojures...
- davexunit 11y agoI think JSX is just terrible, glad to see someone else feels the same. The ClojureScript way is much better, though I think SXML style is best: http://okmij.org/ftp/Scheme/SXML.html http://okmij.org/ftp/Scheme/SXML.html
- steego 11y agoOh noes! Don't give people these bad ideas! :) In all seriousness, I worked with a bright guy who was a lot of fun to work with, but every once in a while his exuberance for this sort of thing would find itself in code that other people had to read/maintain. One particular example, he implemented a small subset of Lisp encoded into PHP arrays and it was used throughout some test code. He effectively proved you could write PHP in a Lisp style and that PHP programmers overwhelmingly hate PHP flavored Lisp.
- lotyrin 11y agoDrupal "theme arrays" are not entirely different. They wanted expressions covering what to be themed and how to theme those things and to allow nesting of this information - S-expr flavored PHP. I wish I knew if this had been done on purpose or if it was (just) a sad accident.
- ksenzee 11y agoI'll guess theme() was inspired by s-expressions, whether consciously or not. The theme() function dates from when Dries was a CS student writing a lot of the code himself. (It's also worth noting that theme() hasn't worked this way since 2011; it now takes a more PHP-style associative array of named options.)
- lotyrin 11y agoI'm not sure you understand. theme() appears to just be a pretty simple observable ("hookable") delegator... I mean the extreme flexibility (and great potential for large amounts of slow synchronous processing from abuse) of using nested trees of elements with '#theme' function set as passed to drupal_render().
- justinhj 11y agoThat sounds really horrible, but as a lisp enthusiast that worked on a substantial live system in PHP for a couple for years, I do believe it's possible to write a fair amount of PHP in a functional style. Making use of array reduce, map and filter for example.
- latenightcoding 11y agoLisp articles have been making their way to HN's 1st page the whole week. Keep them coming.
- nkassis 11y agoMaybe we can designate this week as Lisp week every year where we revive our collective love for the language. Sure beats shark week in value.
- zeveb 11y ago> Maybe we can designate this week as Lisp week every year For some of us, every week is Lisp week grin
- TeMPOraL 11y agoAnd others only dream that maybe their grandchildren will live such happy times as their grandfathers did. But it's time to go to bed, get some sleep before another day of reimplementing half of CL in Java...
- DonaldFisk 11y agohttps://xkcd.com/297/ https://xkcd.com/297/
- smizell 11y agoI wrote a very similar tool one time: https://github.com/smizell/geneva https://github.com/smizell/geneva It is Lisp in JSON. I did it for fun, but thought it would a cool way to send instructions across the wire from the server to the client and back. Imagine validation rules that could be ready in any language with really very little parsing instructions.
- smizell 11y agoWe're also working on a data format that allows for this use of arrays. https://github.com/refractproject/refract-spec/blob/master/refract-spec.md#compact-format https://github.com/refractproject/refract-spec/blob/master/r... We use it very similarly to how you would with Lisp, where the "element" may be a function of sorts.
- ekmartin 11y agoCreating a Lisp is a great way to learn a language. https://github.com/kanaka/mal/ https://github.com/kanaka/mal/ has thorough tests and step by step instructions to help you along the way, definitely recommend checking it out.
- roblabla 11y agoThis is very similar to miniMAL [0]. They even have a miniMAL interpreter written in miniMAL [1] in the Make a Lisp project [2]. [0] : https://github.com/kanaka/miniMAL https://github.com/kanaka/miniMAL [1] : https://github.com/kanaka/mal/tree/master/miniMAL https://github.com/kanaka/mal/tree/master/miniMAL [2] : https://github.com/kanaka/mal https://github.com/kanaka/mal
- agentultra 11y agoYou could also take your proto-eval and spit out ASTs into your favorite language for your given special forms and bootstrap a new interpreter from there. Hy does this for Python (except that its initial implementation started from a parser). It essentially becomes a syntax for manipulating Python ASTs as plain old data-structures instead of classes with terrible interfaces. It's actually a great way to become intimate with the inner workings of your host language. It's funny how far you can get by sprinkling a few parentheses around.
- chriswarbo 11y agoI've made an embedded language called Plumb, which works along similar lines: http://chriswarbo.net/essays/plumb http://chriswarbo.net/essays/plumb Plumb is certainly not a Lisp though; it's actually a syntax for lambda calculus with de Bruijn indices, which just-so-happens to embed easily in common scripting languages (PHP, JS, Python, etc.).
- bliti 11y agoOne of these days I'm going to stumble into something like this in a project. Probably written in Delphi or VB.NET. Not that I use those languages, but it tends to be that the weird stuff tends to appear there. At least for me.
- jimbokun 11y ago"Not that I use those languages, but it tends to be that the weird stuff tends to appear there." I guess programmers of those languages must desperately want to escape to another language.
- lispm 11y agoIF is not a function. Functions don't evaluate their arguments. Functions actually get evaluated arguments passed. But IF is a special form, built into the language. Special forms are not functions. There is something special about special forms. A basic set of special forms is needed and can't be implemented as macros.
- zeveb 11y ago> But IF is a special form, built into the language. It doesn't have to be built into the language; it could be a macro based on COND or even on WHEN/UNLESS. But… > A basic set of special forms is needed and can't be implemented as macros. One has to have some special forms in order to build everything else as macros. And in practice, of course, there can be some big efficiency gains to having lots of special forms vice having only a few and lots of macrology.
- lispm 11y ago> It doesn't have to be built into the language; it could be a macro based on COND or even on WHEN/UNLESS. But… In Common Lisp IF is built in and COND is a macro. One of the conditionals needs to be built-in. http://www.lispworks.com/documentation/HyperSpec/Body/s_if.htm#if http://www.lispworks.com/documentation/HyperSpec/Body/s_if.h... > One has to have some special forms in order to build everything else as macros. For conditionals, one conditional needs to be there, into which the other macro-based conditionals can be expanded. > And in practice, of course, there can be some big efficiency gains to having lots of special forms vice having only a few and lots of macrology. Not really. Common Lisp has a minimum of special forms and usually has some of the faster Lisp implementations.
- lisper 11y ago> One of the conditionals needs to be built-in. That's actually not true. IF can be implemented in terms of LAMBDA. (defun _true (then else) then) (defun _false (then else) else) (defmacro _if (condition then else) `(funcall (funcall (function ,condition) (lambda () ,then) (lambda () ,else)))) ? (_if _true (print 123) (print 456)) 123 123 ? (_if _false (print 123) (print 456)) 456 456 ?
- eru 11y agoCompare https://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours https://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_... for Lisp in Haskell.
- candeira 11y agoI'm working on a data validation pipeline, and I recently noticed that the rules in my jury-rigged rule engine already look a bit like lisp, and briefly considered embedding a tiny scheme. That consideration lasted about a coffeetime. My solution is going to be turning these rules into something that looks like Python, and feed each line to eval(). I reckon that will make 90% of the rule evaluation engine, which is my brittler code, to just disappear. Sometimes the most obvious choice is also the best. No, none of these rules are input by users. All of them come from our repo. We're safe and good.