4 ms·
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
by Stubb 13y ago
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 https://github.com/JuliaLang/julia/issues/265.
- RivieraKid 13y agoThat annoys me too but it isn't a big deal, it'll probably get fixed in the future.
- Stubb 13y agoYou change a function, and that change doesn't get reflected in upstream calls—this isn't a big deal? Are you kidding me?
- RivieraKid 13y agoI don't see it as a big deal. You do, so my advice is to wait for 1.0.
- Stubb 13y agoExcept that the linked thread on Github mentions that supporting the redefinition of functions isn't a v1.0 issue.
- RivieraKid 13y agoIt's assigned to the 1.0 mileston.
- simonster 13y agoI think everyone involved with Julia agrees that this is something that eventually needs to work, although it is not as big of a deal if you are loading code from disk, as opposed to writing functions at the REPL. See https://github.com/JuliaLang/julia/issues/265 https://github.com/JuliaLang/julia/issues/265.
- Stubb 13y agoThat's the issues thread that I included in my initial post. Quoting from it: "When you redefine a method, the resulting behavior is undefined." And these people expect to be taken seriously? Sell crazy someplace else, we're all stocked up here. The honest approach would be to forbid redefining functions. This issue was brought to my attention by pals who had investigated Julia and rejected it for this very reason. No way I'll use it for anything. And that will be my recommendation to anyone who asks me about it.
- coldtea 13y ago>This issue was brought to my attention by pals who had investigated Julia and rejected it for this very reason. You should pick different advisors.
- Stubb 13y agoNope, I should buy them beers since Julia is wholly unsuited for what I'm trying to do, which is interactive network performance analysis and interactive development of ionospheric ray-tracing code. It's funny: I've forwarded this issue to several pals with experience in language & compiler design, and to a man they were dismayed that something so basic was going unfixed or was even broken in the first place.
- coldtea 13y agoThat's only an issue for quick iterating tests in the REPL. The REPL is not a priority. You're not supposed to rename functions in your code -- are you kidding me you're hang up on this?
- Stubb 13y agoNo kidding—this is a show-stopper for me. I'm running Emacs with a split window for development. R runs in the bottom window, and the source file I'm editing is in the top. This lets me send code to R for evaluation and supports an incremental style of development. I'll slowly build up functions, and this sometimes requires editing functions that my current function uses. This style of development is typical for people using R, Matlab, Lisp, or any language featuring a REPL. But you can't do it in Julia. Julia needs to support this style of development if it's to garner support from people using these languages. Full stop. And the fact that Julia doesn't support updating functions makes me think that something is very broken down in the core of the language. The tone of the GitHub thread is: "We don't know how to fix this." Scary!
- ihnorton 13y agoJulia certainly allows you to redefine functions, it simply doesn't trigger automatic upstream recompilation. https://gist.github.com/anonymous/8656066 https://gist.github.com/anonymous/8656066 > I'm running Emacs with a split window for development. R runs in the bottom window, and the source file I'm editing is in the top. This lets me send code to R for evaluation and supports an incremental style of development. I'll slowly build up functions, and this sometimes requires editing functions that my current function uses. This style of development is typical for people using R, Matlab, Lisp, or any language featuring a REPL. But you can't do it in Julia. This is what everyone does in Julia too, with Emacs, IJulia, and others. Here is how to do it: put "module X" at the beginning of your file, and an extra "end" as the last line. Each time you send the file to Julia, the module is recompiled, and inter-dependent functions are updated to the latest version. Problem solved. This is mentioned (in a slightly different context) in the FAQ: http://docs.julialang.org/en/release-0.2/manual/faq/#how-can-i-modify-the-declaration-of-a-type-immutable-in-my-session http://docs.julialang.org/en/release-0.2/manual/faq/#how-can... But I admit it's not immediately obvious, and we should probably put it front-and-center somewhere.
- ihnorton 13y agoNot getting something so basic correct tells me to avoid the whole thing for fear of getting subtly screwed by some other oversight. No one denies that this is a problem, and it will be fixed. But I disagree that it represents a fundamental flaw. For iterative development, it is a minor inconvenience, so other priorities have taken precedence. If you are redefining functions in this way in tested code, there may be bigger problems to worry about. The Julia developers have paid fastidious attention to correctness (to the point of making a pilgrimage to visit Kahan early on). The type system is well thought-out and nice to use. Spurious crashes are almost nonexistent (and fixed within hours, without fail). The foundation is solid, but it's still a work in progress, and it will take some time to shake these sorts of features out.
- Stubb 13y agoI was cheering out loud when I first downloaded Julia and started working with it. The type system, multiple dispatch, so much win! I'm working on ionospheric ray tracing at my day job and would love to use Julia. But when I can write a nine-line example that produces incorrect output—no thanks. Especially when one of the lead developers (see the linked thread) states that supporting function redefinition isn't needed for v1.0. Clearly these people are working under a very different set of priorities than me. "The foundation is solid"—I do not think it means what you think it means.
- coldtea 13y ago>Clearly these people are working under a very different set of priorities than me. Yes, they are pragmatists. Plus they know that the language is the first priority, not the REPL.
- charlieflowers 13y ago(to the point of making a pilgrimage to visit Kahan early on) What does that mean?
- ihnorton 13y ago"The Father of Floating Point" http://en.wikipedia.org/wiki/William_Kahan http://en.wikipedia.org/wiki/William_Kahan