Live data from Hacker News

Try Clojure

tryclojure.org

351–360 of 404 posts

Re: Try Clojure

#351

Earlier quoted context omitted.

Clojure also teaches you functional programming, where-as CL only teaches you the LISP beauty. Clojure teaches you both Lisp and Fp. So the FP part should still be worth it even though you got the Lisp part from CL.

How does fp in clojure differ from fp on common lisp?

Clojure has immutability built into the language and the core data structures are all persistent so that you can get sufficiently efficient partial updates while still preserving a pure FP style.

Furthermore, the data structures in clojure also have interfaces that make it easier to swap out which data structure you're using while still keeping whatever map/filter/reduce algorithm implementation you're sending it through.

Common lisp, on the other hand, has setf. Which more or lets you mutate anything. You certainly can code in an FP style in common lisp, but it doesn't restrict you in any meaningful way. Not a problem if you control the entire codebase, but when gluing components together this can be a source of friction.

Re: Try Clojure

#352
post #324
post #298

Earlier quoted context omitted.

We shouldn't overestimtae the complexity of expressive language like Clojrue vs Go. Go is perfectly simple and easy to follow, even compared with Clojure. If you come from background of Computer Science or programming first, Go is easier to follow.

I always feel this comparison is a fallacy. Assembly is also perfectly simple and easy to follow, like each instruction is trivial. Yet you will fail to grasp the whole, as “you are zoomed in too close”. I feel go has a good scale for many kind of tasks, but at the same time, it lacks the expressivity to change the zoom level, which I feel is needlessly limiting and makes the language a bad language for problems that…

I tried Go for a while after coming from JavaScript and didn't feel productive enough. I think this explains why exactly.

Re: Try Clojure

#353
post #337

Earlier quoted context omitted.

Here's what I'd do: array = []; function clos(val) { return () => val; } for (var i = 0; i console.log(fn())); This outputs 0-9 instead of 10, though I'm just a silly self-taught person that never got schooled at these things, maybe there is some reason not to use closures that I don't know about.

These days in JS you can just use let instead of var and it will work, but in itself that inconsistency is a bit weird

Yeah, let/const is what I tend to use. Here I wanted to change someone else's code as little as possible.

Edit: Oh, right, it also solves the 10-issue. Thanks, didn't realise at first.

Re: Try Clojure

#354
post #252

Earlier quoted context omitted.

I'm not sure if you meant this as evidence for or against my point, but this is exactly what I mean. Every year dozens of people think they're going to make some holy-grail language and it's 1% different from the prior version but now every single library needs to be rewritten, a dozen years of patches/bugs/security-holes must happen, whole resumes get shined up rewriting tech stacks that were perfectly capable, all…

Is that how you see people that know several natural languages? You think they're intellectually fractured?

I don't really get what you're getting at here.

It sounds like you're trying to draw some equivalence between multiple spoken languages (largely seen as something brag-worthy-ish) and multiple programming languages. Like if culture thinks it's sexy to know french that somehow that means it's sexy to know Cobol [It's not].

The two are wildly different of course, a programming language can be learned in weeks and a spoken language takes years.

But if your question is -- would the world be a better place if we all spoke the same language? Then yes, absolutely.

Fortunately AI will help continue to reduce these artificial barriers between languages.

Re: Try Clojure

#355
post #252

Earlier quoted context omitted.

I'm not sure if you meant this as evidence for or against my point, but this is exactly what I mean. Every year dozens of people think they're going to make some holy-grail language and it's 1% different from the prior version but now every single library needs to be rewritten, a dozen years of patches/bugs/security-holes must happen, whole resumes get shined up rewriting tech stacks that were perfectly capable, all…

Is that how you see people that know several natural languages? You think they're intellectually fractured?

[deleted]

Re: Try Clojure

#356
post #314

Earlier quoted context omitted.

These Java features are ruined by not allowing mutable variables to be captured. Having to do the 1-element array trick when the compiler could just do it for me is insane. If you are making JavaScript look good you are failing as a language.

Typically I can use a forEach in such cases, and when I can't it's probably an incrementer and the IDE just switches out my int as an automatic solution to its complaint. I think its OK to be reminded that the context is mainly immutable when chaining on a stream. Method polymorphism to achieve default parameter values is a much worse nuisance, but not particularly hard to get used to when one decides to focus on the…

Doesn't the forEach method on arrayList have the exact same issue?

Re: Try Clojure

#358
post #252

Earlier quoted context omitted.

Is that how you see people that know several natural languages? You think they're intellectually fractured?

I don't really get what you're getting at here. It sounds like you're trying to draw some equivalence between multiple spoken languages (largely seen as something brag-worthy-ish) and multiple programming languages. Like if culture thinks it's sexy to know french that somehow that means it's sexy to know Cobol [It's not]. The two are wildly different of course, a programming language can be learned in weeks and a spo…

I'd consider a person that has only studied programming for weeks extremely junior.

Edit: And no, "AI" is not going to affect any such barriers. It's already trivial to learn new natural languages, and some people do, some don't. Those who don't, generally don't care about people that speak other languages than the one they learned in childhood.

Re: Try Clojure

#359

Earlier quoted context omitted.

That's what I said. I do use functional programming techniques, I just wonder why functional programming languages don't see a larger following.

Good question. I suspect it's because the downsides of losing the larger ecosystem of more mainstream languages outweigh the upsides of a functional language. The libraries, package managers, tooling, runtime, debuggers, documentation, and editors etc just aren't anywhere near as mature for Haskell or Ocaml as they are for Typescript or Python, for example.

Debugging is a known sore point with OCaml for example. But what is the problem with the Haskell RTS or the OCaml runtime? Why is it not “anywhere as mature” as Python’s or something like Node for JS?

Python’s had the GIL while Haskell has had a well functioning parallelized runtime for a long time. And both Haskell and OCaml’s runtimes outperform Python’s and are on par with Node.[1]

As for documentation, every time I come back to Hoogle,[2] I remember how I miss it in other languages that just don’t have anything similar going. The lack of types doesn’t help, and reading the documentation of the Python standard library or a popular library like torch is sometimes like solving a puzzle because it’s unclear what a function or a class constructor really does or even what class’ instance it returns.

[1] https://benchmarksgame-team.pages.debian.net/benchmarksgame/... for CPU usage but their memory usage is comparable too, and OCaml’s benefits from the language’s eagerness.

[2] https://hoogle.haskell.org/

Re: Try Clojure

#360
post #224
post #190

Earlier quoted context omitted.

The JVM cold-starts, loads a Hello, World program from a compressed JAR, runs it and shuts down in 40ms. But Clojure compiles quite a bit of Clojure code generating hundreds if not thousands of classes and then loads them before starting up the Clojure program. Still, there's ongoing work on the JVM (Project Leyden [1]) to speed up both startup and warmup even of such programs by caching more state. [1]: E.g. see htt…

>>The JVM cold-starts, loads a Hello, World program from a compressed JAR, runs it and shuts down in 40ms. Im yet to reach the X-men level super qualities that can detect, and work in 40 ms chunks. Or at least even notice a 40 ms delays. I envy the humans who can notice such small chunks of time.

I don't like how this issue is constantly dismissed out of hand. It very obviously is actually a massive glaring issue which severely limits what clojure can reasonably be used for. Nobody would ever accept a 1 second startup time for CLI applications that we use all the time like git, kubectl, npm, docker, etc.
Post reply on HN