Why I Moved From Go To Rust
Why I Moved From Go To Rust

Prior to creating this application in Rust I was doing it in Go. Beautiful times. Go is just beautiful. Its syntax is pretty simple. Its source files tend to be short. I loved it. But there were 2 things that made me get off the Go-train.

1. CSRF Protection Inconsistencies

Coming from a web development background where cyber security is of paramount importance, CSRF protection of forms is pretty important. Go does have some libraries built for this but the most recommended is Gorilla's CSRF package. Not bad at all until you learn that the original developer of the library abandoned it. While Google took over the maintenance of the library not much action has been seen on it.

On top of it, the library had a pretty odd way of working. On production the library would crash with a nasty 'Invalid origin' error. Not to mention that the library suffers from memory leaks.

2. Templating Engine

While the Go standard's 'html/template' library's is good enough the Web Development space has been thoroughly affected by Jinja's rather simple syntax. Learning a new templating engine with its peculiarities can be confusing. On the other hand, Rust's Tera templating engine has been inspired by Python's Jinja so it was easier transitioning to it.

It is far intuitive to type this in Rust's Tera templating engine:

	
	{% for key in some_list %}
	  {{ key }}
	{% endfor %}
	

...than this in Go's 'html/template' library:

	
	{{ range .Somelist }}
	  {{ .Key }}
	{{ end }}
	

Strangely enough, while it took me 3 months to create just a tiny CRUD version of this blog in Go/Golang it has taken a month or so in doing it better and in a more advanced way in Rust. Perhaps it's just that I "understand" Rust better than Go/Golang. This is not to say that Go/Golang is bad. It has its use cases and may be I was trying to use it for something that it was not made for.

WORDCOUNT: 339 words.

Latest Blog Posts