barskern
assert!((samples as u32) <= u32::MAX);
EDIT: I know it's a contrived example, but I was just curious if my understanding is correct. I also found this page in the nomicon about casting: https://doc.rust-lang.org/nomicon/casts.htmlEDIT2: As I thought casting a `usize` which is 64-bits to a `u32` causes it to be truncated and hence the assertion is always true. Further by using a number that's bigger than a `u32`, this example contains undefined behavior. This is due to the use of `slice::from_raw_parts` where `self.samples` is left as a `usize` and hence takes a much bigger slice than what was allocated (the leftover of the truncate operation). I made a small playground which demonstrates the segfault. https://play.rust-lang.org/?version=stable&mode=debug&editio.... The assertion should rather be:
assert!(samples <= u32::MAX as usize);
Don't get me wrong, I think the blogpost is a great explanatory article about memory ordering and the example is rather contrived. I just wanted to reassure myself that my understanding was correct and further perhaps help someone not seeing this issue (as this is a very easy trap to fall into).Instead of:
const add = (a, b) => {
return a + b;
}
It could be written as: const add = (a, b) => a + b
Or functions can also easily be turned into curried functions by doing: const add = a => b => a + b
Which can be really powerful when used properly.I felt it was worth mentioning, but I understand that the goal of the article was not to provide a in-depth comparison.
I am not thinking about the official documentation of the language. Normally translating the explanations in the official documentation only requires contributers.
However when someone makes a tutorial series or similar, that series will normally only be limited to one language because they will write the actual code itself in their language.
I think this would split an already small community.
Localization seems like a two-edged sword. Wouldn't it cause a spilt in the community when it comes to tutorials and documentation? Especially if the community is small.
In Excel I repeatedly faced the problem that the formula "programming" language was my own language and not English, which meant that all English Excel formulas I found had to be translated. In my opinion the benefit of writing my native language does not outweigh the problems of constantly translating formulas.
What are your thoughts on this problem? Have you thought of any ways to prevent such problems?
I don't fully agree with this neither. Especially for mathematical concepts, visualization can give insight into how theorems are constructed and combined. This can prove to be vital when applying concepts and theorems to new problems.
I would especially like to bring forth 3blue1brown[1]. He is a creator of videos which beautifully visualizes and explains complex mathematical problems. His efforts has given me an insight into math which theorems explained in text and variables could never do.
However I do see your point that visualizations without understanding can be misleading. Hence the pure, written math is important to read and reason about, but I do believe that some concepts need to be visualized to be fully understood.