Live data from Hacker News

Clojure will affect the way you think about programming

eli.thegreenplace.net

111–120 of 226 posts

Re: Clojure will affect the way you think about programming

#111
post #71

Clojure also affected the way I think about programming in a very positive way. There are downsides to it - stack traces - jvm - lein is pretty slow but the upsides - immutable data structures - lisp/macros - repl (you can send code from your editor to the repl) - community - great open source web app libraries (for me, anyway) outweigh the downsides. I encourage everyone here to try clojure at some point, it might j…

For people familiar with java, the jvm is an upside. Being able to use libraries (especially client ones) from your project can be very useful. The amazing interop support is very nice if your pragmatic over purist and don't plan on rewriting a ton of things.

Re: Clojure will affect the way you think about programming

#113
post #88

Earlier quoted context omitted.

> The perfect language to expand your brain. Clojure is still restricted/limited compared to Common Lisp.

In what ways, specifically? Building binaries?

To fully explain, it would require a blog post, and it has been covered before, but i'll make a try:

- Proper stack traces. Debugging Common Lisp code is not only easy, it is far easier than in 90% of programming platforms out there. Clojure is severly lacking here; it has been promised that there will be an improvement; i will be watching since this will greatly improve Clojure

- "Lisp-2 versus Lisp-1": On Common Lisp, functions and variables have separate namespaces so they don't conflict. This makes writing code, especially macros much easier. Macros are one of the biggest reasons to use a Lisp dialect in the first place, so this is a rather strong point.

- Object orientation facilities: CLOS, CL Object System, is arguably the most powerful OOP system on a mainstream language. You should really take a look at it, it can just blow your mind. Clojure has no comparable OOP implementation. I recommend CLOS to anyone that feels disillusioned with OOP.

I could stop here, because the three points above are very strong differences, but there are some other points to consider:

- Standarization and portability (1/2): CL is an ANSI standard, and there are many ANSI-compliant, mature, compilers: LispWorks, SBCL, Allegro CL, ABCL, Clozure CL, ECL, CLISP, and others. There are features that the ANSI standard does not cover, like interacing with C libraries, but there are already portable libraries that allow you to also do this on a portable way. So, in this way, your code can be compiled by those implementations, often without any change needed at all.

- Standarization and portability (2/2): The ABCL compiler allows you to target the JVM and call Java code from Lisp or call Lisp code from Java. The Clozure compiler lets you target the LLVM. Practically most modern platforms can be compiled from CL to native code by using the suitable compiler.

- Interfacing: As mentioned above, you can interface with Java, and with C, as needed. C interfacing is very easy, btw.

- Speed: CL can be very fast. For example SBCL is really fast, particularly with numbers where it can be as fast as C. In general it is in the same speed of Java code running under the Oracle's latest JVM. I think that CL code under SBCL probably should be much faster than Clojure running under JVM.

- Number data types: CL supports, with high perfomance and natively: Complex numbers, Rational (fractional) numbers, floating numbers (with the IEEE standard), integers, binary numbers, and arbitrary-length numbers. Bonus: The same typical operators (+,-,*,/) work perfectly with them, so using them is simple. In this feature, CL fares even better than Fortran (seriously.)

- Static typing? CL is not statically typed, but the standard allows you to declare the type of your variables. A compiler like SBCL will catch many type errors during compilation (and of course they will also be catched at runtime). Doing this has also the big bonus of increasing performance dramatically.

- Mainstream: While not popular, Common Lisp is a mainstream language, so there are tons of books and resources out there, as well as having been used successfully complex production systems, like for example auto-piloting the Deep Space 1 spaceship (NASA) for days.

Re: Clojure will affect the way you think about programming

#114
post #20

Clojure is the language where LISP clicked for me. Can't recommend it enough, it's got all of it - immutable datastructures, convenient data literals, simple and composable concurrency primitives, very thin interface to host VM. Just put enough effort to get beyond that "omg parenthesis" barrier and it will be a delight. It's like that Half-life joke: there are two kinds of people, those that finished Half-life many…

There are many things to love in Clojure, like core.async, the lispyness, etc. But for me, their biggest breakthrough is with no doubt the data-structures. Clojure default of immutable hash maps and vectors was really bold. They had to innovate by giving a twist to Bagwell's great research on data-structures, and they managed to build what in my opinion are the first set of general data-structures suitable of represe…

> In the past I also did some other work on bringing Clojure Transducers to C++ ... consider it a much less important effort---without the data-structures the other parts of Clojure feel almost like just sugar.

Very few clojure programmers consider Transducers very important even in Clojure. While they're convenient for implementing Clojure's stdlib and they have some nice properties, they're very difficult to work with. It takes a very experienced clojure programmer to use transducers. Heck, I know some famous clojure developers who admit they themselves don't feel confident using them.

But the main challenge for them is that transducers just scream for some basic type validation so that you don't accidentally chain together nonsense. C++ could provide that, and you'd end up with all the same properties. In particular, they offer something like half the monad laws and a more easily composed form of CPS (how your continuation is called is more predictable).

I'd think that might be a really valuable thing in C++, as it's a construction that reproduces stream fusion.

Re: Clojure will affect the way you think about programming

#115
post #78

Earlier quoted context omitted.

There are many things to love in Clojure, like core.async, the lispyness, etc. But for me, their biggest breakthrough is with no doubt the data-structures. Clojure default of immutable hash maps and vectors was really bold. They had to innovate by giving a twist to Bagwell's great research on data-structures, and they managed to build what in my opinion are the first set of general data-structures suitable of represe…

Do you know of a good resource for reading about their data-structures, especially anything Haskell doesn't have?

Folks have linked you to the paper and mentioned tutorials.

You might also Okasaki's Purely Functional Data Structures, which ends up in the citations for a lot of these.

Re: Clojure will affect the way you think about programming

#116
post #32

Earlier quoted context omitted.

One huge difference is the workflow you have in Clojure. REPL driven development is an experience unique to Lisps. When you're working with Clojure, any code can be run in the context of the live app straight from the editor as you write it. This is an amazing experience and very mind expanding in what a development process can look like. Also, anybody who wants to try FP style programming, but isn't interested in st…

I work in Scala and it has live code update, interactive worksheets and a repl. As for type systems increasing complexity I think that depends on the application. As a beginner to Clojure I would pass unstructured data around all over the place and then have the mental overhead of trying to remember the structure or fix it all at runtime.

This is what clojure.spec is meant to address. It's helped me, but I am actually trying to get some momentum in Haskell now... I have a saying, "Constraints free the mind." Frameworks, Type systems, etc., provide the constraints we need to let our mind think about the actual problem instead of suffering from analysis paralysis.

Re: Clojure will affect the way you think about programming

#117

That's true of any language. Even within the same language paradigm. If you know C#/Java then learn C++ or vice versa and it'll affect the way you think about programming. Go outside of the statically typed OO world and try out the dynamically typed OO languages like ruby or python. Even better, learn a weakly typed procedural language like C ( lingua franca for CS ). Or choose an architecture and learn some assembly…

That is true. Heck, eating a particular meal might affect the way you think about programming. But the article title, and the original HN title, is "Clojure - the perfect language to expand your brain?" So it's asking if Clojure is better at it than other languages/paradigms.

Re: Clojure will affect the way you think about programming

#118

I would love to use Clojure (it's probably the only language I would consider moving to right now) but the JVM just doesn't work for me. Clojure-native that offered all of Clojure and was realistic - there was one that indirectly used Gambit Scheme at one time, and an incomplete Python version - would be awesome. Clojure that requires you to use the current Java approaches to interfacing with C is not of interest.

I've felt that way about clojure native, but what makes a language is the ecosystem, and the JVM brings a fantastic ecosystem. There really is no way to offer "all of clojure" as native because the ecosystem is part of what "all of clojure" offers. I've long thought about ways of doing a "native" clojure, and have eventually come to the conclusion that it doesn't offer anything compelling. If you want fast start up t…

> the JVM brings a fantastic ecosystem

Unfortunately it's (intentionally) horrible for interfacing with C libraries.

> it doesn't offer anything compelling

Unless you need to interact with native libraries.

There's currently a lot of excitement about Scala Native and Kotlin Native. Those projects aren't being done just for the heck of it.

Re: Clojure will affect the way you think about programming

#119
I agree with the article, but would also like to mention that it has a very steep learning curve.

1.5 months after my first line of Swift I had my app in the app store (granted I was proficient in Objective-C). 2 years since I've started learning Clojure and a couple of months since I'm working professionally with it and I'm still quite shaky.

Luckily, it's not difficult to begin - you can start hacking small programs in a couple of days, but when it comes to building large applications, that's when it becomes a high-level art form (just one of the many possible metaphors :) ).

Quite similar to C++ in this respect - easy to pick up, hard to master.

It humbled me and made me cry many times. But as with everything, if you don't give up, you level-up.

As far as the experience goes, it gives you this 'overview' experience of programming - you can mimic almost any feature from other languages and you have access to all the libs for the JVM (including C/C++ libs through JNI) plus all the javascript libs.

So in terms of libraries you can use, I dare say that Clojure(script) is the language which can access the most libs out there.

So yeah, definitely a powerful language and a powerful tool which you can go very deep into, albeit a bit tough to learn.

Post reply on HN