Live data from Hacker News

Clojure will affect the way you think about programming

eli.thegreenplace.net

91–100 of 226 posts

Re: Clojure will affect the way you think about programming

#91
post #39
post #4

I just saw an article recently about core.async and the "go" macro, which seems to effectively give you goroutines in Clojure. I'd be very tempted to use it for that reason alone. I love Go's concurrency, but it can be a little on the verbose side. Good for some projects, but not all of them.

If you are curious about core.async and want to learn more you can have a look at the post I wrote on it-- [ http://abhirag.in/articles/batman_clojure.html ]. I wrote it while trying to learn it myself so not the most advanced resource but I hope somebody finds it helpful :) Note -- The page is kinda resource intensive because it contains a running clojurescript interpreter for interactive code snippets.

thanks for this. btw, your blog is great as well

Re: Clojure will affect the way you think about programming

#92
post #69

Earlier quoted context omitted.

> - programmers try to be clever in their code, write one giant file full of complicated specialized 'beautiful' code, forget everything they know about breaking big tasks into simple small ones. What on earth does this have to do with clojure? Programmers will do this in any language, there's nothing special about clojure here. I personally don't find LISP languages to be the most readable, but I'm fairly sure it's…

Rubbish. I've worked with a dozen languages, and its unquestionable that certain ones attact a high ratio of terse complicated code. Clojure is specifically renouned (and celebrated) for its low LOC counts; people go as far as saying (literally on /r/clojure) given a choice of library, pick the one with a lower LOC. That's not because people write simple pointless libs like lpad; its because the community actively en…

I've seen this logic about choosing a library but I think you are attributing a different rationale to it. I've seen it said if you find more than one library doing what you need, go through a hierarchy of criteria to choose and choose the first one that wins; in the event of a tie, evaluate the next point

1. pick the one with the most readable, understandable architecture 2. choose the one that focuses more on what you are looking for and not a slew of different things 3. choose the one with fewer lines of code

This third point is not "choose the more clever library" but more along the lines of choose the more straight forward and simple library. It's not code density you are evaluating but focus.

Re: Clojure will affect the way you think about programming

#93
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?

Any book on clojure and website too will go over them. They are fundamental to using clojure.

I don't know enough about haskell to say what it does or doesn't have in relation to clojure. However, it's not simply the data structures, but how the language is built to interact with them from a programmers perspective.

From a user interface to the language point of view, I find the ways of interacting with maps to be very nice.

In particular the dual purpose of "keywords" to serve both as a good index/key in said hash maps, but also as callable look up function for the same key in a hash map leads to simplified code.

This, coupled with the extremely high usage of those maps in typical clojure code, makes a big difference.

To expand on that a little, "keywords" are symbols that begin with a colon, which I believe is the same as common lisp. :for :example :this :is :a :sentence :of :keywords. They are commonly used as the key in a map. Which has a literal syntax like (def map1 {:a 1 :b 2 :c "taco"}). To pull a value out, you can evaluate (:c map1) which will return "taco".

They are hash maps based on work by Philip Bagwell, and I think a lot of languages have versions of this now. At least scheme and Common Lisp do. But I don't believe they have the nice literal syntax and interaction syntax.

Many Lisp traditionalists are bothered by the use of curly braces for maps and square brackets for vectors, however I'm a fan. Without this bit of syntax, you have to add verbosity to the language to differentiate defining a map from doing a lookup, etc.

For resources, Clojure for the Brave and True is pretty popular. Also the online community is quite friendly, although I have noticed some trends toward "the one true way" of doing things that puts me off a little.

Re: Clojure will affect the way you think about programming

#94
post #86

Earlier quoted context omitted.

I wonder the same. And the author writes: >"and Clojure is the first Lisp I'd consider using in production". I can't really understand the logic in this. If anything, CL has more going for it for production​ usage, like ANSI standarization and many high-performance compilers.

Clojure has the advantage of targeting the JVM and Js runtimes. These are two most popular runtimes for writing web apps currently. Clojure can also be easily integrated into existing projects on these platforms.

Your Common Lisp code can also target the JVM runtime by compiling using the ABCL implementation (free, mature). It is ANSI compliant, so your code will work straight away with no change. ABCL also allows easy calling of Java libraries.

Furthermore, not only JVM: other CL compilers let you target the LLVM. And of course you also have native compilers like SBCL which produce blazingly fast code.

Re: Clojure will affect the way you think about programming

#95
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?

Here is a good resource on Clojure's persistent vector type: http://hypirion.com/musings/understanding-persistent-vector-...

Re: Clojure will affect the way you think about programming

#96
I was lucky enough to land a Clojure job (stitchdata.com, we're hiring!) before having to learn Clojure, because I had the benefit of experienced mentors helping me get to grips with lisps (which were alien to me) and a development workflow that leaned heavily on the REPL (emacs + cider). Clojure has changed the way I think about many programming concepts and has been a joy to learn. It has it's warts but the core is very well built and I find the documentation to be quite good once you understand the basics.

Re: Clojure will affect the way you think about programming

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

Or move on to different paradigms...

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. Now that will affect the way you think about programming.

Move out of onto a different domain altogether and try one of the flavors of a declarative language like SQL.

Learning a bit here and there of many different languages and paradigms will affect the way you think. Clojure isn't special.

You can even just stay within a framework and try to get a deep understanding of .Net language/IL/Framework Libraries/Runtime stack. Then you get into the debate of breadth vs depth. Should you learn one language/framework/paradigm exceptionally well or should you learn a bit about a lot of a lot languages/paradigms?

Re: Clojure will affect the way you think about programming

#99
post #38

Earlier quoted context omitted.

I've learned to love the parentheses, because they embody what is so nice about lisps (and particularly Clojure)--inside the parentheses is a little nugget of functionality that generally stands on its own. No syntactic tricks, the only "trick" is the macro system, but it's so straightforward that I'm not sure I'd call it a "trick". The other immediate barrier is when Clojure barfs an ugly stack trace. I've heard tha…

hmm sexy idea to have spec help for stacktrace. I expect something cute like elm error messages. About the parens, it's true it's one great thing, every construct has a value [1]. It's funny because You hear about object orientation where things are uncoupled and standalone yet the language isn't this way. Lisp has this, it's the incarnation of its own idea. But it looks silly if you're in it for the syntactic appeal…

stack traces still suck as far as I've seen on the 1.9 alpha branch. And while clojure spec is pretty neat, the barge-load of information it dumps on a spec failure is overwhelming.

That said, the info it dumps is in the form of clojure data structures. In my own programs, I've added code to refine this output to something useable, but it's particular to my project and I don't think generally useful.

There are other projects to aid in this fashion too. Expound is one that takes inspiration from Elm, and Inspectable is intended to help at the repl by launching a gui for exploring Specs and failures.

I've tried both, but couldn't get inspectable to work in my environment, and expound isn't meant to handle the error I've been dealing with, so I can't speak to either.

Re: Clojure will affect the way you think about programming

#100
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?

Hash Array Mapped Tries are what underly the default maps in Clojure: http://lampwww.epfl.ch/papers/idealhashtrees.pdf

They are pretty amazing. Of course there are implementations in Haskell now, but the reason they are especially cool in Clojure is how well they integrate with the language and its other features.

Post reply on HN