I am working on fedi software that is hoping to allow Kodi, Plex and Popcorn Time get rid of IMDb/TMDB dependency. Dm me if you're skilled in SvelteKit and/or Go, especially the Fiber framework, or machine learning with Rust and willing to contribute.

  • 1 Post
  • 23 Comments
Joined 10 months ago
cake
Cake day: September 10th, 2023

help-circle


  • Rust's memory safety is much different (ownership, lifetimes, immutability). Also Rust has null safety while Go doesn't. Go has some uninitialized variable use protection, but you can still screw up if you do stuff like accessing a struct field that hasn't been assigned a value. In C there's much higher chance of segfaults, use-after-free precisely due to manual memory management (malloc and free, which do not exist in Go). For example earlier versions of Java and most interpreted languages of the past whilst offering memory safety, consumed a lot of system resources, making them unsuitable for performance critical things like games, drivers etc.

    Then innovations in memory management and the resulting safety improvements and easier development these new languages offer allowed using them for writing performance critical code. Hope that answers your question.





  • In short when a program runs, it allocates memory for the data it is using. Then the garbage collector which you can think of a 'program' (though not in a strict sense, just a part of the runtime), takes care of freeing the memory which is no longer needed. In languages with manual memory management, like C or C++ it is up to the programmer to properly (de)allocate memory, which might result in issues like dangling pointers (references to already freed memory, which might cause unpredictable behavior and compromise your whole system's security) or memory leaks (gradually increasing memory usage over time in absence of user action that would prompt that, like e.g. opening more and more browser tabs, which is also partly why in the past you've often had to restart your PC every once in a while to free some trashed memory. In Go most of the stuff is done by GC and only code that uses the unsafe package or relies on external resources, like reading a file or database connection needs to have programmatic termination of access to these (usually by calling something like defer db.Close() ).

    Also Go is a nice balance between low and high level, one of such examples is the use of pointers. They might be complicated for most beginner coders, but in reality there is seldom any use of uintptr, double pointers and even slice (list) pointers, but it has a tremendous performance amount since when you do some operation, especially loops where without a pointer you would copy the data you're iterating through by value instead of just it's memory address.

    Which is especially important with large sets of data, where 160 bytes might seem miniscule with one call, but if you loop over 1 million records, that's 160 MB (for example in some database used by municipal authorities of a large city). That's one of the reasons some databases like CockroachDB were written in Go.




  • Also one really good practice from pre-Copilot era still holds, that many new users of copilot, my past self included might forget: don't write a single line of code without knowing it's purpose. Another thing is that while it can save a lot of time on boilerplate, you need to stop and think whenever it's using your current buffer's contents to generate several lines of very similar code whether it wouldn't be wiser to extract the repetitive code into a method. Because while it's usually algorithmically correct, good design still remains largely up to humans.












  • Why not gitignore the build artifacts and either publish them with releases or include a build directive in makefile/justfile? I mean, your platform might not be someone else's. Also consider using less global variables and shortening your main() in favor of dedicated functions ( that can still run in a loop inside main()) and using shorthand := assignment. Otherwise good job with documenting your code well.

    PS, this one's more of a marketing tip really: try including a GIF in README.