Clojure is a general-purpose language supporting interactive development that encourages a functional programming style, and simplifies multithreaded programming.

learn more… | top users | synonyms

4
votes
0answers
92 views

How to represent hard-to-calculate “properties” of “objects” in functional code?

I have a polyline "class" in my Clojure program, which is represented by a vector of points. (It's not really a class or anything.) The polyline's length (in the geometric sense) is something that is ...
0
votes
0answers
13 views

More idiomatic syntax for 2nd level vector value update

I'm pretty sure there has to be a more idiomatic way of writing this: (defn update-2nd-level-vector [map index value] (assoc map :key1 (assoc (get map :key1) :key2 (-> map (get-in [:key1 ...
0
votes
0answers
53 views

Hot swap/plug components in clojure?

I'm using OSGi for some time and I really like the ability to swap/replace components while my application is running. I simply have to build my module and push it to the OSGi container. Is there a ...
7
votes
1answer
443 views

Pattern matching in Clojure vs Scala

What are the key differences between pattern matching in these two languages? I am not referring to syntax, but capability, implementation details, range of use cases and necessity. Scala ...
5
votes
2answers
204 views

Evaluation order of expressions in Clojure?

I'm currently learning Clojure (my first functional programming language), and I'm curious as to its order of evaluation. Here is an example: (take 10 (cycle [1 2 3])) If the cycle expression was ...
1
vote
1answer
48 views

How to unit test hiccup template generating function?

How do I unit test a function that takes a list of maps and returns an HTML table with the same data in Clojure/Hiccup?
2
votes
2answers
280 views

Lisp/Clojure: Removing unnecessary parentheses through conventions

I am fascinated to Lisp as it is simple yet powerful. I am just a beginner and I know there have been lots of discussions on removing parentheses from Lisp and its dialects. Yet I request Lisp ninja's ...
1
vote
1answer
90 views

What is the relation between clojure reducers and loop fusion

I just stumbled upon Clojure reducers library. It looks a lot like loop fusion. However the term is not mentioned anywhere on the page. Is there a difference between the two?
6
votes
1answer
193 views

Is it fair to say that “macros don't compose”?

On this blog post aphyr (who is a brilliant programmer) states: Clojure macros come with some important restrictions. Because they’re expanded prior to evaluation, macros are invisible to ...
2
votes
3answers
169 views

Is there a reason for the crossover from the Ruby community to the Clojure Community?

When we look at the the overlap between the Ruby Community - we see the following overlaps: Think Relevance (now Cognitect) has switched from Ruby to Clojure Jay Fields has switched from Ruby to ...
0
votes
1answer
379 views

Why the Scala fascination with flatmap? (This doesn't seem to be the same for mapcat in the Clojure world) [closed]

In the Scala community - there is an apparent fascination with the FlatMap function. Now I understand that FlatMap is significant because it is used for the bind part of a Monad. (and that the ...
6
votes
1answer
476 views

How to refactor a Java singleton to Clojure?

I'm writing a simple game in Java and I want to learn Clojure, so I've decided to refactor my current Java code to Clojure. The problem is that I've coded so much in object-oriented languages that I ...
9
votes
2answers
396 views

Where do we put “asking the world” code when we separate computation from side effects?

According to Command-Query Separation principle, as well as Thinking in Data and DDD with Clojure presentations one should separate side effects (modifying the world) from computations and decisions, ...
3
votes
2answers
412 views

Why does Clojure neglect the uniform access principle?

My background is Ruby, C#, JavaScript and Java. And now I'm learning Clojure. What makes me feel uncomfortable about the later is that idiomatic Clojure seems to neglect the Uniform access principle ...
9
votes
4answers
661 views

Python decorators and Lisp macros

When looking Python decorators someone made the statement, that they are as powerful as Lisp macros (particularly Clojure). Looking at the examples given in PEP 318 it looks to me as if they are just ...
32
votes
6answers
2k views

Why is “tight coupling between functions and data” bad?

I found this quote in "The Joy of Clojure" on p. 32, but someone said the same thing to me over dinner last week and I've heard it other places as well: [A] downside to object-oriented programming ...
0
votes
2answers
118 views

What is the exact semantic of reduce in clojure?

The Clojure docs regarding (reduce f val coll) state: If val is supplied, returns the result of applying f to val and the first item in coll, then applying f to that result and the 2nd item, ...
0
votes
1answer
307 views

Is Clojure development required to be open-source?

This question could be generalized to any language where the language development is open-source, potentially, but I'm most curious about Clojure specifically. If Clojure (as a language) is ...
6
votes
2answers
607 views

How do people get rid of conditional branches in Functional Programming?

Long running switch cases or if-else-if constructs are avoided in OOP using polymorphism wherever it is applicable. instead of branching by matching a value, branching is done at class-level itself. ...
7
votes
2answers
382 views

When would I require a Macro instead of a function?

I am new to Clojure, I am new to Macros and I have no prior background in Lisp. I went on to create my own switch case like form and ended up with this: (defmacro switch-case [v cases default] (if ...
30
votes
4answers
3k views

What did Rich Hickey mean when he said, “All that specificity [of interfaces/classes/types] kills your reuse!”

In Rich Hickey's thought-provoking goto conference keynote "The Value of Values" at 29 minutes he's talking about the overhead of a language like Java and makes a statement like, "All those interfaces ...
-1
votes
2answers
135 views

Are there any Clojure libraries for p2p? [closed]

I'm a web developer, but lately I have been learning Clojure and now I'm interested in creating a p2p application. And since Clojure is a general purpose language, I guess I can just use that. Any ...
7
votes
2answers
970 views

Could we build a functional computer?

As mush as FP has done, in the end, all our programs are structured. That is, it doesn't matter how pure or functional we make a them - they are always translated to assembly, so what actually runs ...
7
votes
1answer
931 views

How to write readable Clojure Code?

I am new to Clojure. I can understand the code I write but it becomes too difficult to understand it later. It becomes difficult to match parentheses. What's the generic conventions to follow ...
6
votes
5answers
3k views

Is Clojure's syntax really simpler than Scala's? [closed]

Argument which is always made in favour of Clojure is that. The syntax is simpler and there is only one way of expressing code with no complicated rules. However Scala has loads of different types ...
6
votes
2answers
1k views

Is Haskell/Clojure actually unsuited for dynamic systems such as particle simulation?

I've been told in previous questions that functional programming languages are unsuited for dynamic systems such as a physics engine, mainly because it's costly to mutate objects. How realistic is ...
7
votes
2answers
797 views

Are square brackets and curly braces in Clojure still S-expressions?

I am trying to learn Lisp and looking at all the Lisps out there and their differences. I see that in some implementations of Scheme, you can use square brackets interchangeably with round brackets ...
2
votes
2answers
2k views

clojure/erlang/go for high volume server

I have a project that will need to handle 1000s of requests a second with a decent amount of processing for each. For the most part, the processing will be done on a list of items, basically ...
13
votes
5answers
2k views

In what programming language did “let” first appear?

I was wondering about the origins of the "let" used in Lisp, Clojure, and Haskell. Does anyone know which language it appeared in first?
2
votes
4answers
1k views

What are the practical benefits of LISP like syntax which Clojure uses over Java like syntax of Scala?

I spent couple of months learning Scala and got overwhelmed by number of different constructs it had, After looking at partial functions, partially-applied functions, pattern matching, actor syntax, I ...
11
votes
3answers
563 views

Byte code weaving vs Lisp macros

I have been reading about the libraries people have written for languages like Java and C# that make use of byte code weaving to do things like intercept function calls, insert logging code, etc. I ...
9
votes
1answer
223 views

Accessing the history of a `ref` in Clojure

The documentation for ref shows a :max-history option and states that "refs accumulate history dynamically as needed to deal with read demands." I can see that there is history at the REPL, but I ...
3
votes
1answer
554 views

Is Clojure a 3GL or a 4GL?

A bit of background (in case I'm mistaken)... I think I understand that (it's an oversimplification): manually entering codes into memory (or on a punchcard) is "first generation language" using ...
11
votes
2answers
1k views

How will the new development of Java influence its interoperability with languages like Scala and Clojure?

As far as I understand, both Scala and Clojure have been designed as new languages that depend on the JVM, and easily integrate with Java code, in the sense that they allow to use Java classes ...
4
votes
2answers
219 views

Determinism of functions using PRNG in Clojure and functional languages

I'm a bit surprised by a sentence found in the book "Clojure Programming" (1st [and only as I write this!?] edition), page 78: It should be obvious that it's impossible to deterministically test a ...
14
votes
3answers
10k views

What's so great about Clojure? [closed]

I've been taking a look at Clojure lately and I stumbled upon this post on Stackoverflow that indicates some projects following best practices, and overall good Clojure code. I wanted to get my head ...
9
votes
3answers
936 views

Why can't we write nested shorthand functions in Clojure?

I tried to evaluate a Clojure expression with nested shorthand functions today, and it wouldn't let me. The expression was: (#(+ % (#(+ % (* % %)) %)) 5) ; sorry for the eye bleed The output was: ...
5
votes
2answers
911 views

Can Clojure's thread-based agents handle c10k performance?

I'm writing a c10k-style service and am trying to evaluate Clojure's performance. Can Clojure agents handle this scale of concurrency with its thread-based agents? Other high performance systems ...
5
votes
1answer
333 views

Setting up Clojure Project And Sub Projects

This is primarily a lein question about setting up a major project and its sub-projects, and is not intended to be a discussion question. Instead, I am interested in either a pointer to documentation ...
3
votes
2answers
559 views

Alternate method to dependent, nested if statements to check multiple states

Is there an easier way to process multiple true/false states than using nested if statements? I think there is, and it would be to create a sequence of states, and then use a function like when to ...
1
vote
1answer
467 views

Understanding clojure keywords

I'm taking my first steps with Clojure. Otherwise, I'm somewhat competent with JavaScript, Python, Java, and a little C. I was reading this artical that describes destructuring vectors and maps. E.g. ...
1
vote
2answers
244 views

What does using (vec col) or (vector arg1 & args) cost?

I am working through some Lisp exercises using Clojure. If I were to convert Lisp lists to Clojure vectors, solving some of the problems would be simpler, so here is my question: Does using vec or ...
8
votes
9answers
2k views

OS choice for functional developing

I'm mainly a .NET developer so I normaly use Windows/VisualStudio (that means: I'm spoiled) but I'm enjoying Haskell and other (mostly functional) languagues in my spare time. Now for Haskell the ...
15
votes
1answer
3k views

Is shipping a Clojure desktop app realistic?

I'm currently shipping a desktop Java application. It is a plain old Java 5 Java / Swing app and so far everything worked nicely. Java 5 was targetted because some users were on OS X version / ...
12
votes
1answer
1k views

Does Clojure have the continuation?

I started programming with Python. When using python, concepts like coroutine, closure made me really confusing. Now I think I know them some superficial level, but I want to get the "enlightement" ...
3
votes
1answer
136 views

For csv database extracts, how do map keys not create a dependency?

A lot of my work is done with .csv extracts (reports) from databases. As I have been programming in Clojure, I've received comments that relying on vector indexes creates dependencies. I understand ...
25
votes
4answers
4k views

What limitations does the JVM impose on tail-call optimization

Clojure does not perform tail call optimization on its own: when you have a tail recursive function and you want to have it optimized, you have to use the special form recur. Similarly, if you have ...
4
votes
3answers
490 views

Clojure state and persistence

I'm learning Clojure to see if it's something I can leverage at my current job, and more importantly, how I can convince my bosses that Clojure has a 'killer feature' over java that makes it worth the ...
5
votes
2answers
214 views

Can the Clojure set and maps syntax be added to other Lisp dialects?

In addition to create list using parentheses, Clojure allows to create vectors using [ ], maps using { } and sets using #{ }. Lisp is always said to be a very extensible language in which you can ...
2
votes
2answers
420 views

What are examples of Lisp's accomplishments? [closed]

I've more than once heard that sometimes a few individuals come up with great accomplishments from using Lisp. What are those refering to? What are concrete examples of people using Lisp to create ...