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.

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 {
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?