Build and Go Part 1- Git, Hg (Mercurial) and repos

Vacation time! Now that my semester is over, time to tweak around some open source project.

Image result for d'OH homer simpson              I’ve just downloaded mozilla-central. Even though I participated in outreachy as a mozilla intern, I never actually downloaded the browser source code – I contributed to Firefox Accounts…

I confess the first place I looked was github, but well, lots of great projects are not there. In fact, when you duckDuckGo “how to contribute to open software” most tutorials will tell you to explore github. D’uh, not so fast… MDN has great documentation, but coming from git, svn, github, bitbucket etc, things can get a bit confusing.

I had a new challenge: learn mercurial, coming from a svn and git.  From this site, some considerations:

  • Functionality like history rewriting must be enabled;  IMHO no history rewriting == messy trees;
  • Git’s blob, tree and commit are equivalent to: file, manifest and changeset.  Respectively. Hmm, so you dont “commit your changes”, you “changeset them”?
  • Graphical representation of history is the same in the two;
  • Local tags are only visible where they were created and do not propagate, so they behave practically the same in both systems.
  • mercurial does not offer an “undo” to what you did without using commands that are referred to as “dangerous”, “not what you want” etc in the help pages. (???)
  • I’ll have to test the communication between repositories and get back here to tell, coz from the tutorial, not clear if the pull command pulls and merges everything. (Unlike git where you select the branch to update);
  • There’s no staging area in Hg

Well, let’s hope I find something fun at Bugzilla to put all that in practice.

Advertisements

Lecture about Rust lang

About 2 months ago I gave my first talk about Rust lang.

In a open software seminar (in portuguese), I could share what I was learning about Rust. Even though I didn’t have THAT much experience in the language, I felt really satisfied to see people were interested in learning about its key features.

Here is the PDF : rust-presentation.

If anyone around Unicamp or Campinas is interested in have a talk or build something fun together, just ping me  😉

How Browsers Work – Part1 the DOM

Following my university course on compilers and OS I decided to propose another hands on project. Instead of coding a web server, i would try to build a VERY simple browser.

As I’m writing my final report I decided to dust off this blog and tell you about some of my findings.

The first consideration: I’ll not do the network part; The whole process will start with local HTML and CSS files.

Second consideration:  I’ll write it all in Rust, a language I’ve been falling in love with since I finished my internship at Mozilla. So, any code reviews are welcomed.

Third consideration: I’m trying to take the common parts of WebKit, Blink, Gecko and Servo into account. I won’t dive into any specifics of any of this engines.

Now, let’s get started.

How to construct the Object Model?

Basically, a well formed* HTML file goes though 4 steps till we get a complete DOM tree:

1- Conversion: Browser reads raw bytes of HTML off the disk, turns them into chars based on specific encoding on the file. Note: this part is going to be simplified on my toy engine, just laying out the truth to y’all.

2 – Tokenizing: Converts strings of chars to tokens. Ex: “<html>”, “<body>”, “<p>”.

3 – Lexing: The aforementioned tokens are converted into objects. These objects hold their properties and rules. Again, my version is gonna be waaay too simple.

4 – DOM construction: HTML markup defines relationships between different tags, so the created objects get linked in a tree so we can explicit the hierarchy relationship between them.

My data structure is going to be something like**:

pub type AttrMap = HashMap<String, String>;

pub struct Node {
// comum a todos os nos
pub children: Vec<Node>,

// especifico de cada tipo de nó
pub node_type: NodeType,
}
pub enum NodeType {
Element(ElementData),
Text(String),
}
pub struct ElementData {
pub tag_name: String,
pub attributes: AttrMap,
}

After these 4 steps the output is going to be a marvellous DOM tree.

*well formed because in real life we have some rules in place to display even messed up HTML files.

**How to add code snippets to wordpress?

First contribution to a Mozilla project

How did I decided to which project I wanted to contribute?

2 factors: curiosity about an almost entirely new technology (android) x familiarity with javascript.

I’ve decided to face familiarity first. It was the right choice, coz the way to my first pull request was a curious one.

It was A LOT on information to process. I had to remind myself to calm down and take long breaths from time to time. Not that it was hard, it was just a lot of information. But ALL you need is out there, either documented on wikis or gitHub or available through the communication channels (IRC or email).

My first impression was wonderful: I got interested by a project (Improving user experience of Firefox Accounts) mentored by a very attentive and mindful tutor . (I dont know if I can tell his name, better ask him first…). At first I felt very challenged because I couldn’t figure out why I had problems running it locally. Turns out sometimes it’s not enough to read all the docs at once, at the beginning most of it doesn’t make sense yet.

I found myself wandering through LOOOOOTS of code. Then I asked for help and it worked =)

Just one important tip: pull requests can be messy to understand. make sure you have a copy of the code on YOUR gitHub, otherwise you’ll end up trying to push stuff over to upstream code. And sure, YOU DONT HAVE ACESS TO IT, DUH! =p

Eventually it all works out. You add another remote to git, understand which branches you are working with and then sends your pull request to be reviewed. And if you get lucky your reviewer will give you very helpful insights on how to improve your solution.

Just another important tip: make sure you follow the tutorials and have a cheat sheet with IRC commands and the readme from the main repo open.

Now I’m diving myself into the tests code. =) And helping to figure out how to keep my clone in sync with mozilla’s repo. Think I have to do it in order to avoid conflicts =)

 

Hello World || TODO List

I’ve just got back from my biggest adventure: Almost 3 years in France. (Well, not quite, I’ve returned to Brazil 7 months ago.)

But this itchy in my shoe keeps me pushing forward: I’m looking for a new adventure. This will include either of the following:

  • participate in more hackathons;
  • contribute to an open source project;
  • learn embedded (arduino or raspberry pi)

For my first post, nothing better than telling you my first step.

The timing is perfect to start contributing to the open source world. I saw a post on facebook about the Outreachy and GSoC programs. So my “path” was chosen by timing/destiny. I’ve taken a look and some projects got me really hooked up: Mozilla’s in both Outreachy and GSoC and Systers’ in GSoC.

As the application deadline for Outreachy is earlier, I’ve just made my first pull request to the Firefox Accounts project.

And it’s UNBELIEVABLE how much I’ve  learnt so far.

I’ll talk about 2 main things in the next post:

  1. entering a community (building the project locally, finding the right people);
  2. Making a pull request (OMG!)

ps: When I started to learn JavaScript I had to code a todo-list app in both Backbone and AngularJS, so I think about it as the equivalent of “hello world” in other languages =) It’s a great way to start.