Live data from Hacker News

Why Go Rocks for Building a Lua Interpreter

zombiezen.com

21–30 of 61 posts

Re: Why Go Rocks for Building a Lua Interpreter

#22
post #11

Well done, writing interpreters is fun! I’m not really sold on why Go would be a particularly good fit for the task, compared to other languages. Seems to be mostly “interfaces are useful for interpreters, and GC means I don’t have to care about memory management” - both of which are true but hardly specific to Go. There’s some form of interface in almost every mainstream language, I think the implementation would be…

I never thought that Go would be a technology of choise for PL stuff. I always considered it more of a Java-lite for Web systems and also for CLI stuff, but here we are! TypeScript rewrote their compiler to Go. Being a compiler, they had no use of piggy backing on the GC, looks like they just liked the language.

I used Go awhile ago for a Blockly interpreter. It's remarkably friendly; if memory serves, the ability to attach metadata to structs was pretty useful.

One hack I'm not super proud of is I implemented return and break with panic / recover. Were I to do it all over, I'd probably use continuations to model that instead.

(Side-note on Lua specifically: among the reasons I like Lua is that it's very simple and its reference interpreter implementation is some very understandable code. I did some truly horrible things to it back in the day for a game engine, and it was very amenable to getting beat up like that).

Re: Why Go Rocks for Building a Lua Interpreter

#23
post #14

Well done, writing interpreters is fun! I’m not really sold on why Go would be a particularly good fit for the task, compared to other languages. Seems to be mostly “interfaces are useful for interpreters, and GC means I don’t have to care about memory management” - both of which are true but hardly specific to Go. There’s some form of interface in almost every mainstream language, I think the implementation would be…

> I’m not really sold on why Go would be a particularly good fit for the task, compared to other languages. Can't every language rock for building a Lua interpreter? It isn't a competition.

I think that’s re-interpretation, making the subject of the article about “why go rocks” shows the author thinks Go has something over other languages. Otherwise it’s like saying “why orange cats are fluffy” then saying stuff that applies to all cats without orangeness specificity

Re: Why Go Rocks for Building a Lua Interpreter

#24
post #9

I'm surprised there was no mention of implementing Lua's coroutines via Go's goroutines.

That feels not quite correct. Lua coroutines aren't separate threads and trying to farm them out to goroutines (which are separate threads) risks violating expectations you can assume with non-concurrent execution. With coroutines, you can fairly believe that your state isn't going to change when you're running until you yield.

Re: Why Go Rocks for Building a Lua Interpreter

#25

tfw you learn lua so you can build robots on minecraft

Lua has a long history with gaming since the late 1990s. The LucasArts adventure game "Grim Fandango" (1998) used Lua internally, and more recently it seems to have become the standard language for "fantasy console" game development such as in PICO-8 and TIC-80.

Re: Why Go Rocks for Building a Lua Interpreter

#26
post #14

Earlier quoted context omitted.

> I’m not really sold on why Go would be a particularly good fit for the task, compared to other languages. Can't every language rock for building a Lua interpreter? It isn't a competition.

I think that’s re-interpretation, making the subject of the article about “why go rocks” shows the author thinks Go has something over other languages. Otherwise it’s like saying “why orange cats are fluffy” then saying stuff that applies to all cats without orangeness specificity

> shows the author thinks Go has something over other languages.

How so? It is clearly just a story of someone's experience, not a technical evaluation of various languages. The only other language (aside from Lua) mentioned is C, and the C implementation was considered so good that it was to be the direct model for the implementation in the story, so we can assume that writing a Lua interpreter in C also rocks.

> Otherwise it’s like saying “why orange cats are fluffy”

Sure. That seems like a reasonably fair title for a story about your fluffy orange cat, even if other cats (and other animals, not to mention other things that aren't animals) are also fluffy. You could call it "Fluffy" instead, I suppose, but then someone would complain about the lack of details. You can never please everyone.

But, regardless of how you want to interpret the title, it remains that there isn't a competition. There never has been, never will be. A poorly written title wouldn't magically create a competition. Where does the bizarre idea that there is one stemming from?

Re: Why Go Rocks for Building a Lua Interpreter

#27
post #14

Earlier quoted context omitted.

> I’m not really sold on why Go would be a particularly good fit for the task, compared to other languages. Can't every language rock for building a Lua interpreter? It isn't a competition.

I think that’s re-interpretation, making the subject of the article about “why go rocks” shows the author thinks Go has something over other languages. Otherwise it’s like saying “why orange cats are fluffy” then saying stuff that applies to all cats without orangeness specificity

As the author of the article, I'll say that my intent was to share the good time I had writing a Lua interpreter in Go. Other folks in the thread are right: more than one thing in this world can rock. :)

Re: Why Go Rocks for Building a Lua Interpreter

#28
post #26

Earlier quoted context omitted.

I think that’s re-interpretation, making the subject of the article about “why go rocks” shows the author thinks Go has something over other languages. Otherwise it’s like saying “why orange cats are fluffy” then saying stuff that applies to all cats without orangeness specificity

> shows the author thinks Go has something over other languages. How so? It is clearly just a story of someone's experience, not a technical evaluation of various languages. The only other language (aside from Lua) mentioned is C, and the C implementation was considered so good that it was to be the direct model for the implementation in the story, so we can assume that writing a Lua interpreter in C also rocks. > Ot…

Usually when something "rocks" it is better than other things in some way. I guess it can mean anything though.

Re: Why Go Rocks for Building a Lua Interpreter

#29

Go rocks for pretty much everything

Go routines are very nice. Way better than async await nonsense in other languages. if err != nil {return .., err} gets pretty tedious however. Everything tends to be very mutable / nullable as well which could be better. Also not really any faster than Java/C# - just another GCed language.

Re: Why Go Rocks for Building a Lua Interpreter

#30
post #26

Earlier quoted context omitted.

> shows the author thinks Go has something over other languages. How so? It is clearly just a story of someone's experience, not a technical evaluation of various languages. The only other language (aside from Lua) mentioned is C, and the C implementation was considered so good that it was to be the direct model for the implementation in the story, so we can assume that writing a Lua interpreter in C also rocks. > Ot…

Usually when something "rocks" it is better than other things in some way. I guess it can mean anything though.

"Rocks" is most commonly used in the context of (rock) music. A statement like " rocks!" usually indicates that someone enjoys said band. But what makes you think it also means that they see other bands as now being inferior in some way?

As far as I can tell, most people who find a band that "rocks" also enjoy other bands as well, often even more, and are not looking for some kind of a battle of the bands to find the one true band that they will only ever listen to again. It is quite possible, and typical, for (rock) music fans to enjoy many bands.

You are right that words mean only what the speaker/author intends for them to mean, but in common usage there is nothing to suggest that "rocks" implies something is better than something else. It only suggests something in the vein of "I enjoy this". Besides, we know what the author meant as he has told us.

Even we were to agree that the title is poorly written, we know from other context that there isn't a programming language competition. This single title wouldn't suddenly make us think that there is one. So where has the idea that there is one coming from?

Post reply on HN