November 5, 2018

Learning how to parse

Intro 

I already forgot why my compilers class was not good, it was the teacher or it was not in my speciallity in electronic. But I heard once that if you know how to parse files you can do any challenge that presents.

I think it is not sure but I think it is a great skill that I want to have. 4 months ago I did some work generating code in Golang and I feel to generate code and compile it is a great feeling.

What and how decide to learn parsing

Well I always wanted to read the official compilers book (the one with the red dragon) but it starts with lex and flex, it is interesting but I want something newer. And because I just want the skill. I was fine with flex and bison but it turns out that I can't parse utf8 in a simple way and the actions could be only in c/c++. So I decide to start from the end. I will learn Antlr4.


Only Perl can parse Perl 6

Right now I am working with Perl and I was wondering: "should be nice if you can parse Perl to other languages" It is a hard task to parse any language to other but. After google and read  I found that Perl can only be parsed with Perl. So I was thinking in stop wondering. But there is a little hope.

It is called PPI Parse, Analyze and Manipulate Perl (without perl) that was interesting. And this is an example:

PPI - Parse, Analyze and Manipulate Perl (without perl)

There is other plan where I want to use the parser skill.

But that is other story

September 10, 2018

flow.state@work

I just change to a new gig and it feels awesome, you know this smell a new is so nice. 

When I told about my new job to a friend from my first work ever he just laugh and tag me as millennial. I feel a little contraried but at the end he was right so I continue with my life.

The things I like most is all this culture around Linux, there are very talented people in the company so I am actually learning new stuff related to Linux.
So this use of ssh and servers and commands and command line is like wow I enjoy it. 

So today I noticed that I was in the flow state when I finished and felt good about the work that I had done during this day when I suddenly remember that I need to pick up my daughters. And I was 8 minutes late.

June 19, 2018

What I like about go generate

I like when a project that uses it, compiles and runs before and after go generate. That is a powerful concept, in the example you have constants shown as numbers when they are printed, but after go generate the stringer generated prints the names of that constants.

Go generate is like having make instructions inside your code. Of course you need a lot of imagination to think that a go generate comment is equivalent to  a makefile instruction.

Besides there is not dependency control at all. Like when run depends on build and stuff like that. But it allows you to run commands using the command go generate.

Anything else are just helper functions

Well I am over simplifying here, the fact that go comes with packages to parse, modified and write updated code is very nice but that part could be done with any other tools( like antlr or lex and yacc).

In the last project

It was decided to have a config to describe what to take from a HTTP request (get something from query, header or cookie), then we describe functions that receive that data and returns other data and finally we specified which data need to be stored and how.

The POC

So the first implementation was a Proof of concept in which show how to do all the process using a config file. In the past a new service was created to do the same work and there was 4 or 8 of them in production. So the POC shows that it would be easier to port them to this new service just by adding some simple configurations.

The first implementation

The first implementation was though to cover any case possible. It will be super generic code. The idea was just implement what is needed but left all the indirections in place so it would be easy to just implement other parts. 

This didn't finish good, because time bugdet issues. We finish with a room with foundations of a cathedral that had space for the future buttress that maybe would not be required. There was a communication problem because there was time.

The second implementation

So it starts as a POC but it was so simple that it stays and now is running in production. Basically now that the config was well specified, A generator was created to output http.Handlers base on configurations.

The service runs without go generate (not handlers registered). But after it runs, it register the handlers.

All the indirections were removed. Thanks that I received an advice from someone that I respect, he recommend just make something that works and test it, refine and test it and so on.

My life were never more easy I was preparing a service for the future but the future is uncertain.  The only thing we can do is fail fast (Implement and receive feedback as soon as possible.). 

Which is now my new motto.

June 8, 2018

How I became a golang programmer

Tldr: by casualty

Well that's it, I was programming in python for 4 years, in a great team when there was a project to try to port one of our services in go. A friend and I started the port effort.

In parallel there was other team doing the same but in Scala. And it was kind of a competition.

The mistakes

I wanted to port all the functionality. For a POC I think is not good to implement all the features. Because you have like a month to finish your port, and you are trying to implement 5 years changes.

Worse I took function by function and I tried to implement them in go. Today I know that I should focus only in produce a  "minimum viable product". Then extend it when needed.

The struggle

 It's difficult to switch your mind from a dynamic typed language like Python to other that is strong typed. The project was programmed in the language, which means that was using a lot of specific features it.

My approach to learn

I didn't really dedicate time to learn the language, I thought that I would just program and ask google how to do stuff but in go. Go by example was very cool resource but incomplete (now I think is complete, but at that time not)

That was a bad idea. Because my mind was so oriented to Python, that I didn't realize like in a spoken language sometimes there is not a direct translation.

The balance

After some time, I started to forget Python and my mind just switch to solutions with the tools that go have. I improved my fluidity. (I did the advent of code 2017 in go, that helped a lot). In other words the old advice is true. There is nothing better than practice, practice and practice.

And then when you kind of start to be intermediate in go, your old experience "kick in" and you start to think "hey I can do that in go with this" That experience was amazing.

Like a fractal

For me golang is like a fractal that looks very simple when you look it from far away. But oh boy! each time I have an interest I can dig in and I can't see the bottom. It is like a fractal each time you zoom in there is more content.

The past week I was interested to learn templates and go generates and wow, is just very cool what you can do with that. And I felt that I only saw the tip of the iceberg.

Go won

Well that was relative at the end, the go project was finished in a fraction of the time of the Scala team. (They were using play framework and during the time of the project a new version appears that change everything, the team wanted to jump in to the new changes. Sometimes the features stability of go is underestimated).

But

Scala was faster due the implementation of couchbase lib, I think with more time we could improve the performance. But the experiment end there.

The team continue working in python and I moved to other company as a go developer.