Live data from Hacker News

Why Clojure?

gaiwan.co

221–230 of 302 posts

Re: Why Clojure?

#221

Earlier quoted context omitted.

Haven't worked much in Clojure, but I have the same experience with Common Lisp. The malleability and live image workflow is just very pleasant to work with.

Clojure is like that, but because data structures are default immutable, and all of the standard library (and the vast majority of 3rd party libraries) are also default immutable, the stress level is much lower. You can still get mutability and I do this on every project. But it's a very small percentage of the code, less that 1%, and also well-defined. Something like FlowStorm [0] isn't really practical in anything…

I know. What I just miss in other implementations is the live reflection in the SBCL REPL via Sly/Slime for example. And conditions.

When I do CL, I try to code it in a more immutable style and avoid things like self until I get my own version bootstrapped.

Re: Why Clojure?

#222
post #192

Earlier quoted context omitted.

The parent comment illustrates the problem with one clear example. In real-world code functions pass around amorphous maps, they add, subtract and transform fields. There is no way to know what's being passed around without reading the source of the whole chain. Statically typed languages reduce the need to know how the data is structured or manipulated. The market has clearly chosen this benefit over what Clojure ca…

> There is no way to know what's being passed around without reading the source of the whole chain. But that's not what a Clojure dev would do. 1) We use Malli [0] (or similar) to check specs and coerce types if needed at every point. Checks can be left on in production (I do), or disable–up to you. 2) If the coercion is difficult, use something like Meander. [1] 3) If even that isn't straightforward and you need act…

Most people don't use those libraries, nor do most libraries use those libraries. They don't help me understand most code out there beyond my carefully orchestrated app code. I'm back to reading the source.

But this long list of runtime libraries is definitely a downside of Clojure. It's people trying to grapple with things mostly solved with static typing where you can just write a(b(c())) and it fails before it hits your fancy yet-another-thing-to-learn Malli library in runtime.

They might be great libraries, but you're only seeing one side of the trade-off.

I learned Emacs with evil-mode, paredit, nrepl/cider, and Clojure in my early 20s and used them for six years, and I was pretty gung-ho about it like you. But eventually I started using static typed languages for work and decided that I couldn't go back. It's like trying to read Javascript after you've spent five years with Typescript. You just think "wow, I can't believe I did that for so long."

And I'm remembering times I've used paper and pencil to figure out how map is being transformed as it's passed through library code. I don't miss that.

Re: Why Clojure?

#223
post #195
post #190

Earlier quoted context omitted.

You can eval strings in Javascript, so pretty sure that's possible.

Looking around I don't find any maintained projects for this purpose.

It's just a native function named eval(), so I wouldn't expect to find projects built up around it.

Re: Why Clojure?

#224
post #195

Earlier quoted context omitted.

Looking around I don't find any maintained projects for this purpose.

It's just a native function named eval(), so I wouldn't expect to find projects built up around it.

That's not enough, there ought to be IDE/editor integration and so on.

Here's one such project: https://github.com/swank-js/swank-js

Re: Why Clojure?

#225
post #93

I've been working in Clojure now for about 12 years. Maybe 12+ years of Java prior to that. I've created some great apps, and great libraries (in both Clojure and Java). I often describe Clojure as "the least worst programming language", which is an off-handed complement, but I think accurate. Things you don't like can generally be fixed (at least locally) using macros and libraries. The core is strong, a good basis…

"...not as clumsy or random as AI, an elegant weapon from a more civilized age."

Re: Why Clojure?

#226
post #177

Earlier quoted context omitted.

Did you or any of your fellow devs have ADD or ADHD? How did they adapt to dynamic types? I have ADD and I once heard that devs with ADD/ADHD have an incredibly small heap size for context but compensate for their weakness by being great at solving logical problems in that small heap. Types have been essential for me when functioning in code bases. I really struggle with pure JS and untyped Python. Clojure was simila…

Reducing cognitive load is the key. Several approaches I usually take are: 1. Make strict rules for code convention, especially naming things, and stick to that. 2. Use intermediate variables (let binding) often 3. Turn meaningful code block to a function often 4. Write Clojure specs and turn them to docstrings In addition to that, a real REPL programming really helps to do small tests and understand the code quickly…

Do you have any resources showing what this type of coding works in the real world? I keep running into this same types issue when I use languages without types specified everywhere, where the cognitive load gets too much for non-trivial projects. I would be pretty unhappy writing python without type hints and tools that check these for correctness built into my workflow for example.

Re: Why Clojure?

#227
If you are using Clojure please look at this:

https://www.flow-storm.org/

If you can get past the serviceable UI then it's coding nirvana literally looking inside the program

Pair that with a good test suite so you can trigger lots of different scenarios and you're in heaven

Re: Why Clojure?

#228

Earlier quoted context omitted.

REPL code is copy/pasted straight into tests. So really, REPL is for helping write tests. BTW, when Clojurians talk about REPL, it's not about that separate window where you type and run the code as in other language such as python. They are talking about an invisible REPL running behind the scene, to which they send code within their editors, and the results show up in the editors too. There's no need to "miss stati…

Neither defprotocol nor deftype introduce static typing into Clojure. Errors in their usage are not checked statically and are only discovered at runtime.

No, defprotocol and deftype have the same properties as Java interface and Java classes, and the types are checked at compile time. This is static typing. Period. Clojure is a compiled language, it does check typing during compilation.

Re: Why Clojure?

#229

Earlier quoted context omitted.

I know people talk about python being Lisp without brackets, but for example in SBCL and in other lisps like clojure I could just run a larger function, figure out that there is the wrong output, change a tiny function in it, eval that, eval the larger output, get the result. In SBCL there is also the break loop which is just magical. I do not know how you do that in python without using a debugger and stepping throu…

> I know people talk about python being Lisp without brackets What on earth?? Who are these people, this is the first I've heard of this and am having trouble understanding what the argument could be. Like, basically all languages get transformed to an AST as part of the compile step soooo I guess any language is sort of a lisp.

Peter Norvig: https://www.norvig.com/python-lisp.html - "Basically, Python can be seen as a dialect of Lisp with "traditional" syntax (what Lisp people call "infix" or "m-lisp" syntax). One message on comp.lang.python said "I never understood why LISP was a good idea until I started playing with python." Python supports all of Lisp's essential features except macros, and you don't miss macros all that much because it does have eval, and operator overloading, and regular expression parsing, so some--but not all--of the use cases for macros are covered."

"Take a Lisp program, indent it properly, and delete the opening parens at the start of lines and their matching close parens, and you end up with something that looks rather like a Python program."

also Peter Norvig on HN: https://news.ycombinator.com/item?id=1803815

Re: Why Clojure?

#230
post #64

As a data point: I've been running my solo-founder SaaS business for 10 years now using Clojure. It changed my life. It would not have been possible without Clojure and ClojureScript, building and maintaining an app of this complexity would have exceeded my limits. The article is excellent and I agree with everything in it. The stability of the language is unbelievably useful. I look around and it seems it isn't valu…

You will find that "whatever language you are most familiar with" is the only one that you will perceive makes it possible for you to build whatever you are working on.
Post reply on HN