Fork me on GitHub
#clojure
<
2018-04-22
>
Drew Verlee00:04:30

Anyone able to quickly spot why evaling this code in my repl would produce the correct results e.g (= 1 (jdbc/query db-info "select COUNT(*) from dogs;") is true. But when i run lein test i get false (there are no inserted rows). I tried inserting a delay in case for some reasons the insert wasn’t synchronize. I suspect i’m doing something much more basic wrong.

demi02:04:28

Very beginner question. Is (require '[clojure.string :as s]) supposed to creash lein test with Call to clojure.core/ns did not conform to spec exception?

andy.fingerhut05:04:33

@U55CJ7CDV (require '[clojure.string :as s]) by itself as a top level form should not cause that error, but if you try to do (ns my.test.namespace (require '[clojure.string :as s])) it likely will.

andy.fingerhut05:04:45

The syntax is slightly different inside an ns form. This should work:

andy.fingerhut05:04:55

(ns my.test.ns (:require [clojure.string :as s]))

datran03:04:03

Is there a way to print out a dependency tree of your namespaces?

Drew Verlee03:04:52

i think lein ancient does this

Geoffrey Gaillard09:04:59

you can try lein hiera 🙂

bherrmann03:04:23

@drewverlee probably test is using in memory db?

Drew Verlee03:04:18

it is actually, why does that tell you something?

Sallide03:04:13

when making an uberjar with lein, is it recommended to use :aot :all? does it matter?

Sallide03:04:26

from googling information seems a bit sparse

seancorfield03:04:27

@squarenegative There's a camp that thinks you shouldn't use AOT at all.

seancorfield03:04:39

At World SIngles, we do not AOT anything.

seancorfield03:04:31

Our uberjars are pure source (well, clojure.core is compiled, but that's how it is packaged).

Sallide04:04:21

@seancorfield what's the advantage of not AOT compiling?

seancorfield04:04:49

AOT can be very problematic...

Sallide04:04:41

causing unexpected behavior?

seancorfield04:04:30

A lot of problems have been fixed over the years but and, if it's the very last step of deployment of a complete application, rather than a library, it can help with startup time, but if startup time isn't a problem, it just isn't worth it, IMO. https://dev.clojure.org/display/design/AOT+Problem+Overview

benzap04:04:31

If you're server is up most of the time, AoT

benzap04:04:35

isn't worth it

benzap04:04:50

I guess it's more reasonable to consider compiling AoT if you're developing a gui application

seancorfield04:04:05

Agreed. For server processes, I see no values in AOT at all.

benzap04:04:20

but then again, is there really any considerable differences in startup time? I've never measured it

seancorfield04:04:58

If you have a lot of code and a lot of dependencies, yeah, start up time can be "high" -- but, to be honest, we see more startup overhead from New Relic weaving all the classes than from Clojure compilation...

Sallide04:04:33

huh good to know, thank you. I'm making a basic server and i'll disable aot

Sallide04:04:06

it looks like you still have to aot compile -main right?

Sallide04:04:23

i tried to put skip-aot in my lein profile and the uberjar wouldn't run

seancorfield04:04:18

No, you don't need AOT at all.

seancorfield04:04:39

But you'll want to specify the main namespace.

seancorfield04:04:54

I think lein makes that more difficult than it needs to be.

Sallide04:04:33

I have :main ^:skip-aot server.core as part of my profiles.clj

Sallide04:04:55

which gives me Warning: The Main-Class specified does not exist within the jar. It may not be executable as expected. A gen-class directive may be missing in the namespace which contains the main method, or the namespace has not been AOT-compiled.

Sallide04:04:12

and the jar won't run

seancorfield04:04:51

Specify clojure.main as the :main. Then the JAR will run a REPL by default.

seancorfield04:04:08

clojure.main accepts -m to specify a "main" namespace.

seancorfield04:04:36

So you can have a single JAR file with multiple -main functions in different namespaces, and specify which one to run at startup.

seancorfield04:04:49

java -jar myapp.jar -m my.namespace

Sallide04:04:08

does running as a repl incur any performance cost?

seancorfield04:04:21

It doesn't run "as a REPL".

seancorfield04:04:43

I just meant that clojure.main's default behavior -- if you do not specify -m -- is to start a REPL.

seancorfield04:04:05

But Clojure's normal behavior is basically how the REPL works: load code, compile it to bytecode, run it.

Sallide04:04:46

gotcha, thanks

seancorfield04:04:39

If you use the official clj command-line stuff instead of lein to run code, it works this way (without making an uberjar).

Sallide04:04:01

yeah, i heard about that. i'm still new though and lein seems super easy, so sticking with it for now

seancorfield04:04:13

Yeah, although I think Boot is much more intuitive.

Sallide04:04:21

yeah i'll definitely check it out intuitively

Sallide04:04:36

right now I just need to finish up a simple api server for a club

Sallide04:04:02

*eventually not intuitively ^^

Sallide04:04:48

is there a way to get the uberjar without aot, and be able to run it as just java -jar app.jar? assumign I only have one main

Sallide04:04:58

i've been playing around but not sure

alex-dixon07:04:07

If anyone wants to mess around with foundationdb: https://github.com/alex-dixon/clj-foundationdb

👍 8
Keith14:04:58

I'm working on a project where I'm implementing SSO via SAML with a single SP and a variable amount of IDPs. I've used buddy-auth in the past for regular user/password auth, but I was unable to tell if that library supports SSO via SAML. Can anyone recommend a stable library?

borkdude15:04:01

@kharper General advice: if there isn’t a proper clj lib available, just use a Java lib directly

Keith16:04:00

@borkdude That's most likely what I'll have to do, thanks!

noisesmith18:04:00

often using the java lib is better even if there is a wrapper available

noisesmith18:04:37

especially if mutation or io are in the fundamental domain of the lib

qqq19:04:51

I realize there is a dedicated channel, posting here as that channel does not seem very active: for those using Neanderthal + ClojureCuda, is there any sample code that uses cuBlas + custom kernel funtions? With neanderthal I see code for using cublas. With ClojureCuda, I see how to sue custom kernels, but I can't find sample code that uses both on a single piece of gpu memory.

emccue20:04:36

piggy backing on that conversation about AOT, has anyone tried using clojure for aws lambda functions?

emccue20:04:44

My biggest concern is startup time

emccue20:04:18

I know java in general performs pretty subpar compared to python and nodejs for cold starts

qqq20:04:36

I use https://github.com/portkey-cloud/portkey for clojure + aws lambda. It's not been a problem so far.

mfikes20:04:17

@emccue I've heard of people using Clojure for AWS Lamba, but also keeping things running. I've also heard of people using ClojureScript / Node instead to address launch latency concerns.

emccue20:04:41

To give some context, we have a need for a 3rd party to send us an "event" for any kind of interaction a user makes with content

emccue20:04:58

so if they change the title of something, we need to process that new title

emccue21:04:20

one idea is to have a lambda process the events from sqs

emccue21:04:43

but good god we get a huge spike in traffic around this time of the year

emccue21:04:53

whatever we put in that lambda will be a small amount of code; the majority of the work will be in the infrastructure and finding a way to be reliable in the case that an aws region goes down

emccue23:04:08

no, honestly i spent the last 2 hours sleeping on the carpet

emccue23:04:54

Ill get around to it at some point

emccue23:04:48

Its still alpha, so its probably not the best choice for work

emccue23:04:26

Id probably end up just gen-class-ing the required entry point or write that in a java file

emccue23:04:14

I know there was a lib somewhere that has a deflambdafn but its whatever

emccue23:04:51

I do like the repl idea though