HNHacker News
TopNewBestAskShowJobs

dmit

6,769 karma · joined February 21, 2011

submissionscomments
dmit··on Iranian teen shocks Magnus Carlsen to win $14k prize
CNN's average reader couldn't pick Magnus Carlsen out of a police lineup. At that point you either try grasping at whatever semblance of credibility you have: "Chess prodigy finally defeats Magnus Carlsen in a blitz tournament", or go for those allegedly profitable clicks and title the article "Iranian teen SHOCKS Magnus Carlsen".

It's all trash. The headline is insulting to Magnus. It's insulting to Firouzja. It's insulting to the readers.

dmit··on Iranian teen shocks Magnus Carlsen to win $14k prize
In fact, it was Magnus himself (currently 29 years old, as of April 2020) who said his favorite chess player was himself, when he was around 23. That Magnus apparently saw things on the board that current (overwhelmingly dominant) Magnus can't any more. So even in chess there's a physical prime, just like in pretty much any other sport.
dmit··on Iranian teen shocks Magnus Carlsen to win $14k prize
Agreed 100%. If you're the editor thinking up this headline, you've got a choice between a) crediting established chess powerhouse Firouzja with a well-deserved victory over Magnus; or b) downplaying his accomplishments in order to make it seem like the reigning champion lost to a random high schooler.
dmit··on What's Next for Scala
Trait params have little to do with OOP.

Opaque types are not a "small OOP improvement", they finally bring zero-cost newtypes to Scala, superseding value classes. Now you can finally ensure that object Ids, people's names, meters, feet, and degrees Celsius all have different types - without any extra boxing at runtime.

Your list is also missing typeclass derivation, which is going to be a fantastic quality of life improvement. Yes, even for people who don't care about what a typeclass is.

This is a point I want to stress the most, I think. Features like type lambdas, or libraries like Shapeless - they can possibly be extremely beneficial to you even if you don't use them directly in your code. Ask your nearby Haskell programmers about the virtues of `deriving (Eq, Ord)` and they'll talk your ear off. And that's before they even get to things like `deriving (FromJSON, ToJSON)`. Don't have a Haskell programmer nearby? It's ok, ask a Rust programmer about Serde instead. Typeclass derivation is just such a massive, massive feature to have in your language's repertoire.

dmit··on I can't keep up with idiomatic Rust
Well, either the language will leave async runtimes in the domain of third-party libraries, which is the current approach. Or, the potential blessed one in std will be an alternative that you may or may not want to use in your code.

When I think of breaking changes, I think removing sun.misc.Unsafe. Which, yes yes, was never supposed to be used, but still was. Evolution of best practices and introduction of alternative implementations doesn't break anything.

dmit··on I can't keep up with idiomatic Rust
Please allow me to share my view of the conversation up to this point:

Boats: Here is an approach I use in my personal projects that has proven to be ergonomic, consistent with other language features, and could possibly even unlock future optimization opportunities long down the road.

OP: That's it, I'm DONE. The language moves too quickly and I can't keep up.

You: More breaking changes are on the way. They never learn.

-----

Would you agree that this escalated way, way too quickly?

Boats didn't "move" the language with a blog post, it's not even a pre-RFC. As pointed out elsewhere in this thread, the language hasn't been moving at all since 1.0 - you could say the frontier has been inching forward, but that's what frontiers do; nobody's forced to fight on the front lines all the time. And then the cherry on top - "more breaking changes on the way", when 1) prior changes weren't breaking; 2) it's not clear there will be any new ones; 3) if there will, those won't be breaking either.

dmit··on Rust docs team is no more
TeX
dmit··on Choosing Between Rust or Go?
> Thot Leaders

That's a completely different industry, I think.

> The added cruft, not so much. We have generics! We have type theory! We have lambdas! We have functional programming! We have threads! We have futures! We have async!

Generics, lambdas, and threads are must-have basics. Futures and async are the same thing. Rust doesn't "have functional programming", unless you mean chaining `map` and `collect` methods, in which case Java also has functional programming.

HTTP and error handling are third-party libraries. Multiple choices in this area are a direct result of not trying to bundle the kitchen sink with the language. These things don't standardize in a year.

dmit··on The Hardest Program I've Ever Written – How a code formatter works (2015)
I feel like it's a subset of a much larger, more general topic of how latency impacts computer interactions. People have long tried to emulate real-world activities in computer programs, but not much attention has been paid to making those programs instantaneous.

When you mold clay, there is no lag - the tactile and visual feedback is immediate. Same with handwriting, painting, or petting a dog. On the other hand, even in this current world of multi-core 4Ghz+ computers most software fails to provide immediate feedback.

100ms, I believe, is the magic number. The maximum delay between cause and effect that still registers as "instantaneous" by the human brain. Yet, surprisingly, it's still a rarely reached target. FPS video game studios might be the only major industry that consistently cares about and delivers on this metric. (Edit: "major" was an intentionally vague word to use here. Obviously, all kinds of embedded software projects have to deal with real-time or soft-real-time requirements.)

If reformatting the whole current code file took 1ms, why wouldn't you enable it? If compilation took 50ms, why not recompile on each new line? There's a magic latency barrier below which actions feel "free", so why not try and move as many of them as possible below that threshold?

dmit··on The Hardest Program I've Ever Written – How a code formatter works (2015)
To see this concept taken to its logical conclusion, check out Casey Muratori write C code with the editor configured to reformat on every keystroke: https://www.youtube.com/watch?v=S3JutszP9fg&t=11m37s

I'm not sure I'd ever go this far, but that might just be years of conditioning by editors that format code much more slowly than the fork of 4coder that he's using in the video.

dmit··on Firefox's low-latency WebAssembly compiler
One cool application that cropped up in the Rust ecosystem is to use WASM for procedural macros. That way not only can they be distributed as precompiled (arch-agnostic) blobs from crates.io, but you also get all the benefits of the sandbox environment to guarantee freedom from malicious side effects. The W in "WASM" doesn't have to limit possible applications to just the web browser.

https://github.com/dtolnay/watt

dmit··on EOF is not a character
Option<T> is conceptually easier because:

1) It applies exactly the same way to any type, not just char.

2) You don't need to read the man page for every single function that returns an int on the off chance that said int actually contains a bool, a char, or a short plus additional flags.

dmit··on EOF is not a character
In fact, that's exactly what Rust already does today! Option<char> uses the exact same amount of bits to store as plain char, because the compiler has enough information to encode the Option-ness of char in what it knows is a garbage bit of the underlying type.

https://play.rust-lang.org/?version=stable&mode=debug&editio...

dmit··on EOF is not a character
No, encoding additional information in unused bits of an int that you return is stupid over-engineering that needs multiple textbooks to grok. Option<char>, on the other hand, is the simplest possible solution for this problem.
dmit··on Firefox 74
If you specify a catch-all url to open in No Container, would that work?

  !*.google.com , Google
  !* , No Container
dmit··on A half-hour to learn Rust
Would a macro work ok for you, like the inbuilt vec! one? There's a crate for that named maplit: https://docs.rs/maplit

    let map = hashmap!{
        "a" => 1,
        "b" => 2,
    };
dmit··on A half-hour to learn Rust
Pretty much. The mere existence of cdecl(1) says a lot about the simplicity of C's type declaration syntax.
dmit··on T5: The Text-to-Text Transfer Transformer
I'm sorry for being blunt, but is it possible that the `very brittle "exact match" method of evaluating whether an answer is correct` means value equality? Is `==` the secret sauce?
dmit··on The Zen of Go
I meant vendoring the source code of dependencies when I wrote the parent comment, but it appears you feel strongly about going one step further? Vendoring arch-specific binaries? What is the benefit of doing that, in your opinion?
dmit··on The Zen of Go
> The same properties of the language which helped Google have helped me

To be fair, I don't think anything I wrote contradicts that. If your goals align with Google's, great.

dmit··on The Zen of Go
Go was so obviously designed by Googlers, for Google. After the initial release, outside adopters would frequently report issues where Go undermined their productivity. And every time the core team's response was the same - complete disbelief.

"Dependencies? What? Do you not vendor every single library you depend upon in your monorepo?"

"Advanced type system? Why? Do you not hire thousands straight out of college, and expect employees to stay put for 2-3 years (give or take)?"

Every single issue that was raised in the past 10 years was met with such incredulity.

Rob Pike, Robert Griesemer, Russ Cox - they've done a tremendous job. A great, stunning achievement for their employer. The more of the infrastructure transitions to Go, the less money Google will need to spend on people in the long term. Those three have earned billions for their company, no doubt.

And none of that means Go is a great language for your 12-person team working on a CRUD web app.

The Zen of Go is not reducing your problem to "can it be put in an array?" or "can it be put in a hashmap instead?"

The Zen of Go is looking at individual persons and deciding whether it's net positive to cut them now, or 6 months from now, after their next performance review.

dmit··on Who’s in charge at Amazon? Moves on secretive S Team signal giant’s priorities
Wow. They say that policies are organizational scar tissue. I'd love to see the blow that inflicted this particular wound.
dmit··on Zeta: Functional Neural Networks in Ocaml
It's always been baffling to me that certain problem domains with extremely slow feedback loops have standardized on using dynamically typed languages. Machine learning and Python. Video game scripting and Lua. A lot of scientific programming as well.

How did that happen? Did the trend start because the work was done by domain specialists who were not necessarily expert programmers, and C was too unergonomic for non-experts to use? Is that the reason a Skyrim modder can't get immediate feedback from a compiler in 2020 - because 25 years ago game devs thought that documenting a C API was harder than embedding a scripting language in the game engine? Or perhaps because evaluating scripts was more secure than loading third-party DLLs and exposing the game's innards to them?

Edit: also, if every CSV file came with a schema, that would be great. Even if it says that every column is of type Option<Any> - at least then I know what to expect.

dmit··on Kaboom: an unusual Minesweeper
In a similar vein: Cheating Hangman, once described as "an app that perfectly recreates the infuriating feeling of playing hangman with your older sibling who was definitely cheating and also knew way more words than you". https://cheatman.danq.me/

Implementation details: https://danq.me/2019/09/26/cheatman/

dmit··on The Road to Scala 3
Kotlin is not the future of anything. They got the Android boost and still, two years later, all they have to offer is a molasses-slow improvement pace and a shitty dev experience in their signature IDE (which also happens to be made by the same company).

Last time I tried to create a Kotlin project in IDEA, it couldn't provide type information on hover. The Kotlin dialect of Gradle was barely supported enough to be called a "third-class citizen". It's super embarrassing.

dmit··on New Features in ES2019
I think it's mostly a usability tradeoff. If you can use the same data type for calendar appointments and high-precision performance logging, then you save your users the necessity of choosing between different types. Bonus points for being able to get away with a single nanosecond-based Duration type that has straightforward arithmetic with nanosecond-based timestamps.

And if you're deep enough to worry about the cost of those extra bits, you probably want to have your own date type anyway, tuned for your exact problem.

dmit··on New Features in ES2019
If by BigInt you mean an arbitrary-precision integer type, then AFAIK no major language uses it to represent dates.

If you mean a 64-bit integer type (which, to be fair, is 11 bits larger than what JavaScript supports), then that's still not enough. As long as you want nanosecond-level granularity, and range beyond the current decade for your timestamps, you'll need more than 8 bytes to represent them in code.

dmit··on Bad JSON Parsers
Over-under on when the first "ML-based approach to parsing JSON" story hits HN: 1.5 years from now.
dmit··on Bad JSON Parsers
Interestingly, I recently encountered an issue in the wild where these two recursion limits are both prominently involved.

Yew, the Wasm web framework, provides an html! macro that allows you to write templates that look like HTML within your Rust code. The macro is notorious for requiring the macro expansion `recursion_limit` to be raised even for fairly small templates. Now, if you happen to have a syntax error in a template and ask cargo to return the build errors as JSON, it will diligently report every macro expansion that led to the problem as a nested structure. Which is what the commonly used cargo-web tool does, so when it sees JSON with 128+ levels of macro expansion details describing a build error (again, not uncommon with Yew's html! macro), serde_json fails to parse it with `ErrorCode::RecursionLimitExceeded` and cargo-web panics.

https://github.com/yewstack/yew/issues/661#issuecomment-5467...

dmit··on Biogrid’s GPU-accelerated world simulation
Flat. Which apparently raised some very important questions: https://twitter.com/BioGridGame/status/1101496659102650369
← PreviousPage 6 of 11Next →