Live data from Hacker News

Why Clojure?

blog.cleancoder.com

21–30 of 202 posts

Re: Why Clojure?

#21
> I saw the CARs and CDRs and CADDADDRs and thought it was all just academic baloney; interesting but not truly useful.

car and cdr are accessors for the fields of a basic data-structure; nothing academic about that. The very origin of the names is rooted in systems work, not academics.

(caddr x) provides a shorthand for (car (cdr (cdr x))), which is a pragmatic thing.

You know, like #(* % %) instead of (lambda (x) (* x x)).

Re: Why Clojure?

#22
post #19

Earlier quoted context omitted.

What is 'd'?

It's an alias given to an imported module name. In Python it might be: import really_long_name as rln rln.foo()

I know that part :) What module is it referencing?

Re: Why Clojure?

#23

> I saw the CARs and CDRs and CADDADDRs and thought it was all just academic baloney; interesting but not truly useful. car and cdr are accessors for the fields of a basic data-structure; nothing academic about that. The very origin of the names is rooted in systems work, not academics. (caddr x) provides a shorthand for (car (cdr (cdr x))), which is a pragmatic thing. You know, like #(* % %) instead of (lambda (x) (…

i thought CAR and CDR were named after IBM (?) assembly language on an old machine.

https://en.wikipedia.org/wiki/CAR_and_CDR

Re: Why Clojure?

#24
post #14

Can someone explain me why they always (OK let's say almost always) use math formulas to show what you can do with a programming language ? I'm a desktop application programmer, not a mathematician. I don't need to print the first 25 squares of integers or Fibonacci whatever. In fact I think the hardest math I did at work was using modulo to get even and odd numbers ... Show me how you parse a csv file, how do you co…

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}))

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?

#25

> I saw the CARs and CDRs and CADDADDRs and thought it was all just academic baloney; interesting but not truly useful. car and cdr are accessors for the fields of a basic data-structure; nothing academic about that. The very origin of the names is rooted in systems work, not academics. (caddr x) provides a shorthand for (car (cdr (cdr x))), which is a pragmatic thing. You know, like #(* % %) instead of (lambda (x) (…

i thought CAR and CDR were named after IBM (?) assembly language on an old machine. https://en.wikipedia.org/wiki/CAR_and_CDR

That's right; and that's a systems programming origin, not academics.

Re: Why Clojure?

#27

The most annoying phrase was "less code, less time, less...". Uncle Bob thought us to be explicit, help the reader understand the code and be verbose with the variables etc. Now he loves a Syntax that says #(25 % %)... Aaaalright, try to get a new company member understand a big code base with this massive oneliners. I doubt that this is the right language for enterprise projects.

But that's not a contradiction. He wants you to be explicit with using the language, but if we speak the same language, the standard bits can be concise.

So it's ok to say #(25 % %) because we both speak the same language and we know what it means, the intent is clear.

But it's not okay to call your variables a, b, c, because that's meaning, not syntax, and I can't understand your intent from those variables.

Massive one-liners probably fall into the latter, but I don't think he's advocating those.

Re: Why Clojure?

#29

Can someone explain me why they always (OK let's say almost always) use math formulas to show what you can do with a programming language ? I'm a desktop application programmer, not a mathematician. I don't need to print the first 25 squares of integers or Fibonacci whatever. In fact I think the hardest math I did at work was using modulo to get even and odd numbers ... Show me how you parse a csv file, how do you co…

I'm with you. Reading a text file (line by line) is the thing I do most and what I look for first. If you can't do that in a simple way, I move on. I also look at returning datasets from SQL databases, how you can make a GUI, and a host of other practical things. I think fibonnaci is a sort of one step up from "Hello World", so in a sense it gives a little taste of the language and syntax.

Re: Why Clojure?

#30
post #12

Can anyone give a pro/cons analysis of a ML variant versus of a Lisp variant. Let's say F# versus Clojure? One of the general arguments in Lisp vs the world is that lisp is more concise. F# is really concise. It has datastructures as intrinsic part of the language syntax (just like Clojure, i.e in F# [|,,,|] is an array and in Clojure [...] is a vector, so more or less the same thing). Furthermore, the type inference…

Great question as I'm trying to make that decision myself. I love Lisp in general and the JVM is great and ubiquitous, so Clojure seems good. The reality is that every time I try to learn it, I get stuck learning leinegen, Emacs...etc, which is more than I have to deal with when using Python, so I skip it. Also, it seems like you get a .jar file and have to run it in conjunction with something like "Java -jar clojurefile.clj". I know that isn't too bad, but once I installed F#, I just put the compiler "fsc.exe" and the REPL/interpreter "fsi.exe" in my path and it is pretty simple now. I normally have an fsi window open for testing and write my full code in Notepad++ and then feed that to fsc.exe when I'm done and I get a little executable that is ~5kb. As long as a coworker has the .net runtime on their computer I can give that to them no problem. I'm sure Clojure can do something similar, but as I'm not a Java/JVM person I have no clue how.
Post reply on HN