6 ms·
I 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 simi
by giancarlostoro 9y ago
I 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>linkers and loaders Do you mean the book by John Levine? I had read it, it was good.
- marcpaq 9y agoI hope this helps: https://github.com/marcpaq/b1fipl https://github.com/marcpaq/b1fipl I collect single-file language implementations. None in my collection (so far) use Lua, but I'm always on the lookout.
- UncleEntity 9y agoMinischeme (can be found on github and elsewhere) could go on your list. I found a copy of the original public-domain code a while back and have been hacking on it here and there, mostly pulling in fixes from tinyscheme.
- fsloth 9y ago"I never got anything useful out of that book" Everyone to his own taste, but I think that is just short selling the book. I had no problems in starting to convert the lisp evaluator described in the book to C++ after only a few years of programming experience and I'm not an ace programmer. It was not straightforward, but it was not intimidating either. I did it for fun, not as a compulsory exercise. Specifically, Chapter 4 (Metalinguistic abstraction)[1], starting on 4.1 [2] Sure, you need to figure out that you need to tokenize strings to symbols, and do recursive descent parse stage or such to push the token/symbol list into hierarchical lists. But that's precisely the sort of thing that I feel figuring out has made me a better programmer. The key was that I knew the solutions had to be simple, so I sought simple solutions. Yes, I agree, the book could have verbatim explanation - "hey, after you know some Scheme go to chapter 4, where we give you a damn good literate programming based exposition of a scheme interpreter." - and since it doesn't, I do think your critique does have pedagogical merit. I remember leafing through the book and marking stuff up, trying to figure it out, until I realized it was standing there in front of my eyes the whole time. My paper copy is quite dog-eared by now. [1] https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-25.html#%_chap_4 https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-25.htm... [2] https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-26.html https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-26.htm...
- bch 9y ago>> "I never got anything useful out of that book" > Everyone to his own taste, but I think that is just short selling the book. I had no problems in starting to convert the lisp evaluator described in the book to C++ after only a few years of programming experience and I'm not an ace programmer. @sillysaurus3 just made that book more accessible to everybody by giving them a guilt-free exit, based on experienced results, and your first instinct is to pull a quote out of context and explain why their personal experience is “wrong”?
- fsloth 9y agoI'm sorry. I was not trying to be confrontational. Sillysaurus said he did not see much merit in perusing the book after professing some experience in language implementation, and I felt an answer based on personal learning was in order as a counterpoint. Good Books, that actually teach something and mean something are exceedingly rare... this quality, is of course often quite personal. The concept of 'guilt' when abandoning a book is completely foreign to me. I presume it is a facet of poor self esteem? This is quite useless as a concept and people need to find their own intellectual feet. Not all need to dig the same things. If some weird book some unknown dudes in the internets glorify feel useless to me I just dump the book without a second thought. I don't have the time to become an expert in every subject, so I should only investigate those concepts that arouse a personal feeling of beauty. Doing brainy things "just because you imagine it makes you look smart" is counterproductive.
- cat199 9y agoI would probably have 'opened and felt dumb' as well - However, the recorded lectures are quite illuminating: https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-001-structure-and-interpretation-of-computer-programs-spring-2005/video-lectures/ https://ocw.mit.edu/courses/electrical-engineering-and-compu... also, this is more a 'computing philosophy' sort of course
- 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.