Live data from Hacker News

Clojure 1.9 is now available

blog.cognitect.com

81–90 of 121 posts

Re: Clojure 1.9 is now available

#81

Earlier quoted context omitted.

Yup, specs can be used at runtime as well. Very helpful to validate data, or perhaps a set of business rules. Insures the spec you use to test is the same logic you use at runtime.

>specs can be used at runtime as well. What do you mean "as well"? I thought it was only a runtime check at all.

One of the stated goals of spec is generative testing. While technically runtime, it's is not runtime from the user's point of view.

Re: Clojure 1.9 is now available

#82

Earlier quoted context omitted.

Well that was condescending.

More disillusionment than condescending. I jumped on learning Clojure waiting for big, nice surprises, new stuff, or an enlightening moment, but there wasn't any. I do, however, find it easy to learn and that's a good thing. On the other hand i am not really knocking down Clojure. If somebody wants me to do a project that requires interacting with lots of Java classes, I'm really glad Clojure exists, since it liberat…

I think your description is fair, although I feel like you could have started with the Clojure/ClojureScript combo for making SPAs in your first comment. That is really the biggest driver of Clojure right now, the fact that it has a mature compile-to-JS implementation that can share source code with the backend.

Re: Clojure 1.9 is now available

#83
post #35

Earlier quoted context omitted.

If you need to force yourself, or if you need extra special motivation to use Clojure .. most likely you will never use it You might spend sometime learning it out of curiosity, but you will never use it The languages I used, are ones I had to use, either because they were the only option, or clearly the best option for my solution (C#, VB.Net, Powershell, SQL) Clojure will never be your only option, and .. it being…

I'm quite surprised by your conclusion that Clojure "is not the best option" for Business Intelligence. What general purpose language is better for that in your opinion? There's a difference between "best tool for the job" and "most widely used tool for the job" at this moment in time. People's habits sometimes take years or decades to break (if they ever do).

Clojure as a data-oriented language is great in itself, but I can see why someone would choose say R or Python for BI/data science due to the ecosystem. Clojure can of course freeride on the Java or JS ecosystems, but I don't think those ecosystems offer the same breadth as R or Python either.

Re: Clojure 1.9 is now available

#84
post #42

Is clojure.spec a replacement for static typing? I ask because I've taken a look at clojure in the past and generally like what I see, but after moving from JavaScript to TypeScript at work I don't think I can ever return to a dynamically typed language again. Types are just priceless when refactoring, integrating someone else's code with your own or just exploring new libraries or APIs.

I think it's better referred to as a toolkit for building more correct software.

One of the things it can be used for is to check variable types at dev time, just as static type systems check a type compile time. It can also be used for runtime validation, randomized generative testing, more advanced checks/rules than current type systems can specify(eg checking outputs are correctly related to inputs).

Also an important philosophical difference with type systems is an open approach to data structure, where types are generally closed. The concept is that it allows more flexible systems that are easier to adapt to new needs.

Here's the best intro to spec I've seen, it's long and sound is terrible, but it's a great talk. https://vimeo.com/195711510

Re: Clojure 1.9 is now available

#85
post #67
post #34

Earlier quoted context omitted.

I'm looking forward to hearing a long-form rational of the :args :ret :fn function instrumenting decisions, and seeing if the devs see it as an easy choice or up for debate. It feels really uncomfortable declaring a full spec for a function & instrumenting it, then getting feedback if the args don't conform to spec but Clojure being A-OK if the return value doesn't. I understand well that in theory the functioning of…

I'm not familiar with Spec, but what you're describing sounds like enforcing preconditions but not postconditions by default, which is what most DbC frameworks (or languages with intrinsic support) normally do. The idea being that most of the time, you're running library code, and you want to validate what you're passing in, but you trust it to do the right thing for any input that is valid.

That’s fine, and makes sense, but without hacks, it is not possible to turn on ret checking in your tests that are not generative tests - so no post condition checks in the rest of your test suite.

I believe this is a missed opportunity to find bugs.

Re: Clojure 1.9 is now available

#86
post #24
post #2

Can anyone sell me on why I should use clojure over say, any of the other nice Lisp-1s, given that I don't care about java.

I am planning on learning Clojure for essentially two reasons: the community / ecosystem seems very active (which is really my primary reason for picking a programming language; I have no interest in writing something if a library exists), and I've heard good things about a couple of things that distinguish it from other Lisps, like maps and spec. I'm somewhere between indifferent to unhappy that it runs on the JVM,…

The good thing about Clojure is not that it's not married to the JVM. I think the JS implementation has been carrying the torch for the past year because of the many excellent front-end frameworks based on React, which are oddly faster than just using React in JS due to the code-optimisations performed by the ClojureScript compiler and Google Closure. It also has one of the best front-end dev experience in the shape of figwheel, which has become the default for all front-end dev in the language.

Re: Clojure 1.9 is now available

#87
post #30

Earlier quoted context omitted.

If you're indifferent to Java then you can use a Lisp that just so happens to let you interop with Java libraries which is very very handy. It's also a nice Lisp, tho not as pure or quite as powerful as others. But I'm not very much up-to-date on anything new in the past few years, and I was never a guru anyways, so maybe there are better pitches.

Do you have a favorite accessible guide to comparisons of lisps with respect to purity and power?

The main "unpure" parts of Clojure is that

* it doesn't do tail call optimisation unless you explicitly mark the self-call using by using recur (the lack of implicit TCO is a JVM limitation) * it doesn't use macros as much, although they are they're there and still used pretty often * it has language literals for the built-in data structures that look odd to other LISP'ers, e.g. {...} #{...} [...] * it's error messages are ecosystem dependent, e.g. Java stack traces for Clojure or and JS ones for ClojureScript

Re: Clojure 1.9 is now available

#88

Earlier quoted context omitted.

Yup, specs can be used at runtime as well. Very helpful to validate data, or perhaps a set of business rules. Insures the spec you use to test is the same logic you use at runtime.

>specs can be used at runtime as well. What do you mean "as well"? I thought it was only a runtime check at all.

i think they're talking about production run time versus development runtime. think of it as turning asserts off on production builds. but spec can conform data and explain the reason for non-conformance so some might leave some spec in production for logging, messages, etc.

Re: Clojure 1.9 is now available

#89
post #2

Can anyone sell me on why I should use clojure over say, any of the other nice Lisp-1s, given that I don't care about java.

> Can anyone sell me on why I should use clojure over say, any of the other nice Lisp-1s, given that I don't care about java. It's the same question I make myself, since after learning Clojure here I am, still using Common Lisp happily ever after. Well, if you think that data should be immutable by default, if you really need readymade syntax sugar for hash table and the likes, if you don't have any need for object o…

Protocols cover many OO use cases.

Re: Clojure 1.9 is now available

#90

Earlier quoted context omitted.

At the moment, most of the things that are spec'ed in the box are the gnarly macro "languages" like destructuring, defn, ns, etc. These spec'ed macros do catch a far more complete set of error messages than the macro did with custom error handling. However, those error messages are in many case more challenging to read than before. This is an area of ongoing research - the reasons for the complexity are varied. In ge…

Do you have an idea of how far along clojure.spec is for a stable, non-alpha/beta release? clojure.spec is by far the most interesting and compelling reason for me to check out Clojure. I would also love for it to apply to ClojureScript as well, although I understand that's a separate project.

Spec is also available for ClojueScript: http://cljs.github.io/api/cljs.spec.alpha/
Post reply on HN