HNHacker News
TopNewBestAskShowJobs

barskern

27 karma · joined February 19, 2018

A student that has a burning passion for computers.

[ my public key: https://keybase.io/barskern; my proof: https://keybase.io/barskern/sigs/LHWKxAyi9yM2XL4uu64jIwq3O60taGF2gb6tYwZTB7E ]

submissionscomments
barskern··on Examining ARM vs. x86 Memory Models with Rust
Isn't the following statement always true, as casting using `as` will silently ~~overflow~~ truncate the `u32` if `usize` is 64-bits?

    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.html

EDIT2: 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).
barskern··on Nice syntax – Popular languages' syntaxes compared
This is a minor nitpick but I feel that the usage of the arrow function in Javascript was overly verbose.

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.

barskern··on JavaScript fundamentals before learning React
No it is not equal because the former autobinds `this` into the body of the arrow function, however the latter is "just" a function pointer hence will not be called with the correct `this` value. One way to get around this is using `this.smth.bind(this)`, which binds the correct `this` for the later execution.
barskern··on Crayon programming language
I understand what you mean, but I don't think you understand my point.

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.

barskern··on Crayon programming language
Thank you for the explanatory answer.

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?

barskern··on Crayon programming language
I'm not really sure I understand what Crayon fixes for Javascript. Based on my understanding from the intermediate tutorial it seems to be mostly identical to Javascript, with a game library built in. Can somebody help me understand what makes this language stand out?
barskern··on Practical Tips for Cheating at Design
Thank you for the share. Simple and useful tips to bring UI to a prettier state. Especially for a "pure" programmer, myself, who has no idea how to make nice interfaces without being guided.
barskern··on Ask HN: As a data scientist, what should be in my toolkit in 2018?
> And don’t over use viz. [...]

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.

[1]: http://www.3blue1brown.com