Go is a compiled, garbage-collected, concurrent programming language developed by Google Inc. [1]
Point-by-Point Comparison:
- Philosophy - Go [2] and Lua [3]
- Type system - Go supports static typing without inheritance or any relationships between types.
- Types - Go has a larger number of builtin types (e.g. integers of various sizes and signedness), whereas Lua code normally just uses the number type (typically floating point). For Lua, see also the [LNUM patch].
- Multiple return values - supported by both languages
- Strings are immutable in both languages
- C/C++ interfacing - Well developed in Lua (BindingCodeToLua). Go can link to C using cgo[4] and SWIG now supports Go. [5].
- Concurrency - Lua and Go both support forms of coroutines ("goroutines" in Go). Go has channels, making concurrency safer, and the goroutines can be multiplexed over concurrent threads (see GOMAXPROCS runtime option).
- RAII/exceptions - Go's "defer" statement supports execution on scope exit (function not block level) [6]. Lua doesn't natively support it, but see ResourceAcquisitionIsInitialization. Go and Lua don't have a try-catch statement [7], but the pcall function in Lua is analogous, and similarly the panic/recover construct in Go.
- Standard library - Go is larger [8] and doesn't limit itself to ANSI C.
- Stability - Go 1 release is stable[[9]] and widely used in production[10]. Lua is a mature language and implementation. See also LuaFiveTwo.
- Compilers - Go has two full stable compilers, the main 'gc' compilers, and gccgo[11], there is also an llvm frontend in progress: llgo[12]. Lua has LuaImplementations.
- Syntax - Go follows C brace and comment syntax closer than Lua though still deviates from C in many ways [13].
- Runtime speed - Both Lua and Go emphasize efficiency, especially for the LuaJIT implementation of Lua. Go is readily a compiled language.
- Compilation speed - Both Lua and Go emphasize speed of compilation. Go has a novel approach in handling big project trees, resulting in exponential speed gain.
- Pointers - Go has pointers but no pointer arithmetic, for safety [14]. Lua has no pointers.
- Garbage collection - Both Lua and Go use garbage collection.[15]
- Portability - Lua runs anywhere you have an ANSI C compiler. Go runs on unix-style systems and Windows. A Plan 9 port is on it's way.
- Go has named result parameters [16] (see also: Multiple Return Values mentioned above).
- Go has Python-style slices.
See Also
RecentChanges · preferences
edit · history
Last edited August 16, 2012 10:34 am GMT (diff)