Live data from Hacker News

Clojure is cool

ahungry.com

61–70 of 133 posts

Re: Clojure is cool

#61
post #55

I really like and use Clojure professionally, but I have become wary of the extraordinary time I spend dealing with runtime issues because of the dynamic typing. I hope the future of core.typed is bright. I know it is being very seriously worked on. It can't come soon enough for me. Nowadays, I prefer to write in any statically typed language even if it is more line counts, just for my own sanity.

For Clojure, check out Ghostwheel [1] - a lightweight DSL for writing specs. If you want proper static typing though, ReasonML might be a good choice. Static, compiles to js and native, super easy to learn, and there’s an experimental Lisp frontend with Clojure-like syntax if you can’t live without paredit. [1] https://github.com/gnl/ghostwheel

To me, core.spec has valid uses, but not as a replacement for static tying.

Re: Clojure is cool

#62
post #26

Earlier quoted context omitted.

Studies have found that bug count is roughly proportional to program length, across languages. Saying you prefer verbosity essentially means you prefer more bugs. 500 lines is generally less understandable than 40 lines. There may be cases where terseness can be too extreme, but I don't see it here. Is there some particular aspect of the Clojure code here that you think is overly clever, or hard to understand? This C…

And studies show that the number of lines of code a developer puts out in a day is basically constant across all languages. This is usually cited as an argument for more expressive languages. But if bug count is proportional to LOC and LOC per day are constant across all languages, then bug per day will also be constant across all languages. You can write shit code in any language. I used to think Java made it harder…

Bug count per day is constant...but functionality per line of code is higher with the more expressive language.

Umm...so for the same amount of bugs I can have more features if I choose the more expressive one...

Re: Clojure is cool

#63
post #46

Clojure is something I have been wanting to experiment with, but not having types makes it very difficult for me to reason while coding. It's just me. I am used to thinking in types.

So speaking as someone who has been on both sides of that fence (and, honestly, prefers static or optional typing; Dialyzer for Erlang is probably my favorite approach there), I think a large part of that comes down to how types are used. In a very OO language, where you're encouraged to create a complex type for every function/method contract (i.e., I have a type of RoomMeasurement, that internally contains a list o…

GP was talking about how they think, not how types are used in practice

Re: Clojure is cool

#64
post #58
post #33

Earlier quoted context omitted.

The claims regarding JVM bloat are largely exaggerated, especially now that the JVM introduced modules. However, if it's not your thing it's worth noting that ClojureScript happily runs on Node. Here's an example of how easy it is to get up and running with https://github.com/yogthos/mastodon-bot

I'm working on my first Clojure project and find JVM to be painful (it starts very slowly and eats lots of RAM). I'd appreciate any tips on making JVM non-bloated.

Logically, don't use Clojure & the JVM if you want to avoid bloat. Try LFE, Lisp Flavored Erlang: http://lfe.io/ or SBCL: http://sbcl.org/

Just a recommendation if you want to avoid the JVM bloat issues, which are real and have existed since the JVM was developed

peace

Re: Clojure is cool

#65
post #30

Earlier quoted context omitted.

There could be a counterpart here that Java as a language is so complicated that people often come up with these design patterns because they THINK they are necessary.

Except nobody actually writes Java code like this. Nobody implements the Map interface. It's just stupid code. The myth of Java bloat only serves people writing silly blog entries and others hung up on "best practices" from 15 years ago. It doesn't seem to have any practical basis.

Sure they do. Every Java code base I've seen, including stuff written in the past year, using Java 8, with a mix of senior and junior developers (i.e., both those who cut their teeth on Java 8) was bloated. I'm thinking of one thing I'm dealing with now; 30 classes, 1800 lines (admittedly, using wc -l, so variable declarations and getters/setters are counted, but that is still visual space I had to skim through to figure out what it was doing. Oh, and that was -after- I removed some of the more obvious cruft), all of it proper OO...or I could have gotten it done in The myth of the myth of Java code only serves people defending Java academically, and those hung up on defending a language that enourages and defaults to bloat in any sort of shared coding environment. It doesn't seem to have any practical basis.

Re: Clojure is cool

#66

Every few weeks I see a Clojure post on HN, and almost always there's a battle going on in the comments over whether the language is too clever, impractical, a toy, poorly designed, etc. My experience with clojure (a ~1500 loc library) has been quite good. I won't say it's intuitive for those coming from imperative/OO backgrounds, but when it clicked it really clicked. If a team decides to invest the time to learn cl…

Code-sharing between ClojureScript and Clojure is a killer app

Not really. Although Clojure and Clojurescript are both dynamically typed, Clojure is strongly typed while Clojurescript is weakly typed.

Clojure:

(+ "1" 1)

ClassCastException java.lang.String cannot be cast to java.lang.Number clojure.lang.Numbers.add (Numbers.java:128)

Clojurescript:

(+ "1" 1)

"11"

They may be close, but that is all the reason for concern. There are a million ways that small semantic differences like this can completely fuck you and leave you in a debugging nightmare. I would rather use javascript, AKA the worst language ever invented, than a language that claims to be cross platform but with semantics that change depending on the platform.

Re: Clojure is cool

#67
post #33

Jvm is bloated. So no closure for me. I prefer Go

The claims regarding JVM bloat are largely exaggerated, especially now that the JVM introduced modules. However, if it's not your thing it's worth noting that ClojureScript happily runs on Node. Here's an example of how easy it is to get up and running with https://github.com/yogthos/mastodon-bot

And it seems to be working on Graal, though people are trying to find a way around limitations related to reflection, so I understand.

Re: Clojure is cool

#68
post #44
post #41

Earlier quoted context omitted.

> Java 8 is still relatively recent for the Enterprise world. Most actual surveys put Java 8 penetration at 70 - 80%. Dig deeper and the This is what makes the entire exercise a myth. People may want to believe this stuff but again it has no practical basis.

Yep, like Java 1.4 running on Red-Hat Linux 5 deployments, where no one is allowed to touch beyond bug fixes and security updates.

I thought RHEL5 security updates were over right?

Re: Clojure is cool

#69
For web projects, the benefits provided by Clojure on the backend side may not be very large; there are already good languages with extensive libraries available (Django, Rails, etc.). It arguably may seem hard to choose Clojure with its minimalistic libraries when these frameworks provide an "easy" [1] way to get running with a full-blown admin interface. Furthermore, backend code by itself tends to be dependency-heavy in the way that you need dependencies which you'll definitely not write yourself: You need a library to interface with your database, you need something for cryptography / passwords, etc.

Looking at the frontend (React) side however, things are different. The JavaScript ecosystem is a mess. From a viewpoint of a React developer, there are lots of libraries which vary widely in quality. react-router is an interesting example here, it had 4 (?) breaking changes so far by replacing the entire api. There's a ton of mental overhead for the normal React developer trying to write a "simple" app.

Ironically, developers start rolling their own stuff. Instead of using a form library which tightly couples your components to your redux state (redux-form), you start writing your own. Instead of coupling your entire views to graphql via apollo, you start doing it differently, your way.

This is where ClojureScript is a game changer. If your app differs just slightly from a (very) vanilla CRUD app and whipping some libraries together doesn't do the trick, you start writing custom stuff. When writing custom stuff, you want a programming language which is a) well thought through (great standard library, immutability, sane concurrency) b) predictable and c) productive. ClojureScript has all three while JS has none.

We (Merantix) are currently developing a medical image viewer in ClojureScript and had prototyped two separate versions: One in JS with React, another one in ClojureScript with reagent and re-frame. Even though it is dependency-heavy (webgl stuff), ClojureScript turned out to be the superior choice: Immutable data structure at its core which ironically perform better than Immutable.js and way higher developer productivity due to less random bugs and a more interactive development (REPL).

Using Clojure on the backend now seemed like an obvious choice: We can reuse and share code from the frontend and more importantly, all our developers are "full-stack" in the sense that everyone can at least understand what's going on "on the other side" (backend / frontend) of the stack as it's literally the same codebase.

The learning curve is significant but the advantages are tremendous. I wholeheartedly recommend learning Clojure even if you're not allowed to use it at your job. It sounds cliché, but it will make you a better programmer for sure.

[1] https://www.youtube.com/watch?v=rI8tNMsozo0 (to understand the meaning of "easy" above)

Re: Clojure is cool

#70
post #20

Earlier quoted context omitted.

Your experience appears to be an outlier. Lots of companies are using Clojure for large scale projects, and my own team has been happily using it for nearly a decade now. The fact that your team struggled to get anything done probably says more about your team than Clojure to be honest. https://clojure.org/community/success_stories

Thanks to the rise of SOA, basically any language no matter how obscure can claim multiple corporate users for for what are ultimately inconsequential projects. But as long as we're using personal anecdotes, I saw several teams using clojure at Amazon when it was more popular. Less than two years later, all of them that I knew of (I was a clojure user too, interested in its use in the company, so I was keeping track)…

Most companies don't really publish their tech stacks in the first place. However, there are a number of consulting companies, such as JUXT and Metosin, who built their entire business on Clojure consulting. Clearly there is a market for it, and if you look at the clients of these companies it's quite clear that it's not just some one off projects.

There are plenty of companies that are switching to Clojure all the time, and feedback is overwhelmingly positive. Here's a recent example https://blog.takipi.com/clojure-at-scale-why-python-just-was...

Again, my personal experience is that my team grew from 3 to around 20 people now all working exclusively with Clojure, and we've never had any problems onboarding, or being ideologically aligned.

Just because it allegedly didn't work out at Amazon doesn't really translate into sweeping assertions you're making about it.

Post reply on HN