HNHacker News
TopNewBestAskShowJobs

jules

8,235 karma · joined September 15, 2007

julesjacobs@gmail.com

julesjacobs.com

submissionscomments
jules··on One Reason Typeclasses Are Useful
I think one practical disadvantage of the Haskell approach is that you need to wrap and unwrap your types if you want a different ordering on an existing type.

But the main reason why I didn't like the Haskell approach isn't ergonomic but conceptual. To me, the type of the heap should depend on the Ord instance, because the invariant satisfied by the values of type `Heap a` depends on the Ord instance of `a`, not just on the type `a` itself. This invariant is not encoded in the type system in Haskell, but in a dependently typed language you could do that. But in order to even write down the invariant, you need access to the Ord instance.

So the type signature of union could be:

    union : {a:Type} → {o:Ord a} → Heap o → Heap o → Heap o
In this case the problem of mixing up heaps with different orderings is ruled out by ordinary type checking, rather than via an extra meta-theoretical invariant satisfied by the language. Although ML modules don't let you encode the invariant either, they at least set it up in the same way, because the type Heap(o).t depends on the o and not just on o.t, and the type checker also views it that way and will say Heap(o).t ≠ Heap(o').t even when o.t = o'.t.

In Haskell on the other hand, if we desugar type classes to passing around records, then we can suddenly break the invariant in type safe code.

Maybe I'm imposing values on Haskell that have no practical significance in that context, but to me the way Haskell does it feels like a hack.

jules··on One Reason Typeclasses Are Useful
Probably the last word on this problem hasn't been said, because all approaches seem to have some downsides. Could you give an example where Haskell's approach makes it easier?
jules··on One Reason Typeclasses Are Useful
If you compare it with how you'd implement such a data structure using ML modules, it becomes very clear that the bug here is the definition of Data.Heap.Union, not the non-canonicity of type classes.

With ML modules you'd define a Heap module that is parameterised by an Ord module. Different instantiations of the Heap module for the same type `a` but different instances of `Ord a` are different: heaps with Ord1 are of a different type than heaps of Ord2.

From this point of view, passing the Ord instance into each individual heap function call (such as union) is clearly not the right setup. The canonicity of type classes is merely a bandaid for that problem.

jules··on Show HN: I made a modern web UI for Wikipedia
I like having the table of contents on the left. I often have to scroll back to the top to look at the table of contents again. The font size is rather large though: for many pages you have to scroll to see the full table of contents. Seeing the full table of contents at a glance is a critical feature for me. I would use this extension if you could scale the table of contents like you can for the main text.
jules··on Aphantasia
I don't think they are. If you see a picture of a wrong bike you can immediately see that it is wrong. So it is probably not the case that people are vividly visualising a picture of a wrong bike and then drawing that.
jules··on Why has the price of electricity in Europe reached record highs?
Batteries are so expensive that it is unclear whether they will ever solve the large scale storage problem: yes they're getting cheaper, but they have to continue to get cheaper for a long time before they're suitable, and it's unclear whether fundamental limits will be hit before that. If battery technology improves to the extent that it becomes viable for large scale storage, then wind and solar can become our main source of energy. Until then, nuclear is the only proven solution. Betting on batteries now amounts to gambling with the planet.
jules··on Today Sci-Hub is 10 years old. I'll publish 2M new articles to celebrate
Why? The authors write the papers for free, the peer review is done by other scientists for free. Why should this "netflix for science" get to reap the profits by locking it behind a paywall? The reason why predatory publishers still exist is a coordination problem. The journals have prestige built up historically, and the scientists need to publish in prestigious journals for their career. It's a chicken and egg problem.
jules··on Bottled water is 3,500 times worse for the environment than tap water
By law, the water from the tap may only contain 1 microgram pollutants per liter, and the water companies usually set themselves stricter standards (and stricter than the standards for bottled water, IIRC). Assuming you drink 2 liters per day that is 0.066 grams over the course of a 80 year life. If the cause of the illness of your family is is the tap water, then it is very likely a problem with the plumbing in or near your house.

However, even that is very unlikely. Even if the plumbing in your house is lead, that's not likely to make you ill immediately (but it will over the long term). If the pipes leak, then the water is more likely to go out than pollution getting in, due to the water pressure. Given that several members of a family get ill, the overwhelmingly more likely explanation is either a contagious disease, or food poisoning.

jules··on Bottled water is 3,500 times worse for the environment than tap water
This was tested and they found that this made the water quality worse, because the Dutch tap water is already of high quality and the water filter makes it dirtier because bacteria start to grow on it after a while. In fact, the water company filters the water through the same type of activated carbon filter, except that the filter in the Brita is at best a couple of centimeters long whereas the filter of the water company is 2x250 centimeters long (and they use other filtration steps, not just activated carbon).
jules··on The Babylonians used Pythagorean ideas long before Pythagoras
How would you notice that without proof? Seeing that two squares sum to the same area as a third isn't easy.
jules··on The Babylonians used Pythagorean ideas long before Pythagoras
How would one discover the Pythagorean theorem without having a proof?
jules··on Twitter tests Reddit-style upvote and downvote buttons
Twitter has a few subgroups. They discuss and some tweet with the dominant opinion on that issue will get 1100 likes and a tweet from the minority opinion will get 400 likes. After this change you might get 800 net votes for the dominant opinion and -300 votes for the minority opinion. I think this will drive minority opinions out of Twitter and consolidate into one dominant opinion.
jules··on Xiaomi becomes number two smartphone vendor for first time ever in Q2 2021
A big reason why people buy iPhones is the Apple ecosystem and status signalling. A $300 Xiaomi phone also isn't as good as a flagship iPhone, but it's ~90% as good for 1/3 the price. For people who spend several hours per day on their phone, it isn't irrational to buy an iPhone. Americans spend on average 5.4 hours per day on their phone. Over two years, the savings from a Xiaomi phone come out to less than 20 cents per hour use. For these people it may well be worth the 20 cents for an hour of better phone experience. I think Samsung should be way more worried than Apple.
jules··on Nuclear Energy Will Not Be the Solution to Climate Change
The real question is energy storage.
jules··on Nuclear Energy Will Not Be the Solution to Climate Change
What is the cost of storage you used in that comparison?

I remember calculating at some point that having enough battery storage to support my electricity needs for 1 day, costs about the same as the total of electricity I will use in 10 years. And this was with favourable numbers, and only accounts for electricity and not other forms of energy use.

jules··on Quadratic Method: Detailed Explanation (2020)
It's easy to motivate using a picture. If you draw the parabola x^2 + bx + c then the minimum is at x = -b/2 and you can visually see that the average of the x-values of the roots is that minimum x = -b/2. So then u is simply the x-distance from the minimum to the roots.

The more problematic step is the assumption that you can write the parabola as (x - r1)(x - r2). It isn't obvious why that is possible.

jules··on Scala 3.0
Sounds nice. I'll try it out!
jules··on Scala 3.0
I'm familiar with VS code and have a set up that I'm familiar with (shortcuts & settings) and I've only briefly looked at IntelliJ, so I'm not qualified to answer this question. What is the reason you're using IntelliJ rather than VS code?
jules··on Scala 3.0
It does work quite well with Scala 3.
jules··on Scala 3.0
Worksheets are a simple concept: you write lines of code in them, and the IDE runs the code automatically as you type, and displays the return value of each line. If you're familiar with the concept of Jupyter notebooks, it's a bit like that.

I tend to not view it as a replacement for an ordinary code file, but as a replacement for a REPL session. It has several advantages:

* Keeping track of your previous commands in a file is much more convenient than keeping track of it in your input history of the REPL.

* You can keep re-editing previous lines easily, and you can see the output of all lines.

* There is no hidden state (unlike a REPL). Everything is run from scratch every time.

* It's easier to define helper functions than in a REPL.

* It's easier to turn a worksheet into a unit test than it is to turn a REPL session into a unit test.

That said, it's also possible to start writing a module in a worksheet, and then turn it into an ordinary code file later.

Worksheets aren't perfect yet; I can think of many improvements, but they're already very useful to me. I think the end game will be to merge the concept of worksheet, unit test, debugger, printf debugging, and ordinary code file into one system, like Sean McDirmid's usable live programming research work (which in my opinion remains one of the most underrated research projects).

https://www.youtube.com/watch?v=01Xyoh-G6DE

jules··on Scala 3.0
Scala 3 + VS code + worksheets is my favourite exploratory programming environment. Its has:

* Powerful functional features

* Powerful OO features

* Imperative features

* Powerful type system

* Great stdlib

* Great syntax

* Very fast write/test cycle with worksheets, way better than a REPL

* Great IDE features such as autocomplete

Scala may not be the best on any one axis, but the combination is unparalleled.

jules··on Ask HN: Why is the Linux community struggling to implement hibernation?
For a laptop it is important to be able to close the lid, go to zero power state after X minutes, then resume where you left off.
jules··on The matrix calculus you need for deep learning (2018)
Yep thanks! I cannot edit any more..
jules··on The matrix calculus you need for deep learning (2018)
Do people do it this way? Isn't using index notation + Einstein summation convention way easier and more powerful? You only need to remember two rules:

1. dx_i/dx_k = [i==j] where [i==j] is 0 if i != j and 1 if i == j

2. (AB)_ij = A_ik B_kj

You don't even need the second rule if the function you want to differentiate is in index notation in the first place.

The example of the other comment:

f(x) = x^T A x = x_i A_ij x_j

df/dx_k = d/dx_k (x_i A_ij x_j) = [i==k] A_ij x_j + x_i A_ij [j==k] = A_kj x_j + x_i A_ik.

You can also skip the intermediate [i==k] step and immediately set the indices of other factors in a term equal. For example, differentiating with respect to A is immediate, even though the method from the article can't even handle it directly:

df/A_kl = x_k x_l

jules··on The Zen Anti-Interpretation of Quantum Mechanics
> Once you measure it, the wave function collapses, and you no longer have the same system.

Comes down to definitions of words: same "system" (by which you mean wave function) vs same particle. See bubble chamber: particle interacts with several atoms along a trajectory. Sure, you can claim "the wave function has collapsed after the first interaction", so it's "not the same system"...but then you're just saying that measurement affects the wave function...well, yeah, it does. Or you can say that the bubble chamber "is just a series of filters"...ok sure, everything that happens is just a series of filters, with sufficiently broad interpretation of that phrase.

> You appear to have completely missed the point. The path-length difference in the experiment I pointed you to is orders of magnitude larger than the standard two-slit experiment. That matters.

Seriously? I explained in detail what will happen in your proposed experiment as a function of path length and why the explanation comes down to the same thing as with the double slit. You completely ignored this, and then say that I completely missed the point...I honestly find your behaviour quite rude.

jules··on The Zen Anti-Interpretation of Quantum Mechanics
That's playing word games. Let's remove the word "measure" and insert the word "bloop". If you bloop something twice, you get the same result twice. Even in QM. And bubble chambers bloop a trajectory.

> If you think you can, describe the experimental setup for me.

It's called the Stern-Gerlach experiment. See the section "Sequential experiments" on wikipedia:

https://en.wikipedia.org/wiki/Stern%E2%80%93Gerlach_experime...

> But in order to see the vase, your eyes have to accumulate a lot of photons, and that takes time. So the vase on the table has to persist at least long enough for your eyes to accumulate enough reflected photons to see it. If you stop looking at the vase, the vase is still there. If you look at it again, the vase will still be on the table and it will still be green.

I could similarly say that you cannot look at the same vase twice. By the time you measured the vase, the vase doesn't exist any more. Each photon in fact comes from a different vase. So what does "green" actually mean at that point?

This is an irrefutable philosophical position. It all depends on what you define as the same vase, and what measurement means. There are accepted meanings of these words in QM and those meanings coincide with the conventional meanings in the appropriate limit. I'm happy to use different words though, since you're right that those meanings are not exactly the same as the everyday meanings of those words.

> If you doubt this, read the following:

Have you considered the double slit experiment, where the whole point is the difference in length of trajectory?

Note the following facts, consequence of QM:

(1) the fact that if you bloop spin twice that you get the same result twice

(2) the fact that if you bloop a particle with a more or less spherically symmetric wave function (such as arising from a collision) in a bubble chamber, that you get linear tracks

(3) the fact that a single photon can interfere along paths of different lengths

You've painted yourself into a linguistic corner that makes all these phenomena incredibly difficult to understand, and causes you to make statements that contradict experimental evidence under a non-word-play interpretation of the words.

As for point (3), consider that Maxwell's equations are the quantum theory of a single photon. The reason they also work for macroscopic amounts of light, is that the equations are linear and photons only weakly interact with each other. One shouldn't think of a photon as a particle moving in straight lines at the speed of light. A photon is a wave distributed in both space and time. The wavefront tends to move at the speed of light, but you can't think about it as a point particle moving along trajectories. In some cases you can: there are solutions of Maxwells equations in which a wave packet more or less moves in a straight line at the speed of light, and the probability amplitude is more or less zero everywhere else. But the situation being set up in your experiment, or indeed in the double slit experiment, is not of that form.

Therefore, the outcome of your proposed experiment depends on the shape of the wave packet of the photon and the distance difference. If the wave packet is sufficiently localised in space and time, and the distance difference is sufficiently large, then there will be no interference. The wave packet will travel to the half-mirror and split into two, then those two packets will continue traveling such that they never meet again at the same point in space-time (you can see this by visualising the movie of what happens), and there will be no interference. There will be some probability distribution of observing the photon at a given point on the detector at a given point in time, with two peaks in space-time corresponding to the two wave packets.

If however, you decrease the distance difference so that the two wave packets will overlap in space-time again after the bounce, there will be interference.

jules··on The Kilobyte’s Gambit
It lets me move all of the 4 center pawns two squares forward :) Nonetheless, it's very impressive how well it plays with such a small amount of code!
jules··on The Zen Anti-Interpretation of Quantum Mechanics
> it is actually not possible to measure the same particle in the same basis twice in a row

If the robot's protocol is to measure the particle twice, it will measure the same outcome twice.

> that the particle "actually" was spin up

I didn't say that it was up, I said that it is up. Very important distinction.

> But it emphatically does NOT say that this outcome is actually real.

Seems like a distinction without a difference to me.

> but you cannot actually measure its trajectory

Bubble chambers do measure particle trajectories. https://cds.cern.ch/record/39474

jules··on The Zen Anti-Interpretation of Quantum Mechanics
I don't understand what's so surprising about only ever seeing one particular outcome. Suppose you have a robot that can observe some spin. We put the robot in a box together with a spin and make it measure the spin. Now the robot's mind plus the spin is a superposition of ("I measured up", spin is actually up) and ("I measured down", spin is actually down), but in no case is the robot's mind in a state "I measured both up and down". To me, the weird part is that there are phenomena (like the EPR paradox) where the final result cannot be explained by adding up the probabilities of the individual possibilities, but has to be explained by adding up of probability amplitudes of the individual possibilities and then taking the probability of that.
jules··on Beyond Meat signs global supply deals with McDonald’s, KFC and Pizza Hut
If you put the grass where nothing grew before, like a desert. The situation in reality is the opposite: people make forests into grassland.
← PreviousPage 6 of 34Next →