Hacker News new | past | comments | ask | show | jobs | submit login

Interesting that it just reinvokes the whole function. I always thought that Wolfram does have some effects - like, you can print things. You can’t rerun the whole function if you have done any effects. But maybe I’m wrong about the effectfulness of the language.

Wolfram may not have inline caches or GC but it has lots of super interesting things that JS doesn’t have. Must be a fun system to work on!




The effects are how I tested this out; I used FunctionCompile on a function that uses first uses KernelFunction to call a user-defined function that increments a counter, and then calls Sqrt on the function's argument.

When you give it a non-negative argument, the counter increases by one; when you give it a negative argument you get the message of it reverting to the uncompiled evaluation and the counter increases by two.


Isn't this a potential for a lot of crazy bugs then?

I've never used Wolfram in earnest (touched it once in undergrad ever so briefly) so I may be misunderstanding.

EDIT: I see that the documentation for FunctionCompile indicates it's for pure functions only.https://reference.wolfram.com/language/ref/FunctionCompile.h...


In Wolfram Language, a "pure function" is what others would call an "anonymous function" or a "lambda". It doesn't actually imply the lack of side-effects.

The older Compile function also does the same thing when there's an error.

Given the difficulties of doing something fancier, I think it's a reasonable strategy. Mutating state that doesn't originate in a function isn't too common, and less so with the kinds of functions you'd compile. If the compiled function fails, you probably have some other bug in your code anyways.


Interesting...


It has GC, e.g. DataStructures (https://reference.wolfram.com/language/guide/DataStructures....) are GC'd. IIRC it uses refcounting for this.


By GC info in my post I mean tracking which registers and stack slots at each safepoint contain object references so the tracing GC can precisely identify all of the GC roots.

Since Wolfram Language uses referencing counting instead, it doesn't need all of that complexity; it just has to insert MemoryAcquire/MemoryRelease at the appropriate spots in the IR.


You don’t need to track registers and stack slots to do GC. JSC doesn’t.


I see what you mean, simpler indeed!




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: