Clojure differences between Ref, Var, Agent, Atom, with examples

I highly recommend “The Joy of Clojure” or “programming Clojure” for a real answer to this question, I can reproduce a short snip-it of the motivations for each: start by watching this video on the notion of Identity and/or studying here. Refs are for Coordinated Synchronous access to “Many Identities”. Atoms are for Uncoordinated synchronous … Read more

Clojure: reduce vs. apply

reduce and apply are of course only equivalent (in terms of the ultimate result returned) for associative functions which need to see all their arguments in the variable-arity case. When they are result-wise equivalent, I’d say that apply is always perfectly idiomatic, while reduce is equivalent — and might shave off a fraction of a … Read more

What are the differences between Clojure, Scheme/Racket and Common Lisp?

They all have a lot in common: Dynamic languages Strongly typed Compiled Lisp-style syntax, i.e. code is written as a Lisp data structures (forms) with the most common pattern being function calls like: (function-name arg1 arg2) Powerful macro systems that allow you to treat code as data and generate arbitrary code at runtime (often used … Read more

Why exactly is eval evil?

There are several reasons why one should not use EVAL. The main reason for beginners is: you don’t need it. Example (assuming Common Lisp): EVALuate an expression with different operators: (let ((ops ‘(+ *))) (dolist (op ops) (print (eval (list op 1 2 3))))) That’s better written as: (let ((ops ‘(+ *))) (dolist (op ops) … Read more

Simple explanation of clojure protocols

The purpose of Protocols in Clojure is to solve the Expression Problem in an efficient manner. So, what’s the Expression Problem? It refers to the basic problem of extensibility: our programs manipulate data types using operations. As our programs evolve, we need to extend them with new data types and new operations. And particularly, we … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)