[HN Gopher] Fennel: A Practical Lisp ___________________________________________________________________ Fennel: A Practical Lisp Author : mattroelle Score : 95 points Date : 2022-04-14 16:45 UTC (6 hours ago) (HTM) web link (www.mattroelle.com) (TXT) w3m dump (www.mattroelle.com) | esrh wrote: | Calvin rose, the author of fennel is a really great programmer | and an even better language designer. Personally, i dont use or | like lua, but I'm a big fan of one of his other projects, | janet[0] | | [0] https://github.com/janet-lang/janet | pull_my_finger wrote: | > i dont use or like lua, but I'm a big fan of one of his other | projects, janet | | As a big fan of both Lua _and_ Janet, I'll just point out that | a lot of what makes Janet nice and interesting are in fact | inspired by Lua. Tables, fibers (coroutines), prototypes | (metatables/metamethods), custom module loaders, a lot of the | API, the peg parser (LPEG), etc etc. I understand no language | is for everyone, but the influence can be felt throughout Janet | if you're familiar with both. | mattroelle wrote: | I'll also add that Fennel fixes some of things about Lua most | people dislike, like the global variables by default thing. | IMO it's worth checking out even if you didn't like Lua at | first | andai wrote: | I love that it comes with build instructions for Haiku--and | that they're listed before Windows! | kbd wrote: | I didn't realize the author of Janet was the author of Fennel, | thanks for making the connection. | mattroelle wrote: | Yup, same author! Although to my knowledge Calvin has mostly | stepped away from the Fennel project at this point. It is | primarily maintained by the same dev that made Clojure's | Leiningen, technomancy. | andai wrote: | See also: | | Fennel - Lisp in Lua (2020, 112 comments) | https://news.ycombinator.com/item?id=24390904 | | Fennel - Lisp in Lua (2018, 62 comments) | https://news.ycombinator.com/item?id=18016168 | | Neovim Configuration and Plugins in Fennel Lisp (2019, 19 | comments) https://news.ycombinator.com/item?id=21676606 | | Raymarching with Fennel and LOVE (2019, 3 comments) | https://news.ycombinator.com/item?id=24835766 | ncmncm wrote: | Curious how this compares to Guile. | | Guile is designed for embedding. But it is vanilla Scheme, which | might not be as modern as the Fennel flavor. | | Maybe, the Fennel all gets lowered to Lua at build time, so you | don't need a (maybe more expensive) Guile runtime? Or, Lua has a | more comprehensive library ecosystem? | harryvederci wrote: | If I recall correctly, you can do both. You can compile your | fennel code to lua, or you can use fennel as a library in your | lua application so it will understand your fennel code. | hcs wrote: | Correct, it's all converted to Lua, Fennel has no runtime. | jonpalmisc wrote: | Fennel is really cool, and the fact that it builds on Lua--an | already-popular language--is a huge win; Fennel gets access to | the entire Lua ecosystem. | | Importantly, Lua is pretty easy to embed in native applications. | I haven't found a Lisp or Scheme as easily-embeddable as | Lua(+Fennel). | | It's also a good drop-in replacement for Lua. I write my | Hammerspoon config in Fennel, and hopefully my Neovim config soon | as well. | bjoli wrote: | Chibi scheme is easily embeddable. Guile is a different beast | to manage, but then you get a lot more power and speed. Not | luaJIT speed, of course, but a lot faster than vanilla lua, and | with proper threads as a bonus. | | The others I haven't tried embedding, but I hear racket is | really no fun to embed,but things might have changed with the | chez transition. | petre wrote: | Chibi Scheme, interesting. Also beautiful. Thank you. | | Racket CS is also quite fast, comparable to Lua or faster | (for numeric ops). It also uses rational numbers which makes | it useful for exact numeric operations. | rufugee wrote: | As a fellow hammerspoon user who is not smitten with Lua's | syntax, I would really appreciate seeing your config :-) | jonpalmisc wrote: | It's pretty minimal right now as I'm in the process of | porting over a larger config. Here's what I have, although | you might find it might be a bit underwhelming: | | https://github.com/jonpalmisc/dotfiles/blob/master/hammerspo. | .. | [deleted] | keb_ wrote: | I love Lua and the Lua community, but as a native Windows user, | it's historically been a nightmare to use. To this day, I have | never gotten LuaRocks to work reliably on Windows. | | This is very different than Node + NPM, which you can get set up | and going in <5 minutes. | ncmncm wrote: | So, another advantage, then? | keb_ wrote: | I'm not sure I follow; it's an advantage that it doesn't work | well on Windows? | ncmncm wrote: | Might help encourage you to move away from Windows. | keb_ wrote: | I have plenty of reasons to move away from Windows, and | also plenty of reasons to stay. :) But I think it's | overall a net-negative that there is no simple way to use | LuaRocks on Windows. I don't believe in gatekeeping, | especially when so many programmers still begin their | journey on Windows. | charbuff wrote: | What kind of possibilities are there for Lua on android and ios | app development? Any experiences there? | mattroelle wrote: | If you're interested in discussing further, there is a growing | community that hangs out on #fennel on the Libera Chat IRC | server. You can connect via matrix chat using | https://matrix.to/#/!rnpLWzzTijEUDhhtjW:matrix.org I'll be | hanging out there all day today and I'd love to talk about | Fennel. There is also a Fennel User Group meeting this Saturday | at 10am, open to all. More info at https://fennel-lang.org/events | usgroup wrote: | Thanks I will give this a go. I had a long fling with Lua a while | back. Wrote everything in Lua -- it is a great language. I would | have used it for data science if only it had more well maintained | packages. The main API for Torch was in Lua for a while before | they abandoned it for Python. Had that carried on we could be | using Torch with Fennel right now. | mattroelle wrote: | Not sure when you used Lua but there is a package manager | called LuaRocks now which has some pretty nice packages in it | for many purposes. I don't think it'd be too hard to get Lua | running inside of a Python env either :) | | https://luarocks.org/ | giraffe_lady wrote: | It's really pretty rough compared to everything else I've | used. I really don't feel like luarocks solves very many of | my problems. A _lot_ of gaps in there, or libraries that only | target 5.1, or only luajit. Or are completely unmaintained, | or have poorly documented dependencies on C libraries. etc | etc. | | I use lua a lot and like it fine but the | build/dependency/tooling situation is a fucking mess. It | exposes you to a lot of the inconvenience of C in the end. | mattroelle wrote: | Yeah, my experience is limited mostly to web dev, via | OpenResty, and game dev, via love2d. | | The Lua libraries in these areas are very well maintained. | | That said 90% of the time libraries ship as a single lua | file and it's often better to copy and paste it into your | project. I have a modified version of lume I like to use | floating around :) | | This spartan approach to libraries is a strength of Lua. | abrax3141 wrote: | So, I don't exactly see how one uses this in an already-embedded | Lua. For example, my son knows Lisp, and a bit of Lua because he | uses PowderToy, which (to your point) has built-in Lua. So if he | wanted to program his Lua extensions to PowerToy in Lisp (Fennel) | instead of Lua, how would he go about it, exactly? Compile | outside of PT from Lisp to Lua and then load the Lua code into | PT, or, run the Fennel Lua code on PT's internal Lua? Either | seems clunky. I skimmed the online doc, and there may be | someplace that gives guidance on this, but I didn't see it right | away. If you can point it out (or, if it doesn't exist, perhaps | explain a bit) that would be great. Thanks! | mattroelle wrote: | Hi there! Once you have lua running somewhere you're 90% of the | way there. You can do AOT compilation which will output lua | code via. | | fennel -c my-fennel-code.fnl | | Or you can use the lua package api to automatically load .fnl | files via require seamlessly: | | local fennel = require("fennel") table.insert(package.loaders | or package.searchers, fennel.searcher) | | Enjoy! | az_reth wrote: | It seems those are indeed the two options. This link gives | details on how to perform either or the other. | | https://fennel-lang.org/setup#embedding-fennel | mattroelle wrote: | The primary maintainer of Fennel, Phil Hagelberg, has put | together some brief instructions on how to get Fennel running | inside of Powder Toy for you :) https://p.hagelb.org/hello- | powdertoy.fnl.html | teataster wrote: | The thing I hate the most about Fennel is when you go back to | Clojure and type `print` rather than `println`. | cyberbanjo wrote: | (ns foo.bar (:refer-clojure :exclude [print] :rename | {print println})) (print "Should have a newline") | kgwxd wrote: | ;; How to infuriate your co-workers | kleiba wrote: | Workaround: print C-x a - println | M-x abbrev-mode | harryvederci wrote: | Not all clojurians use emacs ;) | [deleted] | [deleted] | rcarmo wrote: | I've been considering rewriting a bunch of my stuff in Fennel | since it has two other advantages the article doesn't point out: | both Lua and Fennel are _very_ stable and unlikely to go through | major changes over, say, the next five years or so. | | That kind of thing also has a lot of value when you only want to | write something once. ___________________________________________________________________ (page generated 2022-04-14 23:01 UTC)