DEV Community

Cover image for What I learned from building REST APIs in 3 different languages
Lucia Cerchie
Lucia Cerchie

Posted on

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!

1. The basics of REST APIs are the same in all three of these languages

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!

2. It's ok to build something without having memorized every last bit of the syntax

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.

3. Python, JavaScript, and Golang are all different languages

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.

Conclusion

If you normally build something in one language, try it in a new one! The perspective you gain may surprise you.

Top comments (4)

Collapse
 
nasrulhazim profile image
Nasrul Hazim Bin Mohamad

API can be written in any programming language. usually there is API gateway that expose the APIs, that sometimes written in different kind of programming languages. Usually these APIs called as polyglot, doesn't matter what programming languages, as long it serve as API.

Collapse
 
briankopp profile image
Brian Kopp

Nice article! There are also significant runtime differences in the languages, like how they handle threading, async, and such. These become things to consider when building more complex apps.

Collapse
 
cerchie profile image
Lucia Cerchie

Say more!

Collapse
 
cerchie profile image
Lucia Cerchie

Thanks Dewald, glad you liked it!