Fork me on GitHub

Is there a time complexity table somewhere for clojure structures?


not a table, but in the book “Clojure Standard Library” for every discussed function there is a performance considerations paragraph:

Steve Smith09:07:39

Hey all, I've been listening to Rich Hickey's talks and I've been convinced. I want to make a web app with a clojure back end and a clojurescript front end.

Steve Smith09:07:25

I want to have user authentication/authorization and I'd prefer to use a document store like mongodb.

Steve Smith09:07:43

Will compojure work for me?


Compojure will likely be part of your app, since it's widely used and you'll find lots of people who know it well enough to answer questions about it. Compojure is just the piece that connects /some/app/url to the code that's supposed to respond to that URL, so you'll need more than just Compojure.

👍 8
Max Deineko12:07:24

Hi all, I'm currently trying to follow leiningen+cljsbuild setup instructions and having trouble running lein cljsbuild once -- which yields a java.lang.ClassNotFoundException: clojure.lang.Tuple exception. Has anyone encountered said problem and/or could point me to ways of debugging this?

Max Deineko12:07:23

project.clj contains

(defproject hello_world "0.1.0-SNAPSHOT"
  :plugins [[org.clojure/clojure "1.9.0"] 
            [lein-cljsbuild "1.1.7"]]
  :dependencies [[org.clojure/clojurescript "1.10.339"]
                 [cljs-ajax "0.7.3"]]
  :cljsbuild {:builds
              [{:source-paths ["src"]
                :compiler {:output-to "out/main.js"
                           :optimizations :advanced}}]})

Max Deineko12:07:17

Output of lein cljsbuild once:

Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
Compiling ClojureScript...
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
Exception in thread "main" java.lang.NoClassDefFoundError: clojure/lang/Tuple
	at Source)
	at<clinit>(Unknown Source)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(
	at clojure.lang.RT.loadClassForName(
	at clojure.lang.RT.load(
	at clojure.lang.RT.load(
	at clojure.core$load$fn__5018.invoke(core.clj:5530)
	at clojure.core$load.doInvoke(core.clj:5529)
	at clojure.lang.RestFn.invoke(
	at clojure.core$load_one.invoke(core.clj:5336)
	at clojure.core$load_lib$fn__4967.invoke(core.clj:5375)
	at clojure.core$load_lib.doInvoke(core.clj:5374)
	at clojure.lang.RestFn.applyTo(
	at clojure.core$apply.invoke(core.clj:619)
	at clojure.core$load_libs.doInvoke(core.clj:5413)
	at clojure.lang.RestFn.applyTo(
	at clojure.core$apply.invoke(core.clj:619)
	at clojure.core$require.doInvoke(core.clj:5496)
	at clojure.lang.RestFn.invoke(
	at cljsbuild.compiler$eval9$loading__4910__auto____10.invoke(compiler.clj:1)
	at cljsbuild.compiler$eval9.invoke(compiler.clj:1)
	at clojure.lang.Compiler.eval(
	at clojure.lang.Compiler.eval(
	at clojure.lang.Compiler.load(
	at clojure.lang.RT.loadResourceScript(
	at clojure.lang.RT.loadResourceScript(
	at clojure.lang.RT.load(
	at clojure.lang.RT.load(
	at clojure.core$load$fn__5018.invoke(core.clj:5530)
	at clojure.core$load.doInvoke(core.clj:5529)
	at clojure.lang.RestFn.invoke(
	at clojure.core$load_one.invoke(core.clj:5336)
	at clojure.core$load_lib$fn__4967.invoke(core.clj:5375)
	at clojure.core$load_lib.doInvoke(core.clj:5374)
	at clojure.lang.RestFn.applyTo(
	at clojure.core$apply.invoke(core.clj:619)
	at clojure.core$load_libs.doInvoke(core.clj:5413)
	at clojure.lang.RestFn.applyTo(
	at clojure.core$apply.invoke(core.clj:619)
	at clojure.core$require.doInvoke(core.clj:5496)
	at clojure.lang.RestFn.invoke(
	at user$eval5.invoke(form-init769454222035647546.clj:1)
	at clojure.lang.Compiler.eval(
	at clojure.lang.Compiler.eval(
	at clojure.lang.Compiler.load(
	at clojure.lang.Compiler.loadFile(
	at clojure.main$load_script.invoke(main.clj:294)
	at clojure.main$init_opt.invoke(main.clj:299)
	at clojure.main$initialize.invoke(main.clj:327)
	at clojure.main$null_opt.invoke(main.clj:362)
	at clojure.main$main.doInvoke(main.clj:440)
	at clojure.lang.RestFn.invoke(
	at clojure.lang.Var.invoke(
	at clojure.lang.AFn.applyToHelper(
	at clojure.lang.Var.applyTo(
	at clojure.main.main(
Caused by: java.lang.ClassNotFoundException: clojure.lang.Tuple
	at java.lang.ClassLoader.loadClass(
	at sun.misc.Launcher$AppClassLoader.loadClass(
	at java.lang.ClassLoader.loadClass(
	... 57 more
Subprocess failed

Max Deineko12:07:22

There's one file ins src : src/hello_world/core.cljs, containing

(ns hello-world.core
  (:require [ajax.core :refer [GET]]))

(GET "")

Max Deineko12:07:58

lein --version says

Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
Leiningen 2.8.1 on Java 1.8.0_152 OpenJDK 64-Bit Server VM

Max Deineko12:07:40

also, currently there is no file under ~/.lein/profiles.clj path


[org.clojure/clojure "1.9.0"] is listed in :plugins rather than :dependencies


That doesn't look right...


@U9TGHG3LP Try fixing that

Max Deineko13:07:59

Yes! Great thanks! Do you happen to know why this also fails without explicit clojure dependency? Some hardcoded old clojure version in leiningen? The example on the lein-cljsbuild github page does not include the clojure dependency either..


That's a great question and I'm afraid I don't know


It looks to me like leiningen-core uses Clojure 1.8

Max Deineko13:07:33

When replacing clojure version above with 1.8 build still works here, 1.7 breaks then -- I guess the default version is dependent on leiningen build. Thanks again for spotting this! 🙂


@lee.justin.m “I’d like to maintain the “looks imperative” style.” Aha! I have been trying to get a Clojurian to admit threading is imperative/procedural! You will be cited in many footnotes to come. 🙂


We’re gonna need a bigger bibliography…


i feel that way about lengthy lets


@hiskennyness well undoubtedly someone will tell me i’m using the word “imperative” wrong. but when my internal model is “do this then that” I want the code to look that way. i think this is why sql of any complexity is very hard to understand.


Yeah, a die-hard Clojurian swore to me that do-this-do-that threading was functional, so yer in trouble. 🙂


I use CTEs in SQL so I do not lose my mind.


there's nothing not-functional about it


the problem is in what is meant by these words. threading still gives you referential transparency (which is functional), but the code is time-ordered (which is imperative, in my mind).


any synchronous code is time-ordered. by that logic do or when or even defn are imperative because you can have multiple sequential statements?

👍 4

imo threading is just syntax sugar for regular clojure code, syntax sugar can't be imperative or functional, as it does nothing by itself

👍 24

yes this is exactly how i thought the conversation would go. 🙂


I agree, but I think let (as opposed to threading) is a bit more than just syntactic sugar for regular code. let lets you get away with writing very imperative-styled code though


Y’all need to read Paul Graham’s On Lisp. Syntax is semantics.


Right, Paul Graham wanted an imaginary tax on let.


@vale yes, i do think they are imperative in a sense. any def is imperative since it mutates the global state 🙂


I’m talking about style, really.


def is definitely imperative to me, as well as ns

Alex Miller (Clojure team)15:07:43

who cares?

😂 24
💯 12
👍 8
🎉 4
✌️ 4
Alex Miller (Clojure team)15:07:51

these are unimportant labels

Alex Miller (Clojure team)15:07:59

just solve problems

🎆 8

Threading’s excuse is that no new “places” in the sense of named state are introduced. Not buying it, ->>! 🙂


in my case, I don’t care. but in my original question from yesterday i was trying to use some word to communicate what problem i was trying to solve


Who cares about code readability? Me, anyway.


maybe I’ll say “time-ordered code” next time because the word “imperative” always draws sharp reactions


i think it’s downright funny that people emoji’d up the “who cares” above because people clearly do care! it always draws a reaction


I don't really get what you mean time-ordered, but I get what you mean by imperative. It's not like every top-level form executes asynchronously


I guess as-> helps a little. Me, I can never keep straight where the imaginary “place” is in threaded code. No, ,,, was not the answer. 🙂


I mean “first add this thing, then add that thing, then do that”


and the code is in that order


I mean, who cares that def is imperative (creating side effects), if it doesn't create problems for you/your program (in contrast with general data structure mutability)


Funny seeing the incredibly conformist Clojure crowd suddenly cheering “Who cares?”

Alex Miller (Clojure team)15:07:21

I do not see the Clojure crowd as conformist :)


@joelsanchez That’s fine, but if I put a closing parens on its own line I get tarred and feathered. 🙂

cparen 16
Alex Miller (Clojure team)16:07:48

well, that’s just wrong ;)

parens 4

Have you ever read a Clojure style guide?


I also believe that's poor style but I don't see the connection to the current discussion


Love the closing parens emoji!! On its own line! Twenty pushups for both of you.


Paul Graham illustrates functional code as flowing down and to the right. Lispers “get it”. Clojurians turn it into a thread of steps, losing (to a Lisper) the true functional flow.


OK, back to beating my head against RN.


doesn't CL lack immutability by default, anyway?


let over lambda's author (the book that builds on On Lisp) strongly argues that lisp is not functional (at least common lisp)


so how can we be less functional?


Could someone explain to me the situation with Java licensing? Should I try and get openjdk? Currently I'm talking about my laptop/home computer.


CL is a big ball of mud. We do what we want. If we are smart, we code functionally. It is better. But no one collapses in a heap if a SETF comes in handy.


“Who cares?“, as some wise soul noted.

🙂 4

I vote for threading being functional 😎

😤 4

@joelsanchez I would distinguish between functional and immutability. With threading we start with x then create f(x) which becomes x for the next f(x) etc. Each f(x) leaves its x unmutated, but in effect a “temp” var is being created and then re-written at each step. as-> is explicit about that. Functionally we say “The dog that chased the car that ran the red light”, beginning with the semantic outcome (the dog) then revealing recursively its derivation from inputs. In threading we have, “There was this red light. A car ran it. A dog chased that.” Imperative, step-wise evolution of the semantics.


I look a functional programming as a pipeline anyway though


threadings dont create temp vars, try macroexpanding it to see it...I guess its more of a "mental concept" problem you're talking about


they are also very dumb in the sensw that they dont care what you are threading, as others have noted before


I'd argue against the "rewritten" part regardless - even when you reuse a binding name in let, there's no rewrite in the sequence of operations


shadowing maybe, no mutation


@clojurians-slack yep, threading is a functional pipeline, but it is necessarily of functions with one parameter, the result of the prior step. My functional mind works with functions of N parameters, so threads look like strait jackets.


@hiskennyness I guess we need a thread-fork -< 😉


Yeah, it can get messy quick


@avovsya openjdk can't hurt. That's always been the first thing I install on a Linux box.


While you all are on this topic. I've been asking around lately... Do you think learning common lisp along with clojure would be confusing. I'm a hobbyists programmer and I've taken a liken to lisp so there are a lot of older texts that I want to go through. I have Paul graham's ansi common lisp and paip. Ive heard good things about LoL but that seems to be a book I need more under my belt for.


I'd say learning scheme and ml would contribute more directly to appreciating clojure


@noisesmith :thinking_face: OK. I've skimmed through sicp. I also wanted to go through the osaki book at some point so I'd expect to have to take a look at ocaml. But why do you say ML over common lisp? Just to experience a purely functional environment?


in terms of the functions used and idiomatic coding style


there's a lot of things that are normal in common lisp that aren't really normal clojure things


and normal ml things that clojure also shares


So I just switched to Spacemacs. I used Emacs for like a week a few years ago, so I am pretty new to the whole Emacs/Spacemacs thing. I have it installed and set up with the clojure layer. However, when it comes to the rest of how to use the editor, I'm pretty lost. Any recommendations/links to good tutorials, things to go through? Trying to get up to speed on Spacemacs as fast as I can so I can get back to learning Clojure 🙂 (I also posted this in the #spacemacs channel)


I’m going through this myself really and these have been fairly helpful. But mostly, it’s been pick things up as I need them.


I use lispy/evil-lispy. It kind of adds another mode on top of evil to navigate similar to the built in lispy mode. I use lisp state for certain things but am starting to get used to lispy/evil-lispy


@ryan.russell011 Recommendations? Stop sounding so cheerful and optimistic, you are crossing the River Styx and the boatman does not like you. Abandon most hope. A wise soul once said “It is easier for a good programmer to learn a new language than a new editor,” and Emacs is a lost-in-the-sixties joke. Spacemacs only make it worse with all its opinionation. Get IntelliJ and spend your next night of drinking on Cursive instead. If however you are an RMS-bred Communist refusing to pay for anything other than beer just go with raw Emacs and Cider and paredit. You’ll be fine in a month. hth!

😬 4

hahaha... well that was an entertaining response. I am wanting to learn Spacemacs for my own personal enjoyment. tbh.. I don't really feel like using IntelliJ for the moment, kind of burned out on it for now. I was using VSCode, but it is still missing things.... and I use Vim for everyday quick editing of config files and such... so figured wth.. might as well learn Spacemacs 🙂 And I am cheerful... I enjoy such things. When I used Emacs for like a week (or two)... I spent like 3 solid days customizing it to what I wanted... started using it for stuff, and ended up in Java where I needed IntelliJ.