DEV Community

Cover image for I Left Go for JavaScript After 3 Months (Yes, I'm Insane)
Benjamin Koimett
Benjamin Koimett

Posted on

I Left Go for JavaScript After 3 Months (Yes, I'm Insane)

I learned Go for three months. Made a few CLI tools, wrestled with pointers, felt smart.

Then I switched to JavaScript… a week ago. Yesterday I finally understood for loops and regex. Today I'm writing this article instead of crying.

Here's what the journey has been like so far. Spoiler: my brain hurts, but I'm laughing.

Day 1: "Wait, no types?!"

In Go, you write:

var age int = 25
Enter fullscreen mode Exit fullscreen mode

In JavaScript, you write:

let age = 25;   // cool
age = "twenty five"; // still cool?! 
Enter fullscreen mode Exit fullscreen mode

I stared at my screen for 5 minutes. No compiler yelling? It felt like a teacher leaving the classroom. Pure chaos.

Then I tried "2" + 2 and got "22". Go would never. JavaScript is like that friend who says "yeah sure whatever" to everything.

Day 3: Loops… finally loops

I know loops from Go. for i := 0; i < 10; i++ – simple.

JavaScript has:

  • for
  • for...in
  • for...of
  • forEach
  • map

I asked my roommate which one to use. He said "depends". I said "depends on WHAT". He walked away.

I just use the normal for loop. It works. I'm happy.

Day 4: Regex (send help)

Go regex: re := regexp.MustCompile(\d+) – weird but fine.

JavaScript regex: /d+/ – wait, no quotes? And slashes? And why does test() exist but also exec() and match()?

I spent 20 minutes trying to get a simple email validator. My code worked. Then it didn't. Then it did again. I haven't slept since.

Joke break:

Why did the JavaScript developer go bankrupt?

Because he used == instead of === and his bank thought "0" meant zero dollars AND free money.

Day 5: The undefined abyss

In Go, variables have zero values (0, "", nil). Predictable.

In JS, there's undefined AND null.

I tried to print a variable I forgot to declare: undefined. No error. Just… nothingness.

Then I accidentally typed console.log(agee) instead of age. Still undefined. No crash. JavaScript just shrugged at me.

I miss Go's "agee not declared" slap on the wrist.

Day 6: Semicolons – to use or not to use?

Go forces semicolons behind the scenes. Fine.

JavaScript? You can skip them. But sometimes skipping breaks everything. Automatic Semicolon Insertion (ASI) sounds like a disease.

I now put semicolons everywhere. Even after if statements. Sue me.

Day 7: One week review

Thing Go JavaScript
Types "You shall not pass" "Eh, do whatever"
Loops One kind, works fine A zoo of options
Regex regexp.MustCompile /slashy bois/
Errors if err != nil everywhere try { } catch(e) { } then forget to catch
Fun level 7/10 (serious fun) 9/10 (chaotic fun)

Should you switch after 3 months of Go?

Only if you enjoy pain and laughter in equal measure.

I'm still terrible at JS. But every time something breaks in a hilarious way, I learn something new. Like yesterday: I learned that [] + [] is an empty string. WHY.

Anyway, back to studying regex. Pray for me.


P.S. If you know why [1,2] + [3,4] equals "1,23,4" – please comment. I need therapy.

Top comments (2)

Collapse
 
ahmad_shokry profile image
Ahmad Shokry

Learn JS .. but never use it 😅

Collapse
 
bwanachairman profile image
Benjamin Koimett • Edited

At this rate, I'm just learning languages for fun 😅