Changes between Version 64 and Version 65 of Clojure Client Tutorial


Ignore:
Timestamp:
Aug 22, 2011 11:35:36 AM (13 years ago)
Author:
kedwar10
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Clojure Client Tutorial

    v64 v65  
    3030
    3131Lisp and Scheme resources:
    32 * The Little Schemer, The Seasoned Schemer (very gentle introduction to scheme).
     32* The Little/Seasoned/Reasoned Schemer (very gentle introduction to scheme).
    3333* How To Design Programs [[http://www.htdp.org/]] (introduction to scheme and programming).
    3434* Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp, by Peter Norvig (introduction to lisp and AI).
     
    3636* Lisp source code for AIMA [http://aima.cs.berkeley.edu/lisp/doc/overview.html].
    3737
    38 
    3938Some advice for clojure programming:
    40 * For debugging, use [http://richhickey.github.com/clojure-contrib/trace-api.html].
     39* Always strive for pure functions (as in no side effects).  This is critical if you want to avoid refactoring your code later on. 
     40* For tracing functions, use [http://richhickey.github.com/clojure-contrib/trace-api.html].
    4141* :pre and :post conditions can be used to put constraints on functions.  Here is an example [http://blog.fogus.me/2009/12/21/clojures-pre-and-post].
    42 * Leiningen provides "compile" and "run" commands: NEVER USE THESE (unless you want java interop, then you must be careful to recompile the function you wish to export, before running them in the REPL).
     42* Prefer working from the leiningen REPL, avoid compiling and running.
    4343* If you define a record in a namespace and wish to access it in another, you must explicitly import it with the ":import" keyword in your namespace declaration.
    44 * Giving names to your anonymous functions will dramatically increase the usefulness of clojure error reporting (an example: (fn identity [x] x).  Doing this will also allow the function to call itself.  Sometimes you can get slightly better error reporting if you compile your project; if you do this, run "lein clean" immediately afterwards.
     44* Giving names to your anonymous functions will dramatically increase the usefulness of clojure error reporting (an example: (fn identity [x] x).  Doing this will also allow the function to call itself.
    4545* If you want to ensure tail cail optimization, use the "recur" function instead of using your function name.  "recur" also works with loops.
    4646* "Weird" error messages usually result from forgetting to specify the arguments during a function definition or from mismatched parenthesis.
    47 * The function that you pass as an argument to swap! must be pure (as in no side effects).  This is because the update to the atom is retriable so it may get called more then once.
    4847* Atoms are your go-to way to manage state.
     48* The function that you pass as an argument to swap! must be pure.  This is because the update to the atom is retriable so it may get called more then once.
    4949* If you must define a type, prefer the simplest option.  A decision flowchart: [http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/].
    5050* If a future fails silently, try just running your function in a regular thread instead.