Live data from Hacker News

Try Julia

forio.com

51–60 of 105 posts

Re: Try Julia

#51
post #23

Is round(x) broken? Julia's standard library includes a host of mathematical functions, in addition to the standard operators. Complex numbers are also supported, using the built-in im unit: round(pi) lcm(54, 392, 232) # least common multiple sqrt(square(100)) e^(pi * im) log(e ^ 2) + log10(100) When you're ready, type "next" to continue julia> round(pi) no method round(MathConst{:π},)

To give some context, several common math constants are use the MathConst type to provide multi-precision constants. This allows e.g. a*pi to be extremely accurate if a is, e.g. a BigInt.

This issue was also reported at https://github.com/JuliaLang/julia/issues/5561

Re: Try Julia

#52

Fun with Julia: julia> 3 ** 60 syntax: use ^ instead of ** julia> 3 ^ 60 -3535985420588157519 julia> factorial(45) -8797348664486920192 julia> factorial(75) 0 julia> 5 * 5555555555555555555 -9115710369641325457 julia> 5 * 55555555555555555555 syntax: invalid numeric constant 55555555555555555555 This isn't C. The expectations have changed thanks to scripting languages. If I'm supposed to use this promising language t…

BTW, the invalid numeric constants thing was fixed

    julia> 55555555555555555555
    55555555555555555555

    julia> typeof(55555555555555555555)
    Int128

    julia> typeof(5555555555555555555555555555555555555555)
    BigInt (constructor with 7 methods)

Re: Try Julia

#53
Julia is very fast, 0.12 second, 0.60 second for sbcl (lisp)

julia>function haz(n) s = 0 for i in 1:n if i % 2 == 0 s = s+1 else s = s-1 end end s end haz (generic function with 1 method)

julia> @elapsed haz(10^8) 0.12459633

Compare with lisp sbcl on the same machine:

(defun haz(n) (let ((s 0)) (declare (optimize (speed 3) (safety 0)) (fixnum n s)) (loop for i fixnum from 1 upto n do (if (zerop (mod n 2)) (incf n) (decf n)) finally (return s))))

Re: Try Julia

#54

Fun with Julia: julia> 3 ** 60 syntax: use ^ instead of ** julia> 3 ^ 60 -3535985420588157519 julia> factorial(45) -8797348664486920192 julia> factorial(75) 0 julia> 5 * 5555555555555555555 -9115710369641325457 julia> 5 * 55555555555555555555 syntax: invalid numeric constant 55555555555555555555 This isn't C. The expectations have changed thanks to scripting languages. If I'm supposed to use this promising language t…

Yes, Julia doesn't auto-convert to BigInt, it's a trade-off between performance and easy-to-useness, but they've definitely made the right decision.

You have to convert to BigInt or BigFloat like this:

   julia> big(3) ^ 60
   42391158275216203514294433201

Re: Try Julia

#56

Earlier quoted context omitted.

Julia supports arbitrary precision arithmetic just fine, but you need to explicitly use it. Overflow checks don't matter in Python or Ruby where everything is relatively slow. See also: http://www.johnmyleswhite.com/notebook/2013/01/03/computers-...

My point wasn't that it can't be done. My point was about usability and what programmers have come to expect from a modern language. I understand that things get trickier when trying to implement arbitrary-precision arithmetic while keeping performance high.

My guess is that it would lead to at least 10x slowdown in very maths heavy code. So, considering that the main goal of Julia was performance, it doesn't make any sense. And you can easily convert to arbitrary precision with big(1234).

Re: Try Julia

#57
Julia appears to be a perfect fit for much of what I do at work. I tried it, got very excited, and then facepalmed earlier today. Let's define two functions in the REPL:

    function foo()
      return 42
    end

    function bar()
      return foo()
    end
Evaluating bar() gives 42, just as one would expect.

Now let's redefine foo():

    function foo()
      return 69
    end
Evaluating bar() still gives 42!

Not getting something so basic correct tells me to avoid the whole thing for fear of getting subtly screwed by some other oversight. Actually, oversight isn't the right word, since broken automatic compilation has been a known problem for two years: https://github.com/JuliaLang/julia/issues/265.

Re: Try Julia

#58
post #42

Earlier quoted context omitted.

Eh, in the case of Closure pervasive immutability, I don't want to write imperative code anymore. I am sure you could write in a functional style in Julia but all the code I have seen seems to rely pretty heavily on explicit stateful loops. At that seems to be a design choice not just for speed but, from what I have read elsewhere, to be familiar to Fortran and Matlab people, seems like a bad trade off to me.

Removing loops or mutability from Julia would be a terrible decision. There's nothing inherently wrong with mutability or imperative programming.

I just was answering the case for the advantage of Clojure over Julia as a general purpose language. And pervasive immutability is an advantage in that case. I agree Julia needs mutable arrays, I think for the domain it is targeting mutable arrays are a must but that should not mean that it needs big old imperative loops absolutely everywhere either.

Re: Try Julia

#59
A lot of the comments I see about Julia (and other trendy high level languages) are of the following form:

"I can do things I needed C to do before, and almost as fast"

which leads me personally to ask,

If you could do this in C before, and faster, then why are you switching?

Most people will say "because C is bad/difficult/clumsy for doing X"

which leads me to say,

why are you using C to do X?

I sincerely believe (as a computational scientist) that a combination of a high-level language for real-time interactive exploration and prototyping with a fast language like C for doing the actual gruntwork, is the best.

Attempts to combine the best of C (speed) with the best of scripting languages (easy to do things fast without having to pay attention to what you are doing) in my opinion end up merely joining the worst of both worlds rather than the best of both worlds.

Besides isn't programming about being specific? Do you really want to code stuff without having to worry about the details?

Re: Try Julia

#60
post #57

Julia appears to be a perfect fit for much of what I do at work. I tried it, got very excited, and then facepalmed earlier today. Let's define two functions in the REPL: function foo() return 42 end function bar() return foo() end Evaluating bar() gives 42, just as one would expect. Now let's redefine foo(): function foo() return 69 end Evaluating bar() still gives 42! Not getting something so basic correct tells me…

That annoys me too but it isn't a big deal, it'll probably get fixed in the future.
Post reply on HN