top | item 47155526

Woxi: Wolfram Mathematica Reimplementation in Rust

337 points| adamnemecek | 4 days ago |github.com

132 comments

order

Grosvenor|1 day ago

My Bona fides: I've written my own Mathematica clone at least twice, maybe three times. Each time I get it parsing expressions and doing basic math, getting to basic calculus. Then I look up the sheer cliff face in front of me and think better of the whole thing.

There is an architectural flaw in Woxi that will sink it hard. Looking through the codebase things like polynomials are implemented in the rust code, not in woxilang. This will kill you long term.

The right approach is to have a tiny core interpreter, maybe go to JIT at some point if you can figure that out. Then implement all the functionality in woxilang itself. That means addition and subtraction, calculus, etc are term rewriting rules written in woxilang, not rust code.

This frees you up in the interpreter. Any improvements you make there will immediately show up over the entire language. It's also a better language to implement symbolic math in than rust.

It also means contributors only need to know one language: woxilang. No need to split between rust and woxilang.

porcoda|1 day ago

I noticed the same thing, having also written an interpreter for the Wolfram language that focused on the core rule/rewriting/pattern language. At its heart it’s more or less a Lisp-like language where the core can be quite small and a lot of the functionality built via pattern matching and rewriting atop that. Aside from the sheer scale of WL, I ended up setting aside my experiments replicating it when I did performance comparisons and realized how challenging it would be to not just match WL in functionality but performance.

Woxi reminds me of some experiments I did to see how far vibe coding could get me on similar math and symbolic reasoning tools. It seems like unless you explicitly and very actively force a design with a small core, the models tend towards building out a lot of complex, hard-coded logic that ultimately is hard to tune, maintain, or reason about in terms of correctness.

Interesting exercise with woxi in terms of what vibe coding can produce. Not sure about the WL implementation though.

(For context, I write compiler/interpreter tools for a living - have been for a couple decades)

larodi|14 hours ago

Sorry, perhaps, a dumb question:

Is it not that Mathematica, and most of the Wolfram innovation, is about a smart way of applying some rule-based inference. I think of it as parametrized PROLOG rules, with large lib. So term rewriting all the way to the end, correct me if I'm wrong.

Where does the mini-core+JIT come into this?

Thanks for taking time to answer.

adius|1 day ago

Mh, I thought about this a little and came actually to exactly the opposite conclusion: Implement as much as possible in Rust to get the fastest code possible. Do you have any more insights why this should not be possible / unsustainable?

nextaccountic|1 day ago

implementing addition in woxilang itself?? this gotta be terribly slow. am i missing something?

0x3f|1 day ago

Switching out to an interpreted language has got to be anathema to a rewrite-it-in-Rust project

the__alchemist|1 day ago

I love Rust for mathematical and scientific tasks (I am building the structural bio crate infrastructure), and I love Mathematica and have a personal sub. I should be the audience, but... What makes Mathematica great, IMO, is the polish and overall experience created by consistent work with applications in mind over decades. So, I look at this project with skepticism regarding its utility.

adius|1 day ago

Sure, but you've got to start somewhere! And with the amount of progress I was able to make in just a few weeks, I'm very optimistic that the polish will come sooner rather than later.

drnick1|1 day ago

Half-assed reimplementations of existing software (often in the name of "memory safety") is what the Rust community is best known for.

rustyhancock|1 day ago

Similarly I'm not sure Octave ever really got that polish to compete with MATLAB.

SPSS is hilariously painful to use. Still it's only losing ground ever so slowly. PSPP remains almost unheard of among SPSS core users.

amelius|1 day ago

Yeah, the Mathematica language is the least interesting aspect of the Mathematica system. Closely followed by the interactive notebooks.

adius|4 days ago

Hi, I'm the main developer. We're steadily getting closer to the next release which will support most features of Mathematica 1.0 plus some of the most popular newer functions (> 900 overall!). AMA!

cs702|1 day ago

Thank you for sharing this on HN.

It's a worthwhile effort. If successful, Woxi can enable a large mass of scientists and engineers who don't have access to Mathematica to run legacy code written for it. Also, Woxi would give those scientists and engineers who regularly use Mathematica a non-proprietary, less restrictive alternative, which many of them would welcome.

How does Woxi compare to other "clean-room implementations"[a] of the same language?

--

[a] Please check with a lawyer to make sure you won't run into legal or copyright issues.

egl2020|1 day ago

There's a mystique around Mathematica's math engine. Is this groundless, or will you eventually run into problems getting correct, identical answers -- especially for answers that Mathematic derives symbolically? The capabilities and results of the computer algebra systems that I've used varied widely.

utopiah|1 day ago

Interesting, thanks for sharing. Naive question as I'm not familiar with Mathematica much (but aware of it and Wolfram Alpha and related tools), how does it compare to e.g. Jupyter or Julia or maybe another language (with its framework) that might be even closer?

apetresc|1 day ago

What percentage of the overall code was written primarily by agents?

jacquesm|19 hours ago

What is your plan for long term support?

foobarqux|1 day ago

How is the popularity/rank in functions.csv determined?

dist-epoch|1 day ago

Why would I use this and not Wolfram Script?

Better license? Allowed for commercial operations?

foobarqux|1 day ago

Have you considered using quickcheck/random/property-based testing with LLM code generation to automate function implementation?

anandijain|1 day ago

This is cool! I've always wanted a polished kernel on the terminal. I spent a lot of time a few years ago writing my own Wolfram Kernel. It was a blast to understand how a pattern matching (symbolic) language is implemented.

https://github.com/anandijain/cas8.rs

WillAdams|1 day ago

For folks who are considering passing, note that there is a "Jupyter Lite" mode in addition to "Woxi Studio" --- seems very promising and the former addressed my first concern out-the-gate.

peterus|1 day ago

I regularly use Mathematica for working with symbolic expressions (for its DSolve and transfer function stuff) and it is way more maintainable and elegant to have fractions, symbols and powers rendered in math mode instead of having to deal with a text only representation. Are there any front ends (either custom or somehow extending jupyter) for this project which recreate this experience?

unexpectedtrap|16 hours ago

Glad to see Rust project under AGPL-3.0. I wish to see more Rust projects under (A)GPL, because (A)GPL is rare in the Rust community for some reason.

RagnarD|14 hours ago

Have you gotten any nastygrams from Wolfram about this? They're pretty protective of their IP. Not saying I think that it's some violation of it, but I could see them being alarmed.

qubex|3 hours ago

Wow! Do my eyes deceive me? What kind of ‘sunset’ are we talking of here?!

samwillis|1 day ago

Have you considered doing property tests with Mathematica as an oracle?

An ai based development workflow with a concrete oracle works very well. You still need the research and planing to solve things in a scalable way, but it solves the "are the tests correct" issue.

What we've done is pull out failing property tests as a unit tests, makes regression testing during the agentic coding loop much more efficient.

singularity2001|1 day ago

Is the syntax for symbolic computation already near optimal or should something be rethought and redone?

evanb|23 hours ago

> The initial focus is to implement a subset of the Wolfram Language so that it can be used for CLI scripting and notebooks.

If you have Mathematica installed you can write CLI scripts and notebooks.

oofbey|1 day ago

AGPL licensed. An interesting choice. Author really doesn’t want Wolfram to use it??

adius|1 day ago

Why should I want them to use it?

asdfe3r343|20 hours ago

How did claude code became contributor?

LowLevelKernel|1 day ago

Many Wolfram language algorithms are proprietary right?

esafak|1 day ago

I wonder if it would make a good Zeppelin interpreter. https://zeppelin.apache.org/

adius|1 day ago

Oh cool, haven't heard of this before. Could be a good fit - I'll have to try it out some day!

fnord77|1 day ago

vibe coded?

adius|1 day ago

Such a massive undertaking would be almost impossible without AI agents, so yeah, they help me. But with around 5000 tests, they are actually helping to improve the software quality!

downboots|1 day ago

Great! Math tools for everyone.

what's stopping some Mathematica employee from taking the source code and having an agent port it. Or even reconstruction from the manual. Who owns an algorithm?

Will everything get copied eventually?

MengerSponge|1 day ago

> what's stopping some employee from something like Mathematica from taking the source code and having an agent port it to open source

Laws against theft. Also the same reason employees don't release the code on pastebin or something.

> Who owns an algorithm?

The org or person who was granted the software patent. https://en.wikipedia.org/wiki/Software_patent

> Will everything get copied eventually?

If we're lucky. More likely everything bitrots as technical capabilities are lost. Slowly at first, then quickly.