Monthly Archives: December 2014

First Step on Learning Haskell

As part of my practicing in functional programming, working on some Haskell program for several weeks. It’s great experience, but the learning cost is pretty high around I/O and Types. I’m pretty much struggling, but there are many nice resource online, and gradually grasping the underling concept.

Especially, http://learnyouahaskell.com/ is a great resource to learn its concept step by step. With some experience on funcational aspect of Erlang/Elixir/Ruby, gradually getting to understand them, though the Monad or IO Action part is difficult to digest yet. Anyway, its declarative expressions are powerful and concise and impressive.

Then, it starts with fibonacci as always.

import System.Environment (getArgs)
main :: IO ()
main = do
args <- getArgs
let n = read $ head args :: Int
putStrLn . show $ fib n
fib :: Int -> Integer
fib 0 = 0
fib 1 = 1
fib n = fib(n - 1) + fib(n - 2)
view raw fib.hs hosted with ❤ by GitHub
import System.Environment (getArgs)
main :: IO ()
main = do
args <- getArgs
let n = read $ head args :: Int
putStrLn . show $ fib n
fib :: Int -> Integer
fib = (map fib' [0 ..] !!)
where fib' 0 = 0
fib' 1 = 1
fib' n = fib (n - 1) + fib (n - 2)
view raw fib_memoize.hs hosted with ❤ by GitHub

The pattern match is pretty nice as always. The lazy evaluation and memoziation would be one Haskell’s key factor, and it works nicely.

(on my MacBook Air)

% /usr/bin/time -p runhaskell fib.hs 40
102334155
real        11.71
user        11.49
sys          0.22

% /usr/bin/time -p runhaskell fib_memoize.hs 40
102334155
real         0.30
user         0.16
sys          0.05

References

Watching – State of the Art in Microservices

State of the Art in Microservices by Adrian Cockcroft (Battery Ventures)

Just watching some presentations from dockercon, and this one from Netflix architect nicely describes the trend of cloud architectures.

Some notes are,

  • (3:00) The adoption of cloud is growing faster, and docker was growing even faster. Docker was not in anyone’s 2014 roadmap, but it’s in everyone’s 2015 roadmap.
  • (8:00) The silo’s of development teams. Just having cross-structured product team is not so efficient. Service/API based infrastructure with DevOps concept is good for optimizing the product development pipeline.
  • (15:30) A Microservice Definition: Loosely coupled service oriented architecture with bounded contexts.

Docker is providing granular applications infrastructure, and good for composing them from the smaller services. As introduced in DockerCon EU: Keynote on Orchestration (Docker Machine, Swarm, Compose), new orchestration layer on top of existing services are coming up too.

Service oriented architecture concept may be getting more reachable with simple and composable architectures, without deeply going into the legacy-style enterprise complexities. It’s interesting.