mfashby.net

Website mfashby.net
git clone git://code.mfashby.net:/mfashby.net
Log | Files | Refs | Submodules | README

2023-09-12-mcl.smd (1554B)


      1 ---
      2 .title = "Mcl (minecraft launcher)",
      3 .author = "Martin Ashby",
      4 .date = @date("2023-09-12T07:03:15+01:00"),
      5 .layout = "single.shtml",
      6 .custom = {"comments": true},
      7 ---
      8 
      9 I wrote a [minecraft launcher](https://code.mfashby.net/mcl/about/) in [zig](https://ziglang.org/) as a learning exercise. 
     10 
     11 I got a lot of practice writing zig code and I learned a few things about it.
     12 
     13 - The [GeneralPurposeAllocator](https://ziglang.org/documentation/master/std/#A;std:heap.GeneralPurposeAllocator) is really useful for finding memory leaks, as is the std.testing.allocator for use in tests.
     14 - The standard library HTTP client is really cool, but unfortunately fails on a lot of websites because it lacks TLSv1.2 support.
     15 - Calling into C code is really easy. I used [libCURL](https://curl.se/libcurl/) instead of the zig stdlib and it was easy to write a wrapper around it.
     16 - The standard library JSON parsing is good, but error messages are not verbose enough to help you and by default they don't indicate _where_ in the tree the problem is. This can be added but it's not obvious how to do it (spoiler: set the .diagnostics element on a std.json.Scanner). For types which the standard library can't cope with, there is an escape hatch: implement jsonParse method for that type.
     17 - The builtin module has useful constants for checking the current operating system and CPU architecture, which I used for hacking in linux-aarch64 support.
     18 
     19 Finally however, I learned that minecraft on the pinebook pro sucks :( It's just not got enough power to run the game well.