Fork me on GitHub
#off-topic
<
2018-01-23
>
tbaldridge00:01:46

@qqq any decent JIT will do what's known as deoptimizing. Integers will be stored as ints until you start using floats. Integers will be stored unboxed in arrays until you add a non-integer value, etc.

tbaldridge00:01:06

That's one of the major reasons why unhinted math is so much faster in CLJS than CLJ.

qqq00:01:50

@tbaldridge: I missed something important. What does the JavaScript VM do that JVM does NOT do that makes "unhinted CLJS math faster than unhinted CLJ math"?

tbaldridge00:01:00

The JVM is restricted by the (limited) type system it implements. On the JVM if you say arr[idx] = 42, the JVM will box the number if the array is of type Object. In JS VMs the value is not boxed until the VM discoveres that you try to do something like arr[idx + 1] = "foo"

tbaldridge00:01:43

So it starts with the array being a int[] until you stick something that's not a int into it, then it transparently converts the array into a object[]

tbaldridge00:01:20

Apply the same logic to function arguments, object fields, etc.

tbaldridge00:01:10

Hrm, looking at it now @qqq that may not be the case for arrays. It is the case for functions and object methods it seems.

tbaldridge00:01:37

And in V8 ints are stored as tagged integers, so there's never boxing as long as your integer stays less than 31bits

souenzzo01:01:44

there is some Work In Progress implementation of clojure to python? even though still experimental but intended to be "complete" (I find ~10 projects on github, half of them by @tbaldridge, but no one has many activity)

souenzzo01:01:43

Why you want to use clojure on pythonvm?? Most of the material on the internet from machine learning is in python Yes, there is awesome stuff in JVM/Clojure/JS... but python looks like de "main" language

qqq06:01:29

I tried "Hy Lisp" for precisely the same reason, gave up, then tried looking for numerical libs in Java (Tensorflow Java API, MXNET, and JCuda)

cvic08:01:21

Weka, Deeplearning4j, MALLET are OK.

sb00:01:50

Yes, mainly with JNA/JNI methods. You work with Python in the Clojure. JNI a little bit more stable.

sb00:01:46

Yes, mainly with JNA/JNI methods. You could work with Python in the Clojure (like ~java). JNI a little bit more stable.

sb00:01:16

And both use Cpython 😉

cvic08:01:33

Cython is pretty awesome yes. https://spacy.io is the proof 😄

sb18:01:29

Sounds interesting!

gonewest81805:01:02

Isn’t that just a least common multiple of a bunch of terms? Yes, it is.

(def terms '(24000 ;; i.e. 24 Hz theatrical film framerate
             25000
             30000 ;; 30 Hz NTSC video
             48000
             50000
             60000 ;; 60 Hz NTSC fields
             90000
             100000
             120000
             8000  ;; 8 kHz audio
             16000
             22050
             24000
             32000
             44100 ;; 44.1 kHz audio
             48000 ;; ... etc.
             88200
             96000
             192000))

(defn gcd [a b]
  (if (zero? b)
    a
    (recur b (mod a b))))

(defn lcm [a b]
  (/ (* a b) (gcd a b)))

(reduce lcm terms)
;; => 705600000

qqq11:01:20

is there a way to interpret webasembly on rhino https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino ?