HNHacker News
TopNewBestAskShowJobs

matt-noonan

166 karma · joined March 9, 2017

submissionscomments
matt-noonan··on Let's remove quaternions from every 3D engine (2018)
Yes, you are mistaken. You need 3 dimensions to represent a 3D rotation (2 for picking an axis, plus one for picking an angle). To represent translations and rotations together, you need 6 dimensions.

This also shows that the talk of needing to visualize 4d to understand quaternions is disingenuous. The formula for using a quaternion to rotate a vector is qvq^-1, from which it is immediate that changing the length of a quaternion does not change the rotation it represents. So you can just deal with unit-length quaternions, which form a 3D space.

matt-noonan··on Hyperscan: High-performance multiple regex matching library from Intel
This is a pro-level troll!

For context, see slides 5 and 6 about the history of Hyperscan and Sensory Networks Inc.: https://openisf.files.wordpress.com/2015/11/oisf-keynote-201...

matt-noonan··on Algebraic Structures: Things I wish someone had explained about FP
There are two different notions of algebra in common usage. One is the definition you gave (vector space with a bilinear product, as in Lie algebras, Clifford algebras, etc). The other definition, as used in the blog, comes from universal algebra. https://en.m.wikipedia.org/wiki/Universal_algebra

Which one(s) you have been exposed to just depends on which mathematical subcultures you’ve interacted with.

matt-noonan··on Software projects written in Haskell
> How common is it for the same person to have both strong Haskell experience and experience building large real-world applications?

I would conjecture that it is more common than what you’d expect from random chance. In my case, I picked up Haskell only after building large systems in C++, Objective C, Lisp, and Python. The draw was that Haskell let me express the kind of system invariants that make it possible to reason about a large codebase.

Since then I’ve written production Haskell in three different companies, none of which appear on this list.

matt-noonan··on The exponential function is a miracle
You mean the seven fundamental constants?

e^(i * pi) + 1 = 0 * 17 * 42

matt-noonan··on Maybe Not [video]
I don't disagree, except to say that "don't break anyone's code" is a bit better than "break in a way that the compiler catches and helps you fix", which is a GREAT deal better than "silently break code".

Paranoia about breaking code makes sense in languages that have few mechanisms for aiding in refactoring. It makes less sense when the language is acting as your teammate.

matt-noonan··on Maybe Not [video]
No, I'm arguing that this kind of breaking change is fine-ish, because the compiler helps the end users upgrade their code to the new API in a very straightforward way.

In other words, I'm arguing that this kind of breaking change is (1) rare, and (2) ok anyway if you have a strong enough type system that the compiler will just tell you what callsites need modification, and the modification is simple (as in this case).

matt-noonan··on Maybe Not [video]
Even without wrapping, I'm not sure that "it breaks existing callers" is such an awful thing. Yes, it is slightly annoying. And if it was a language like Python, making a function suddenly start returning None is going to silently break existing callers, which is pretty awful. But in a language like Haskell, the compiler will find every broken callsite immediately, and the cleanup needed on the caller side is very straightforward.

All that aside, in my experience the case of parameters becoming optional or return values losing nullability actually does not happen that much in practice. It's a bit of a strawman.

matt-noonan··on Clojure at Netflix (2013) [slides]
I'm not sure about the history. It looks like UHC supported existential types at some point, but I'm not sure how that would interact with what I am presuming is a more sophisticated system in GHC Haskell.

This post had some interesting tidbits about technical challenges, but I didn't fully grasp everything on first read: http://blog.ezyang.com/2016/04/hindley-milner-with-top-level...

I really like tome's observation in the other comment: universally-quantified types have a direct encoding in System F as type abstractions, but there is no such direct encoding for existentially-quantified types.

matt-noonan··on Clojure at Netflix (2013) [slides]
> I just haven't seen it in practice, and the few studies that have looked at it empirically haven't seen a clear advantage either. If you know of such a study, please point it out!

This is basically right; there are not a ton of studies, and the ones that exist mostly have pretty bad methodologies. Dan Luu summarized a bunch of them, circa about 2014. [1]

Since then, there has been one study in this area that I think has a solid, well-defined, and plausible methodology [2]. Plus a "Threats to Validity" section, sorely missing from many other papers in this area. They work from a corpus of real-world public bugs in Javascript programs and quantify how many are detected by simple type annotations via TypeScript and Flow. They cap the amount of time for trying to resolve a bug with type annotations at 10 minutes. The result is that over a corpus of 400 bugs, they were able to resolve about 60 using either of TypeScript or Flow, suggesting that 15% of Javascript bugs can be eliminated by using either type system.

That's not a huge difference, but it isn't trivial either. The authors quote an engineering manager at Microsoft: "That’s shocking. If you could make a change to the way we do development that would reduce the number of bugs being checked in by 10% or more overnight, that’s a no-brainer. Unless it doubles development time or something, we’d do it."

I suspect with languages that are more amenable to static types the results would be even better, but there is no solid research that I know of to back that up.

[1] https://danluu.com/empirical-pl/

[2] http://ttendency.cs.ucl.ac.uk/projects/type_study/documents/...

matt-noonan··on Clojure at Netflix (2013) [slides]
That blog post was a nice read, thanks!

I realize this is just one example, but you might be interested to know that I've done some work making this kind of invariant enforceable via static types (though in practice, you need a combination of features that aren't found in many mainstream language besides Haskell afaik).

See the README here for motivation and some examples (in Haskell, but hopefully the idea is still clear): https://github.com/matt-noonan/justified-containers

Or the tutorial module here: https://hackage.haskell.org/package/justified-containers-0.3...

Or this paper, if you really want to go off the deep end: http://kataskeue.com/gdp.pdf

matt-noonan··on Clojure at Netflix (2013) [slides]
I'd rather have the compiler ensure that my discipline (and my team's) never slips, and to get guarantees about all possible executions instead of just those executions that have been tested.

For these reasons and others, I don't personally find run-time checks to be an adequate replacement for compile-time checks. But there is no really convincing research on the subject, and I certainly don't begrudge your preference here.

matt-noonan··on Clojure at Netflix (2013) [slides]
In Haskell designs, developers tend to be quite careful about setting things up so that verifying types does indicate valid data. Coming from other languages (C++, Common Lisp, and Python in my case), it can be a little surprising just how often and how easily you can make this happen.
matt-noonan··on The algebra and calculus of algebraic data types
Interesting, thanks! I hadn't considered using "forall a. a" as the bottom type, but it makes sense.
matt-noonan··on The algebra and calculus of algebraic data types
The "should be able to just return its argument" part is wrong; the types pretty clearly don't match, yeah? It is true that there is a unique function of type `Void -> a` for each `a`, but that isn't it.
matt-noonan··on The algebra and calculus of algebraic data types
`Void -> a` is inhabited by the slightly weird empty-case construct in (GHC) Haskell: `\x -> case x of {}` has type `Void -> a`
matt-noonan··on Understanding contravariance
> So I immediately hit a block as I'm struggling to understand why I need the notion of a Functor to understand what in the end looks like just lazy mapping of a function over a stream.

You don't, for this one example.

You don't, for any one example.

But if you keep looking, you'll find more and more of these examples of functors embedded in the code you are already writing. You need the notion of functor when you want to abstract over all of these examples, or generalize one of your examples to handle things that it couldn't before.

matt-noonan··on Railway-Oriented Programming (2015)
Haskell got exceptions in 1999, I think, but your guess about the motivation as "oh, whoops, result types don't scale" is entirely unfounded.

The real issue is this: figuring out how to do exceptions in a lazy language is simply not obvious. Work was needed, e.g. https://www.microsoft.com/en-us/research/wp-content/uploads/...

Even so, exceptions are generally not used for error handling in Haskell, yet life seems to go on. You'll see code using `throwError` or `catchError`, but usually these will just be providing a nice bit of sugar on top of an Either or Maybe type. So it seems like the takeaway should be that Result types do scale, with proper library+language support.

matt-noonan··on Notes on Idris (2017)
Yes, you really need at least Pi types (dependent products, as above) or Sigma types (dependent pairs) to have dependent types. So you could get away with it in Python by munging a return type based on a parameter, but not C++ or most other statically typed languages!

Unfortunately it seems like there is a lot of fog around this. Even the wikipedia page for dependent types botches the first example: "pairs of numbers where the second element is greater than the first" is just a normal type. A dependent type would be something like "pair<int,vec<T,n>>" where the n is supposed to equal the first element of the pair.

The waters are muddied even further by the fact that you can reproduce many of the canonical examples for dependent types using other mechanisms, as you pointed out below for the vector-append operation!

Edit: After complaining a bit about the Wikipedia page, it was pointed out that you can think of that example as a Sigma type. I contend it is not obvious unless you have already spent time thinking about dependent types, though.

matt-noonan··on Notes on Idris (2017)
You can make C++ types that depend on constant values computed at compile-time, but this isn't the same as dependent types. In a hypothetical dependently-typed C++, I would be able to do this:

    template <typename T, int N> struct vec { T data[N]; };
    vec<T,n> repeat(int n, T const& x) {...}
Note the run-time value n appearing in the return type of `repeat`. Because of this, repeat (if we could write it) has a dependent product type: the actual return type varies based on an argument's value.
matt-noonan··on Notes on Idris (2017)
Can you elaborate on the DT / QuantifiedConstraints connection a bit? I haven't thought enough yet about QuantifiedConstraints to see the everyday benefits, but I'm getting contact-excited by everybody else's anticipation of it. I'd love to get some concrete benefits to hold in mind.
matt-noonan··on Reasoning with Types in Rust
To me, parametric polymorphism is much nicer for reasoning about a program locally / modularly. It's kind of like reasoning about a function with linear control flow vs reasoning about a function with lots of nested if/elses. You can do the reasoning once and be done with it.

I tried to make a general point along those lines in this blog post, thought I think it deserves more extensive examples. http://storm-country.com/blog/abstract-is-simple

matt-noonan··on Evolving a Decompiler
Actually, I'd expect Go to work really well! Not if you tried to generate C code that compiles to a given Go binary, of course.

But that's not what you'd do. Instead, you'd use the Go compiler as the black box, and learn Go code to produce the given binary. And for that, Go might work better than C: the speed of the compiler would help churn through generations that much faster.

matt-noonan··on Emacs org-mode examples and cookbook
Oh, but you can! Check out ein-mode: https://tkf.github.io/emacs-ipython-notebook/
← PreviousPage 2 of 2