Fork me on GitHub
#beginners
<
2017-09-20
>
chang10:09:31

Does anybody know of a wiki/tutorial for Chas Emerick's pomegranate?: https://github.com/cemerick/pomegranate Also how do you guys usually explore a new library? How do import all dependencies into the repl if possible?

michaelwfogleman11:09:50

In terms of looking at new libraries, making a local playground that has all the dependencies and such can be a useful starting point

michaelwfogleman11:09:30

Looking at the project's source can also be useful, especially its tests if there are tests. Then you can see how it's meant to be used

michaelwfogleman11:09:41

You can also search for usage of the project on Github and see how other people are using it

michaelwfogleman11:09:02

https://crossclj.info/ is a good tool for that last tip

timgilbert14:09:03

I like the lein-try plugin for stuff like that, you give it a library and it downloads it and fires up a repl without needing to go through a lot of project.clj ceremony: https://github.com/rkneufeld/lein-try

chang14:09:56

@U5GP7SDN2 Thanks for the suggestions.

chang14:09:28

@U08QZ7Y5S I just tried lein-try, it seems like a very handy tool 🙂

skarmeta12:09:24

I'm supposed to implement a function that is tested by this:

(let [test-clock (clock->string (clock 24 0))]
      (is (= test-clock "00:00"))))
What is the ->string thing here? Is that just a naming convention? Like I should define my function defn clock->string [clock]?

pkova12:09:53

it's a clojure naming convention, clock->stringmeans clock to string

skarmeta12:09:31

Thanks. i didn't know if the -> was some sort of special keyword

chris12:09:43

I suggest reading elements of clojure by ztellman

chris12:09:48

the first chapter covers this

chris12:09:58

(also it's great)

skarmeta13:09:13

Thanks for the reference. I'll probably pick it up when I have a little bit more experience under my belt.

Jim Rootham15:09:33

Is there a way to configure httpkit to handle CORS? Or do I need to use something else (jetty)?

Jim Rootham15:09:04

Found a SO post that says no. Off to track down jetty.

cgore15:09:32

Just realized this isn’t the work slack 😄 But the ring.middleware.cors bit still holds. This might be what you want? https://github.com/r0man/ring-cors

Ben Redden17:09:29

after a bit of trial and error, realized I only had the JRE installed and not the JDK, but was up and running once that was installed; i’d always been kinda against Java up until now.. not sure if it’s because my only experience with it was when a friend showed me some Android code and tons of XML files

noisesmith17:09:04

yeah - “best practices” in the java ecosystem can easily make you hate the language, but it’s possible to use it in more reasonable ways

vuuvi17:09:12

at least for me I always found the excessive boilerplate code to be annoying. I also had a terrible teacher so both things tainted pure Java for me

vuuvi17:09:19

working with JVM is cool though

yogidevbear18:09:30

Hi. Just curious, but is there a more idiomatic way to achieve the same result for (apply str (reverse "abcd"))

dpsutton18:09:55

(clojure.string/reverse "whatever") would be pretty idiomatic i think

yogidevbear18:09:57

Now wondering what clojure.string/reverse is doing under the hood 🙂

dpsutton18:09:59

(.. (split "") (reverse) (join ""))
after handling some unicode things it seems

yogidevbear18:09:53

Looks like it's using Java's StringBuilder, using the Java reverse function, and then using .toString

yogidevbear18:09:04

Am I looking at the wrong bit of code?

ghadi18:09:30

nope that's correct. the clojure.string one will be faster than a generic sequence operation

dpsutton18:09:36

i'm not sure. i'm a little confused now. i navigated to the impl in my editor

dpsutton18:09:51

ahh, i was in a cljs version. my apologies

yogidevbear18:09:07

No need to apologise 🙂

ghadi18:09:11

(apply str (reverse "abcd"))
that code ^ is creating a sequence of java.lang.Characters

dpsutton18:09:11

clojure.string/reverse is defined in target/raw/jib_out/js/clojure/string.cljs.

dpsutton18:09:20

from my editor

dpsutton18:09:39

which explains the lack of stringbuilder usage 🙂

yogidevbear18:09:54

I really need to spend some time going through sequences in more detail

noisesmith18:09:10

my version of the tl;dr is that they act like linked lists (regardless of what they have under the hood) and most of clojure.core knows how to use them so they lend themselves to simple general code (which is good) at the cost of performance (which is less good but it depends on what your actual bottle necks and such are as always)

noisesmith18:09:59

so with the StringBuilder vs. seq of characters comparison, it’s the difference between code optimized to build a String in memory with a data structure optimized for that purpose, vs. a linked list of Object that just happens to carry instances of Character and then using str (which finally does the StringBuilder thing under the hood itself)

genec20:09:50

Anyone have an opinion on choosing between Atom or VS Code with Clojure?

sundarj08:09:50

VS Code (unfortuately) doesn't seem to a have a good Clojure plugin (with REPL and so on), whereas Atom does. I was previously using VS Code, tried using Atom, but it was very unstable and generally unusable in my experience, so have been using Emacs (IntelliJ is also good).