Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Julia (julia-lang) code be statically analyzed to avoid run-time type errors?

Tags:

julia

I recently ported one of my simulations to Julia and I discovered several type errors only at run-time. I wish to statically analyze my Julia code. MATLAB has a similar problem in only finding many errors at run-time.

The only tool I found (TypeCheck.jl) performs a small subset of the static analysis that I would expect from a compiler.

Is there a static analyzer for Julia scripts so I can avoid many of what are now run-time errors?

Is there something that I could use with the LLVM JIT compiler? (I don't know much about how the Julia compiling works and what is and isn't possible)

Is this even possible due to the nature of Julia?

like image 788
novelistparty Avatar asked May 22 '14 19:05

novelistparty


People also ask

Is Julia dynamically or statically typed?

A Beautiful Type System. One of the first things you'll be told is that Julia is dynamically typed. That is, statically typed (C++, Java, Haskell) versus dynamically typed (Lisp, Python, JavaScript).

Is Julia compiled?

Julia uses a just-in-time (JIT) compiler that is referred to as "just-ahead-of-time" (JAOT) in the Julia community, as Julia compiles all code (by default) to machine code before running it.


1 Answers

I think the answer depends on which kind of run-time error you want, since Julia's compile-time occurs at a point in time that most compiled languages would call run-time.

If you type the inputs of all of your functions and also type all of the variables in all of your functions, you'll be able to get a lot of type errors at Julia's compile-time.

like image 84
John Myles White Avatar answered Sep 28 '22 00:09

John Myles White