21
What I learned from building REST APIs in 3 different languages
While I was in bootcamp in 2020, I built REST APIs using JavaScript and Python.
Recently, using @karanpratapsingh's helpful tutorial, I got started on building a REST API in Golang.
It was during the process of following the Golang tutorial that certain things really clicked for me. I'm writing to share them with you!
Building a REST API enabled me to establish a CRUD pattern, whether I was doing it in JavaScript, Python, or Golang.
In each of those languages, I had many of the same considerations. Which CRUD operations did I really need for my end project? How was I going to handle errors? Security? Testing? I am now understanding by my own experience that API design can be language-agnostic!
Since I wrote my Python and JavaScript APIs in a fast-paced bootcamp, I was 'forced' to dive in headfirst after a quick review of language syntax. My Golang API is a side-project so there was none of that external pressure, and for that reason I put it off for a long time.
But after about the twelfth video on the ins and outs of pointers, I realized it was time to get started actually building something-- because getting to know language syntaxes is like getting to know people: learning the names is the beginning, but you have to start interacting with them to understand their behavior.
I know, shocker. ;)
But after working with them all I understand the differences better. When I only knew Python and JS, I thought maybe Golang was more like Python than I realize it is now, and that Python and JS were less alike than I think they are now.
I got hung up on the syntax differences -- try
and catch
in JS vs try
and except
in Python -- without realizing that these languages had some similarities as well. For example, JS and Python are both dynamically typed. You can declare a variable and the runtime gods will determine its type. Just try that with Golang! It won't let you, because you, as a Go developer, must declare a variable's type, it's not the runtime's concern.
As far as similarities go, all three languages also participate in object-orientation to varying degrees/in varying ways -- as always, this depends on how you define object-orientation! That could be a whole separate blog post so I'm stopping here.
If you normally build something in one language, try it in a new one! The perspective you gain may surprise you.
21