Fork me on GitHub
#beginners
<
2015-09-11
>
goodwind8901:09:45

I'm trying to understand the performance differences of 1. (inc x) 2. (+ 1 x) and 3. (def myinc inc) (myinc x). What should be faster, and why? When I test with criterium it seems like the fastest would be 1 then 2 then 3.

ecelis02:09:38

hmmm... interesting

goodwind8902:09:51

how do I know if the inline path was taken, or the main path?

goodwind8902:09:21

(thanks, btw. I didn't think of going to the source)

ecelis02:09:48

I am begginer like yourself, lets see if some one else sheds light

surreal.analysis04:09:42

@goodwind89: I believe inline is used whenever the function is called directly

surreal.analysis04:09:51

Function body used whenever it is used as a higher order function

surreal.analysis04:09:09

But that's just based off this - https://groups.google.com/forum/#!topic/clojure/8ixHD07XdX0 - not real experience with that meta attribute

surreal.analysis04:09:28

Specifically tbc++'s answer

goodwind8904:09:58

Thanks. I'm just trying to understand why (def myinc inc) (myinc x) performs worse. Guess the only option is to read the bytecode.

Alex Miller (Clojure team)05:09:09

@goodwind89: compare the generated bytecode

xlevus12:09:50

I've just installed my OS on a new PC, and trying to create a new lein project, and I'm getting:

$ lein new chestnut fiddle
Failed to resolve version for chestnut:lein-template:jar:RELEASE: Could not find metadata chestnut:lein-template/maven-metadata.xml in local (/home/xlevus/.m2/repository)
This could be due to a typo in :dependencies or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.
Could not find template chestnut on the classpath.
I did this on another machine just a week ago and I could have sworn it worked flawlessly.

xlevus12:09:38

cleared out everything in ~/.lein and ~/.m2 and still no go

$ lein version
Leiningen 2.5.1 on Java 1.8.0_45-internal OpenJDK 64-Bit Server VM

Alex Miller (Clojure team)13:09:30

you can set the DEBUG env var to get from detail from lein

xlevus13:09:05

$ DEBUG=true lein new chestnut fiddle                                                                                                        (14:02)
Leiningen's classpath: /home/xlevus/.lein/self-installs/leiningen-2.5.2-standalone.jar
Applying task new to [chestnut fiddle]
Failed to resolve version for chestnut:lein-template:jar:RELEASE: Could not find metadata chestnut:lein-template/maven-metadata.xml in local (/home/xlevus/.m2/repository)
This could be due to a typo in :dependencies or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.
Could not find template chestnut on the classpath.

xlevus13:09:09

not much more detail in that

xlevus13:09:09

ah hah, fixed it by uninstalling and reinstalling java

xlevus13:09:59

so, with 1.7, has the runtime conditionals made cljx irrelevant?

meow13:09:06

@xlevus: Yes, I would write any new files using cljc files with reader conditionals. @danielcompton has a really good tutorial on them here: http://danielcompton.net/2015/06/10/clojure-reader-conditionals-by-example

paulb16:09:34

in the first chapter of Clojure Applied there's an example of defining a record that uses java.lang.Comparable and compareTo - how would this be done in ClojureScript?

roberto17:09:27

can you paste the example?

paulb17:09:45

(defrecord Money [amount ^Currency currency]
  java.lang.Comparable
    (compareTo [m1 m2]
      (validate-same-currency m1 m2)
      (compare (:amount m1) (:amount m2))))