https://new.pythonforengineers.com/blog/learning-go-as-a-python-developer-the-good-the-bad-and-the-ugly/ Python for Engineers * Home * About/Contact * Books * Blog Subscribe Learning Go as a Python Developer: The Good and The Bad * Shantnu Tiwari Shantnu Tiwari Jul 18, 2022 * 3 min read I've been thinking about supplementing another language to Python for some time - mainly to cope with areas Python struggles with, or is a pain to use (which I'll go over in a minute). I had used C/C++ some years ago, but don't want to go back to them. C is great for embedded work, but I wouldn't use it for anything else. C++ is a monster, everything from C-with-classes to whatever the latest version is with fancy new smart pointers. I looked at Rust, and while I understand the sentiment and reasoning, I felt I was constantly fighting the compiler/borrow checker/ whatever. I just want to write some code, dammit :) I had heard of Go for many years, but never stuck with it; it gets constant negative press on Hacker News/Reddit- every top post is: Why I gave up Go with reason 37 being iT dOesNT hAve gEneRIcs (yes, we got generics this year, I want to put in a rude joke about virgins and not enough sex but I guess I'm a family-friendly / my new employer-friendly blog now). Last few months, I slowly picked up Go again, and this time stuck with it. Problems with Python I have written about this before (and gotten hate), but let me give the tldr: * Python code is great if you control the machine. It's a pain if you want to share your code with others That's it- my main complaint. Sharing your code is even pain with colleagues even if they are using the same operating system, mainly because the Python requirement file doesn't pin dependencies, which means 2 people installing from the same requirements file can get different dependency versions (that said, Poetry fixes this problem, and is an awesome tool. I'm never using plain virtual envs every again). A few months ago, I rediscovered Go (using the great Head First Go book) and rediscovered the joy of Go. Go: The Good * The code just works! You can compile for any platform (like compile for Windows from a Linux machine) and have it just work without messing with virtual environments or installing libraries * It is fast- no doubt, mainly because it's a compiled language. * Unlike Python web apps, which need Wsgi (or something similar) in addition to Nginx, Go apps can run directly on a server with nothing extra needed. I did use a server for https, but the tool I used (Caddy, a great tool) comes with a Go library so you can get https directly in your Go code! Go: The Bad Sometimes, you just want to try some code or a new library. You don't care about it being perfect. But Go has a very school-teacher-like attitude to this- the smallest warning (unused import) and your code won't compile. Everything must be perfect, all i's dotted and t's crossed. The libraries for Go aren't as good as for Python- certainly, the documentation is lacking. For Python, you can find a dozen good libraries for anything you can think of; with Go, as soon as you get off the main Server coding Highway, libraries are hard to find, often abandoned, and usually without good docs. I especially struggled with the DynamoDb library for Go; so much so I wrote a Python script to query Dynamodb, and called it from Go. However, that might be due to poor documentation on Amazon's side. That said, the official Python libs for Dynamo weren't that hot either, but I did find great 3rd party libs that worked. And that's my point: This is easier for Python than Go. Minor quibble: I found the Go mod system confusing, but that just may be my own inexperience. I hate how it forces to you create a module everytime. I just want to try something out, why are you forcing me to create a module o_O There is a way to turn if off but it is non-intuitive and I only found it by chance. Final Words Overall, I really like Go- it's a great companion to Python. I die a little when I have to install a library, and it wants me to install Python or Node, as I know I'll be struggling with versions. Node is worse, as I find I have to constantly change the Node versions to get libs to work, they all seem to be built with different versions. Compared to this, Go programs are a joy. One executable, and it just executes without you having to jump thru hoops. If I ever build a tool I need more than 2 people to use, I would prefer Go. Go just works. Sign up to know when the next post is out, and get exclusive content Enter your email Subscribe My Poor Experience With Azure (or why I'm sticking with AWS) AWS has a lot of haters. Lots of horror cases where people thought they were on the free account but ended up with a $20,000 bill. We are told Azure has a much better model. You have to manually move to a paid service. No surprise bills. Like AWS, * Shantnu Tiwari Shantnu Tiwari Jul 13, 2022 * 3 min read Learning about AWS/Cloud by Building Practical Projects I heard about the Cloud challenge some time ago and liked the idea-- of building a practical project to show you Cloud/AWS knowledge. The challenge just builds a simple online resume, which is fine as the challenge is aimed at complete beginners. I decided to go one step ahead * Shantnu Tiwari Shantnu Tiwari May 18, 2022 * 4 min read The Problem with Most Programming Tutorials / Books Or Why they all suck (and how to improve them) I can't remember the number of tutorials / books on programming I've had to abandon, because the author jumped to advanced concepts too fast, or tried to teach too many concepts at the same time. Having worked with beginners and been * Shantnu Tiwari Shantnu Tiwari Apr 11, 2022 * 5 min read Python for Engineers (c) 2022 Powered by Ghost