Live data from Hacker News

Why Clojure?

gaiwan.co

171–180 of 302 posts

Re: Why Clojure?

#171
post #142

Earlier quoted context omitted.

> Gleam takes more code to write than rust. Do you have some source for that? Perhaps an example?

No. Take that with a grain of salt. I did some large file reading in the past and gleam doesn't have a good abstraction for that yet whereas in rust it was straightforward. Simplifile basically reads the whole file into memory.

They've added https://hexdocs.pm/file_streams/0.6.0/ for this purpose.

There's a bit of ceremony but similar to how you can interface with Java libraries from Clojure you can pull in Erlang when Gleam isn't enough.

You can do some code shortening with use, https://erikarow.land/notes/using-use-gleam, but it will likely always be rather chatty and won't support metaprogramming: https://lpil.uk/blog/how-to-add-metaprogramming-to-gleam/

Re: Why Clojure?

#172

Earlier quoted context omitted.

> justify using it Justify using it against what? Can you name a single other language that does things better than Clojure? Not from your "point of values," but try seeing it from my position. Is there anything that can replace Clojure for me? I love the dynamism, malleability of the language - the flow; writing Clojure programs for me feels like playing a video game - it's plenty of fun. I don't get the same kicks…

What was it about Elixir that you found dissatisfactory? I am currently evaluating Clojure vs. Elixir for a new project.

I spent a lot of time objectively evaluating languages for a new project I built several years ago. Elixir won out. It has now been 12 years and I still believe Elixir was the right choice for the following reasons (this list is not exhaustive):

BEAM handles concurrency better than the JVM.

Elixir threads are implemented using private memory where Clojure uses public memory.

Mix is superior to Clojure’s tooling.

Elixir is easier to learn and write.

OTP is fantastic.

Phoenix is an excellent web framework.

Re: Why Clojure?

#173

I love writing Clojure. Whenever I say that publicly, there are inevitably some voices challenging my stance with skepticism, criticism, and attempts to discredit whatever I say provides practical value for me. Then I have to explain to them, "no, it's not the only language I know," "yes, I've used dozens of other languages before," "yes, including languages with robust static type systems as well." And you know what…

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…

Types and other techniques as an accessibility tool for the ADHD brain - Michael Newton talk https://www.youtube.com/watch?v=vd1-rAIYV6I

Re: Why Clojure?

#174
post #164

Earlier quoted context omitted.

I've never seen anything but praise for clojure.

The dynamic typing and "everything is a map" can be a PITA. At the moment I'm working on a codebase that has I/O to JSON APIs, Avro schemas and postgres databases. That means that a field called "date" can be either a string, integer days since the epoch or a Java Date, and (because this codebase isn't great) there's no way of knowing without tracing the call stack. With the right discipline (specs, obsessively norma…

I'd emphasize that it's a problem with your particular code base. If you set it up correctly, all dates are properly parsed at the boundaries and you would only deal with one type of date inside your app. I'm working on a large Clojure app with a lot of date handling and never had any issues. For me, a date is always juxt/tick date.

Re: Why Clojure?

#175

I love writing Clojure. Whenever I say that publicly, there are inevitably some voices challenging my stance with skepticism, criticism, and attempts to discredit whatever I say provides practical value for me. Then I have to explain to them, "no, it's not the only language I know," "yes, I've used dozens of other languages before," "yes, including languages with robust static type systems as well." And you know what…

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…

Not everyone with ADHD struggles with small heap size.

Even if I have a smaller total heap size (maybe), personally my hyper focus allows me to nearly dedicate all the heap space to the specific task at hand. I probably outperform neurotypical people here. I just can't have anything else in my head. Task switching kills me.

So it is hard to say cause everyone is a bit different.

For me the interactive, REPL-based workflow makes my ADHD brain very happy. Always having a program running is really nice.

Plus immutability makes it much easier to reason about things.

I do like static typing as well and I could see how it might help. I strongly believe that gradual typing allows for the best of two worlds, so that you can do both exploratory, interactive programming and type driven programming, depending on your needs.

Not sure how well the solutions for gradual typing in Clojure work though. I have only experience with Common Lisp. Coalton might the exactly what you need: https://github.com/coalton-lang/coalton

Re: Why Clojure?

#176
post #108

Earlier quoted context omitted.

I played with Clojure just a bit in 2014 because I wanted to write GUIs in Om, and this gave me a seriously warped habit of calling React.el('div',...) for a while. Sorry not sorry. I'm used to using TDD for fast feedback as I'm molding my code. Do you miss unit testing? Or, do you find that the REPL in no way obviates unit testing? And, do you miss static typing?

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.

Re: Why Clojure?

#177

I love writing Clojure. Whenever I say that publicly, there are inevitably some voices challenging my stance with skepticism, criticism, and attempts to discredit whatever I say provides practical value for me. Then I have to explain to them, "no, it's not the only language I know," "yes, I've used dozens of other languages before," "yes, including languages with robust static type systems as well." And you know what…

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, immutable data structures with data-oriented approach and locally scoped code blocks combined with structural editor are godsend as well.

Re: Why Clojure?

#178
post #169

Earlier quoted context omitted.

Nobody would argue that Java is not statically typed. That's my point. Clojure offers the same as what Java offers. If you write code in a defprotocol everywhere style, as many Clojure libraries do, your code won't compile if you got the types wrong. The same as Java. How's that not static typing? Which part of that is weaker? So what exactly this "Clojure dynamic typing" nonsense is about, I fail to see. Automatical…

> If you write code in a defprotocol everywhere style, as many Clojure libraries do, your code won't compile if you got the types wrong. The same as Java. How's that not static typing? Which part of that is weaker? > So what exactly this "Clojure dynamic typing" nonsense is about, I fail to see. No-one has the time to learn all these languages, so for those of us not in the know, the most generous we can be is to tak…

The part of code not compiling got me interested. Do you happen to have an example or tutorial about this?

Re: Why Clojure?

#179
post #90

I've worked around an open source Clojure codebase for a few years. I've grown to dislike Clojure by virtue of the culture it apparently fosters. As a community organizer in some vibrant decentralized spaces, reading articles from inside the community gives me ick feelings. There's a strange phenonemon involved when you have a diehard community that continually extols the virtues of the language, while the popularity…

> really hard to cultivate a community of people who have a deep love for something, but for some reason can't see what is actually wrong with it that drives ppl away

Elm is another example

Re: Why Clojure?

#180
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…

Maybe I miss what REPL really is, but...

If REPL is the main value proposition, how is it better from average JavaScript development? Dev tools allow you to basically interactively work with your code.

Post reply on HN