Earlier quoted context omitted.
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.
Go can be way faster than those. Garbage collection is not an issue at all if you write efficient code And the error handling is way better than catching stuff because it’s so explicit
Why Go Rocks for Building a Lua Interpreter
41–50 of 61 posts
Re: Why Go Rocks for Building a Lua Interpreter
#42In particular, because Go is memory-safe, you don’t have the control over memory layout you need to do tricks like NaN-boxing. Anything that requires a union with a pointer (which will be every value in a dynamically typed language) must be represented as a value of interface type, and interface values are quite fat - 16 bytes on a 64-bit machine.
Interpreters are atypical programs to optimize. Few other programs use unions so much in their inner loop.
Re: Why Go Rocks for Building a Lua Interpreter
#43Earlier quoted context omitted.
Typescript chose Go specicfically because they didn't rewrite it. Go has close enough semantics to TypeScript that they could write a Go backend for tsc and do a machine port to Go and continue working from that
Didn't MSFT also fire the lead engineer for this project shortly after?
Re: Why Go Rocks for Building a Lua Interpreter
#44Performance is scarcely mentioned. It probably doesn’t matter that much for a build system. But for projects where it does matter, you won’t get performance in the same ballpark as a Lua interpreter written in C if you use Go. In particular, because Go is memory-safe, you don’t have the control over memory layout you need to do tricks like NaN-boxing. Anything that requires a union with a pointer (which will be every…
Most stuff people use in C for writing interpreters with optimal performance, isn't ISO C, rather C compiler specific extensions, or inline Assembly.
All things being equal, same rules apply.
Re: Why Go Rocks for Building a Lua Interpreter
#45Go rocks for pretty much everything
Re: Why Go Rocks for Building a Lua Interpreter
#46Performance is scarcely mentioned. It probably doesn’t matter that much for a build system. But for projects where it does matter, you won’t get performance in the same ballpark as a Lua interpreter written in C if you use Go. In particular, because Go is memory-safe, you don’t have the control over memory layout you need to do tricks like NaN-boxing. Anything that requires a union with a pointer (which will be every…
Re: Why Go Rocks for Building a Lua Interpreter
#47Performance is scarcely mentioned. It probably doesn’t matter that much for a build system. But for projects where it does matter, you won’t get performance in the same ballpark as a Lua interpreter written in C if you use Go. In particular, because Go is memory-safe, you don’t have the control over memory layout you need to do tricks like NaN-boxing. Anything that requires a union with a pointer (which will be every…
You can do raw memory access via the ‘unsafe’ package, so I don’t think it would be impossible to do NaN boxing in Go. It would be somewhat less convenient than in C.
And then since you’ve disabled the system GC, you need to write your own GC that understands NaN boxing to find out when memory can really be freed.
I see it as so awkward that it’s not worth doing.
Re: Why Go Rocks for Building a Lua Interpreter
#48Performance is scarcely mentioned. It probably doesn’t matter that much for a build system. But for projects where it does matter, you won’t get performance in the same ballpark as a Lua interpreter written in C if you use Go. In particular, because Go is memory-safe, you don’t have the control over memory layout you need to do tricks like NaN-boxing. Anything that requires a union with a pointer (which will be every…
Or do it like C in the age of K&R C, and compilers ramping up for C89 compliance, with a little bit of Assembly. Most stuff people use in C for writing interpreters with optimal performance, isn't ISO C, rather C compiler specific extensions, or inline Assembly. All things being equal, same rules apply.
Re: Why Go Rocks for Building a Lua Interpreter
#49Earlier quoted context omitted.
Or do it like C in the age of K&R C, and compilers ramping up for C89 compliance, with a little bit of Assembly. Most stuff people use in C for writing interpreters with optimal performance, isn't ISO C, rather C compiler specific extensions, or inline Assembly. All things being equal, same rules apply.
It’s different because Go is garbage collected. See my other reply.
Just sticking to the old ways is why we don't get progress in some industry corners.
Re: Why Go Rocks for Building a Lua Interpreter
#50Well 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…