Live data from Hacker News

Clojure is cool

ahungry.com

51–60 of 133 posts

Re: Clojure is cool

#51
post #26

I like verbosity in programming language. It becomes pretty easy to read the code, compared to lambdas or other concise languages. If you are not working for a startup, majority of the time, you will be maintaining legacy code or bug fixing. I would take easily understandable verbose code over "clever" concise code every time.

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…

> There may be cases where terseness can be too extreme

I don't know about that, a lot of people seem to like j[1]

1: http://www.jsoftware.com/

Re: Clojure is cool

#52
post #20
post #13

Thankfully Clojure will go nowhere beyond a few edge places. I saw a decent sized project written in Clojure script that had to be rewritten once the original authors moved on as new hires struggled to get anything done. Small features took enormous amounts of time.

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) were at some stage of abandonment or rewrite into more boring languages. If you're lucky enough to keep your team small and ideologically aligned, it might work for your team, but I have yet to see large company make a significant bet on it (as in more than a few one-off teams) and come out ahead.

Re: Clojure is cool

#53
post #13

Thankfully Clojure will go nowhere beyond a few edge places. I saw a decent sized project written in Clojure script that had to be rewritten once the original authors moved on as new hires struggled to get anything done. Small features took enormous amounts of time.

Literally interviewed at a company that is doing the same thing. B series, clojure/scala codebase, moving away to Elixir Phoenix.

Looks like a big waste of time and resources. They're probably just trying to use the "coolest" thing without worrying about delivering things.

Re: Clojure is cool

#54

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.

Are you using core.spec in your codebase? Did that help at all?

Re: Clojure is cool

#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

Re: Clojure is cool

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

> 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.

Of course -- but the important thing is that bug count per feature/app will be lower in a more expressive language.

Re: Clojure is cool

#57
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 of Measurement interfaces, each of which is in fact implemented as a MeterMeasurement, which wraps a double), static typing is very, very necessary, because it's not at all obvious what a function takes. And you need thorough API documentation because how another developer has chosen to represent things is not obvious (that is, you are trying to interoperate with a library that doesn't understand your RoomMeasurement, but does work with just a list of measurements, but they have to be in imperial, not metric, and how do you get the list of measurements from your RoomMeasurement, and convert them? Do you have to write a function, is there one already, does it take the RoomMeasurement, does it take the list of MeterMeasurement, does it just take a single MeterMeasurement? Etc)

When sticking with simple types, though, it becomes a lot easier to reason about, and you can get away with just comments, or very slightly more complicated types. A list of measurements is just a list of ints...but maybe dropped into a tuple where the first arg is the type (i.e., roomMeasurements = {meter, [4.22, 5.7, 3.1]} ). And all you have to find/write (and since it's just data it doesn't matter which because there's no hidden stuff that needs tweaking) a meterToFoot function, and apply it as a map. I.e. (pseudocode), ->

feet = {foot, map(roomMeasurements[1], meterToFoot)}

Now, is that perfect? No; even if you as a developer choose to apply type information, another developer can choose to ignore it. But I think that's rarer; more common is when people don't think to supply type information at all, and pass around just (per the example), an array of doubles. You can do that in a statically typed language too, though.

I think the key difference is that people coming from a statically typed, OO language, to a dynamically typed FP language, can either end up creating the same complex data types (which are a nightmare to deal with even with static typing, but doubly so without), or they see all the examples, embrace the simpler data structures...and then don't actually supply the necessary typing information.

The reason, then, that I think static typing -is- good, is because it makes it harder for me to ignore/forget to handle the typing I have provided. That is, I may have a 'metricToImperial' function, that takes in a type tagged array of doubles, and a desired type, and determines and applies the appropriate function. But I can still forget to include a necessary conversion in the resulting case statement ('whoops, I called it with a lb to g conversion over here, and I forgot to implement that one'). It's times like that I really like optional/inferred typing; many places I don't need to check for typing, because it's obvious, both to the developer, and to the compiler if it can infer types...but I can still make mistakes, per that. Of course, that brings me to unit testing...

Re: Clojure is cool

#58
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

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.

Re: Clojure is cool

#59
post #54

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.

Are you using core.spec in your codebase? Did that help at all?

No, core.spec does not address the main issues with dynamic typing. It offers some neat stuff, but it is not a replacement for static typing.

Re: Clojure is cool

#60

I like verbosity in programming language. It becomes pretty easy to read the code, compared to lambdas or other concise languages. If you are not working for a startup, majority of the time, you will be maintaining legacy code or bug fixing. I would take easily understandable verbose code over "clever" concise code every time.

In my experience ease of reading code is not a function of verbosity, but a function of familiarity. And in the general case verbosity and cleverness are orthogonal properties.

> In my experience ease of reading code is not a function of verbosity, but a function of familiarity.

You would think so, sure. I used to write Perl code and I was extremely familiar with it and it used to be pretty easy for me to hack a script. Going back after couple of months and trying to understand it though, was a totally different animal.

You can argue that it was my fault for writing bad Perl code, but ask any old farts who ever had to write Perl.

Post reply on HN