Happy birthday Ada Lovelace- first programmer

Happy birthday Ada Lovelace- first computer programmer

She would be 200 years today!

Who is she?

Augusta Ada King, Countess of Lovelace was a British mathematician and writer, chiefly known for her work on Charles Babbage’s early mechanical general-purpose computer, the Analytical Engine. Her notes on the engine include what is recognised as the first algorithm intended to be carried out by a machine. Because of this, she is often regarded as the first computer programmer. (Wikipedia)

800px-Ada_Lovelace_portrait

  • Hip hip hurra för den första programmeraren: Ada Lovelace!

Haskell – Functional programming

As you may have noticed I study computer science and therefore I would like to write some things regarding the studies on my blog. Of course the focus is mainly music and environmental but technology is also a big part of our life so… Here it comes.

Haskell is a programming language that is functional and my experience of programming is, before entering the program, mainly Java, an imperative language. And also a lot of webbprogramming as a hobby but it is not real programming in this sense.

Functional programming can shortly be described as programming with no side-effects.

But even side effects are possible since you for example will sometime need input and output, so called I/O. This type of programming in Haskell is called inpure.

This picture I found on Internet makes me a little bit sceptical about I /O monad:
image

(pic from Haskell guide)

What sites you should check out when programming with Haskell :

  • Hoogle. Oh yes, stop googling and start hoogling !
  • Learn you a Haskell. An online book about Haskell. Learn you a Haskell for great good. Well, well. I’m just doing it to pass the course 🙂 The examples in the book are ethically miserable but you can learn a lot from here.
  • Haskell Wiki. The how to guides of Haskell.
  • A Haskell guide here.

Have you used another site that should be on the list? Let me know and I will update!

The fun of Haskell

What I find intriguing about Haskell, as my first functional programming language is how compact the expressions can be. Following syntactic structures are very cool:

Pattern matchning

A simple and very clarifying example is lucky seven:

lucky :: (Integral a) => a -> String
lucky 7 = “LUCKY NUMBER SEVEN!”
lucky x = “Sorry, you’re out of luck, pal!”

The example is from LearnyouaHaskell.

 guards

bmiTell :: (RealFloat a) => a -> String  bmiTell bmi     
bmi <= 18.5 = “Underweight”
bmi <= 25.0 = “Normalweight”
bmi <= 30.0 = “Overweight”
otherwise   = “Check your input again.”

The example is from LearnyouaHaskell and the program feedback is modified because the original is hideous (unethical), supposedly fun but I think they should rethink it. Whatever, check the cool guards!

I/O

The input/output (I/O) of Haskell is called inpure programming, since it is programming with side effects.

The classic “Hello world!” in Haskell:

main = putStrLn “hello, world”

Learn you a good Haskell has a chapter with Input and Output.

Is Haskell my new passion in life?

No, actually but I am happy to have experienced it. I still would say I totally prefer imperative programming like Java, it makes more sense to me.

//

Publicerar detta inlägg bara på engelska eftersom alla sidor som ovan nämns är på engelska och även vår undervisning.