viernes, 22 de mayo de 2015

Clojure in Action - Book Review

I just finished reading this book a couple of minutes ago...so here's my small review...


The book is kinda big...with 434 pages...and it's the first book and my first approach to Clojure.

I have to say...I'm not a big fan of Java...I don't even actually like it...but Clojure...it's something else -:) With its Lisp like syntax and it's functional orientation...it's a delightful programming language...

The book itself it's a great introduction to have us ready for something else...but...as Clojure is still a young language...some of the examples don't work mainly because some keywords or libraries had become obsolete...gladly most of the examples work just out of the box...

There are also many examples that help to fully understand what Clojure is all about...





If you haven't heard about closures, recursion, higher-order functions or currying...the this book is for you...

While I'm planning to read more Clojure books, I can say that this book is the perfect way to get started...

Greetings,

Blag.
Development Culture.

miércoles, 22 de abril de 2015

An Introduction to Programming in Go - Book Review

I finished this book a long time ago...but somehow...I never wrote a review for it...sorry about that -:P

This was the first book I read about Go...and I have to say...I totally love it -;)

It's very concise and to the point with only 165 pages...more than enough to get your feet wet and nurture your interest in learning Go -;)



In a fast and nicely explained way, this book guide through Arrays, Slices, Maps, Functions, Concurrency, Pointers, and the Core Packages...

A good programming book doesn't have to be huge...doesn't need to teach you about every single command or technique...a good programming book should give you the basics...the elements that you need to start grasping the language itself and slowly build up so you can gain confidence and the start to move forward on your own...

I totally recommend this book to anyone learning Go...and I wish every programming language had a book like this...it would make beginners life much easier -;)

Greetings,

Blag.
Development Culture.

The Way to Go - Book Review

I finished this book a long time ago...but somehow...I never wrote a review for it...sorry about that -:P

This book has 629 pages, so it's really big...

The book is really good and it's a really nice and comprehensive guide for anyone learning Go...

It's full...and I mean it...full of examples! -:D


And I might be getting picky here...but I would have appreciate more images -:)

The books of course goes along installing Go, explain it's syntax and touch interesting topics like Interfaces and Reflection, Error-Handling and Testing and hooking up with Google App Engine.

I would like to say more about it...but sadly...it's been a while since I finished it...so my last words are only...if you're new to Go...this is really good book to begin with...if you have some Go experience...it's up to you...

Greetings,

Blag.
Development Culture.

miércoles, 1 de abril de 2015

LED is my new Hello World - Clojure Time

The more I learn Clojure...the more I like it...and I'm liking it so much that I couldn't help myself and start working on my beloved "LED_Numbers" application...

After making the Fibonnaci Generator app work...this one wasn't as hard as I expected...actually I think I'm slowly getting used to Clojure...which is always nice when learning a new language -;)

Here's the source code...

LED_Numbers.clj
(def leds {"0" (list " _  " "| | " "|_| ") "1" (list "  " "| " "| ")
           "2" (list " _  " " _| " "|_  ") "3" (list "_  " "_| " "_| ")
           "4" (list "    " "|_| " "  | ") "5" (list " _  " "|_  " " _| ")
           "6" (list " _  " "|_  " "|_| ") "7" (list "_   " " |  " " |  ")
           "8" (list " _  " "|_| " "|_| ") "9" (list " _  " "|_| " " _| ")})

(defn toList [number]
 (map str(seq(str number))))

(defn get_led [x n num]
 (cond 
  (> (count x) 0)
   (concat (nth (get leds (first x)) n) (get_led (rest x) n num))
  (and (= (count x) 0) (< n 2))
   (concat "" "\n" (get_led (toList num) (+ 1 n) num))
  (and (= (count x) 0) (= n 2))
   (concat "" "\n")))

(defn showLED [num]
 (do (print (apply str (get_led (toList num) 0 num))))(symbol ""))

Wanna see it in action? Of course you want to -:)


Well...let's go back and keep learning -:D

Greetings,

Blag.
Development Culture.

My first post on Clojure

My good friend and Programming Languages adviser Chris Whealy, send me tweet saying this...


I knew then that I needed to learn Clojure...after all...Chris was the one who get me into Erlang -;)

So...I started to read this book Clojure in Action so yes...you can expect a review later on...


I have experience with Functional Programming and specially with Lisp-like languages (Racket) so I guess my Clojure experience was going to be an easy one...nope...it's being fun but not easy as I thought...and not because Clojure's learning path is hard...but just because I keep thinking that it's pretty much like Racket when indeed its not so...

Clojure is a Lisp-like language...but being based on Java (on the JVM to be exact) it has some really "weird" things that take some time to digest and assimilate...but of course...that has never discourage me...I have learned Haskell after all...so no challenge is too big enough for me -;) (Ok...maybe ASM...but I'm planning to learn Fasm one of this days...)

As always...I couldn't get myself happy by just reading the book...I needed to write some code for it...and what better than a Fibonacci generator...

fibonacci.clj
(defn fib [num a b]
 (cond 
  (and (> a 0) (> num 1))
   (concat [(+ a b)] (fib (- num 1) (+ a b) a))
  (= a 0)
   (concat (conj (conj [a] b) (+ a b)) (fib (- num 1) (+ a b) b))))

(defn showFib [num]
  (fib num 0 1))

Here's the screenshot..


Obviously...you can see that I based my code on my previous Racket code...but the only similarities that remain are the parenthesis...being a Lisp-like language...you can't expect no to use parenthesis, right? -:P

Greetings,

Blag.
Development Culture.

jueves, 19 de marzo de 2015

Real World OCaml - Book Review

I finally finished reading the Real World OCaml book...and I really enjoyed it -:)


This book, just like all the "Real World" series gives you a deep introduction into the language and allow you to start coding pretty fast...of course...if you have used any Functional programming language before...that really helps and OCaml has of course some aspects that makes it not so easy to learn...


The more you read this book, the more you're going to like OCaml...it's a really nice language -:)

The book covers the basics like Lists and Patterns, Records, Variants and Error-Handling.  But of course it goes beyond with Functors, Objects and Command-Line Parsing...not letting important concepts like JSON handling Concurrent Programming aside. So...it's a pretty complete reference to start out.

By the way...the book is 509 pages...so it's pretty long...but full of examples and demonstrations...

Here's a little code that I wrote to flat out lists -;)

Flat_List.ml
open Core.Std

let rec flat list =
 match list with
  | [] -> ""
  | head :: tail -> head ^ (flat tail)

let () = 
 printf "%s" (flat ["1";"2";"3"])

Here's the result...


As you can see...OCaml is fun...so go ahead...read this book and expand your knowledge -;)

Greetings,

Blag.
Development Culture.

lunes, 2 de marzo de 2015

LED is my new Hello World - OCaml Time

Learning OCaml is not easy...I have to admit that...but I'm moving forward -;) So, here's my take on LED Numbers...

LED_Numbers.ml
open Core.Std

let get_leds number =
let leds = [0, [" _  ";"| | ";"|_| "];
            1, ["  ";"| ";"| "];
            2, [" _  ";" _| ";"|_  "];
            3, ["_  ";"_| ";"_| "];
            4, ["    ";"|_| ";"  | "];
            5, [" _  ";"|_  ";" _| "];
            6, [" _  ";"|_  ";"|_| "];
            7, ["_   ";" |  ";" |  "];
            8, [" _  ";"|_| ";"|_| "];
            9, [" _  ";"|_| ";" _| "]] in
 for i = 0 to 2 do
  for j = 0 to String.length(number) - 1 do
   let line = List.Assoc.find_exn leds 
        (int_of_string(Char.to_string(number.[j]))) in
   printf "%s" (List.nth_exn line i)
  done;
  print_string "\n"
 done
 
let () =
 print_string "Enter a number: "
 let num = read_line() in
 get_leds num

The funny thing is that at first I tried to translate my previous Julia and Go codes...but then I remembered that even when OCaml can be made into some sort of an imperative language...it's actually Functional in its core...so I said...Ok...I need to reuse my Haskell code...but somehow I start thinking about a new whole different way of doing it...and I think I came out with a more cleaner and well done version...which is something that only learning a new programming language can give you...a new way of thinking about old problems -;)

Here are the screenshots as always -:)



Greetings,

Blag.
Development Culture.


martes, 24 de febrero de 2015

My first weekend with Amazon Echo

So...after a not so long wait...this Saturday, the Amazon Echo arrived home -:) After a weekend using it...here are my thoughts...

Being an Amazon Prime Member, I got a discount on the Echo, so I get it for $100...which is a pretty good deal...

The Echo comes in a nice black box...which makes it more elegant...


The Echo itself is of course...Black too -;)


It comes with a charger and a remote control...that I haven't used yet as Echo comes with enough microphones to hear you out even a long distances...


Setting it up was easy enough...in no time I had it on my network and the companion app was linked to it...


Of course, I tried the expected, like..."Alexa, what's the weather" or "Alexa, play some music"...I even when farther beyond as asking "Alexa, make me a sandwich"...which Alexa (the waking up word for Echo) kindly replied that she lack the skills for that...

When I told her "Alex, I'm hungry", she told me that I should get something to eat -:)

Of course...there are some things missing...like when I asked her "Alexa, where's the nearest Italian Restaurant"...where she replied to me that she didn't had enough information to answer my question...but...Echo is still young and in constant development...so it's all good in the hood -:)

If you want to see and hear more...here's a small video...



So far...I can only say that I love Echo...I can pair it with my phone via Bluetooth and stream music...I can ask it about Wikipedia facts...and many more things that I'm sure I haven't tried yet...

And of course, I have applied already to be able to code for it as soon as it's available...as always I have a lot of ideas in my mind...

Would I have bought it if it cost me $200 instead of $100? Sure...of course...after having for a weekend...I can't think of not having it -:) And I'm excited about all the possibilities that it can bring in the future...

Happy Echoing!

Greetings,

Blag.
Development Culture.

sábado, 21 de febrero de 2015

My first post on OCaml

After tasting some Functional Programming with Erlang and Haskell I knew it was time to keep moving forward -;) This time...I choose to learn OCaml -:D

OCaml is a multi-paradigm, imperative, functional, object oriented programming language.

Of course...I'm reading a book to learn about it -:) So will see my review as soon as I finish it...


My first impressions on OCaml is that it looks like Haskell...but with some differences...which makes it akward because I tend to code in Haskell but then realized that some things are quite different...anyway...OCaml seems like a really nice language so far and of course...it's not a pure as Haskell...

As the best way to learn is to code...I build a Fibonacci Sequence Generator...based of course of my previous Haskell code -;)

Fibonacci.ml
open Core.Std

let rec fib num a b = 
 match num with 
 | num when a > 0 && num > 1 -> string_of_int (a + b) ^ " " ^ fib (num - 1) (a+b) a
 | num when a = 0 -> string_of_int a ^ " " ^ string_of_int b ^ " " ^ 
                     string_of_int (a + b) ^ " " ^ fib (num - 1) (a+b) b
 | num -> ""
 
let () =
 print_string "Enter a number: "
 let num = read_int() in
 printf "%s" (fib num 0 1)

When we run it...we're going to see this -;)



Greetings,

Blag.
Development Culture.

miércoles, 3 de diciembre de 2014

Keep going with BeagleBone Black - Small Midi Piano

Looks like I'm on fire these days -;) I got somehow the plan of building new things on the BeagleBone Black as fast and often as I can...better way to learn for sure -:)

This time I have made a small Midi Piano...and excuse my total lack of Piano skills -:(


For this I used Python, AdaFruit_BBIO, PyGame and Timidity++.

Greetings,

Blag.
Development Culture.