KieranP / Game-Of-Life-Implementations

Conway's Game of Life implementation in various languages
MIT License
52 stars 8 forks source link

Go (golang) implementation #8

Closed DeyV closed 6 years ago

KieranP commented 6 years ago

@DeyV This is awesome. Thank you so much for your contribution. I'm currently away on a business trip, but will be back home this weekend, so will review and either merge or provide feedback then.

KieranP commented 6 years ago

@DeyV This is awesome. Thanks so much. I have committed it here: https://github.com/KieranP/Game-Of-Life-Implementations/commit/d9488531e320eba9fea29c530cf9366438765c3b

DeyV commented 6 years ago

An interesting fact for the drowned people 😉

In ‘go’ simple change from hash table to multi dimensional array can speed up this algorithm by 100x

Thx for merge

KieranP commented 6 years ago

@DeyV Thanks for the feedback. I'm aware of some potential speed boosts such as the one you mentioned. The same multi dimensional array approach would likely improve most of the implementations.

However, the point of this repo though wasn't for measuring raw/optimised speed (since there are many benchmarks all over the place that showcase those sorts of things). My purpose here is to:

a) showcase different constructs for each language (classes, loops, arrays, hashes, etc). Replacing the hash table with a 2D array would leave no other hash tables in the code, which would exclude a rather large part of many languages. b) write code that is easy to understand, pleasing to read, and a little bit naive (intentionally not optimised). If a language can run fast with unoptimised code, then it's going run even faster once optimised.

Also, since all implementations are written similarly, it's put them on an even playing field. I feel these implementations are actually a better benchmark, not of how a language could be, but of how people in general would probably write in that language.

DeyV commented 6 years ago

I'm understand that, so .. this is my code.

But You should know, that this is not "how people in general would probably write in that language".

For example building key's for hash table in this manner - You newer ever see in normal "go" codebase. I force myself to change variable and method name convention - my IDE was all yellow. And Go newer use spaces as whitespace - always tab - this is defined in global formatting rules and official tools.

Anyway - this in interesting project, and I had fan with that

KieranP commented 6 years ago

@DeyV Thank you. I do appreciate your points, especially regarding tabs vs spaces. I wasn't aware any languages actually enforced whitespace rules, very interesting, learnt something new :-)