All systems Go: Learning Go To Make NFTMart Images More Optimised and Faster to load

in #golang2 years ago

Hi everyone,

Long time no see, I know. I've finally gotten some time to sink my teeth into another language, which was motivated by the wonderful @foxon touting how awesome his experience with Go was.

Whenever I go (ba-dum tiss) to start a new language, I always find a project which can make good use of that language's features. As Go is known for being very fast due to its lower-level nature than the majority of languages I use, it had the benefit of increased speed.

The previous image server was a combination of a JavaScript server for some images, and third party URLs for other images. This lead to a very inconsistent user experience, and could mean some pages were slower to load than others. This also had the drawback of us not being able to optimise the images (via newer formats, such as WebP and via resizing the images to be more appropriately sized for our use case). Therefore, recently I took it upon myself to learn Go through the creation of a better Image Cache solution for NFTMart.

Firstly, major props to the Go developers. When I started the language was mostly very easy and intuitive to understand, and so I actually managed to finish the project (mostly, with a few bugs) within two days.

Of course, plain sailing is never an option when you first start, and I learned the hard way that you're on your own when it comes to locking and unlocking maps (or what some may call dictionaries, key -> value pairs), but fortunately the ever reliable @foxon let me know about Mutexes which allow you to store the Locked/Unlocked states in a safe way and make the code wait for the resource to be available.

Probably the best thing is that unlike JavaScript, Go developers tend to use libraries more sparingly, meaning less dependency hell, and we haven't had to update any libraries due to vulnerabilities (yet!) but usually that happens for javascript very quickly.

Anyway I hope you enjoy this probably incoherent post :P (but at least you know I'm not dead)
~ CA

Sort:  

Not exactly a beginner project! Nice work

Gracias por su voto.

Lots of new stuff here I don't even know lol! Indeed learning is a continuous process.