In other words: Ruby, JavaScript or Go?
I applied to a position in a really nice company from Sillicon Valley, with an office in Berlin. In the job description I just paied attention to the fact that the person should know Python - the language I like most. π€
When the first email from the company arrived, I was very excited!
Hi Ana, Thank you for your interest in Bla! We would like for you to work on our Coding Exercise. Please let me know some times (indicate your time zone) when youβre available to work on this assignment. You will have 48 hours to complete it. Once you confirm a date with me, I will send it over to you. Please also indicate what you prefer coding in with the following options: JavaScript, Ruby, and Go. Looking forward to hearing back from you soon!
Hm… Where is Python?
I must confess that I read the email few times and for few minutes I wondered about what would be less worse for me: JavaScript, Ruby or Go?
To be honest, I felt frustrated at the first moment. After all, how could I get it right using a language that I don’t feel comfortable? Specially because those three languages were the same for me: I did a Hello World at least.
With Golang I dare to create a small web app (a personal phrases generator). With JavaScript I did some ugly code using jQuery many years ago and using Ruby just few scripts using the best of Go Horse style.
I couldn’t help my self, so I decided to ask on the internet, at last the people are always right, Vox populi, vox Dei.
Tweets in Brazilian Portuguese followed by an explanation:
Entre Ruby, JavaScript e Go: qual tem a menor curva de aprendizado em pouco tempo?
— Ana Paula Gomes (@AnaPaulaGomess) 13 de outubro de 2017
At the beginning of the conversation I was unwilling. As a Pythonist, it seems easier to go with Ruby, since both languages are similar. After all, I’m afraid of JS (π€) and as far as I remembered the Golang sintaxe was ugly (yes, this is a honest blog post).
So, let’s go to the qualifications: why not JS?
Sim, o background com certeza interfere. JS Γ© multi paradigma, e atua tanto client-side quanto server-side … por isso o tempo seria maior
— Yan MagalhΓ£es (@yaanmagale) 13 de outubro de 2017
Yan suggested Go and he summarized well the problem. JS is flexible and is everywhere. But I had no idea about which challenge I would face during the process. Thais almost read my mind and I crossed the name off the list.
Depende muito do background… Se for python eu diria Ruby, se for c go… Se for manicΓ΄mio js
— this Viana (@thaisviana) 13 de outubro de 2017
It depends from the background… If the background is Python, I would say Ruby, if is C, Go… If it is bughouse, JS.
At this stage, I was getting crazy: what will it be? An API? Algorithms?
Meanwhile, at the Hall of Justice, beyond the tweets tip, I asked recommendations for Rubist friends. After all, Python looks like Ruby, right?
Yes, that’s the problem.
Porque a linguagem Γ© mais simples mesmo, tem menos irregularidades e pegadinhas.
— Luciano Ramalho β (@ramalhoorg) 13 de outubro de 2017
Because the language is more simple, has less irregularities and gotchas.
In the meantime, I realized that Ruby could trick me with a self-confidence that I couldn’t have. And it would be a disaster.
Should I stay or should I Go?
Finally I decided: I would go with Go.
Well, time to draw up a plan. The email arrived and I must answer. I would have 48 hours to study and to answer the challenge! I tried to come up with some ideas of what would be important to learn in a programming language:
- Create variables, control flow, interations
- Main libraries
- Conventions
- Run
- Test
- How to organize a project
Many details for a short time.
At that time I got a subscription on Alura (in pt-br) and they have a basic Go trainning. I found the project used during the trainning interesting: creating a website monitoring, like pingdon. Something like that would give me the change to learn the sintaxe basics and the http library.
I did some exercises on Exercism.io to pratice problems resolution and I even try to create some small project during the weekend but no luck; I didn’t have as much time as I want to.
But I dedicated plenty of time reading and I found nice stuff, like:
Go In 5 Minutes - Short, helpful screencasts for professional Go developers
And more:
Code by Go lang official website
Avelino shared most part of this list, thanks man! ππ½
This talk, specially, it’s quite interesting. But how could I been thinking about Anti-Patterns since I have no Pattern in Go? Incredible as it may seem, I already had done mistakes in my few hours as a Go developer. But it was cool to being exposed to it to understand more about the language!
But… did I go to the bottom of all of it? Of course not
All those content have helped me along the road. I finally had started the challenge scared to death but at this point I wasn’t writing variables with snake_case. π In the middle of all of this, I had a trip of 26 hours ahead of me. To keep coding offline, I bought an e-book Programando em Go (pt-br).
Go at first sight
Like moving from Portugues to Deutsch, there are many many things we found different when moving from a language to another. In Go, for instance:
- Compiling error in unused variables ππ½
- Variables without a value are, by default, “”, false, 0, 0.0 ππ½
- There are just 25 keywords ππ½
- There is no try/catch ππ½
- Inheritance is different - try to build something like abstract classes might be awkard at the begining π€
- There is no while, only for ππ½
- You can create as many types as you want to ππ½
- Comments are highly recommended when you have public functions π
- Lot of code to do simple stuff like read and write files π
- Bizarre, the way to format dates π£
Well, I could list many things but I think these eye-catched me. As a beginner, I may be talking silly things - it’s part of the process.
Bonus: I used VSCode and I can say I was surprise how it helps me to learn. A lot of people are recommending it. The plugins for Go lang are quite mature and the IDE is fast.
Final thoughts
So, this was the odissey of learning Go. About the challenge? I just submited and I could pratice everything I listed above. From the design perspective, I had surprises with Go. As far as I understood, the language is structured but it’s possible to use with OO.
Was interesting to remember things like memory allocation and at the same time exercise software design to use better the language features in my favour.
Despite the gut feeling, was really nice to learn something new. I’d like to thank all the tweets and tips. Now it’s just crossed fingers! π€π½
See you soon!
os.Exit(0)
comments powered by Disqus