Fork me on GitHub
#clojure
<
2018-08-25
>
meow01:08:12

What's the best way to install and manage Java on Ubuntu for someone hopping into the ecosystem purely for Clojure / Clojurescript?

timothypratley01:08:31

@meow I use sudo apt install openjdk-8-jdk and am happy with the results. One thing to be aware of is that Current Ubuntu installs java11 if you just request the default; You will run into issues with java11 (these are easy to overcome, but is just a bit of a pain). You can also install both versions and switch between them with sudo update-alternatives --config java if you need to.

valerauko02:08:34

i'm using that too, no issues

dottedmag12:08:45

How do I make Cursive recognize browser built-ins, e.g. js/DataView?

stephenwithav13:08:37

Is Immutant still considered a best-practice when building app servers?

joshkh14:08:31

is it possible to test for the fniness of something? for instance, a set is a data structure and also a function, but returns false when passed to fn?:

(fn? #{1 2 3})
=> false

joshkh14:08:20

solved as soon as i opened my mouth:

(ifn? #{1 2 3})
=> true
(ifn? "string")
=> false

seancorfield16:08:57

@cureadvocate so far I've never needed the JEE features that Immutant offers. All my Clojure web apps run on either embedded Jetty or http-kit.

stephenwithav16:08:59

Thank you, Sean. Preparing for an interview Monday, so just curious what's popular now. (I switched to Go for channels for bit since Clojure lacked transducers at the time.)

andrea.crotti17:08:46

what's a good way to do restful APIs with Clojure?

andrea.crotti17:08:14

I've seen Liberator which might be interesting for example, other ideas?

andrea.crotti17:08:25

I also rewrote the routing from Compojure to Bidi, but I don't find a way to have a route like /100 instead of /resource/100 where 100 should be mapped to resource-id for example

andrea.crotti17:08:19

it's nice to have routes as data, but I don't find it so easy to wrap my head around this data centric DSL used

g17:08:03

perhaps i’m misunderstanding, but i think bidi does have regex support for cases like that

seancorfield19:08:22

@andrea.crotti something like ["/" {[:resource-id ""] :your-route}] maybe?

seancorfield19:08:58

(and, yeah, I find Bidi pretty hard to get my head around)

seancorfield19:08:34

@cureadvocate Good luck with the interview! I think Jetty is popular by default since that was kind of the "batteries included" setup with Ring for a long time. We ran into some problem around thread management with it some time back, so we switched to http-kit for most of our server processes. I think if we were building something more monolithic and needed built-in queuing and other JEE stuff, we'd look at Immutant but, I'll be honest, I haven't been following its development for a while now. It seemed very interesting when it first appeared tho'...

tcrawley20:08:05

Immutant hasn't been JEE focused in a long time :) You can use it piecemeal, and embedded. So if you just need an embedded webserver, you can use immutant-web just like you would Jetty/http-kit

seancorfield20:08:01

Nice! Thanks @tcrawley! I didn't realize it had changed so much -- that's great!

tcrawley20:08:01

Yep, with 2.0 we dropped the need for the container and broke it up. See http://immutant.org/documentation/2.1.10/apidoc/guide-web.html for an example of using the embedded web server

seancorfield20:08:48

run-dmc :rolling_on_the_floor_laughing: Love it!

seancorfield20:08:18

I'll have to take another look at it!

stephenwithav20:08:05

Thank you, @seancorfield! I'm looking at http-kit with Compojure right now, then monads and caching libraries. Tomorrow I'll build a front-end with ClojureScript and will hopefully be ready to go.

seancorfield20:08:05

@tcrawley Very nice to see Immutant being as simple to get up and running as Jetty or http-kit!

seanc@DESKTOP-JMD1DBJ:~/clojure$ clj -Sdeps '{:deps {org.immutant/web {:mvn/version "RELEASE"}}}'
Clojure 1.9.0
user=> (require '[immutant.web :as web])
20:32:31.963 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
nil
user=> (defn app [req] {:status 200 :body "<h1>I'm Immutant!</h1><p>I'm modular now!</p>"})
#'user/app
user=> (web/run #'app)
20:32:54.962 INFO  [org.projectodd.wunderboss.web.Web] (main) Registered web context /
{:path "/", :immutant.internal.options/validated? true, :dispatch? true, :auto-start true, :static-dir nil, :port 8080, :host "localhost", :virtual-host nil, :configuration nil, :contexts {#object[org.projectodd.wunderboss.web.undertow.UndertowWeb 0x662be9f7 "org.projectodd.wunderboss.web.undertow.UndertowWeb@662be9f7"] ({:virtual-host nil, :path "/"})}, :servlet-name nil, :filter-map nil}
user=>

gfredericks22:08:00

a sequential destructuring naming pattern I just thought of:

(let [[foo & +foos] foos]
  ...)

👌 4