Difference between revisions of "Go"

From RogueBasin
Jump to navigation Jump to search
 
(15 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Programming language| name = Go
{{Programming language| name = Go
|company = Google
|company = Google
|influences = C, Python
|influences = C, Pascal, Python, Smalltalk
|updated = 2013-08-13 (1.1.2)
|updated = 2021-02-16 (1.16)
|status = Stable
|status = Stable
|licensing = Open Source (MIT License)
|licensing = Open Source (BSD-style)
|platforms = Linux, OS X, Windows, FreeBSD
|platforms = Linux, OS X, Windows, FreeBSD, Plan 9, Solaris
|site = http://golang.org/}}
|site = http://golang.org/}}


'''Go''' is a programming language announced by Google in November 2009. It is a native-code compiled, garbage-collected, concurrent language, born from the developers' frustration with developing concurrent server applications with C++. Version 1 of Go was released in March 2012, and should be a stable target for future applications.


== Roguelike Issues ==
Go (or ''golang'') is a general-purpose, statically typed compiled language, with garbage-collection and explicit support for concurrent programming, that has been created at Google by Rob Pike, Ken Thompson, and Robert Griesemer since 2007. It was born from the developers' frustration with developing concurrent server applications with C++.


Go has several modern programming features, such as garbage collection and closures, which help when developing roguelikes. It has a reasonably simple duck-typing-based object system, which is clean, but doesn't necessarily match the complex problem of roguelike data modeling. The concurrent features aren't much needed in main roguelike logic, which is generally very sequential, but can help when programming an user interface that runs asynchronously with the game logic.
First announced at [https://www.youtube.com/watch?v=rKnDgT73v8s Google Tech Talks] (YouTube), in October 2009, version 1.0.0 was released in March 2012, and they currently follow a 6 month release cycle, with new major versions being released on February 1 and August 1, so the language should be a stable target for future applications.


Go has two compilers, the standalone '''gc''' one and a GCC front-end '''gccgo'''. The official GCC distribution has included the Go front end since version 4.6. The gc toolchain supports Linux, BSD, OS X and Windows on x86-32 or x86-64. Gccgo uses GCC as a backend, and can theoretically target any platform supported by GCC. As of 2012-07, there is some ARM support, but Go is not suitable for the standard type of Android app development, where native code is compiled into a dynamic library invoked by a wrapper application in Java, since Go code cannot be easily compiled into a dynamic library.
== Roguelike Development ==


There is FFI support for linking to external C libraries like [[SDL]] or [[Curses]]. Calling C code from Go is reasonably straightforward.
Go has a number of features that can be desirable to the roguelike developer:


As of 2012-08, there is a long-standing [http://code.google.com/p/go/issues/detail?id=909 issue] which makes garbage collection occasionally fail and the application to eventually run out of memory with some memory use patterns on 32-bit Go applications. 64-bit applications do not have the problem. This may be an issue for games, which can use complex memory allocations and run for a long time.
* Easy to learn - a simple language with a small number of keywords.
* Garbage Collection.
* Fast - faster than Java in most use cases [https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/go.html (citation)], considerably faster than Python.
* Super fast compile speeds - often just a few seconds, which compared to compiling C++ code, is several orders of magnitude faster.
* Compiles to a native OS binary, allowing you to keep you source code private.
 
The language has a reasonably simple duck-typing-based interface system, which can lead to very clean reusable code.
 
The concurrent features such as channels and goroutines are powerful, but often are not much needed in main roguelike logic, which is generally very sequential. That said, several areas could gain some benefits, such as game initialisation, dungeon generation, user interface, and other features that can run asynchronously with the game logic.
 
One of the more recent additions to the language that may bring great benefits to roguelike developers is the ability to cross compile for different OS. This means that a game being developed on a macOS system, can compile for Windows and Linux without the need to boot into those operating systems. In the future it will also be possible to use Go to target Android devices.
 
There is also good FFI support for linking to external C libraries like SDL and Curses. Calling C code from Go is reasonably straightforward.
 
For Go developers who wish to use Curses, there is the [https://github.com/rthornton128/goncurses goncurses] library, however a good alternative is the excellent [https://github.com/nsf/termbox-go Termbox-Go], which provides a cross platform lightweight ncurses-like API written in pure Go.
 
[http://foo.wyrd.name/en:bearlibterminal/ BearLibTerminal] is compact, display-centered API for roguelike developers. It supports Go bindings officially.
 
If you don't want to rely on a binding or stay in the terminal you can try out [[ramen]]. It's a simple console emulator written go and inspired by libtcod.
 
You can also try the [[gruid]] framework that offers terminal, SDL2 and browser drivers. It provides many additional features, such as pathfinding, FOV and map generation.
 
==References==
{{Reflist}}


== Related Links ==
== Related Links ==


* [http://go-lang.cat-v.org/ Go Programming Language Resources at cat-v.org]
* [https://tour.golang.org/ A Tour of Go at golang.org]
* [https://golang.org/doc/code.html How to Write Go Code at golang.org]
* [https://golang.org/doc/effective_go.html Effective Go at golang.org]


[[Category:Programming languages]]
[[Category:Programming languages]]

Latest revision as of 15:41, 5 January 2023

Go
Programming Language
Company Google
Influences C, Pascal, Python, Smalltalk
Updated 2021-02-16 (1.16)
Status Stable
Licensing Open Source (BSD-style)
Platforms Linux, OS X, Windows, FreeBSD, Plan 9, Solaris
Official site of Go



Go (or golang) is a general-purpose, statically typed compiled language, with garbage-collection and explicit support for concurrent programming, that has been created at Google by Rob Pike, Ken Thompson, and Robert Griesemer since 2007. It was born from the developers' frustration with developing concurrent server applications with C++.

First announced at Google Tech Talks (YouTube), in October 2009, version 1.0.0 was released in March 2012, and they currently follow a 6 month release cycle, with new major versions being released on February 1 and August 1, so the language should be a stable target for future applications.

Roguelike Development

Go has a number of features that can be desirable to the roguelike developer:

  • Easy to learn - a simple language with a small number of keywords.
  • Garbage Collection.
  • Fast - faster than Java in most use cases (citation), considerably faster than Python.
  • Super fast compile speeds - often just a few seconds, which compared to compiling C++ code, is several orders of magnitude faster.
  • Compiles to a native OS binary, allowing you to keep you source code private.

The language has a reasonably simple duck-typing-based interface system, which can lead to very clean reusable code.

The concurrent features such as channels and goroutines are powerful, but often are not much needed in main roguelike logic, which is generally very sequential. That said, several areas could gain some benefits, such as game initialisation, dungeon generation, user interface, and other features that can run asynchronously with the game logic.

One of the more recent additions to the language that may bring great benefits to roguelike developers is the ability to cross compile for different OS. This means that a game being developed on a macOS system, can compile for Windows and Linux without the need to boot into those operating systems. In the future it will also be possible to use Go to target Android devices.

There is also good FFI support for linking to external C libraries like SDL and Curses. Calling C code from Go is reasonably straightforward.

For Go developers who wish to use Curses, there is the goncurses library, however a good alternative is the excellent Termbox-Go, which provides a cross platform lightweight ncurses-like API written in pure Go.

BearLibTerminal is compact, display-centered API for roguelike developers. It supports Go bindings officially.

If you don't want to rely on a binding or stay in the terminal you can try out ramen. It's a simple console emulator written go and inspired by libtcod.

You can also try the gruid framework that offers terminal, SDL2 and browser drivers. It provides many additional features, such as pathfinding, FOV and map generation.

References

Template:Reflist

Related Links