Wasting time with Zig and Life

When I want to learn a new language I usually re-implement some algorithm I know well. In zig’s case I recreated a life program. If anyone is interested to see the result you can clone:

you will also need the zbox code from:

(the original zbox needs a fixes and an enhancement - push request sent)

Have fun


Looks fun! Perhaps you can share an example with https://asciinema.org/ ?

1 Like

Interesting utility. It works fine locally for both recording and playback. One not so small problem is that the files produced are big. Running a pattern for 20 seconds generates a 221M recording. Think this is a little bigger than most terminal sessions.

1 Like

Now you can waste time faster. I added multithreading to the program.

phreads are not all that much slower than the native linux futex based code in std.Thread, which has a broken Condition variable implementation (there are at least two issues with fixes for this problem). Now the life code is not using spin loops and benefits when add threads (at least until thermal throttling occurs…). You will now need to add -lpthread when building.

Lots of improvements here. The most important of which was fix SIGSEGVs that occured more often as threads were increased. Also quit not longer give randome SEGSEGVs. Autotracking code as update and usizes replaced with u32 where possible.

1 Like

Now about 20% faster.

Was interested in looking at the code but then immediately saw GPL3. I’ll have to avert my gaze lest any code I write after looking at this code is liable to be considered “derivative work” forcing me to use a GPL-compatible license in my code. If you decide to use a different license let me know so I can take a look :slight_smile:

Would GPL2 make you happier?

GPL is “highly infectious”, even GPL2. If I were to look at your code, and I see a single line of code that I like and mentally “copy” it to one of my own projects, then my entire project must use a GPL-compatible license to be complaint with the GPL.

This is more liability than I’m comfortable with given how much code I write and how many projects I contribute to. I only look at GPL code when I “have” to (such as the linux kernel code) and I think developers would be wise to do the same.

Given that, if you want to share your code without it being a liability for others, I would choose a more open license like MIT, Apache, Bsd, Unlicense, etc. But that’s up to you. If you want to prevent your code (and the ideas) from being used in non-free software, then stick with the GPL. If you want others to be able to look at and use your code without having to worry about complying with the GPL, then make it more open.

I changed the license to Apache version 2. However I do think you are taking derivative work MUCH to broadly. While code copyrighted by under exclusive licenses by large corps need to be ‘cloned’ with clean room rules, I have never seen this applied to GPL licences. If some one based their code (copied large chunks of source) on a GPLed program and did not follow the rules that is one thing. If they make new code, using an idea, from a GPLed program they might have problems if they tried to patent it (prior art), but I have not heard of any cases where the idea forced the new code to be a derivative work. Do you have examples of where/when it has happened?


However I do think you are taking derivative work MUCH to broadly.

As I understand there isn’t much consensus on what is considered “derivative work”, so the amount of liability is unknown. However, the consequence of being on the wrong side of it could be dire given how much code I write and how many projects I contribute to. So it seems prudent to limit my consumption of GPL code to only when necessary.

If some one based their code (copied large chunks of source) on a GPLed program and did not follow the rules that is one thing.

As I understand, if your project contains any GPL code, the entire project must be licensed under a compatible GPL license. So even if you copied 1 line of code from a GPL project, it would affect the entire project’s license. But the GPL doesn’t even say you need to “copy” code, it could contain code that is considered “derivative work”, which as I understand is not well-defined. This could require as little as “taking ideas” or as much as “verbatim chunks”. Since it’s not well-defined, any amount of code “osmosis” becomes a liability.

If they make new code, using an idea, from a GPLed program they might have problems if they tried to patent it (prior art), but I have not heard of any cases where the idea forced the new code to be a derivative work.

To reiterate my answer to this is “I don’t know” so I error on the side of caution. The GPL doesn’t seem to elaborate on this so it would likely be up to each copyright holder’s idea of what they think could be considered “derivative work” and what the courts decide. If there was a precedent and legal cases that show that reading source code and using the ideas from it would not constitute a derivative work, then I would reconsider my hesitance on keeping my eyes away from GPL code.

I think this is an example of this issue: https://www.techradar.com/news/this-popular-code-library-is-causing-problems-for-hundreds-of-thousands-of-devs#:~:text=A%20license%20incompatibility%20in%20an,licensed%20Ruby%20library%20called%20mimemagic.

That seems to be an example of the GPL working. There was no dispute that GPL code had been reused improperly. So the developer did the correct thing and changed his license. The point that I was making is that “derivative work” historically (the GPL has been has not be considered when reusing an idea). It required that code be reused. The GPL is not new. Its been around since 1991 (V2) and 2007 (V3). IMHO if reuse of ideas or very small snippets of code was a problem it would have shown up in the 31 years its been around.

Lets close this discussion - Since (1) I did update the license to Apache V2 and (2) because I do understand why you want to be cautious. While I do believe it is over kill - you are very entitled to your opinion.


I like to keep discussion open. I think it’s good to discuss these things, I don’t want to disuade people from sharing more examples and their own experiences.

1 Like

I have no problem with keeping it open.

This site has a list of cases involving the GPL: Migrated/GPL Enforcement Cases - FSFE Wiki

And lots of questions about the GPL are answered here (I’ve quoted one Q&A):


"Can I use snippets of GPL-covered source code within documentation that is licensed under some license that is incompatible with the GPL?))

If the snippets are small enough that you can incorporate them under fair use or similar laws, then yes. Otherwise, no."

IMHO opinion, this is saying that just reading GPLed code or reusing an idea is okay.

I have no problem with keeping it open.

Maybe I misunderstood you when you said “Let’s close the discussion”? I’m enjoying the discussion and am interested in hearing other people’s perspective on these sorts of things.

“If the snippets are small enough that you can incorporate them under fair use or similar laws, then yes. Otherwise, no.”

I think this person you’ve quoted may not understand “fair use”. It sounds like they are saying that if you only copy a small snippet of code that it would automatically fall under “fair use”. As I understand, the purpose of “fair use” is to allow copyrighted work to be used for specific reasons like education, criticism and/or parody. If someone uses copyrighted material outside of these specific reasons, even if its a single line of code, then I don’t see how that could be considered “fair use”. Not to say that the amount copied doesn’t matter, it does, but including just a snippet is by no means enough on its own to qualify for “fair use”.

As to how this would apply to my everyday life. This means I don’t copy code to be used in my own project, even a single line, unless its released under a license I’m able to comply with. The exception to this is if my usage would be considered “fair use” which would include things like copying the code to include in an article I’m writing about said code, or including it in a meme/joke I’m making about the code, etc

I should also mention that I believe what I’ve said here only applies to “verbatim” copies. One you start “transforming” the work then it’s even easier to qualify for “fair use”. This “transformative” concept under fair use is similar to the idea of “derivative work” under the GPL. If I see two similar pieces of code, is one a “transformative copy”/“derivative work”, an “inspired original” or maybe the similarities are “coincidental”? The reality of how the two works were created is irrelevant, the only thing that matters is what can be proven in court. This is why I think it’s wise to exercise some discretion into what code you consume.

A few more quotes from that gnu.org website

"In an object-oriented language such as Java, if I use a class that is GPLed without modifying, and subclass it, in what way does the GPL affect the larger program?

Subclassing is creating a derivative work. Therefore, the terms of the GPL affect the whole program where you create a subclass of a GPLed class."

and (the interesting part of this Q&A are the Bison provisions)

"Can I use GPL-covered editors such as GNU Emacs to develop nonfree programs? Can I use GPL-covered tools such as GCC to compile them?

Yes, because the copyright on the editors and tools does not cover the code you write. Using them does not place any restrictions, legally, on the license you use for your code.

Some programs copy parts of themselves into the output for technical reasons—for example, Bison copies a standard parser program into its output file. In such cases, the copied text in the output is covered by the same license that covers it in the source code. Meanwhile, the part of the output which is derived from the program’s input inherits the copyright status of the input.

As it happens, Bison can also be used to develop nonfree programs. This is because we decided to explicitly permit the use of the Bison standard parser program in Bison output files without restriction. We made the decision because there were other tools comparable to Bison which already permitted use for nonfree programs."

more info on this can be found at: GNU General Public License v2.0 w/Bison exception | Software Package Data Exchange (SPDX)

" Bison Exception

As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn’t itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception.

This special exception was added by the Free Software Foundation in version 2.2 of Bison."

This one is also interesting:

My take… obviously I’m not an authority…

The minute an open source license prevents you from doing what you want with some code, then it has violated the spirit of openness.

Great harm has been caused to the entire ecosystem in the form of duplication of effort, sometimes using a poorly implemented replacement, and an unwillingness to cooperate between various camps over license issues. FreeBSD had zfs for -years- before Linux had it, all due to license concerns. It’s likely that people lost data during that time that needn’t have been lost if they had zfs. The entire Gnome project probably would never have gotten off the ground if people hadn’t been concerned with the QT licensing issue, because the community would have rallied around KDE, perhaps making it a better desktop in the process.

Maybe I leave myself open to legal challenges, but as long as the code is open source, I consider it fair game. And I feel that we would advance the state of the art a lot faster if everyone did the same. My own projects mostly use the Beerware License, Revision 42.