HNHacker News
TopNewBestAskShowJobs

rntz

2,169 karma · joined May 25, 2009

www.rntz.net email: http://www.google.com/recaptcha/mailhide/d?k=018XOhLYKe9NqLdmoSmt6HsQ==&c=mcxnT-9mQPQEL6wailXqNUHk3aPs4Jv1T3vTJsNNAkg=
submissionscomments
rntz··on 0^0
The code I gave translates easily into Agda, a computerized proof checker, and as such more formal than most mathematics. However, here's the same thing in a modernized version of Peano arithmetic. We assume all the usual properties of equality: reflexivity, symmetry, transitivity, and substitution.

    -- Axioms (only 1 and 2 are relevant)
    1. 0 ∈ N
    2. ∀ x∈N. S(x) ∈ N
    3. ∀ x∈N. 0 ≠ S(x)
    4. ∀ x∈N, y∈N. S(x) = S(y) ⊃ x = y
    5. P(0) ∧ (∀ x∈N. P(x) ⊃ P(S(x))) ⊃ ∀ x∈N. P(x)

    -- Definition of addition
    6. ∀ a∈N. a + 0 = a
    7. ∀ a,b ∈ N. a + S(b) = S(a+b)

    -- Proof that S(0) + S(0) = S(S(0))
    9. S(0) ∈ N                     [from 2 and 1]
    10. S(0) + S(0) = S(S(0) + 0)   [from 7 and 9]
    11. S(0) + 0 = S(0)             [from 6 and 9]
    12. S(S(0) + 0) = S(S(0))       [substitution of equals, from 11]
    13. S(0) + S(0) = S(S(0))       [transitivity from 10 and 12]
Edit: Ah, I see I was beaten to it by pavelrub.
rntz··on 0^0
Whitehead & Russell didn't have the proof machinery we have today; they were inventing the wheel, and they did it badly. (Which is not to insult their achievement. Note that I say inventing the wheel, not reinventing it.)
rntz··on 0^0
I did not in fact mean that 2 is defined as 1+1; you (and several others) are correct in saying that 1+1=2 requires proof for all reasonable definitions of +. 0^0 = 1 follows much more directly from the definitions in which it is true. My overall point has been articulated by arketyp in a sibling post to tomp's; like ^, + is "just a definition" which we arranged so as to line up with our intuitions.

I disagree with your assertion that 1+1=2 and 0^0=1 are of completely diferent kinds. That depends on what intuitive angle you approach them from; my intuition for ^ is that it is the iteration of multiplication, and in this context the only sensible definition is that x^0 = 1 (the unit of multiplication), for any x. The generalization to continuous bases and exponents should preserve this property.

But this is certainly a matter of taste, and certainly you'll find more disagreement here than in the matter of 1+1=2. What this tells us about human nature, I think, is not much: humans will disagree more when things get more complicated (^ is more complicated/abstract than +) and there is more room for disagreement.

rntz··on 0^0
Here is a simple definition of the natural numbers and addition, in Haskell:

    data Nat = Zero | Suc Nat

    plus :: (Nat, Nat) -> Nat
    plus (Zero, y) = y                  -- axiom 1
    plus (Suc x, y) = Suc (plus (x, y)) -- axiom 2

    one = Suc Zero
    two = Suc one
Here is a proof that plus (one, one) = two:

    plus (Suc Zero, Suc Zero)
    = Suc (plus (Zero, Suc Zero))  [by axiom 2]
    = Suc (Suc Zero)               [by axiom 1]
rntz··on 0^0
In a certain sense, "1+1 is 2" is also merely a definition, in the same sense that "0^0 is 1" is a definition. Addition can be formally defined in mathematics; we habitually omit this definition because it is tedious, and because addition is such an intuitive operation that we do not require a definition in order to reason about it.

Much as the question "what if the parallel axiom didn't hold?" leads to alternative geometries, the question "what if addition didn't work in the same way?" (or "how can we generalize addition?") leads to some basic notions in abstract algebra.

rntz··on 0^0
In fact, exponentiation f : C x N -> C has a natural generalization to any monoid C, where f(x,n) is x "multiplied" by itself using the monoid operator n times. In this setting, the only sensible choice is that x^0 = 1 for any x, where 1 is the unit of the monoid in question. In particular, that is the only definition of exponentiation which is parametric in our choice of monoid.

Naive Haskell example code (using Int for Nat):

    f :: Monoid m => (m,Int) -> m
    f (x,0) = mempty
    f (x,n) = x `mappend` f (x,n-1)
    -- or equivalently
    f (x,n) = msum (replicate n x)
rntz··on The Problem With Photorealism
As I see it, the OP is frustrated that people mistake mere graphics (and in particular, realtime raytracing) as the gold standard for "realism" in games, when there are open problems both more challenging and more important that are still unsolved (truly dynamic behavior, scalable content creation).

I don't know about industry, but in academic CS graphics is a huge field; by contrast, my impression the other problems mentioned are rather neglected (though certainly not unknown). However, graphics and games aren't my specialty; I would love to be mistaken.

rntz··on Regex Golf Part 2: Infinite Problems
They wrap for me in Chrome, but not in Firefox. (What the hell?)
rntz··on Philosophy and "for" loops — more from Go and Rust
Yes. You might be able to get something like it back with Rust's macro system, though. But it's probably better just to use the new syntax & iteration protocol, assuming the Rust folks come up with something reasonable.
rntz··on Philosophy and "for" loops — more from Go and Rust
Internal iterators are just syntactic sugar for a higher-order function. As long as Rust has higher-order functions, internal iteration will be possible (just not "the standard way to do things").

Edit: In fact, this is true of any language with higher-order functions. For example, this is how you'd define a Rust-style internal iterator for lists in Racket scheme:

    (define (iter l f)
      (when (and (pair? l) (f (car l)))
        (iter (cdr l) f)))
And how you'd use it:

    ;; displays elements of the list, up to and including the first one >= 3
    (iter '(1 2 3 4) (lambda (x) (display x) (< x 3)))
rntz··on Philosophy and "for" loops — more from Go and Rust
Rust is actually in the middle of changing how iteration (and eventually for-loops) works, from "internal iterators" as described in the article to even more flexible "external iterators". I'm not fully up-to-date, but this comment (http://lwn.net/Articles/557494/) on the original article links to a mailing-list post on the topic: http://thread.gmane.org/gmane.comp.lang.rust.devel/4528
rntz··on “What part of Milner-Hindley do you not understand?”
You could elaborate polymorphic values to type functions; and if you were compiling ML to System F or System F-omega, that is certainly what you would do. But in practice this might produce performance problems (I shouldn't have to call a function every time I use the empty list just because it has polymorphic type!). I must admit I'm not sure what SML and Haskell compilers actually do.

So in some sense the value restriction is there to prevent us from having to make the ugly choice between unsafety on the one hand, and inefficiency and unintuitive behavior on the other.

rntz··on Asm.js: a strict subset of js for compilers – working draft
Oh! Closure pointers would absolutely suffice. But as far as I could tell, asm.js doesn't support closure pointers either. Obviously I could use a value of "unknown" type to pass them in, but section 2.1.9 says "Since asm.js does not allow general JavaScript values, the result must be immediately coerced to an integer or double."

So I'm under the impression that asm.js can't really deal with closures or functions as values. Am I reading the docs wrong? I hope I am.

rntz··on Asm.js: a strict subset of js for compilers – working draft
The fact that you can't represent function pointers (not closures, just plain old C-style function pointers) in asm.js severely limits its usability as a target language for even C-like languages.
rntz··on Ten predictions (2004)
Maybe I'm missing something, but I don't see any infix notation on the linked page.
rntz··on Game Over
It's twitter-endemic, if not twitter-specific, for the simple reason that it's hard to express a coherent, well-justified argument in 140 characters, but easy to express anger.

The anger might even be justified; just don't go to twitter expecting to read the justification.

rntz··on Why I think Rust is the "language of the future" for systems programming
All that means is that Go was announced much later in the development process than Rust was. If Rust had been developed like Go, it wouldn't have been made public yet. But that's not the way Mozilla does things.
rntz··on The Linguistic Interface
This has strong similarity to the thesis of the classic article "The Anti-Mac Interface": http://www.useit.com/papers/anti-mac.html

The connection to the ideas in the Kingdom of Nouns, though, is new and intriguing. It's obvious only in hindsight that job-specific apps can be thought of as nouns, while unix-style tools can be thought of as verbs.

rntz··on Tell Your Boss Anything
If a user uses your service in an inappropriate way, then stop letting that user send messages. Don't reveal their identity.

Threats of physical harm might constitute a valid exception. At that point, law enforcement should be involved.

rntz··on Study of 49 programmers: static type system had no effect on development time
> the GHC Haskell compiler now allows you to treat type errors as warnings.

Explain? Or post a link?

EDIT: found it: http://hackage.haskell.org/trac/ghc/ticket/5624

rntz··on Interviews Can Be a Terrible Way to Identify Good Programmers
The author places a lot of stress on memory. I think he's overgeneralizing from his personal experience.

Personally, I have a very bad memory, especially when confronted with query-like questions like "explain how you solved some hard problem when working at company X". I remember based on associations, not time: If you sit me down in front of the code I wrote, or pose the problem to me directly, I'll remember in a jiffy, but looking back on my time at a company/at school/etc it just seems like a blur---I can't remember anything at all that way!

rntz··on Rust 0.2 released
Both Rust and Go have GCs. It is true that Rust has mostly per-thread GC, which should help to curb performance concerns quite a bit. And Rust aims to have more explicit control over where things are allocated. But it's still a GCed language.

Whether GC is acceptable in systems work depends on what you construe as "systems work" (kernels and GC don't mix nicely; browsers and GC is OK if you're careful).

rntz··on Why Systems Programmers Still Use C (2006)
You misunderstand his argument. He's not arguing that we should replace C with "higher-level languages" that don't give you precise control of the hardware; in fact, he bemoans the fact that the PL community at large seems interested only in such high-level languages. Nor is he complaining that C is hard to learn (I'm not sure where you got that impression). In fact, the paper mostly takes for granted that C needs to be replaced, and discusses the challenges in doing so, which may be why you assumed that BitC is (was, really) just another typical research-community high level programming language project.

The fact is, C is broken, and we all suffer every day because of it. From a security perspective, C is a nightmare. It is not just an unsafe language (in the PL sense of having undefined behavior), but a rampantly unsafe language. Null pointers (which C.A.R. Hoare famously called his "billion-dollar mistake"), buffer overruns, unrestricted pointer arithmetic, arbitrary casting, manual memory management; all of these are the cause of innumerable bugs in real code, often critical security vulnerabilities. C is also not the nicest of languages to code in. It is terribly verbose. There is no good way of writing generic code in it. The preprocessor is a gigantic ugly hack. Writing portable C is a pain in the ass, and building it portably is doubly so.

The worst part is, we know reasonable ways to solve most of these problems. In many cases we have known them for decades. Unfortunately, how to best integrate these solutions into a language and still keep it useful for systems programming was (and is) an open problem. I can't speak for Shapiro, but as I see it this is what BitC was aimed at doing.

rntz··on Raph Koster - Rigid programming philosophies are the devil
"Prototype as fast as possible" is itself a rigid programming philosophy.
rntz··on Deca - a systems language based on modern PL principles
Rust, while interesting and admirable, isn't quite as low-level as C or Deca. For example, one of Deca's explicit goals is to not require a garbage collector or a runtime library. Rust has GC and a light-weight-threading runtime. So it's not quite a replacement for C, though it's certainly a good replacement for much of the application-level programming C and C++ are (unfortunately) widely used for.
rntz··on The Wasteful Legacy of Programming as Language
This article touches on some interesting ideas, but doesn't hint at the enormous amount of work that would need to be done to even see if they are feasible, let alone implement them. The author also makes important mistakes regarding PL implementation. Examples follow.

"Without the need for a language, it also disappears the need for a compiler. Everything is such a system is already parsed and ready to use."

A compiler is not just a parser! In fact, the parser is generally regarded as the easy, tedious part of a compiler. This confusion between the syntax of a language and its semantics undermines most of the purported benefits of his proposed "languageless system".

"Whatever the form used to interact with the program, a language-less system doesn’t care if parts of the program are shaped as s-expressions or C blocks: it just combine them as needed to create a program."

The difference between s-expressions and C blocks is not superficial: s-expressions present a natural API to the syntax of the programming language itself, allowing Lisp's distinctive feature: macros. Language syntax and language capabilities are not so easily separable!

"In a program written in this way, using garbage collection is just a matter of plugging the right run time support, which you could get along with the system or you could buy from a third party."

Performant garbage collection algorithms need guarantees about the code they manage (eg. the ability to distinguish pointers from integers for precise GC, and write-barriers for incremental GC). Choice of GC algorithm affects the compilation and capabilities of your entire program, and even the ways you can interact with other programs! You can't just mix and match PL features you find from various languages and expect them not to conflict.

rntz··on Deep C
Most code is buggy. Usually its author isn't nearby, and even if they are, hitting them rarely helps. Knowing the symptoms of buggy code, however, will help you debug it.
rntz··on Scheme vs. Commmon Lisp
Sussman says Lisp can't do it, need to use C; Greenspun proposes Common Lisp; Sussman says that if that's true (if CL can do it but Scheme can't), then Scheme has been a waste of time (an odd conclusion IMO); Greenspun proves that CL can do it; Bill Rozas points out that the problem is in Scheme's inefficient reader implementation, not an inherent problem with Scheme itself.
rntz··on If you gaze into nil, nil gazes also into you
It has nothing to do with compilation. It has to do with static typing -- that, before ever evaluating something, you typecheck it. It is perfectly feasible to interpret a statically typed language -- SML/NJ for example, includes an interpreter for SML. However, statically typed languages are generally easier to fully compile than dynamic languages; SML/NJ also includes a compiler for SML.
rntz··on I take illegal drugs for inspiration
> If you choose to live in a democratic society, why not obey the democratically ordained laws?

As opposed to choosing not to live in a democratic society? Is there some psychedelic-utopian society out there that's just like a standard first-world social-democratic country (high standard of living, good education and job opportunities, I can speak the language, etc, etc) except that drugs are legal by fiat?

← PreviousPage 12 of 15Next →