Haskell – 52 – riparto con un nuovo tutorial

Ricomincio con Haskell –o almeno ci provo come dicevo qui— un nuovo tutorial.

Ce ne sono millemila online, anzi sul sito di Haskell c’è una ricca lista di documenti, perché non cominciare dal primo? Anche perché è consigliato in diversi altri luoghi. E allora via con Learn You a Haskell for Great Good! di Miran Lipovača.

Miran è un po’ misterioso, questo dovrebbe essere lui. Non l’ho trovato sui social, chissà. Ah, prima che mi dimentico:

Il tutorial non è recente (aprile 2011) ma non dovrebbe essere un problema (sempre della serie “mi dicono”). E poi parte bene, quasi come la H2G2: Hey yo! This is Learn You a Haskell, the funkiest way to learn Haskell, which is the best functional programming language around. You may have heard of it. This guide is meant for people who have programmed already, but have yet to try functional programming. The whole thing is completely free to read online, but it’s also available in print and I encourage you to buy as many copies as you can afford.

OK, parto, qui.

Miran è anche un illustratore, bravo, e io adoro le immagini quando pertinenti e OK, ecco.

This tutorial is aimed at people who have experience in imperative programming languages (C, C++, Java, Python …) but haven’t programmed in a functional language before (Haskell, ML, OCaml …).

I failed to learn Haskell approximately 2 times [uh! 😯] before finally grasping it because it all just seemed too weird to me and I didn’t get it. But then once it just “clicked” and after getting over that initial hurdle, it was pretty much smooth sailing. I guess what I’m trying to say is: Haskell is great and if you’re interested in programming you should really learn it even if it seems weird at first. Learning Haskell is much like learning to program for the first time — it’s fun! It forces you to think differently, which brings us to the next section …

Ma cos’è Haskell?
Haskell is a purely functional programming language. OK, salto questa della differenza tra i linguaggi imperativi e quelli funzionali l’ho già sentita, saprei anche ripeterla, casomai la difficoltà è applicarla.

So in purely functional languages, a function has no side-effects. The only thing a function can do is calculate something and return it as a result. At first, this seems kind of limiting but it actually has some very nice consequences: if a function is called twice with the same parameters, it’s guaranteed to return the same result. That’s called referential transparency and not only does it allow the compiler to reason about the program’s behavior, but it also allows you to easily deduce (and even prove) that a function is correct and then build more complex functions by gluing simple functions together.

Haskell is lazy. Anche qui salto, ma è importante, se del caso Miran lo spiega bene.

Haskell is statically typed. Non come altri linguaggi anche molto di moda, sapete a chi mi riferisco.

Haskell is elegant and concise. Because it uses a lot of high level concepts, Haskell programs are usually shorter than their imperative equivalents. And shorter programs are easier to maintain than longer ones and have less bugs.

Haskell was made by some really smart guys (with PhDs). Work on Haskell began in 1987 when a committee of researchers got together to design a kick-ass language. In 2003 the Haskell Report was published, which defines a stable version of the language. Ehi! se i nerds lo usano devo poterlo fare anch’io, nèh! 😋

Cosa serve per partire
A text editor and a Haskell compiler. Li ho. For the purposes of this tutorial we’ll be using GHC, the most widely used Haskell compiler. Anche questo. So hanche della possibilità di compilare ma della praticità della versione interattiva, la REPL ghci: The usual workflow for me when playing around in stuff is defining some functions in a .hs file, loading it up and messing around with them and then changing the .hs file, loading it up again and so on. This is also what we’ll be doing here. Uh, anch’io. Insomma pronto a (ri)partire 😁


Posta un commento o usa questo indirizzo per il trackback.



Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo di WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...

Questo sito utilizza Akismet per ridurre lo spam. Scopri come vengono elaborati i dati derivati dai commenti.

%d blogger hanno fatto clic su Mi Piace per questo: