Fork me on GitHub
#beginners
<
2018-07-13
>
jeremy64201:07:06

Is there a time complexity table somewhere for clojure structures?

novel06:07:48

not a table, but in the book “Clojure Standard Library” for every discussed function there is a performance considerations paragraph: https://www.manning.com/books/clojure-standard-library

professionalstevesmit09: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.

professionalstevesmit09:07:25

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

professionalstevesmit09:07:43

Will compojure work for me?

manutter5111:07:10

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.

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: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 -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Dswing.crossplatformlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel
Compiling ClojureScript...
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Dswing.crossplatformlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel
Exception in thread "main" java.lang.NoClassDefFoundError: clojure/lang/Tuple
	at cljs.build.api__init.__init0(Unknown Source)
	at cljs.build.api__init.<clinit>(Unknown Source)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at clojure.lang.RT.loadClassForName(RT.java:2098)
	at clojure.lang.RT.load(RT.java:430)
	at clojure.lang.RT.load(RT.java:411)
	at clojure.core$load$fn__5018.invoke(core.clj:5530)
	at clojure.core$load.doInvoke(core.clj:5529)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	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(RestFn.java:142)
	at clojure.core$apply.invoke(core.clj:619)
	at clojure.core$load_libs.doInvoke(core.clj:5413)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invoke(core.clj:619)
	at clojure.core$require.doInvoke(core.clj:5496)
	at clojure.lang.RestFn.invoke(RestFn.java:512)
	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(Compiler.java:6619)
	at clojure.lang.Compiler.eval(Compiler.java:6608)
	at clojure.lang.Compiler.load(Compiler.java:7064)
	at clojure.lang.RT.loadResourceScript(RT.java:370)
	at clojure.lang.RT.loadResourceScript(RT.java:361)
	at clojure.lang.RT.load(RT.java:440)
	at clojure.lang.RT.load(RT.java:411)
	at clojure.core$load$fn__5018.invoke(core.clj:5530)
	at clojure.core$load.doInvoke(core.clj:5529)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	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(RestFn.java:142)
	at clojure.core$apply.invoke(core.clj:619)
	at clojure.core$load_libs.doInvoke(core.clj:5413)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invoke(core.clj:619)
	at clojure.core$require.doInvoke(core.clj:5496)
	at clojure.lang.RestFn.invoke(RestFn.java:436)
	at user$eval5.invoke(form-init769454222035647546.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:6619)
	at clojure.lang.Compiler.eval(Compiler.java:6608)
	at clojure.lang.Compiler.load(Compiler.java:7064)
	at clojure.lang.Compiler.loadFile(Compiler.java:7020)
	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(RestFn.java:421)
	at clojure.lang.Var.invoke(Var.java:419)
	at clojure.lang.AFn.applyToHelper(AFn.java:163)
	at clojure.lang.Var.applyTo(Var.java:532)
	at clojure.main.main(main.java:37)
Caused by: java.lang.ClassNotFoundException: clojure.lang.Tuple
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 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 -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Dswing.crossplatformlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel
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

acron12:07:25

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

acron12:07:30

That doesn't look right...

acron12:07:48

@ 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..

acron13:07:06

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

acron13:07:17

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! 🙂

hiskennyness15:07:19

@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. 🙂

hiskennyness03:07:29

We’re gonna need a bigger bibliography…

vale15:07:06

i feel that way about lengthy lets

lee.justin.m15:07:56

@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.

hiskennyness15:07:58

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

hiskennyness15:07:46

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

vale15:07:25

there's nothing not-functional about it

lee.justin.m15:07:36

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).

vale15:07:47

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

joelsanchez15:07:26

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

lee.justin.m15:07:40

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

bj15:07:50

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

hiskennyness15:07:03

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

hiskennyness15:07:38

Right, Paul Graham wanted an imaginary tax on let.

lee.justin.m15:07:53

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

lee.justin.m15:07:13

I’m talking about style, really.

joelsanchez15:07:33

def is definitely imperative to me, as well as ns

alexmiller15:07:51

these are unimportant labels

alexmiller15:07:59

just solve problems

hiskennyness15:07:11

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

lee.justin.m15:07:34

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

hiskennyness15:07:03

Who cares about code readability? Me, anyway.

lee.justin.m15:07:19

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

lee.justin.m15:07:59

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

bj15:07:07

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

hiskennyness15:07:24

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. 🙂

lee.justin.m15:07:31

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

lee.justin.m15:07:40

and the code is in that order

joelsanchez15:07:13

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)

hiskennyness15:07:43

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

alexmiller15:07:21

I do not see the Clojure crowd as conformist :)

hiskennyness15:07:28

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

alexmiller16:07:48

well, that’s just wrong ;)

hiskennyness15:07:49

Have you ever read a Clojure style guide?

joelsanchez15:07:42

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

hiskennyness15:07:47

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

hiskennyness15:07:18

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.

hiskennyness15:07:44

OK, back to beating my head against RN.

joelsanchez15:07:30

doesn't CL lack immutability by default, anyway?

joelsanchez15:07:24

let over lambda's author (the book that builds on On Lisp) strongly argues that lisp is not functional (at least common lisp) https://letoverlambda.com/index.cl/guest/chap5.html

joelsanchez15:07:36

so how can we be less functional?

avfonarev15:07:44

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.

hiskennyness15:07:41

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.

hiskennyness15:07:45

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

john16:07:42

I vote for threading being functional 😎

hiskennyness16:07:54

@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.

john16:07:04

I look a functional programming as a pipeline anyway though

joelsanchez16:07:24

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

joelsanchez16:07:45

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

noisesmith16:07:02

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

noisesmith16:07:10

shadowing maybe, no mutation

hiskennyness16:07:24

@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.

john16:07:23

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

john16:07:25

Yeah, it can get messy quick

decim16:07:24

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

decim17:07:29

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.

noisesmith17:07:09

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

decim18:07:18

@noisesmith 🤔 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?

noisesmith18:07:53

in terms of the functions used and idiomatic coding style

noisesmith18:07:10

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

noisesmith18:07:24

and normal ml things that clojure also shares

ryan.russell01122:07:41

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)

jeremy64202:07:18

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.

theeternalpulse20:07:16

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

hiskennyness22:07:04

@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!

ryan.russell01122:07:18

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.