5 ms·
The Fennel Programming Language
- _xiaz 2y agoGreat website
- azhenley 2y ago"you can use Fennel right here without installing anything" It sits at 99% forever.
- lilyball 2y agoThere's also a console message for an unhandled promise rejection with an error message about an unexpected sprintf placeholder.
- missblit 2y agoWith "[sprintf] unexpected placeholder". This is presumably https://github.com/fengari-lua/fengari/issues/147 https://github.com/fengari-lua/fengari/issues/147. You can workaround it by substituting "%.f" for "%.0f" in https://fennel-lang.org/fennel/fennel.lua https://fennel-lang.org/fennel/fennel.lua. However Chrome won't let me override the contents of this URL for some reason. And the first Firefox response override extension I tried ended up confusing the page. So you can alternatively override the contents https://fennel-lang.org/fengari-web.js https://fennel-lang.org/fengari-web.js as follows: `"string" == typeof o.response ? a.f = yt(o.response.replace("%.f","%.0f")) : a.f = new Uint8Array(o.response.replace("%.f","%.0f"));` (Just before `var l = Ee(a);`) Opened a bug for it: https://github.com/bakpakin/Fennel/issues/485 https://github.com/bakpakin/Fennel/issues/485
- worthless-trash 2y agoAnd it looks like its already fixed.
- johnisgood 2y agoIt has not been fixed yet. > I've turned the web repl back to 1.5.0 for now while we investigate the issue.[1] [1] https://github.com/bakpakin/Fennel/issues/485#issuecomment-2337059767 https://github.com/bakpakin/Fennel/issues/485#issuecomment-2...
- giraffe_lady 2y agoI've talked about it a few times before when it comes up but I love this language and think it's just an incredible technical accomplishment. Lua is beloved and I have a ton of respect for that project in itself, it's definitely one of the seven wonders of the programming world. But the (well-considered) compromises for its intended use as an embedded scripting language make it pretty rough for large complex projects. Fennel is just an extremely focused aid to some of the worst lua warts. Pattern matching alone is incredible for the overloaded tables lua uses. The macro system is excellent, and since a lot of the time what you're doing with lua is defining a DSL anyway it gives you more powerful tools for that. I initially recoiled but I now think it was a genius decision to do it with just a few special forms over the lua semantics. Other than the lisp syntax there's very little new to learn to use it. And the best part is that it hooks into the lua module loader system so you can freely mix tables and functions between the two, a life changer in legacy codebases. Can't say enough good things about fennel. There are a lot of languages that I like but it's one of the only ones I think is actually good. I rarely write normal lua anymore it's just so flexible.
- techsuvara 2y agoI ported LUA to the Nintendo DS in 2007. It wasn't designed for embedded devices back then, let me tell you, it was one hell of a headache to chop down to size. Not sure if the market for LUA has changed since then... Still, it's a great language for scripting.
- globasterisk 2y agoit's still used heavily in some roblox games (they moved to their own implementation with convenience features) and openresty. https://github.com/leafo/lapis https://github.com/leafo/lapis also, minor observation: https://lua.org/about.html#name https://lua.org/about.html#name
- Baeocystin 2y agoIIRC, Factorio uses Lua for all Mod scripting.
- HexDecOctBin 2y agoWhat I would love to have is a Lisp which is as easy to embed (and as portable) as Lua but comes with all the niceties of Lisp like a restart-system, REPL-driven development, numeric tower, hygienic and non-hygienic macros, etc. Unfortunately, no such thing seems to exist.
- Zambyte 2y agoMaybe GNU Guile?
- whartung 2y agoYou’d think Guile would work. That sounds like a Guile checklist to be honest. But that said, my random forays into Guile have been met with frustration. I can’t say anything specific, but for whatever reason, whenever I tried to use it, I’d get no momentum on my little project du jour, and I’d shelve it once again, moving on to something else. Perhaps next time it’ll click.
- zelphirkalt 2y agoIf I may briefly advertise my Guile examples repository: https://codeberg.org/ZelphirKaltstahl/guile-examples https://codeberg.org/ZelphirKaltstahl/guile-examples Perhaps it will be useful.
- HexDecOctBin 2y agoI am a bit biased against GNU libraries. Maybe irrationally so, but I haven't had a good experience with them all the way down from Glibc. They have a tendency to be developer-hostile in very high-handed ways (sort of how GNOME treats its users). I wonder how many people still remember this piece of code: __asm__(".symver memcpy,memcpy@GLIBC_2.2.5"); Plus, the LGPL license will ensure that it can't be shipped on a multitude of platforms (iOS I believe, game consoles, etc.)
- hatefulmoron 2y ago> Plus, the LGPL license will ensure that it can't be shipped on a multitude of platforms (iOS I believe, game consoles, etc.) Just for my understanding, is this based on the fact that these platforms don't allow the user to modify or upgrade Guile to another version in the future?
- dang 2y agoRelated: Why Fennel? - https://news.ycombinator.com/item?id=37497131 https://news.ycombinator.com/item?id=37497131 - Sept 2023 (102 comments) Language Showcase: Fennel - https://news.ycombinator.com/item?id=32349491 https://news.ycombinator.com/item?id=32349491 - Aug 2022 (2 comments) Fennel: A Practical Lisp - https://news.ycombinator.com/item?id=31029478 https://news.ycombinator.com/item?id=31029478 - April 2022 (85 comments) Fennel: A Practical Lisp - https://news.ycombinator.com/item?id=30963628 https://news.ycombinator.com/item?id=30963628 - April 2022 (2 comments) Fennel 1.0.0 Released - https://news.ycombinator.com/item?id=29221245 https://news.ycombinator.com/item?id=29221245 - Nov 2021 (1 comment) Fennel 0.8.0 Released - https://news.ycombinator.com/item?id=25842797 https://news.ycombinator.com/item?id=25842797 - Jan 2021 (1 comment) Raymarching with Fennel and LÖVE - https://news.ycombinator.com/item?id=24835766 https://news.ycombinator.com/item?id=24835766 - Oct 2020 (3 comments) Fennel – Lisp in Lua - https://news.ycombinator.com/item?id=24390904 https://news.ycombinator.com/item?id=24390904 - Sept 2020 (112 comments) Neovim Configuration and Plugins in Fennel Lisp - https://news.ycombinator.com/item?id=21676606 https://news.ycombinator.com/item?id=21676606 - Dec 2019 (19 comments) Fennel – Lisp in Lua - https://news.ycombinator.com/item?id=18016168 https://news.ycombinator.com/item?id=18016168 - Sept 2018 (62 comments)
- WillAdams 2y agoFor folks who are curious, it is possible to use Fennel w/ the Lua in Lualatex: https://wiki.fennel-lang.org/Fennel-in-LuaTeX https://wiki.fennel-lang.org/Fennel-in-LuaTeX but no activity for this on tex.stackexchange (yet?) --- given the difficulties in doing recursion (see: https://tex.stackexchange.com/questions/723897/breaking-out-of-recursion-in-latex-macro-using-lua https://tex.stackexchange.com/questions/723897/breaking-out-... ) using something like to Lisp could potentially be very helpful.
- nanna 2y agoI've always wondered about this. Thanks for sharing!
- Cokainsky 2y ago[dead]
- freilanzer 2y agoMoveOrDie and Acro were made with Löve and Lua. Does anyone know if I can make a 2d game with fennel alone, without touching Lua? Alternatively, what would be a better choice for simple 2d graphics (Python would be preferred)? I want to experiment with something like Dwarf Fortress.
- ejflick 2y agoYou'll always need to deal with a bit of Lua afaik. If you like fantasy consoles, you can use TIC-80[1] to not have to deal with any Lua. [1] https://tic80.com/ https://tic80.com/
- donio 2y agoDepending on your preferred workflow you would typically have a tiny loader stub in a .lua file that you never need to touch and all of your code in Fennel. You can still add third party Lua libraries if you desire and seamlessly call back and forth between these and your Fennel code. You can even have a live REPL to eval code in your running Löve session.
- trenchgun 2y ago>what would be a better choice for simple 2d graphics (Python would be preferred)? I want to experiment with something like Dwarf Fortress. If you want to experiment with something like Dwarf Fortress, you don't need 2d graphics. You can just start with ASCII-graphics like Dwarf Fortress did.
- freilanzer 2y agoTrue, but at some point I need to integrate graphics, so I don't think it's a bad idea to have simple tile graphics in place. Also, I would need some kind of inventory, text fields, etc. and they might be much easier with a framework that supports them - as you see, I have next to no experience in this area.
- agent281 2y agoYeah, I think most of the games in the Lisp Game Jam are made with Fennel and Love. The game jam is cohosted by technomancy, the maintainer of Fennel. https://itch.io/jam/spring-lisp-game-jam-2024 https://itch.io/jam/spring-lisp-game-jam-2024
- Closi 2y agoSome of the syntax choices seem a little strange to me, but I maybe just don't understand the language. What's the reason for (/ num1 num2) rather than just num1/num2 for division for example?
- dunefox 2y ago... because it's a lisp?
- satvikpendem 2y ago`/` is just a function, there aren't operators as something special above functions. This is because it is a Lisp, and even this syntax is just a generalization of Polish notation [0]. [0] https://en.wikipedia.org/wiki/Polish_notation https://en.wikipedia.org/wiki/Polish_notation
- antiquark 2y agoCall me old fashioned, but I always thought syntax like "x = a * b + c" was a leap forward.
- digitalsankhara 2y agoI am old. And fashioned. "a b * c +" rules! :-)
- whartung 2y agoTo a point, but at a cost. In C++, there's 17 levels of precedence across 60 operators, with varying associativity. In many languages, due to precedence, 1 + 2 * 3 = 7, but in others, like Smalltalk, it equals 9. In those languages, its purely left to right, with no precedence. But at a casual glance, they look identical. And for someone bouncing back and forth, they better ensure they have the right hat on when they start writing out equations. In prefix languages, this is not an issue. Everything looks like a function. +, -, sqrt, sin, draw. You also can have niceties like (+ 1 2 3 4), which simply adds up all of the arguments, in contrast to (+ 1 (+ 2 (+ 3 4))). But, that's not different grammatically from (sin (sqrt (abs x))), (f1 (f2 (f3 x))), which appears like sin(sqrt(abs(x))) in infix languages, not much different really at all. Clearly there are benefits to infix presentation, and for basic (or, even BASIC!) use its very approachable. But underlying it, there's some definite complexity that you need to grok when the equations start to get complicated.
- asymmetric 2y agoHas anyone tried writing their NeoVim config in Lua? Is this a good use case for Fennel?
- marcofiset 2y agoThere is a plugin to help you do so: https://github.com/Olical/aniseed https://github.com/Olical/aniseed Didn't try it myself though.
- Agentlien 2y agoI just finished converting my rather large (just under 500 lines) init.vim to Lua. It took way longer than I had hoped. I feel like I've forgotten the motivation and what benefits it was supposed to bring. At this point I really don't want to consider another conversion, using Fennel or otherwise.
- adregan 2y agoI think about writing the config in fennel all the time, but I’m not a big config tinkerer and already worry about struggling with Lua when I have an upgrade gone awry. I’ve found the neovim ecosystem to churn way more in recent years than it did when I initially started using it 8 years ago. It really reminds me of the JS ecosystem of the past decade: full featured plugin that works great decides to strip things back so that it’s functionality is all plugable and you suddenly have to wade through 2 major release’s migration docs to get things kind of working like they were before. I digress to point out why it might be hard to have yet another layer to translate through. Though if you don’t have kids, I’d say “go for it!”
- adelarsq 2y agoI have 3500 lines config file in Lua that I have converted from VimScript last year. I see that Lua it's way easier to maintain than VimScript. Fennel solves some Lua kirks, so I think that is a good use case, since Fennel has some cool features that can help to maintain the code. Right now I am moving the plugins that I maintain to Fennel. If interested take a look on the https://github.com/Olical/nfnl https://github.com/Olical/nfnl and https://github.com/gpanders/fennel-repl.nvim https://github.com/gpanders/fennel-repl.nvim plugins.
- indigo0086 2y agoWould someone explain the function of scripting languages. Why use a scripting language spun off from another language than use the original host language. What does lua offer as a scripting language when offering it as a scripting language?
- bobajeff 2y agoIdeally all languages would be quick to program in but the reality is that some languages have really long compile times and are unsuitable for quick prototyping, experimenting, creating proof of concepts, or small programs. That's where scripting languages come in handy.
- imtringued 2y agoNothing prevents anyone from building an ABI compatible interpreter where only parts of the program are compiled.
- deleted 2y ago[deleted]
- idle_zealot 2y agoI think the bigger problem is a language design one. Scripting languages are often easier to use than more performant ones because they make a lot of choices for the developer (automatic allocation and garbage collection, doesn't expose reference versus value, no pointers, everything is a table/object/whatever). A runtime can try to make inferences about how language features are being used in order to speed up execution or reduce memory use, but usually even then things end up being less efficient than if the programmer had to actually make choices about memory allocation, if/when to free things, etc.
- bobajeff 2y agoNothing save for time, skill and enough financial support. Sure. While we're at it why not make a Web Browser too? Technically, nothing stops us.
- 2y ago
- mikemee 2y agoStrongly agree. We liked Fennel so much we adopted it for building our mobile apps. We have a SQLite + Lua core that handles business logic and increasingly also view and controller logic with a thin native wrapper for iOS and Android. With over 100k downloads and active users, it’s proven itself stable and practical. It’s a convenient way to access the immense power of SQLite, with the succinctness of a lisp-like syntax. Throw in tests that execute at 350 tests per second and it’s a fast, stable development platform. Right now we’re building a wrapper to display graphics sufficient for simple puzzle games so we can generate the layouts and handle interactions also in Fennel (by mapping to native iOS and Android views). It also does hot reloading in the iOS simulator. Very much a WIP though. We haven’t shipped this part yet. Fun times. Stable. Small. Uncomplicated. Great community.