News for hackers. Stuff that matters.
Re:Why Clojure? by beders on Friday August 23, 2019 @08:48AM (#20776930)
Extracting two columns out of a excel sheet:

     (->> (d/load-workbook file "Questionnaire.xlsx")
       (d/select-sheet "Sheet1")
       (d/select-columns {:A :item :B :price}))
Re:Why Clojure? by jmnicolas on Friday August 23, 2019 @03:15PM (#20781459)
Now we're talking. It would probably take 20+ lines of C# to do the same thing.

How do you manage errors? What happens if Questionnaire.xlsx or Sheet1 doesn't exist ?

Re:Why Clojure? by purple_ducks on Saturday August 24, 2019 @02:48PM (#20788952)
> How do you manage errors?

It becomes unwieldy like every other language.

> What happens if Questionnaire.xlsx or Sheet1 doesn't exist ?

Runtime exception.

I've seen too much Clojure code (and this goes for every language where error handling is optional - Hi Javascript!) just skip error handling and focus on "happy path".

And as demonised as Java's checked exceptions are, they at least forced error handling to be thought of.

Re:Why Clojure? by beders on Saturday August 24, 2019 @03:40PM (#20789256)
Or you could use: https://github.com/adambard/failjure

Ya'll underestimate the power of a programming language to create a programming language. Just replace the arrow with `ok->>`

Re:Why Clojure? by kgwxd on Friday August 23, 2019 @11:25AM (#20778587)
What is 'd'?
Re:Why Clojure? by lastofus on Friday August 23, 2019 @11:57AM (#20778895)
It's an alias given to an imported module name. In Python it might be:

  import really_long_name as rln
  rln.foo()
Re:Why Clojure? by kgwxd on Friday August 23, 2019 @02:36PM (#20780943)
I know that part :) What module is it referencing?
Re:Why Clojure? by sushimako on Saturday August 24, 2019 @05:40AM (#20786215)
Re:Why Clojure? by etatidem on Friday August 30, 2019 @06:18AM (#20837242)
I like the suggestion in namespace aliasing in https://stuartsierra.com/2015/05/10/clojure-namespace-aliase...:

As a general first rule, make the alias the same as the namespace name with the leading parts removed.

  (ns com.example.application
    (:require
     [clojure.java.io :as io]
     [clojure.string :as string]))
Keep enough trailing parts to make each alias unique. Did you know that namespace aliases can have dots in them?

  [clojure.data.xml :as data.xml]
  [clojure.xml :as xml]
Eliminate redundant words such as “core” and “clj” in aliases.

  [clj-http :as http]
  [clj-time.core :as time]
  [clj-time.format :as time.format]
Then you can see immediately what `d` is...

Namely:

  (require '[dk.ative.docjure.spreadsheet :as spreadsheet])
(You would still not know the library and might have to ask the same question, but it makes more sense.)

About `d`:

There are always exceptions. For example, some namespaces have established conventions for aliases:

  [datomic.api :as d]