8 ms·
Urn: A Lisp implementation for Lua
- sillysaurus3 9y agoAlso see Lumen, a Lisp for Lua and JS: https://github.com/sctb/lumen https://github.com/sctb/lumen
- giancarlostoro 9y agoI have never asked this before, but Lua seems to have a couple of different languages implemented in itself, almost making me think of how JavaScript has a similar offering. Has anyone compared JavaScript and Lua in the language building regard? I'm curious to see what the most commonly used JS / Lua features are when designing a new language on top of those two languages. I know some languages have features that help you to build a new language (or it seemed to be like that) I think Java / C# do but I don't remember the names of the classes for that stuff, last I saw it was many years ago. Also of course I know Lisp lets you get there too, if I were to try to create my own language I'd try building my own lisp as a first project, and then go from there to try and make something different.
- fsloth 9y agoIf you are interested in how to implement languages I've not yet come across a better introduction than the classic "Structure and interpretation of computer languages". The 'build your own scheme' section is transferable to any other language. https://mitpress.mit.edu/sicp/full-text/book/book.html https://mitpress.mit.edu/sicp/full-text/book/book.html
- sillysaurus3 9y agoOn the other hand, I've been building languages for a few years, and I never got anything useful out of that book. If you open it and feel dumb, don't worry, it's not just you. MIT and especially books from MIT are held on a pedestal. If you can't understand them or don't feel like pursuing them, just find a different book.
- tonyg 9y agoI got a lot out of "Essentials of Programming Languages" (2nd edition, at the time) by Friedman, Wand and Haynes. It has a great quote from Hal Abelson in the foreword, too: > Perhaps the whole distinction between program and programming language is a misleading idea, and future programmers will see themselves not as writing programs in particular, but as creating new languages for each new application.
- nv-vn 9y agoYes I absolutely loved that book and it served as a great introduction
- giancarlostoro 9y agoAny suggestions as opposed to that book? I would appreciate it. :)
- sillysaurus3 9y agoThe art of the interpreter: http://repository.readscheme.org/ftp/papers/ai-lab-pubs/AIM-453.pdf http://repository.readscheme.org/ftp/papers/ai-lab-pubs/AIM-... On lisp: https://www.lurklurk.org/onlisp/onlisp.pdf https://www.lurklurk.org/onlisp/onlisp.pdf Mainly the key is to start tinkering, rather than jump from book to book. Just start with a very informal v1 and start hacking stuff together. When you run into a design dead-end, you'll know it because it will become increasingly hard to make forward progress. And that's the tricky situation. When you run into a design dead end, what do you do? Books! :) And that's where SICP might end up useful. Or think about the problem really hard, and write down the answer. I've occasionally pulled that off. Oh, I thought of one other suggestion: linkers and loaders. It's another classic. And unlike all the other references, there's no Lisp. Two more: Linkers, Ian Taylor: https://www.docdroid.net/2L1IZ5y/linkers.pdf https://www.docdroid.net/2L1IZ5y/linkers.pdf Assemblers: https://www.docdroid.net/2tgkwNI/assemadvertisasl.pdf https://www.docdroid.net/2tgkwNI/assemadvertisasl.pdf
- vram22 9y ago
- rs86 9y agoRead it again.
- isaachier 9y agoThat's an interesting insight. I think the reason has less to do with the languages being good for language development than it is about other language features. JavaScript is the Internet's only frontend language. For many C/C++ programs, users may write plug-ins only in Lua. The common aspect is that the users are forced into choosing the language for external reasons. Many of them see flaws in JavaScript and/or Lua and would like to write in another language instead. That's how I see transpilers coming into existence for these languages.
- PyComfy 9y agohttp://www.buildyourownlisp.com/ http://www.buildyourownlisp.com/
- jaten 9y agoLua is fantastic for implementing languages. I did an implementation of Golang in it (https://github.com/gijit/gi https://github.com/gijit/gi). With metatables one can implement any kind of object/inheritance/interface scheme. Full builtin asymmetric coroutines, and a massively performant, ABI compatible backend (a just-in-time trace compiler) in LuaJIT are amazing tools.
- i_feel_great 9y agoAnd how is Lua support in the Guile runtime coming along these days?
- bjoli 9y agoI think the best bet is https://github.com/NalaGinrut/guile-lua-rebirth https://github.com/NalaGinrut/guile-lua-rebirth
- krylon 9y agoThat, combined with Guile-Emacs would be super sweet. Not that I have anything against Lisp, but an emacs-ish text editor with Lua as an extension language would be really cool. I know the Zile project tried something like that, but I have no clue how far they have gotten. Also, there is a huge body of code written in elisp that has been around for ages and got properly debugged along the way. Replacing that is not a very realistic task.
- deleted 9y ago[deleted]
- leephillips 9y agoThose are very nice error messages.
- nerdponx 9y agoHow does this compare to Fennel? https://github.com/bakpakin/Fennel https://github.com/bakpakin/Fennel
- eggy 9y agoI would like to know too, and to Lumen also mentioned in a thread here. I may try both, and see what is closer to Lisp, Clojure or a combination of both. Thanks for pointing out Fennel.
- squiddev 9y agoUrn effectively tries to be it's own language which sits on top of the Lua runtime. I've tried to take the nicest bits of Lua and combine it with macros and a little more compile-time checking. Though I'm not entirely sure how successful I've been... Urn was is very much an experimental project for me: part of me wanted to see how much I could do with as little syntax. Consequently Urn has comparatively few "special forms", but meaning it generates less idiomatic Lua. Fennel is much more an alternative syntax to Lua. Most Lua constructs have a corresponding Fennel form, meaning the generated code looks more "like Lua". Lua interop is also much nicer: Urn requires you to declare all variables, so you have to jump through hoops to use external libraries. With Fennel you can just go ahead like you would with Lua.
- ansible 9y agoKudos to you for creating and sharing this. I've toyed around with ideas related to your project. Such as: What if... you had a Lisp that instead of being based around the classic linked list, was based around the Lua table instead? I've briefly tried to come up with formulations for how the code itself should be represented as a series of nested tables. And perhaps have a series of nested tables for all variables in the runtime as well (including local ones), though Lua sort of does this now. All that would increase ease the introspection, creation of macros, and other fun stuff. I hadn't started deciding on a syntax or anything either.
- bakpakin 9y agoAuthor of Fennel here. Urn seems to be greater in scope and code. Fennel is intentionally small and a single file that can be dragged into any project. Fennel does not try to provide Lisp idioms or abstractions unless they have a direct mapping in Lua. For example, there are no linked lists (use tables), and no continuations (use coroutines). Operators are implemented as special forms rather than function literals so that they can be easily implemented efficiently. Fennel also includes abstractions that might not make sense in a normal lisp but help make interfacing with Lua code easier. For example, symbols that have a dot in them, like "table.insert", have the correct interpretation and can be used as normal symbols. Method calls are supported such via the `(:)` form; `(: "hello" :find "llo")` compiles to `("hello"):find("llo")`. Fennel takes this approach because Lua is almost already a Lisp, so I felt it was best to add the minimum abstraction necessary. Also, I prefer simple and transparent tools. Urn may provide more comfortable and "Lispy" abstractions, however, because it takes more control of the environment. It also seems to have pretty great error messages compared to Fennel, and a good website. There are definitely some features in Urn that aren't (yet) in Fennel, like built in pattern matching, although Fennel does do destructuring.
- half-kh-hacker 9y agoHey, I used to play ComputerCraft with the lead developer of this project. Guess that's why it targets Lua.
- squiddev 9y agoI can't deny it! Though Urn was much more a "I want to do something with Lua" project, than something targeting CC. That being said, I know people have got the compiler running on various other fantasy consoles.
- Zolomon 9y agoThis looks interesting! I'm going to take another look at this during my coming vacation and play around together with https://love2d.org/ https://love2d.org/.
- nikofeyn 9y agoi have recently become interested in lua, especially the fun looking love framework [https://love2d.org/ https://love2d.org/]. but one thing i have had trouble understanding is what lua is particularly useful for and/or used for. can someone explain what type of use cases are up lua's alley? thanks.
- drcode 9y agoIt's basically the simplest non-painful-to-work-with programming language that doesn't have a lispy syntax. This makes it very useful for app scripting and programming language experimentation. (And other use cases where you want a dead simple language, but are for some reason averse to parentheses)
- krylon 9y agoAlso, Lua's C API for interfacing Lua and C is very pleasant to work with. I did not really get why Lua was so popular until I used it as a scripting/extension language in a small toy project. That was an eye-opener!
- dwc 9y agoOne of the most popular and compelling real world uses of Lua is for embedded scripting. It's easy to embed, it's easy to use, for a scripting language it's blazing fast. I'm sure Lua has other sweet spots, but that's the one I'm most familiar with.
- spanishgum 9y agoI was introduced to Lua via writing a Wireshark plugin for packet verification. It was hard in the beginning but dove right into working with a C backend. I'd say that's an approachable side project if you want to explore Lua.
- kemayo 9y agoI've mostly experienced it through World of Warcraft -- it's embedded there as the language used to write the game's user interface[1]. Then it's exposed to third-party authors as an API, so they can write addons for the game. It's also embedded in Wikipedia[2]. Complex templates can be written with Lua modules, rather than relying on wikitext. [1]: http://wowwiki.wikia.com/wiki/World_of_Warcraft_API http://wowwiki.wikia.com/wiki/World_of_Warcraft_API [2]: https://www.mediawiki.org/wiki/Extension:Scribunto https://www.mediawiki.org/wiki/Extension:Scribunto
- iLemming 9y agoMy exposure to Lua is limited around writing Hammerspoon scripts. Lua is nice but I really wanted to write those scripts in a Lispy language, maybe something Clojurescque. Has anyone done Hammerspoon either in Urn or Fennel? Which one should I try? Would that even work?