HNHacker News
TopNewBestAskShowJobs

Ruud-v-A

470 karma · joined February 24, 2013

submissionscomments
Ruud-v-A··on How we secretly introduced Haskell and got away with it
The runWorkerLoop function logs a few lines and sends out an initial job request (by enqueueing an event in Redis). It then calls the nested function `go`, which dequeues one event of a TBQueue (a thread-safe bounded queue), matches on the event, and calls the right function to handle it. If the event was not a "stop" event, `go` calls itself to do the next iteration of the loop. `go` takes a WorkerState as argument, which is how it keeps track of which jobs are running, and whether there is an unanswered job request.

In reality the signature is a bit uglier, I simplified it for the post because the point was about effects. In particular we also pass in the configuration, Redis connection details, and a callback to manipulate the TBQueue.

Ruud-v-A··on How we secretly introduced Haskell and got away with it
We do actually use Mypy! I wrote about my experience with it here:

https://www.reddit.com/r/programming/comments/5x3hdd/channab...

Ruud-v-A··on How we secretly introduced Haskell and got away with it
The most serious one is that we were submitting jobs (as json) that were missing a few metadata fields. In Python we passed around dictionaries, and even though we had json schema validation in place, this slipped through. In Haskell, we define a record type and the corresponding serializers. It is more code, but what you get is that invalid data cannot exist at runtime: it simply cannot be represented.

Also, a compiler refuses to compile your code if you make a typo in a field name.

Ruud-v-A··on How we secretly introduced Haskell and got away with it
We are actually using Docker for generating the virtualenv that we ship and running tests now. The motivation for doing this is being able to control the environment; we can run tests and build a package on CI, and we can build the same package locally when CI is down. We don’t use Docker in production.

It is not clear to me how Docker solves the issue of pinning dependencies; I would rather have a file that states the exact version of every package to install, than an opaque blessed container image that has some versions installed, and I do want to have the versions used under source control. Generating the image would not be reproducible (in the sense of having the same Python files inside it) without pinning versions somewhere anyway, right? Or am I missing something obvious?

Ruud-v-A··on How we secretly introduced Haskell and got away with it
> I wonder if PureScript would have been a better choice.

I have an aversion (based for a large part on prejudice) of things that involve Javascript and its ecosystem :)

I hear many good things about Purescript’s effect system, but I haven’t studied it in detail. This is definitely one of the areas where there is room for improvement in Haskell.

Regarding the type class hierarchy and head being partial, those weren’t really an issue in practice.

Ruud-v-A··on How we secretly introduced Haskell and got away with it
Indeed, Rust + Cargo and Haskell + Stack are very similar in this regard. Both have great package managers, and both produce a shippable executable with only a few dependencies on system libraries. One notable difference is that Stack downloads the compiler, whereas for Rust, every version of the language comes with a compiler and a Cargo. This ensures that you can check out a year-old commit and still build your project with Stack (modulo breaking changes in Stack, which so far I have not encountered), whereas for Rust the compiler version is not pinned.
Ruud-v-A··on How we secretly introduced Haskell and got away with it
To be clear, our new application is better (faster, scales better, more maintainable), for the most part because of the improved architecture.

As we were going to do the rewrite anyway, we considered more alternatives than just Python. For programs that have to be reliable and maintainable, I prefer a language with a strong static type system. Haskell has that, and it has a few practical benefits over other tools that made it an excellent choice for our use case.

Ruud-v-A··on Show HN: Summarise all code annotation like TODO or FIXME
Or you could just run `git grep --line-number TODO`.
Ruud-v-A··on Dutch House of Representatives passes dragnet surveillance bill
For the Dutch people here considering what to vote in the March elections, I made an overview of statements of the parties on privacy and internet freedom: https://goo.gl/roiqVJ
Ruud-v-A··on Next Iteration of “The Rust Programming Language” Book
I use Vim. With https://github.com/dan-t/rusty-tags for the occasional jump-to-definition. Ctrl+N autocomplete works well enough for me.
Ruud-v-A··on On the Impending Crypto Monoculture (2016)
> Compare this with old-fashioned CBC+HMAC (applied in the correct EtM manner), in which you can arbitrarily misuse the IV (for example you can forget to apply it completely) and the worst that can happen is that you drop back to ECB mode, which isn't perfect but still a long way from the total failure that you get with GCM.

It is not. As Dan Boneh stresses in his cryptography course, a cryptosystem is either secure or “terribly, terribly, insecure”.

Ruud-v-A··on Zero Cost Abstractions
Actually, the coefficients are only 16 bit, they are just widened before the loop. AVX2 and later are not widely supported, but there is pmuldq in SSE4.1 which is appropriate here. It takes 32 bit operands and and produces a 64 bit result. Because its result is 64 bit (as it should be by the way, because truncating to 32 bit will overflow on real-world FLAC files) it can only do two elements per operation. A few adds can be vectorised too then, but you still need a horizontal add to get the final value. I think it is possible to get a small speedup, but definitely not the 4× or 8× that you might hope for with SSE/AVX. But at this point I would say that this is a pretty advanced optimisation, not your average "vectorise all operations in the loop, increment the counter by 4/8 at a time" transformation that a compiler can do easily. I am impressed that the Intel compiler can actually vectorise things here.
Ruud-v-A··on Zero Cost Abstractions
Good question! It turns out that 64 bit arithmetic does not overflow (I explain this in a comment in the source code [1]) up to the shift. The shift amount must then be large enough to fit the result in 32 (or actually, 24 or usually 16) bits. For a valid FLAC file this will be the case. For an invalid FLAC file it might truncate, but an invalid file cannot be decoded properly anyway. The shift amount is a 5 bit signed number [2], so it is never possible to shift by the integer width or more.

[1]: https://github.com/ruuda/claxon/blob/91b6af9/src/subframe.rs... [2]: https://github.com/ruuda/claxon/blob/91b6af9/src/subframe.rs...

Ruud-v-A··on Zero Cost Abstractions
Thank you!
Ruud-v-A··on Ring, officially a GNU package
This appears to be something phone-related, not the Ring cryptography library written in Rust based on Boringssl. (https://github.com/briansmith/ring)
Ruud-v-A··on WoSign and StartCom: Mozilla’s proposed conclusion
I’m glad that I have been distrusting Startcom on all my devices since early 2014. Time to do the same for Wosign.
Ruud-v-A··on UnGoogled Chromium: Chromium with enhanced privacy, control and transparency
Not a true answer to your question, but ... stop visiting those sites? Hopefully the site operators keep some metrics on how intrusive ads affect their bounce rate. Whenever I end up on a site that pops up a full-screen overlay, 9/10 times the link I followed did not sound interesting enough for me to tolerate the ad, and I hit the back button. There is so much more to read.
Ruud-v-A··on UnGoogled Chromium: Chromium with enhanced privacy, control and transparency
In what sense? I’m using Chrome Beta on Android, and I don’t recall being prompted to log in. Perhaps there was such a prompt during initial setup, but it has never tried to log me in quietly since.
Ruud-v-A··on Richer command line interfaces
> Basically, I wonder what would a shell look like if it was designed today without any concern for compatibility

The TempleOS shell is pretty innovative in this regard.

Ruud-v-A··on Git for Windows accidentally creates NTFS alternate data streams
What is the alternative? Renaming the file?

This was actually an issue with early versions of Servo on Windows: cloning the repository would fail because it contained a file with a # in the name.

https://github.com/servo/servo/commit/43c999905c01627133240c...

Ruud-v-A··on Does 1+2+3+... Really Equal -1/12?
Here’s what’s really going on:

You can define a function f from a subset of the complex numbers to the complex numbers where f(z) = \sum_{n=1}^\infty 1/n^z. Be careful with the domain of this function: the series does not converge for all z. You can plug in -1 and see that symbolically, f(-1) = 1 + 2 + 3 + .... But the series does not converge for z = -1, and it is simply not true that \sum_{n=1}^\infty n = -1/12; the series does not converge; equating it to something is a nonsensical thing to do.

What is going then? Even though f is not defined for all complex numbers, there exist functions from the complex numbers to the complex numbers that -- restricted to the domain of f -- are equal to f. They "continue" f to all of the complex numbers. And if one imposes a restriction on these continuations (namely that they are analytic), then it turns out that there is a unique analytic continuation of f: the Riemann zeta function. And zeta(-1) = -1/12.

Don’t confuse the definitions here. The Riemann zeta function can be defined as the analytic continuation of the series, the series is not defined in terms of the Riemann zeta function!

Ruud-v-A··on Introducing Verve: minimalistic, static, functional language
What is the motivation for making it self-hosting? Just for fun too? It creates a lot of trouble around bootstrapping.
Ruud-v-A··on StartEncrypt considered harmful today
I distrusted all StartCom certificates anyway after 2014; StartCom is a rogue CA who certify the authenticity of sites which they know have been compromised. Read the story here: https://web.archive.org/web/20140412085458/https://revokame.... (the original page disappeared mysteriously a few days after the story was published). And the HN thread about the incident: https://news.ycombinator.com/item?id=7577290
Ruud-v-A··on Urbit Is Building a 'Virtual Galaxy' for Bitcoin Nodes
Now that Urbit is not entirely vaporware any more they regret this, but reverting the decision is not worth the trouble:

https://www.reddit.com/r/urbit/comments/4okcm6/were_the_core...

There are more interesting insights in that thread about Urbit’s unorthodox decisions.

Ruud-v-A··on Urbit Is Building a 'Virtual Galaxy' for Bitcoin Nodes
I find the original blog posts [1] a really interesting read. Nowadays Urbit is indeed full of buzzwords, “your personal cloud computer” and the like. But initially, Urbit was this [2]:

> Urbit is a new programming and execution environment designed from scratch. Any resemblance to existing languages or operating systems is coincidental, cosmetic, or inevitable.

It was based on this idea: suppose that a different civilization (Martians specifically) had invented computing long before humans. Then by now they would have perfected it. What would their system look like? Urbit is an attempt to rethink computing without the bias of human research and our current intuition. At the heart of Urbit is Nock, a “functional assembly language”. Zero is intentionally used to denote “true” to defy programmer intuition.

[1]: https://moronlab.blogspot.com/2010/01/urbit-functional-progr... [2]: https://github.com/cgyarvin/urbit/blob/master/doc/book/0-int...

Ruud-v-A··on How a comment on Hacker News led to 4½ new Unicode characters
U+1F499 BLUE HEART U+1F49A GREEN HEART U+1F49B YELLOW HEART U+1F49C PURPLE HEART U+1F53D DOWN-POINTING SMALL RED TRIANGLE U+1F536 LARGE ORANGE DIAMOND U+1F537 LARGE BLUE DIAMOND ...
Ruud-v-A··on How a comment on Hacker News led to 4½ new Unicode characters
I hear you. If you want pictures then use a markup language. Unfortunately it is too late now. We finally had an almost universally supported character set, and then we ruined it with levitating men in business suits. Recent Unicode versions introduce far more technical challenges than they solve. For instance, now that code points can come with colour, there are conflicting requirements between the requested text colour and the intrinsic colour of a symbol.
Ruud-v-A··on Open access: All human knowledge is there, so why can’t everybody access it?
I try to avoid citing articles that are only available behind a paywall. Even though there isn’t always an alternative source available, if enough people favour citing open-access articles over paywalled ones, that should create an incentive to publish in open-access journals, because in academia, citations are everything. (That is a problem in itself, but it is the status quo.)
Ruud-v-A··on Open-Sourcing CloudFlare’s UI Framework
A shame they didn’t rewrite it in Elm while they had the opportunity.
Ruud-v-A··on More contributions on your profile
It is good to see the streak go. To quote Jeff Atwood, “If I have learned anything from the Internet, it is this: be very, very careful when you put a number next to someone's name. Because people will do whatever it takes to make that number go up.” I hope this move helps focussing a bit more on quality over quantity.

https://blog.codinghorror.com/because-reading-is-fundamental...

← PreviousPage 2 of 4Next →