335 karma · joined Jul 28, 2015 (11y ago) · 158 submissions
comment 9y ago · link · parent
As soon as I had to dynamically build queries (essential when moving beyond the complexity of "select this user record") I ran into issues with yesql's lack of power.
It also fits closer to one of the main principles of clojure, to be data-driven/data-first/just-use-data etc etc
comment 9y ago · link · parent
In case anyone needs it for mysql, the following adds basic support for "on duplicate key update" clauses:
(defmethod sql-format/format-clause :upsert [[_ updates] _]
(let [parts (for [[column value] updates]
(str (sql-format/to-sql column) "=" (sql-format/to-sql value)))]
(str "ON DUPLICATE KEY UPDATE " (string/join "," parts))))
(sql-helpers/defhelper upsert [m [updates]]
(assoc m :upsert updates))comment 9y ago · link · parent
Either way, unrelated to the point in the article about the advantage of immutable values for repl, not immutable bindings.
I would certainly agree that truly immutable bindings would be at best quite a stumbling block for repls, but so far no one was advocating for them as a good repl feature.
comment 9y ago · link · parent
I find I don't get much use out of it anyway, due to immutable values and (mostly) pure functions I find I don't usually need the whole program to be running and frozen in time.
However, I'd like to know what I'm missing.
comment 9y ago · link · parent
Immutability is not the same as rebinding a name (in clojure at least) e.g. the following is perfectly valid (global and local binding of the same name repeatedly)
(def a 1)
(def a 2)
(def a 3)
(println a)
=> 3
(let [a 4
a 5
a 6]
(println a))
=> 6comment 9y ago · link · parent
Choosing libraries shouldn't require careful examination of their output file size, especially if you only want half the functionality.
comment 9y ago · link · parent
There are several things to consider with download time:
- is this a website? why on earth do you need react or anything for a website?
- is this a single page web application? then to develop with a medium sized team and an increasing feature set its nice to pick a language and library/framework that enable that.
- do you really care about mobile users performance and bandwidth? then you need a native app
This is all unrelated to the article, which is merely an uninformed rant about someone who doesn't understand the point of immutability and its use within functional programming as opposed to shoe-horning it into imperative code.
comment 9y ago · link · parent
Plus due to the google closure compiler code can be minified with an aggression unknown to the typical js minifiers.
Add to that tree-shaking (removing unused code) and the long term size of your app is looking good.
I find clojurescript and specifically figwheel reduces language annoyanes and tooling problems. No more do i have to jump through hoops to get a project setup, or pick the latest and greatest build tool (grunt->gulp->webpack->jspm)
comment 9y ago · link · parent
However, there is a better way ... lein new figwheel my-app, clojurescript+reframe gives you all the benefits of redux with an order of magnitude less boilerplate (also hot reloading and immutability by default without no extra setup or ceremony)
comment 9y ago · link · parent
However, for a web page I agree it would be absurd.
comment 9y ago · link · parent
not bashing flash/flex though, my first job was making educational flash games. I wish I could be as productive and have as much fun when working in html and js.
comment 9y ago · link · parent
However, I'm not a haskell pro, so I don't know if I'm just missing the obvious here.
comment 9y ago · link · parent
comment 9y ago · link · parent
I say this as a person learning idris and Haskell and loving it btw, before anyone prematurely tries to convert me to static typing.