Things made with lisp inside.

The lisp language is characterized by “s” expressions; a syntax even more basic than XML. This syntax can be equally used for data and code. Unfortunately, since it was so easy to make a compiler for the syntax, no one could ever agree on which compiler to use. So it is divided up among the likes of:

  • Scheme
  • Common lisp
  • Emacs Lisp

Despite the fragmentation, here are some things made with Lisp

  • Maxima (algebra system) (Common lisp)
  • GnuCash (accounting software) (Sheme)
  • Emacs (Text editor) (Emacs lisp)

Double quotes vs single quotes

As a coder, you are often faced with the conundrum. Do I choose single quotes or double quotes?

Alas, in some languages, single quote is reserved for defining single characters only but other languages give you the options of using either. Sometimes double quotes imply variable interpolation, but you shouldn’t be bothering with that anyway. Single quote is better than double quote for the following reason that you don’t Have to hold shift to type a single quote.

Another way of looking at type systems.

Type systems are often touted as making software more secure and more performent. However there is another dimension that I would like to discuss. Documentation. If you look at much python code you can be stuck worrying just what you are meant to place as arguments to functions. If you are dealing with a large library it’s not so much an issue, but what if you are looking at the internals of a library or a smaller library it can be. If you look at open source Javascript projects you will often see documentation for functions with a consistent layout. Int for integers and Strings for strings etcetera. What about creating a linter that requires that the documentation be kept to a standard? In effect you have created a type checker. Type checkers could also be called “documentation guarantors”.

When clojure is faster than javascript

Here is some propaganda for the Clojure language.

Let’s benchmark the Java Clojure compiler against a Javascript interpreter based on v8(nodejs).

Write the two files as follows:

fib.clj

fib.js

Now we try to benchmark them.

As you can see Clojure took a lot longer. But what if I had a long running app like a web server?
Maybe Clojure just takes longer to load?

In the spirit of presentation driven development PDD this is where a tool I have written comes in. It’s called timeconsole. At the moment, you can get it by

cabal install timeconsole

Now we try to benchmark them again.

As you can see Clojure takes longer to load than node (approx. 2 seconds vs 0.2 seconds), but clojure is still slower even when start up time has been factored out. I entitled this article with the notion that clojure would be faster, so what to do here?

Type hints to the rescue!

If we limit ourselves to the long number type we can get the code to run faster.

fib2.clj

And so it does. I could use something like ASM.js where I think it would beat clojure, but since I don’t have it installed, I’ve left it there.

You can get the source for this article here

Things made with Haskell

Haskell, the language of pretty lambda syntax. What are the fruits of this forest? Here, I will make some propaganda about it.

There are not that many things written in Haskell. You could probably count the ones people use on your hand.

  • Xmonad (Window Manager)
  • Pandoc (Convert between textual document formats)
  • Git Annex (Syncing)
  • Gitit

Darcs used to be bigger but most haskellers have moved to GIt already. It may seem unfair to include GHC, but given how complex a compiler it is, It says a lot about Haskell. Pugs used to be big around decade ago but now how slipped out of attention.

There are a few compilers, most noteably haskell ones such as GHC, which are written in Haskell among some languages which have features that are not present in haskell these are

  • GHC
  • Agda
  • Idris
  • Elm

Then there are Haskell libraries. Some of these libraries are quite exceptional. Again there are not many popular ones, but here is a list.

  • Diagrams (For rendering vector images)
  • Parsec (For parsing text)

Then there are git libraries that on there own, don’t do anything, but can make your code much more fancy. A good example of these are

  • Monad (Type class to compose functions with simple do keyword and arrows <- which you can customize the behavior of per type constructor (Term sourced from on category theory!))
  • Lens (unite getters and setter into a single object)
  • Pipes or Conduit (Compute over streams of data without creating temporary data structures which cause your application to run out of memory).
  • Arrows (like monad, but for constructors with an arity of 2)
  • Comonad (Monad, in reverse)
  • Functor,Applicative,Foldable,Traversable (more typeclasses to generalize functions)
  • Free Monad.

There are a couple of things I might like to try out. These are apparently good.

  • Shake (make alternative)
  • music-suite (render music notation)

There is also some pretty good libraries for dealing with parallelisms. This is also apparently good.

  • STM (Atomic variables)
  • Parallel strategies (There is a book on these).

Then there are a few more apps written in haskell to help people code haskell

  • Ghci
  • Pointfree (compress haskell code into smaller haskell code)
  • Yi (Text editor)
  • Leksah
  • djinn (Generate Code from type signatures)
  • cabal
  • hackage
  • hoogle
  • haddock
  • Template Haskell (useful with Lens library)
  • Generics
  • GHC API

Haskell has a interesting collection of data structures. Here I will mention a couple.

  • ByteString (Serialized, strict or non strict)
  • Sequence (another lIst type, this time based on trees)

Everything listed is open source and there are some non open source ones, but I haven’t mentioned them.

The quantity fallacy

Practice makes perfect. Or so is said. Want to be good at writing? Just do it many times and you will become perfect at it. Something is missing from this. The part where you learn.

Experimentation is essential for overall improvement, although this sounds quite trite, I think it’s more accurate than the quantity argument.  Learning something can take a long time, and when you are changing one thing at a time as is most manageable, you will find yourself going through many of the motions you have gone through before. This part is often refereed to as the practice.

The point I’m trying to make is that if you don’t make enough changes when practicing it will take away the precious time you have to actually learn something. Keep in mind the amount of changes you are making because you may be falling into the quantity fallacy. Also try to go to lengths to reduce the time in your experimentation which does not involve any changes.

Another way of looking at it is from the following quote in the form of a question.

“Did you gain 10 years of experience or just 1 year of experience 10 times?”

There is a real sense in which repetition does make perfect, This is in regards to biology. Stretching muscle long enough will eventually leave it loose like a rubber band. There is also a similar concept in regards to memory where you can recall something quicker if you think it more often.