List of all blog posts

Simple take on monadic types : the List

Monads are often introduced as an abstract mathematical concept or as an abstract design pattern. In this series, humbly called “Simple take on monadic types”, we’re going to manipulate the objects which have monadic instances. We’ll extrapolate their properties and gradually discover their power. If the concept of monads is not familiar to you, you only need some knowledge of Java or Javascript and some attention. For the first article of the series, let’s play with the type List<T> or List a.

The goal of our program is to harvest trees (🌳) to get apples (🍎) and bake them into pies (🥧)! In order to store them, we’ll use the abstract (but familiar) concept of List, everything is much easier when stored in a list.

Bake the piece of pie

Let’s consider this function:

Les types algébriques pour les languages orientés objets

On pourrait renommer les languages fonctionnels (à l’exception d’Erlang, mais c’est une autre histoire) des languages algébriques à tel point que les structures algébriques sont leur outil de base. Nous allons essayer de montrer les analogies que ces structures ont avec les outils qui nous sont offerts dans les languages orientés objets et comment la réflexion en types algébriques permet de simplifier la modélisation de nos problèmes.

Les types sommes

Vous connaissez certainement déjà les types sommes : c’est le nom savant des énumerations. Vous savez ce qu’on utilise en Java pour désigner les méthodes Http ?

public enum HttpMethod {
    DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT, TRACE
}

Happy new year of code

What happened in 2017

2017 has been a rich year for me! All of those good things happened to me this year:

  • I have found a job at malt. It’s the best working environment i’ve experienced so far: a growing team of fantastic individuals, a motivated and welcoming team spirit. I’m super happy to contribute to the adventure!

  • I’m a new member of the Lyon Tech Hub and the Cara Lyon, mostly organizing the Coding dojos and DDD events. Our biggest feat has been the return of the Code Retreat.

  • I wrote a blog post every month at least on this very blog. I didn’t write compuslively, and I tried to search for my articles. Most of them are short but most likely asked a lot of research.

  • I have abandonned the redaction of an unusually long article on processes and threads in different languages. I worked many hours on it, and it will certainly never be published but I learned a lot on concurrency models a low level.

  • I have learned Purescript/Haskell basics while working on side projects. It took a lot of effort to get to a poor level, but it teached me a lot about other languages and gives me a higher point of vue (and reasons to dislike javascript)

What is planned for 2018

Response to Vjeux article on Ocaml

Vjeux works on React at Facebook. He published a small list of things that he feels are bad patterns in Ocaml language. I can’t have an opinion on Ocaml itself, since I don’t know the language, but I disagree strongly on some point he makes about functional programming.

Naming is the most difficult thing in computer science

This famous quote by Phil Karlton captures a lot of our job: naming things is hard, because it’s the only way we have to carry meaning and intentions. Here’s the example vjeux uses to critisize a bad style of writing code:

array.map(fn)
array.map(x => fn(x))

My experience with Purescript so far

Purescript is a pure functional language. It is highly inspired by Haskell and compiles to javascript. I learned it on a side project (not a very serious one) and to write scripts to query our mongodb instances at malt. I will simply present my point of vue on the current state of the language.

Environment tools

First off, the install and setup of the environment is straight forward. Pulp works like a charm! It is intuitive and it never went in my way. The incremental build is super fast on my machine so you can have a quick feedback on your test while you code with a simple pulp --watch test.

The second thing purescript excels at is documentation browsing. If you look for the documentation of the map function, just look up on pursuit. It’s a shame that the results are weidly ordered. I would have preferred to have the Data.Functor (map) at the top, since it’s the most common. But this is only a detail, I’m sure maintainers are aware of these sort of things and are working towards a better browsing experience.

Digging in the depth of Fibonacci

Not so long ago, I read an article on fibonacci. I suggested a more elegant solution to my eyes, but the problem kept bogging me. Let’s get into it!

The naïve recursive approach

The first implementation, which reads like the mathematical formula, looks like this:

def fib(0), do: 1
def fib(1), do: 1
def fib(n), do: fib(n-1) + fib(n-2)

Common pattern for bash auto complete

After reading my last article, I was disappointed. I could have shown you how to deal with the point 1:

[You can] Suggest based on subcommands and options available to the user. This means you need to create a tree of possibilities: goat push supports —force option but goat pull does not, etc.

The first thing to discuss is the COMP_WORDS variable. COMP_WORDS[0] is always the name of the command, goat in our case. Also the current word to be completed ${COMP_WORDS[COMP_CWORD]} represent at least an empty string. You can be sure that you have at least 2 string in your COMP_WORDS array. We’ll use that at our avantage and use a case to complete subcommands:

_goat() {
  prev=${COMP_WORDS[COMP_CWORD - 1]}
  cur=${COMP_WORDS[COMP_CWORD]}

  COMPREPLY=()
  case "$prev" in
    goat)
        COMPREPLY=( $( compgen -W "log commit push pull clone add" -- ${cur} ) )
      return
      ;;
    commit)
      case "$cur" in
        -*)
          COMPREPLY=( $( compgen -W "--author= --edit --no-edit --amend --include --only --allow-empty" -- ${cur} ) )
          return
          ;;
      esac
      break
      ;;
  esac
  COMPREPLY=( $( compgen -f "${cur}" ) )
}

complete -F _goat goat

How to create a bash auto complete

Bash auto-complete seems pretty magic. People using bash extensively (I’m part of them) tend to have a certain love for the [TAB] key! It looked mysterious to me until I implemented one for myself. I’m not proficient at Bash, but basic knowledge of arrays and compgen is enough to implement auto-complete.

The compgen magic

This Bash builtin is the base of auto-completion. It takes two arguments: a list of terms, a dictionary, and an input to compare it with. It will return the list of terms in the dictionary which could match with the input. You can use it like this:

$ compgen -W 'init list new compile install lint' -- li
list lint
$ compgen -W 'init list new compile' -- compile
compile
$ compgen -W 'init list new compile' -- lists

Press review #5

It’s been a long time i haven’t written a blog post, even a press review. This is fixed now and the rate of publishing should accelerate next weeks. I gave myself some holidays, and it gave me even more ideas on things to learn. Anyway, enough with boring news on the blog, let me share my best reading lately!

100 days of algorithm: I’ve got lately into algorithm. It’s an interesting field of software I have forgotten for too much time, the more I read about it, the more fascinating it is. The small subset I had time to read are really mind blowing, I hope it does help!

Project package organization: This article is about package organization in Java. I’m a fan of organizing package by features (as presented in the article). Even if you don’t use hexagonal architecture or CQRS, it forces you to think within your knowledge of the domain.

Deploy Elixir app to a vps: Most tutorial on deploying an Elixir application are unclear or too specific, this one is perfect. It covers the basics of the tools without sacrificing the productivity they offer.

The survival kit for functional language beginner

Functional languages like Haskell, OCaml or Erlang based Elixir are difficult to learn when you come from an imperative or object oriented languages. Concepts like immutability, high order functions or monads are very difficult to implement in classical languages (let's call them that way). Thankfully, those functional languages share a lot in common and i'll try to introduce to the most important concepts behind them.

This kit is not a learning guide, and knowing those patterns will not teach you the specifics of each langugages. The road to mastering functional languages remains a hard path to take!

Pattern Matching

Let's start with the most important syntax helper from functional programming: pattern matching. Did the ruby syntax of a b = b a mixed your head up? Prepare some aspirin because... no, I'm joking! Pattern matching is very straight forward if you start practicing it. It allows to assign variable similarly to arithmetic equations. For instance: (Note: example are written in Elixir or Haskell)

Press review #4

This week's review is so diverse! From SQL WITH syntax to a list of good books, you'll find everything, even a critic of "Corporate Agile"

arpinum/awesome: I think it's important to share shortlists of books and this one seem pretty good!

#NoTDD - by Eric Gunnerson: many problems with TDD comes from the lack of design being done. This article tells how design needs to be emphasize when testing first.

Literate SQL: although I do not practice SQL daily, I find this syntax very interesting! Tell me if you use it in your requests.

Why null leads to bad implementations

Bergson says:

Le néant, c'est la traduction des données de notre perception dans le language de nos attentes.[1]

Void is the translation of our perceptions' data in the language of our expectations.

Expectations are a very wicked things to represent in a program, they are implicit, changing, immaterial and conceptuals. We should instead talk about things that exists, represent reality, and its continuous realm of possibilities.

One could say that we solved this issue in computing systems through the implementation of types. They caracterize systems without leaving any expectations implicit. This vision forgets the infamous null that exists in nearly every language [2].

Press review #3

Today's press review is about mostly Linux and system toolkit. It's a rather short and technical review, so without further a do, let's go into it.

Shell scripts matter: Bash is almost always unconsidered, this blog post learns you how to create better ones. I've been working with git hooks lately and this guide has been a great help!

ssh_config: This one is not really a press review, it's more a discovery i made while searching the way to bookmark ssh connection. For long I used the CTRL + R history functionnality of the terminal, but this time is over!

Manually Throttle the Bandwidth of a Linux Network Interface, Slow down your internet with tc, tc: Adding simulated network latency to your Linux server: not one, not two, but three article at once! They all cover the same subject: the utility tc for linux.

Press review #2

I liked writing the first press review, so i was impatient to write another one! Here it is. It revolves around user experience and more, I hope you'll like it!

Sideways dictionary: As they put it: "it's like a dictionary, but using analogies instead of definitions." A dictonary for technology principle. It's a very well designed website, cool concept and user's suggestion can be funny. I'll let you explore it!

Improving mobile web conversions just by optimizing web forms: This one is easy to summarize: use autocomplete to your forms as much as you can. As promoted, it will reduce the pain for users, especially for mobile users. I'm pretty confused, because as this tweet showed, the autocomplete could be used to steal user's private data.

How to launch software changes without pissing people off: This article seems very important to me. We tend to consider users as passive, ready for every changes. We are not. We are pissed when our habits get crambles. I don't advocate for them not to happen, rather to accompany them for a smooth transition. As Proust said:

The alien erlang syntax choices

Some developers still argue about which punctuation is the best. Some would support the C syntax with semicolon ; at the end of each line, something that would look like:

int main() {
  int a = 6;
  int b = 3;
  if (a > b) // notice this line has no punctuation
    printf("a is greater than b \n");
  return 0;
}

Others will say the best syntax is a ruby/python-like with no punctuation. You can write in elixir (very close to ruby):

def print_file do
  # notice the punctuation in the method
  File.stream!("scratch.txt")
  |> Enum.each(&IO.puts/1)
end

Press review #1

Since I have a lot of time to spend and to read various articles, I thought it would be a nice exercise to review the nice articles i find here.

Want to blog? Read this: i'll start with the article that inspired me to write down this article. It might also inspire you if you plan on writing in your blog but don't have any idea.

Architecting Continuously Testable Systems: Managing large systems is not the most common task for developpers, but delivery management reminds us with the complexity that goes on outside of code. This article goes deep down in the architecture of one system with an emphasis on testability.

Names that Make Computers Go Crazy: how did you configure your database for names? varchar(255)? This article explains how this setup is a nightmare for people like James Dr No From Russia with Love Goldfinger Thunderball You Only Live Twice On Her Majesty's Secret Service Diamonds Are Forever Live and Let Die The Man with the Golden Gun The Spy Who Loved Me Moonraker For Your Eyes Only Octopussy A View to a Kill The Living Daylights Licence to Kill Golden Eye Tomorrow Never Dies The World Is Not Enough Die Another Day Casino Royale Bond, a UK citizen!

Quick introduction to macro in Elixir

When i first ran into macro in Elixir, i felt it was too much for me to learn on the first round. The concept seemed too stepped to digest for the moment. Immutability, pattern matching and Erlang processes are already pretty difficult to grasp when you come from utterly different environment (Java & Javascript in my case).

What a regret i have now! Even if macros are a powerful and complex tool, you can use them to make code much more readable without having to enter the hard bits. That's what i'll try to prove you with some simple examples.

What is a macro

Elixir is a compiled language based on Erlang. Compilation time can be annoying, but it provides more powerful tools such as code generation through their preprocessors. This feature is called a macro in Elixir. When I learned C I felt this was a useless feat, but now that I've grown aware to readability and reusability in programming, thanks to Software Craftsmanship mentality, I see macro a very different way.

Experimenting pushstate to boost page loading

After some nice surfing on dev.to, i realized the loading of articles was blazing fast. After a little investigation, i found out they're using instantClick, a javascript library that speeds page display by loading content on mouseover event, once the user clicks on the link the content is displayed in a flash since it's already downloaded! Although i could have simply used the library, i wanted to experiment with the underlining concept: pjax, the contraction of pushState and Ajax.

I don't need to explain Ajax, but pushState needs a little explanation. It is the DOM api that allows you to manipulate the browser history. Simply put, you can change the url without page reloading. Most frontend frameworks like angular, vuejs or react provide router library using this api under the hood. As usual, the best documentation you can get is available at MDN.

pushState: a naive approach

When i first read the documentation, my first thought was "great! it is as simple as the location api", and i tried without any further information. The code ended up like that:

Developer's Proust Questionnaire

Marcel Proust
Marcel Proust

After finishing reading the Search of Lost Time by Marcel Proust, I desperately craved to connect it with my job. It took me a while to realize that the best way to do that is to complete a developer's Proust questionnaire.

The questionnaire has one goal: capture time. We have long term thoughts that we consider defining our identity. But our relationship with those thoughts change through our lifetime. Proust wrote in Search of Lost Time to capture and make us wonder what we've been doing all these years. I suggest you try reading this wonderful book, although i admit it is particularly hard to read.

What do you have to do ? Simply answer the questionnaire. You'll look back to it In maybe 5, 10 or 15 years from now and i guarantee you that your older self will be very surprised how your younger self is (not) that stupid.

If-less game of life

Let's implement an if-less game of life. I discovered this game during a code retreat and the simplicity of its rules make it the perfect field to experiment patterns.

The rules

The game of life consists of a two dimension board filled with cells. Each cell can be either dead or alive. For simplicity sake, we'll only implement the behavior at the cell level. At each step, a cell behavior follows those 4 rules :

  1. Any live cell with fewer than two live neighbors dies.
  2. Any live cell with more than three live neighbors dies.
  3. Any live cell with two or three live neighbors lives on to the next generation.
  4. Any dead cell with exactly three live neighbors becomes a live cell.

Kafka n'est pas kafkaïen

TL;DR; Utilisez kafkaïen pas « digne de Kafka », machiavélique pas « une politique proche de Machiavel »


La modernité et l’avènement d'internet nous pousse à écrire nos opinions de plus en plus rapidement, à les partager inlassablement, quitte à négliger nos formulations. Bien que twitter nous a quelque peu forcé à raccourcir nos phrases, à compresser notre pensée dans le plus petit espace possible, il nous arrive encore de rallonger notre texte, pensant que l'utilisation d'une phrase plus alambiquée serait le reflet d'un esprit plus vif.

Ainsi en est-il des journalistes qui qualifie des procès, des situations « digne d'un roman de Kafka » (j'admets avoir perdu la référence qui m'inspire ce billet), facilité renforcée par l'origine de l'adjectif qui se trouve évidemment dans le nom de l’écrivain Pragois. « Quel malheur à utiliser ce terme ? » Pourriez vous vous demander.

Ode à l'esperluette

Autrefois 27ème lettre de l'alphabet, aujourd'hui haï pour son nom et son utilisation trop commercial, la beauté de l'esperluette a peut-être trouvé refuge dans la chaleur de nos lignes de code. L'esperluette a toujours un rôle mystérieux qui convient à son apparence tourmentée, sa graphie sinueuse, emmêlée et convoluée.

En C++, l'esperluette a repris souffle. Reprenant les opérations qu'elle supportait déjà dans le simplissime C, la voilà en charge des références. Combien d'étudiants et de développeurs chevronnés auront pensé à ses belles courbes avant de déclarer un argument de fonction par référence ?

Esperluette italique
Esperluette italique

On peut regretter que les polices de caractère monospace ne supportent pas l'italique, nous pourrions alors apprécier sa jolie ligature. Mais devant l'évidence que ce n'est qu'un « e » et un « t » assemblés timidement, nous aurions reconnu ses origines et peut être voulu lui réserver un rôle plus évident, la confiner dans les opérations binaires et booléenne.

L'éthique libérale et l'esprit de l'Agile

Dans son livre L'Éthique protestante et l'esprit du capitalisme, Max Weber a montré l'influence des courants protestants sur le développement du capitalisme dans l'Europe du 18ème siècle. Cette démarche d'archéologie des idées est très inspirante (je vous conseille l'écoute de ce podcast sur le sujet), nous allons nous en inspirer pour comprendre la particularité de la méthode Agile dans l'écosystème des méthodes de l'entreprise et comprendre les risques de sa propagation au delà du monde de l'entreprise.

Agile, discipline et efficacité

Les valeurs de l'Agile sont avant tout des valeurs d'entreprise, rien de surprenant dans cela, c'est le domaine dans lequel l'Agile a vocation de se déployer. Parmi les douze principes de son manifeste, le premier pourrai servir de définition du capitalisme :

Notre plus haute priorité est de satisfaire le client en livrant rapidement et régulièrement des fonctionnalités à grande valeur ajoutée.

L'argument ontologique de l'agilité

L'agilité est-elle un Dieu ?

please please please before starting to write another 'what's wrong with agile' article, rename it to 'what's wrong with my organisation'

— Gojko Adzic (@gojkoadzic) May 25, 2015

Si j'en crois ce tweet, l'agilité n'est pas une méthode théorisée par de simples mortelles, mais est belle et bien un Dieu. Qui ne peut souffrir de reproches si ce n'est Dieu ? On appelle cela l'argument ontologique de l'existence de Dieu.

L'hégémonie de l'agilité

Pourquoi Software & Machiavel ?

J'écris ce blog pour rassembler mes idées, abouties ou non, sur la programmation, le développement logiciel, mon travail en somme, en regard de mes lectures.

Pourquoi Machiavel ?

Rien de surprenant que Machiavel soit une source d'inspiration transcendant la politique ou le militaire, ce n'est pas tant le contenu de son oeuvre qui soit digne d'intérêt, mais sa méthode. En ignorant sciemment l'éducation chrétienne moralisante de ses lecteurs, il a produit une une analyse de la situation politique de son époque en des termes nouveaux ouvrant la voie à une science politique délivrée de la morale.

C'est cette position amorale (et non immorale) que je vais essayer de conserver tout au long du blog et ainsi dépasser les positions simplificatrices.