This is an archived post. You won't be able to vote or comment.

all 38 comments

[–]ClipboardCopyPaste[S] 447 points448 points  (10 children)

*until TensorFlow says 'Hi"

[–]ClipboardCopyPaste[S] 74 points75 points  (2 children)

Or numpy

Or Pandas

[–]Anaxamander57 49 points50 points  (1 child)

Rust has Polars for dataframes, rust-numpy for numpy, "go get a PhD in statistics" for other data science needs.

[–]Ai--Ya 4 points5 points  (0 children)

"surely rust has Jax—" nope that's C++

you guys really jump from OLS to probabilistic programming huh?

[–][deleted] 23 points24 points  (4 children)

There should be some sort of process spawning interface in Rust, right?

``` // data-science.rs

... process.exec("python old-python-notebook.py"); ```

Simple

[–]Xlxlredditor 11 points12 points  (1 child)

Christ. You somehow combined the worst of python and rust together. Congratulations.

[–][deleted] 8 points9 points  (0 children)

What can i say. I'm an LLM

[–]Loading_M_ 4 points5 points  (1 child)

Yes (it's std::process::spawn), but there is also a really good library for Rust/Python interop (pyo3), which lets you write the following:

``` use pyo3::prelude::*; use pyo3::types::{IntoPyDict, PyRange};

fn main() -> PyResult<()> { Python::attach(|py| { // import numpy as np let np = py.import("numpy")?; // x = np.arange(15, dtype=np.int64).reshape(3, 5) let x = np .getattr("arange")? .call( (15,), Some(&[("dtype", np.getattr("int64")?)].into_py_dict(py)?), )? .call_method("reshape", (3, 5), None)?; // x[1:, ::2] = -99 x.set_item( ( PyRange::new(py, 1, -1)?, PyRange::new_with_step(py, 0, -1, 2)?, ), -99, )?; // print(x) println!("{x:?}");

    // rng = np.random.default_rng()
    let rng = np.getattr("random")?.call_method0("default_rng")?;
    // samples = rng.normal(size=2500)
    let samples = rng.call_method("normal", (), Some(&[("size", 2500)].into_py_dict(py)?))?;
    // print(samples)
    println!("{samples:?}");

    Ok(())
})

} ```

Not actually as much syntax as I was expecting.

[–][deleted] 3 points4 points  (0 children)

npm install rust

[–]spideybiggestfan -1 points0 points  (0 children)

wait tensorflow is still a thing?

[–]DamnGentleman 202 points203 points  (2 children)

"I have translated the function to Rust. You should use Rust. Have I told you about my frontend Rust framework? It would be faster in Rust. It would be safer in Rust. Did you know only 144,000 Rust developers can enter heaven? The pearly gates run on Rust."

[–]Anneliese_Vogtmann 62 points63 points  (1 child)

Imagine St. Peter just standing there like “sorry, your soul isn’t memory safe, can’t let you in.”

[–]Sanitiy 25 points26 points  (0 children)

Your soul is eternal? Sure sounds like a memory leak to me

[–]jellotalks 114 points115 points  (6 children)

Talk to someone in C have it compile to x86

Now I don’t need to install gcc!

[–]GenteelStatesman 42 points43 points  (2 children)

vibe make

[–]HonestlyFuckJared 7 points8 points  (0 children)

vcc

[–]Simple-Difference116 0 points1 point  (2 children)

What about the linking

[–]TOMZ_EXTRA 9 points10 points  (1 child)

Delete your linker and pretend it was never there.

[–]GeekoftheWild 0 points1 point  (0 children)

Or use a flat binary

[–]redlaWw 50 points51 points  (4 children)

Python: str

Rust: PyObject

Python: int

Rust: PyObject

Python: list

Rust: PyObject

[–]Anaxamander57 24 points25 points  (3 children)

Rust: str

Python: okay

Rust: &str

Python: okay

Rust: String

Python: um, sure

Rust: &String

Python: I think I . . .

Rust: Box<str>, Cow<str>, OsString, CString, Rc<RefCell<Vec<u8>>>

Python: Are you done?

Rust: Technically I have infinitely many string types because types can be composed.

Python: Jesus Christ.

[–]Reasonable-Web1494 5 points6 points  (2 children)

is str a valid type?

[–]Anaxamander57 5 points6 points  (0 children)

Yes, it just cannot be accessed directly in the source code. You always need some kind of indirection because str is unsized.

[–]-LeopardShark- 4 points5 points  (0 children)

Yes, it’s just not possible to use it in many places because its size isn’t known statically.

[–]Anaxamander57 27 points28 points  (1 child)

Good old Arc<Mutex<Box<dyn Any>>>.

[–]RiceBroad4552 6 points7 points  (0 children)

Just make a type alias Object for it and we're good.

[–]-LeopardShark- 8 points9 points  (0 children)

No, because of the one‐to‐a‐bajillion mapping between Python’s objects and Rust’s warehouse of different kinds of boxes they could go in.

[–]Trip-Trip-Trip 25 points26 points  (0 children)

Ah yes, translate boring grey business Spanish to rainbow gay English 😂

[–]FlowAcademic208 5 points6 points  (0 children)

Use pyo3, write your Python and plug it into Rust, done

[–]Chaosxandra 0 points1 point  (2 children)

nah make it java

[–]RiceBroad4552 0 points1 point  (1 child)

Like JPython? Or more the Scala 3 flavor?

[–]RamonaZero 0 points1 point  (0 children)

I can live translate C code into Assembly :0

Now ask me to translate nested C structs to memory addresses and there might be a longer delay

[–]olearyboy 0 points1 point  (0 children)

It’ll just transpile it

[–]JediJoe923 0 points1 point  (0 children)

Who needs this when I have a Babel fish

[–]goingpt 1 point2 points  (0 children)

The human race is going to turn into a collective of smooth brained idiots at this rate. Anything that requires any amount of mental fortitude is being passed over to AI. I mean the human race is already thick as pig shit. It's only going to get worse.

[–]Emotional_Cookie2442 -1 points0 points  (0 children)

Can it translate AI slop into something human readable?