-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated modified math Rust code version no longer creates correct images. #23
Comments
That happened after I added the |
Yes, the previous vector math version was working fine. |
Yes. All the different versions should produce an image that looks like that. |
Fixed by #24 |
I'm deeply sorry about that. I only noticed this when I checked the Python version (which is the image above). Before, I assumed that the wrong one was the intended. |
I saw the posted corrected (Need to include in I also confirm it's faster for both modes on my Linux OS, System76 laptop: However, I want to raise some issues for consideration, that apply not just to this Rust implementation, but apply to writing code in general. I know Rust code has a "standard" format, and a tool to turn code into it, but like most of these things, these are arbitrary determinations of style. But writing good code, i.e. code that works, is clear and understandable, and concise, I find at times is defeated by presenting code in some "standard" format. After all, writing good code, like any kind of "good" writing, So I want to raise these issues for consideration and reflection. One thing I dislike about Rust "standard" formatting is that it wastes so much space using vertical allocation of structural elements that are best understood if written horizontally. It also waste space allocating single lines to end braces Thus, there are clearly times when writing coding processes as one line horizontal expressions is better for showing what the process the code is doing than separating it over multiple lines. There are also many cases where multiple line strings of closing Using the Rust implementation, here is an example where I think "standard" Rust formatting lends nothing to code comprehension or clarity. (I know others would vehemently disagree with this). :-)
First, a It's obvious, a
Here's anothrer example where verboseness decreases comprehension and clarity.
First a performance tweak. All this is doing: Also, it's clearer to separate the conditional computation from its use, e.g: then you can just write: From a reader's perspective, it's cognitively much clearer and concise on what the process is doing. And from the compiler's perspective, it's all going to be optimized anyway. Thus for all the reasons stated, the following code is not just shorter, but more importantly, easier to read, follow, and understand for any general reader, reducing 33 loc to now 15 loc.
These are not just issues of style and personal preferences. It has been scientifically established, the shorter and more concise you can present ideas to people (their brains) the more likely they are to take time to consume the ideas (read, listen, view) and then understand them too. I've seen in the Rust forums similar questions and issues raised on presenting source code more concisely, and getting rid of syntax Thus, shorter and clearer code will thoroughly be read|understood (and then used) more than longer and less clear code. Of course, people have written books on these topics. But I just wanted to mention them here, since you significantly changed the format of the prior Rust examples, and I just took your code and reformatted into something I like better, as shown. |
On Thursday, May 6, 2021 Rust 1.5.0 was released (with bug fix release 1.5.1 today, Monday, May 10, 2021). I noticed compiling with just Yesterday I noticed the But then I also compiled as below (used for other projects) and got (for avg of 100 iterations): So it seems performance is really dependent on compilation options|manner. FYI, on my system, the fastest Rust compilation make it faster than C|C++, which were the fastest of those I am able to compile (excluding the fast Nim version, which is faster, but doesn't create the exact image as the rest, with both spheres slightly smaller). This begs the question, should you compare times of different versions based on a "standard" release for each, or based on an "optimum" release for each? Or show differences of the various compilation options for readers to be aware of? |
AFAIK |
Rust seems to be very "sensitive" to compilation options|manner because for many|most programs many crates are being used, and their implementations affect ultimate total performance. I think this is the major factor here that affects performance. Compiling with 1.52 caused all the crates to be updated and newly compiled, especially for all the crates used with I thought it was noteworthy to mention this, because the same source code will produce varied performance solely based on how its compiled. For the unknowing Rust programmer, they may be trying to get more speed by doing source code tweaks, when really they just need to use optimal compiling options for their system. |
I don't have much experience with Rust, but if something can be tuned using various flags than there is no reason for not using it - it's better to keep source code idiomatic as possible. |
The original (corrected) parallel Rust version created correct images when run either sequential|parallel.
The modified version, which changed the Vector math implementation, no longer creates correct images.
The text was updated successfully, but these errors were encountered: