Live data from Hacker News

What can Rust do for astrophysics?

arxiv.org

41–50 of 115 posts

Re: What can Rust do for astrophysics?

#41
post #30

I don't know the astrophysics domain at all but shouldn't there be more arguments for Go? * Safer than C * Almost as fast as C * Good concurrency support * High productivity due to simple abstractions and good tooling Is the downside of a GC language really relevant? Does astrophysics suffer from "stop the world interrupts" or is it just because of the performance? The Go GC is already really fast.

> * Almost as fast as C That's the key point. Judging by the (wrong) benchmark above where both C and Go seem to do some work, Go is about half as fast as C. A grad student (if paid properly) costs maybe 60k €/year. In comparison, we regularly spend more than 250k on new and faster computers, not including maintenance, the electricity bill etc. If you can make software even 50% faster by increasing development time,…

I think you misunderstand what "safety" refers to in the context of programming. It's not about flaws in your program being attacked, it's about writing correct programs.

Re: What can Rust do for astrophysics?

#42

Earlier quoted context omitted.

During the past years of coding in C++ in the context of tensor networks in condensed matter physics, I have never encountered the case where a programming error which would have been caught in Rust or Go lead to incorrect results. Yes, there were plenty of crashes and plenty of hard to debug issues, but it was always obvious that something was wrong way before any results were calculated/printed/output.

Does your statement in some way address my point that "wanting correct results" is a legitimate reason to "care about safety in a science context" ?

Yes: Safety does not get you correct results where non-safety would have given you wrong results. Safety gives you correct results in some cases where non-safety would have given you no result. Those cases are easy to identify and can be solved using standard debugging techniques.

So safety gets you faster development: less debugging, easier parallelisation etc., but it does not give you correct results, nor does it give you those results by spending less computational time.

Re: What can Rust do for astrophysics?

#43

Earlier quoted context omitted.

Does your statement in some way address my point that "wanting correct results" is a legitimate reason to "care about safety in a science context" ?

Yes: Safety does not get you correct results where non-safety would have given you wrong results. Safety gives you correct results in some cases where non-safety would have given you no result. Those cases are easy to identify and can be solved using standard debugging techniques. So safety gets you faster development: less debugging, easier parallelisation etc., but it does not give you correct results, nor does it…

You legitimately can not imagine a scenario where a program is written which could give a result that appears correct but isn't due to a bug?

And you legitimately can't imagine how reducing the likelihood of making bugs by using a language+compiler which can identify/prevent more of them would help?

I'll leave you to it then.

Re: What can Rust do for astrophysics?

#44
post #30

I don't know the astrophysics domain at all but shouldn't there be more arguments for Go? * Safer than C * Almost as fast as C * Good concurrency support * High productivity due to simple abstractions and good tooling Is the downside of a GC language really relevant? Does astrophysics suffer from "stop the world interrupts" or is it just because of the performance? The Go GC is already really fast.

I looked at the Rust documentation's getting started page and it says:

> If you’re using more than one word in your filename, use an underscore: hello_world.rs rather than helloworld.rs.

Is the use of underscores a recommendation or a limitation?

Re: What can Rust do for astrophysics?

#45
Just my 2c -- it is a potentially interesting article, but two things have to be fixed:

1. Compile C version with better optimization flags or ask an expert to tweak it for faster performance.

2. Include sample run on some known / meaningful data to test that software runs correctly (not only fast).

IMO rust doesn't have to be faster than C to make a valuable article. If it is as fast or almost as fast it is still a good data point.

Re: What can Rust do for astrophysics?

#46
post #30

I don't know the astrophysics domain at all but shouldn't there be more arguments for Go? * Safer than C * Almost as fast as C * Good concurrency support * High productivity due to simple abstractions and good tooling Is the downside of a GC language really relevant? Does astrophysics suffer from "stop the world interrupts" or is it just because of the performance? The Go GC is already really fast.

Why would one care about safety in a science context?

One wouldn't, generally, at least in the astrophysics domain. The kinds of guarantees Rust makes don't add anything.

Re: What can Rust do for astrophysics?

#47
post #38
post #35

Is the code in gravity_calculate_acceleration correct? I think 'j' will always be 0 in the inner-loop, which seems to defeat the purpose of having a j variable. void gravity_calculate_acceleration(int n_particles, double m[], double x[][3], double a[][3]) { double G = 6.6742367e-11; // m^3.kg^-1.s^-2 for (int i=0; i

This seems to have been fixed 3 hours ago: https://github.com/marblestation/benchmark-leapfrog/commit/c...

Yes, but m is zero anyway.

Re: What can Rust do for astrophysics?

#48
post #30

I don't know the astrophysics domain at all but shouldn't there be more arguments for Go? * Safer than C * Almost as fast as C * Good concurrency support * High productivity due to simple abstractions and good tooling Is the downside of a GC language really relevant? Does astrophysics suffer from "stop the world interrupts" or is it just because of the performance? The Go GC is already really fast.

I looked at the Rust documentation's getting started page and it says: > If you’re using more than one word in your filename, use an underscore: hello_world.rs rather than helloworld.rs. Is the use of underscores a recommendation or a limitation?

Of course it's just a recommendation. Why would you think otherwise? To Rust, module name is just a bunch of characters, it doesn't recognize words anyhow.

Re: What can Rust do for astrophysics?

#49

Earlier quoted context omitted.

Because they want the correct results?

During the past years of coding in C++ in the context of tensor networks in condensed matter physics, I have never encountered the case where a programming error which would have been caught in Rust or Go lead to incorrect results. Yes, there were plenty of crashes and plenty of hard to debug issues, but it was always obvious that something was wrong way before any results were calculated/printed/output.

I was thinking the same thing when I read this quote:

> For instance, a common source of error is the access to invalid memory regions, which produces random execution behaviors and affects the scientific interpretation of the results.

Such errors are astronomically more likely to cause crashes than silent errors in calculations.

Re: What can Rust do for astrophysics?

#50
post #45

Just my 2c -- it is a potentially interesting article, but two things have to be fixed: 1. Compile C version with better optimization flags or ask an expert to tweak it for faster performance. 2. Include sample run on some known / meaningful data to test that software runs correctly (not only fast). IMO rust doesn't have to be faster than C to make a valuable article. If it is as fast or almost as fast it is still a…

> Compile C version with better optimization flags or ask an expert to tweak it for faster performance.

Part of the point they are trying to make is that you don't need to be an expert to reap performance benefits in certain languages. They explicitly state that they did not do things that C experts would know how to do. This is pretty reasonable in the context of astrophysics. The whole idea of the thing is that if there is a language that allows you to write faster code than C without having to "ask an expert to tweak it", you will be more productive using that language.

That said, your point 2 is entirely valid; the paper fails to demonstrate pretty much all of its claims, and it never makes a case for needing Rust's safe dynamic memory allocation features in a program that doesn't use dynamic allocation at all.

For whatever it's worth, the astrophysicists I most recently talked to wrote their simulations in Python (with SciPy or similar) or even something called IDL: https://en.wikipedia.org/wiki/IDL_(programming_language) and they also tend to have mad Bash skills for glueing different data-processing programs together.

Post reply on HN