Mostafa Qanbaryan

Mostafa Qanbaryan

I'm a decent developer... but not a good writer!

I’ve always loved to test new things, and one of my favorites are new programming languages.

And right now… It’s golang!

In my career, I’ve worked with different kind of programming languages: PHP, Python, Javascript and even Java and C#!

I didn’t like some of them (Python), and I even hated a few of them (I’m looking at you, Java!). But each one of them had it’s benefits and beauties.

As I said before, I’ve chosen PHP to work with.

You may ask why, and this is my answer:

  • PHP is great for web development. You can bring a website up without any hassle
  • It’s good for writing Fullstack websites
  • It has a good job market in my country (at least for now)
  • And most importantly, It has Laravel Framework

I like working with PHP and Laravel.

But after all these years, I wanted to try something new. That’s where Golang enters.

Why Golang? Isn’t Rust Better?

So, a few days ago, one of my coleagues asked me, why I chose Golang and not Rust?

I’ve worked with Rust a little and wrote a tiny plugin for zellij. And I follow the language and tools that are rewritten by it. But Rust is not really a good language for web development. It’s so overwhelming and I really hated tokio (ohh, that’s a strong word for something that I didn’t work with!).

IMO, creating a website with Rust is like tightening a screw with hammer: it works, but it’s not ideal.

If PHP Is So Great, Why Leave It Then?

I’m not leaving PHP at the moment. It’s a good programming language and it’s how I make a living.

But recently, We had a problem at work that PHP couldn’t solve.

You see, we have a Graphql API at work that has fine-grained authorization: It means each row and column (therefore each cell) must be authorized (I will speak about that in the future).

We are using Casbin as our authorization system and as they said themselves here, each check could take up to ~24ms.

So for example, for a page that has 100 rows and 10 columns, 1,000 checks should be done and that means… 24000ms or 24 seconds… that’s a lot… and of course, that is golang’s benchmark. The PHP one is much worse!

Casbin and Golang

Casbin’s main library is written for Golang and has some great features. Like BatchEnforce.

Of course, I don’t know if it’s just a for... range loop and Enforce or something else (It’s open-source, you can read it and find out), But it’s much faster than PHP Enforcer.

So we decided that give Golang a chance and migrate our authorization system. It took about 1 week to completely migrate from PHP to Golang version of Casbin, and in my opinion, it totally worth it.

Before the migration, some pages took 18 seconds for authorization. That same page with BatchEnforce of Golang, took 5 seconds! And with the help of goroutines, the same page took 2.5 seconds to load up!

That’s 720% boost performance!

So What? Now Write Everything In Golang?

Of course not! As I said, Laravel is really powerful and has a lot of features and solved a lot of problems that in my opinion, Golang still has.

Maybe someday I wrote a whole backend with Golang entirely, But currently, there is no good structure or framework like Laravel that I could go to and create a website in no time.

I know a lots of gophers say that in golang, you don't need that or There is some Laravel like ORMs/Frameworks for golang, but it’s not quite the same.

Golang is a really good language and I’m happy that it can solve some of my problems, and soon… hopefully all of them.

If you want to #HireMe, take a look at my resumé