sum-csv

Reflections on a little thing I made, to learn how to better create the bigger ones.

After the last blog categories reorganization, I realized that I talk less about what I do and more about what others do. That make sense, as this blog is part of my learning process and I’m always looking around to find ways to improve myself. Yet, I’d like to start writing more about the little things I do. Writing helps me to reflect upon the how, so eventually I’ll learn more about my thought processes. These are likely to be very small things.

sum-csv

sum-csv is a small utility I have built to help me to crunch some statistics I was working with. I had a complete dataset in a CSV file, but what I wanted was an ordered list of the number of times something happened.

Original CSV: What I wanted:

A data transformation

This is a small task – my old self whispered. Yet, instead of opening the editor and start coding right away, the first thing I did was drawing things. I am a visual person and drawing helps me to gain understanding. The algorithm I came up with was a succession of mathematical transformations: Which is to say:

  • transpose the original matrix
  • eliminate the rows I was not interested in
  • for each row, group all numerical values (from column 1 onwards) by adding them, to calculate the total
  • sort the rows by the total

Now, I was prepared to write some code. Amusingly, the gist of it is almost pure English:

d3-array.transpose( matrix ).filter( isWhitelisted ).map( format ).sort( byCount );

Reflection

Creating production-ready code took me four times the effort of devising an initial solution: finding good and tested libraries for some of the operations not built-in in the language such as reading a CSV into a matrix or transpose the matrix itself, creating the tests for being able to sleep well at night, distributing the code in a way which is findable (GitHub/npm) and usable by others/my future self, and, actually, writing the code.

I am not always able to write code as a series of mathematical transformations, but I find pleasure when I do: it is much easier to conceptually proof whether the code is correct. I also like how the code embodied some of the ideas I’m more interested in lately, such as how a better vocabulary helps you to make things simpler.

A more expressive vocabulary for programming

map and friends are more precise, sophisticated ways to talk about consistent patterns in data manipulation. Using them over for is analogous to using the word “cake” instead of “the kind of food that you make by whipping egg whites and maybe adding sugar”.

Interestingly, you can eventually add new layers of category on top of established layers: just like saying that butter cakes constitute a specific family of cakes, one could say that pluck is a specialization of map.

Of vocabulary and contracts, Miguel Fonseca.

Simple made easy

Precise words make communication more efficient. Arguably, software development is about managing conceptual complexity. Simple made easy, by Rich Hickey is a talk that tackles those two topics.

Two takeaways from this talk:

  • The differences between simple and easy.
    • Simplicity is an objective measure, and its units are the level of interleaving (of concepts). Simplicity should not be measured by the cardinality, the number of concepts/units.
    • Easiness is a subjective measure, and it is related to how familiar you are with some topic or your past experience.
  • We can make things simple with the tools we already have by favoring concepts that make things simpler to reason about, not quicker to write. He recommends:

See also:

La La Land

Now, this is a musical that I like. Entertaining, moving, and complex.

I wouldn’t say musicals are my kind of films. My personal favorite is Sweeney Todd: The Demon Barber of Fleet Street, which is typical Burton. I didn’t like Les Misérables and haven’t watched Moulin Rouge. That’s my track record. Yet, this film is energizing, jazz everywhere, a colorful photography, with brilliant performances by Stone & Gosling.

At the core, I’d say this is a wonderful love story, with a positive and naïve message – just what we need right now. That’d be enough to recommend it. At the same time, it is not what would you expect from a Hollywood film: it is sad in many and fundamental ways, which makes the film a modern story about love, life, and personal growth. And has an epic soundtrack.

My office i4

I’ve been working from home for more than 3 years now, and my setup has gone through several iterations – the current one is i4.

office-i4

After joining Automattic, I was encouraged to think about my office setup. The company sponsors the kind of high-quality office perks that you’ll expect in companies at this level, and I took that opportunity to upgrade my own in ways I had been already thinking about. The fact that you are not in their offices, but in your home adds a different feeling to it. Although I appreciate the company efforts and perks, I’d like to stay frugal within comfortable limits, so I didn’t get anything I wouldn’t buy with my own money. I think of my office setup as a gift for the elder me – I wish he’ll be proud of what his younger self is doing for him.

For i4, these are the new additions to my office:

HAG Capisco 8016 chair, which promotes and supports several seating positions.

DIY kit from Autonomous, to build my own height adjustable desktop so I could change between seating and standing positions.

We, humans, are not designed for seating. A lot has been said about the optimal seating position, but an idea that has gained recognition in ergonomics is that changing positions frequently may be the best long-term strategy.

For the past two months, I’ve been experimenting with that idea to learn what works better for me. I’ve used three main positions -traditional seating, saddle seating, and standing- and a lot of other crazy ones. What I’ve found out is that I change positions through the day as my body asks for it, but I mainly use the saddle position (most of the time, but especially when I need to write) and standing (for consuming information). The traditional seating feels a bit unnatural to me now, although it may be a side effect of using the Capisco which is more tailored for other postures. I also have a more traditional chair at home, but I rarely use it.

This is i4. This setup fits me so well that I cannot imagine what i5 will look like yet.

Taking PHP seriously

Slack se une al club de los que usan PHP:

Most programmers who have only casually used PHP know two things about it: that it is a bad language, which they would never use if given the choice; and that some of the most extraordinarily successful projects in history use it. This is not quite a contradiction, but it should make us curious. Did Facebook, Wikipedia, WordPress, Etsy, Baidu, Box, and more recently Slack all succeed in spite of using PHP? Would they all have been better off expressing their application in Ruby? Erlang? Haskell?

Relacionados: inversión y amortización en la selección tecnológica.

React before React

While it might look like an overnight success in hindsight, the story of React is actually a great example of how new ideas often need to go through several rounds of refinement, iteration, and course correction over a long period of time before reaching their full potential.

— Our first 50.000 stars.

Por no mencionar al perro

¿Puede un libro ser a la vez una comedia de enredos, una novela de detectives, una sátira ambientada en la época victoriana y una obra de ciencia ficción? Todo eso, y más, es “Por no mencionar al perro” de Connie Willis.

De esta autora había leído Oveja Mansa. Aunque son libros y temáticas distintas, hay ciertas reflexiones compartidas; por ejemplo, las que tienen que ver con los sistemas complejos y la teoría del caos, reflexiones sobre si el progreso y la Historia es causal o casual. Quizás se deba a que las dos novelas han sido escritas durante el mismo período y Connie Willis no es inmune a la obsesividad que conlleva el aprendizaje sobre un tema (Spielberg hizo varias películas muy seguidas sobre los extraterrestres o la segunda guerra mundial, Stephenson amortizó su tiempo de investigación sobre mitología sumeria y griega en varios libros, etc). Ambas comparten también cierta manera de tejer el argumento que definiría como característica de Willis: su interés por los usos/modas/costumbres en distintos momentos históricos, las aventuras basadas en situaciones cotidianas y una escritura ligera que saca lo mejor de las comedias románticas.

¿Qué se puede decir de esta novela sin destripar la gracia del argumento?

Para empezar, que está ambientada en el año 2.057, donde existe una máquina de viajes en el tiempo que usan sólo los historiadores de Oxford porque no es rentable para nada más. Luego, que los historiadores Ned Henry y Kindle necesitan deshacer una paradoja temporal, de ésas que a la que despistas modifican el curso de la Historia de tal manera que provocan que los nazis ganen la 2ª guerra mundial, por ejemplo. Las paradojas temporales tienen un papel principal en esta novela; sin embargo, con lo que he disfrutado de verdad es con la aparición estelar de la Luftwaffe y la RAF, con el proyecto de reconstrucción de la catedral de Coventry que habría sido vendida primero a una secta espiritista y luego sustituida por un centro comercial, con el viaje que supone leer sobre la sociedad victoriana del siglo XIX durante la segunda revolución industrial o con los paseos en barco por el Támesis que son en sí mismos una road-movie.

Aunque es una novela larga con varios tirabuzones en el argumento, se hace entretenida gracias a la fina ironía y sátira que impregna el estilo de Connie Willis, así como a su capacidad para sacar jugo a los tópicos del género detectivesco y romántico. Quizás no me arrancó tantas carcajadas como en Oveja Mansa, pero sí me puso de buen humor.

Si eres fan del Ministerio del Tiempo o te gustó la película About Time, es probable que también disfrutes de esta novela donde la Historia es un personaje más. Por no mencionar al perro.

Que empiece la temporada

Está siendo un magnífico verano y aunque nos queda un mes completo todavía, ya el ambiente empieza a oler a Otoño. Y a series. El próximo martes 23 se estrena la tercera temporada de Halt and Catch Fire. Dos días después de que acabe, el 21 de Octubre, empieza BlackMirror. Los astros se alinean para darnos un respiro y que podamos compaginar todo. Qué gustazo. ¡Estamos listos para empezar la temporada!