February 1, 2015 clojure notes

'(LiveScript vs ClojureScript)

  1. LS
    1. Pros
    2. Cons
  2. CLJ(S)
    1. Pros
    2. Cons
  3. Racket
    1. Pros
    2. Cons
  4. ES6
    1. Cons
  5. OCaml
    1. Cons
  6. R
    1. Pros
    2. Cons
    3. Compelling RStudio Features
      1. Pros
      2. Cons
  7. But what do they want to build?
  8. Requirements

The following are my pros/cons notes comparing LiveScript (which I really loved using) to Clojure(Script), and eventually to Racket. The conclusion was that ClojureScript wins, partly because of my other biases toward Clojure.

LS

Pros

  • concise, haskell-like

  • improved coffee, a very popular language

  • npm

  • node is fast

  • beautifully simple standard node lib

  • brunch et al

  • jade (hiccup might suffice, but there is clj-jade)

  • angular/backbone

  • express

  • socket.io

  • d3 (but c2)

  • native json

  • many lessons/projects already written in ls

  • put into any proj that uses coffee

  • testing frameworks

  • plugs into everything where js is used with minimal change

Cons

  • callback hell

  • impossible async recursion (and no tco)

  • not multi-threaded so maybe harder to scale for production

  • poor repl

  • too many npm pkgs to choose from

  • won’t paste into browser repl

  • bad vim syntax highlighting (fixable)

  • node won’t go on windows (anyone care?)

  • prelude confused with underscore/lodash/async/nimble

  • obscure

  • syntax heavy; a bit quirky

  • surprising scope issues

  • JavaScript\* community fragmented among langs/tools

CLJ(S)

Pros

  • lisp, beautiful functional

  • a fit for every domain

  • immutability

  • avoids node event loop

  • 4clojure for practice/competition

  • multi-runtime options (java, node, browser)

  • maybe preferred by academics

  • browser repl?

  • native structures more expressive/concise than json and racket’s

  • edn

  • concurrency

  • sensible scoping

  • easier to teach (vs ls), been done many times

  • laziness

  • clojure toolbox (nicely settles on a few tools for any job)

  • many settled libs: korma/sql, hiccup/templating, luminus/web, incanter/stats, midje/testing

  • obviates ChucK with Overtone

  • lighttable as drracket competitor

  • om/reagent/react

  • practical real-world, employable skillset

  • js compatible (ClojureScript)

  • simple web deployment via uberjar/uberwar to jetty, tomcat, or nginx

  • google closure compiler/optimizer (though heavy)

  • macros

Cons

  • too bulky for raspi!

  • memory hogging beast! so not good for kids learning on limited hw

  • slow startup? (but maybe okay since single repl stays alive for days)

  • lots of parens, more verbose

  • prefers emacs (but PG uses vi)

  • heavy on java and suffers from its limitations

  • RPN opaque for beginners

  • lacking JavaScript/node/npm ecosystem?

  • complexity of setup

  • terrible error messages, but clj-stacktrace

Racket

Pros

  • fast and light and easy to generate executables (for meager hardware)

  • nice, kid-friendly starter book (Realm of Racket), plus HtDP

  • actually is plt-scheme, so little schemer and sicp also apply

  • has graph plotting and math modules

  • well accepted as academic/teaching language, with scheme history

  • many teaching resources, maybe even full course

  • well contained/organized documentation

  • might want to build everything from scratch anyway, for teaching purposes

  • DrRacket

  • nice repl(?)

  • scribble documentation

  • a scribble-based blog engine

  • friendly error messages

  • most flexible language (toolkit)

  • accepts [] in place of ()

  • language "teach" packs

  • decent startup time: 230ms for hello.rkt, 46ms with just racket/base

  • no java to deal with

  • probably nice small install with racket-minimal from aur, excluding DrRacket

  • pretty simple to move to clojure from racket, later on

  • probably does recursion right

  • true pattern matching(?)

  • nice unicode identifier support, even as symbols! use λ instead of lambda

  • raco (lein equivalent?)

  • lang hosted on github

  • browsable package repo: http://pkgs.racket-lang.org/ and http://planet.racket-lang.org

  • only 20 MB for racket-minimal install

  • probably great tdd testing utils

Cons

  • syntax not as brief as Clojure

  • lacking ecosystem (web framework, templating, overtone, etc)

  • no vim plugins like fireplace/vim-sexp? (workflow)

  • lacking libraries (mongo, etc)

  • lacking syntax; everything is parens: harder to read (but [] accepted)

  • less powerful data structures

  • maybe not scalable? well, people claim it’s faster than python

  • no good js transpiler story (whalesong?)

  • a little bulky to install at 400 MB (but sans-DrRacket pkg available

  • docs not as friendly as http://clojuredocs.org/

? npm equivalent? maybe raco planet

ES6

Cons

  • still just an ugly and verbose [braces and semicolons] syntax

  • will need transpilation for some time, so might as well use another lang

OCaml

  • fast

  • statically typed

  • tools can be very good

  • immutable by default

  • growing in popularity

  • like haskell but better/simpler

  • great completion

  • utop repl

  • ocsigen web

  • good error messages

  • interfaces are slick

Cons

R

Pros

  • vector oriented

  • replaces graphing calculator

  • fits math/stats curriculum

  • libraries

  • graphing

  • shiny

  • fast and light

  • fantastic repl and help system

  • math and data oriented

  • so many books/learning resources

  • industry standard

  • rstudio(?)

Cons

  • no hash/dict native

  • not a lisp

  • syntax can be awkward and a bit ugly

  • not very web oriented(?)

  • have to know stats to do much

  • probably not as good tdd testing utils

  • maybe slow for big data sets/crunching

Compelling RStudio Features

Pros

  • spreadsheet

  • searchable help and libs

  • graphic window mgmt

Cons

  • binary is 260 MB

  • bad fonts and colors

  • mouse-oriented

But what do they want to build?

  • web apps

  • graphs/stats/analytics/reporting/journalism

  • parallel/fast improvements

  • games

  • robots

  • back-end service

  • cars

  • automation

  • system tools

  • interfaces

  • iot/devices (home automation: lights, garage door)

  • making music

  • language processing

  • measuring instruments (farming, atmosphere, seismology, etc)

  • or whatever, there are lots of jobs if that’s the end goal

Requirements

  • concise

  • functional

  • easy enough to learn

  • simple environment

  • minimal machine/$ resources

  • multi-domain

  • somewhat visual

  • fun and not painful