Live data from Hacker News

Julia as a CLI Calculator

krasjet.com

1–10 of 134 posts

Re: Julia as a CLI Calculator

#2
This seems to be a very neat intro into Julia and a practical use case. I’ve been postponing to learn the language for a while now, but from what I heard/seen it seems to be extremely well designed.

Re: Julia as a CLI Calculator

#3
I love the julia language. I would love to use julia as a command line calculator. Unfortunately, starting the interpreter is excruciatingly slow, an order of magnitude slower than octave or python (and several orders of magnitude slower than bc or dc).

Re: Julia as a CLI Calculator

#4
post #3

I love the julia language. I would love to use julia as a command line calculator. Unfortunately, starting the interpreter is excruciatingly slow, an order of magnitude slower than octave or python (and several orders of magnitude slower than bc or dc).

One way to alleviate the slowish startup is to use PackageCompiler.jl (discussed at the end of the article https://krasjet.com/rnd.wlk/julia/#packagecompiler.jl). I like that there's more than just the standard calculator operations available at the REPL, but I can see why you wouldn't use it if you don't need it and bc satisfies your needs.

Re: Julia as a CLI Calculator

#5
post #3

I love the julia language. I would love to use julia as a command line calculator. Unfortunately, starting the interpreter is excruciatingly slow, an order of magnitude slower than octave or python (and several orders of magnitude slower than bc or dc).

Simply loading the REPL takes half a second for me. I use it all the time as a simple calculator.

Re: Julia as a CLI Calculator

#6
post #5
post #3

I love the julia language. I would love to use julia as a command line calculator. Unfortunately, starting the interpreter is excruciatingly slow, an order of magnitude slower than octave or python (and several orders of magnitude slower than bc or dc).

Simply loading the REPL takes half a second for me. I use it all the time as a simple calculator.

> Simply loading the REPL takes half a second for me. I juse it all the time as a simple calculator.

Half a second is precisely what is meant by "excruciatingly slow". If I need a simple calculator, I expect to be able to use it to compute intermediary results in a shell loop. If my loop has one thousand iterations, you are spending about 10 minutes just initializing the interpreter. This is absurd. Of course, you can rewrite your whole loop upside down, so that the interpreter is called outside the loop. But this kind of defeats the goal of considering julia to be a general-purpose calculator, orthogonal with its usage patterns.

Re: Julia as a CLI Calculator

#7
Oh, brilliant! This is exactly what I've been looking for. Didn't realize the syntax was so succint. So far I've preferred excel for my multidimensional calc needs but this fits my needs exactly (need to do simple back-of-the-envelope vector calculations time to time).

Re: Julia as a CLI Calculator

#8
post #3

I love the julia language. I would love to use julia as a command line calculator. Unfortunately, starting the interpreter is excruciatingly slow, an order of magnitude slower than octave or python (and several orders of magnitude slower than bc or dc).

Maybe a daemon model would be helpful here. REPL client could just boot instantly and forward operations to an already running Julia daemon

Re: Julia as a CLI Calculator

#9
post #6
post #5

Earlier quoted context omitted.

Simply loading the REPL takes half a second for me. I use it all the time as a simple calculator.

> Simply loading the REPL takes half a second for me. I juse it all the time as a simple calculator. Half a second is precisely what is meant by "excruciatingly slow". If I need a simple calculator, I expect to be able to use it to compute intermediary results in a shell loop. If my loop has one thousand iterations, you are spending about 10 minutes just initializing the interpreter. This is absurd. Of course, you ca…

I think the focus is on interactive use, there are surely better options for scripts and one liners

Re: Julia as a CLI Calculator

#10
A problem with Julia is that it does not parse input numbers with arbitrary precision by default. Example:

  julia> sin(1.461920290375737576933544899379e+31)
  -0.9468766486679395

  julia> sin(parse(BigFloat, "1.461920290375737576933544899379e+31"))
  0.6864670207863400975666631018263839509022548965872940746039593018855528710432756
Fricas is better in this regard, some links:

https://en.wikipedia.org/wiki/FriCAS

https://fricas.github.io

https://github.com/fricas/fricas

http://www.euclideanspace.com/prog/scratchpad/fricas/

EDIT: some info about FriCAS: it's implementation is currently based on Common Lisp, on top of which a language called "Spad" (short for Scratchpad) is implemented. Fricas is a fork of the Axiom computer mathematics system, which in turn is a continuation of Scratchpad. EDIT: and, at least with SBCL, it can use GMP for bignum.

I only skimmed the article, but I believe Fricas supports all uses of Julia mentioned in the article, and more, like advanced symbolic integration.

Post reply on HN