Sid Carter

On Simplicity

A must-watch talk by Clojure creator Rich Hickey on simplicity.

Computers and Me

I first programmed on a computer, in LOGO and BASIC, almost 25 years ago. I loved it back then for the things I could do with it and the future possibilities. I love it even more now for all amazing fantastic creations you can make from it. It changed my world then and continues to change it every single day of my life.

I’ve been through some interesting times and there’s more to come. Everything I’ve learnt has been through many successes and failures. When I first started playing with Linux, I would reinstall it almost every day cause I wanted to try something new. Then I started recompiling my own kernels to make it lighter, faster, betterer. So many failed boots. I even used to run only on development versions. That stopped after a while, of course.

I loved getting onto Debian. Then, I got introducted to FreeBSD and the ports system. Magic!

Now, I exclusively use a Mac because it has a FreeBSD kernel and a beautifully designed operating system that just works. I’m learning things, things that didn’t exist almost a decade ago, things that are changing the world as we know it.

I love it. I love the feeling that comes with all of this. There is so much to do and miles to go, many many miles to go.

The future’s bright and this is just the beginning….

On Java

After working on Clojure stuff and then on Java, I can understand why some would prefer Java.

With Java, you have a process, an order so to speak of going about doing things. It forces you to follow a model and that helps build discipline where you have to think of the bigger picture before you can get into the details. And if you don’t think through, you’ll face multiple issues along the way.

You are forced to pay attention to how you want to structure your classes, what types you want to use based on the data that’s coming in or how you want to present the data from those objects more precisely.

That actually helps you improve your programming skills. You think of the data you’re working with much more, since it’s all about playing with that data.

With Clojure, you don’t pay as much attention to type, for instance, because of the dynamic typing, and you can make mistakes there.

Now, because of Java programming, my Clojure is getting better too.

Little nuggets in Clojure and Python

With any new language, as you proceed to use it and learn, you figure out ways to do certain things. For e.g., often times I want to know what the type a certain result or a variable is.

It’s a good thing both Clojure and Python have a REPL.

In clojure, if you wanted to find the type or class of something, you would go:

claws.core=> (map * [3 4] [1 2])
(3 8)
claws.core=> (class (map * [3 4] [1 2]))
clojure.lang.LazySeq
claws.core=> (type (map * [3 4] [1 2]))
clojure.lang.LazySeq

What if I wanted to find the functions in a namespace1? From StackOverflow:

claws.core=> (keys (ns-publics 'clojure.tools.cli))
(summarize parse-opts cli)

If you wanted to find the type of a class or a variable in python, you would use python’s builtin function type thusly:

>>> import boto.ec2 as ec2
>>> conn=ec2.connect_to_region('us-east-1')
>>> type(conn)
<class 'boto.ec2.connection.EC2Connection'>

And if you wanted to get the modules, functions etc., of a class in python, you would use inspect2:

>>> import inspect
>>> >>> inspect.getmembers(inspect, predicate=inspect.isbuiltin)
[('currentframe', <built-in function _getframe>)]

1 More info about clojure namespaces is available here.

2 Inspect module’s documentation is here.

Getting it on with clojure

About a week or two ago, I decided to focus on two things. One would be SaltStack and the other would be Clojure.

Over the last week, I’ve learnt quite a bit about clojure and there’s lot more to learn. I wanted to document all the stuff I’ve found in the process of learning clojure.

I will add more here, as I continue to learn and explore clojure. Also, the folks on #clojure @Freenode are super friendly and helpful.