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 I take illegal drugs for inspiration
> People die after playing video games for 16 hours

Really? In what context? Do you have a link or citation I could read?

rntz··on Of Course ML Has Monads
Close, but no cigar.

  functor MonadUtils (M : MONAD) = struct
    (* type annotations not strictly necessary *)
    fun sequence (ms : 'a M.monad list) : 'a list M.monad =
      let fun mcons (elt, rest) = M.bnd elt (fn e => M.bnd rest (fn r => M.ret (e::r)))
      in foldr mcons (M.ret []) ms
      end
  end
rntz··on Of Course ML Has Monads
SML is impure. You are arguing for purity, which is a separate issue from support for monads. Saying "SML doesn't really have support for monads because it's impure" is confusing an idea (monads) with a particular application of that idea (using special monads like IO to separate pure from side-effectful code).

To be fair, Harper's comment is practically a pretty silly proposition. But the primary technical claim of his post (SML supports monads) is true. This is a common issue with Harper: he rarely says anything factually incorrect, but the moral conclusions he draws are out of proportion with the technical points he makes.

rntz··on Joel Spolsky: Can your programming language do this?
No, you just have to make sure the function you pass is associative.

Only in really strongly typed languages like Agda can you make the associativity constraint /part of the type/ of the function, and thus statically checked by the compiler; but it's perfectly reasonable to make it part of the specification of the function's behavior that it expects its argument to be associative. (Or, slightly more generally, that the order of reduction is unspecified; in which case only an associative function will produce a totally deterministic result.)

rntz··on Some advice on teaching FP
I dunno, I just TA for the guy. I suspect it depends on what you mean by "real programming of significance". I can tell you that Harper is really damn smart. I'd be truly surprised if he was bad at programming. But his actual experience, I don't know. He hasn't written any code for the course itself, but that's not really his role.
rntz··on Some advice on teaching FP
In brief: I prefer Haskell, but I think it has its flaws, and I understand why we're not using it as a teaching language.

In long:

Haskell has much better concrete syntax, better library and tool support, a more active community, and is subjectively nicer to program in.

Haskell is lazy, SML eager. Haskell catches a lot of flack about this from SML fans. I think the typical arguments against laziness (makes it hard to reason about space usage; just a special-case of eagerness) are not false but overblown (it's harder but not that hard once you get used to it; and yes, you can simulate laziness in an eager language using thunks etc, but that's a Turing tarpit argument). However, in the end I'm not sure laziness is worth it.

Haskell is pure and SML is not. I don't mind the impurity of SML (or any other language), but I think Haskell's purity has some nice side-benefits for a high-level FP language (eg. allows more compiler optimizations). I'm also grateful to it for being the main reason Haskell has support for monads, which I think are a powerful unifying idea well worth their weight even if you don't need them to encapsulate I/O & side-effects.

The big difference is, of course, their module systems. Everything Harper says about Haskell in this regard (https://existentialtype.wordpress.com/2011/04/16/modules-mat...) is true, but I don't think it's as big of an issue as he makes out. Typeclasses give you 90% of what you want, in a much more concise package. I've perhaps wanted ML-style modules & functors once or twice when writing Haskell, and I wish I had typeclasses all the time when writing SML. I could say more on this topic, but this response is already overlong.

rntz··on Some advice on teaching FP
That's hard for me to know because, as a TA, I mostly get to see students when they're confused or frustrated, up against a deadline. The fact that almost all our students are also enrolled in spring 251 with Luis von Ahn, and therefore incredibly overworked, doesn't help.

However, a reasonable proportion of students seem interested, and a handful are overtly enthusiastic about the course. If I had to guess I'd say it won't be an order-of-magnitude improvement over 212, but it will be significant one, if only because it will reach more students earlier in their undergraduate careers. However, only time will tell.

As for 212's reputation, you and I must run in different circles; I know plenty of FP enthusiasts who got their first taste in 212. I suspect a strong selection bias is at work here.

rntz··on Some advice on teaching FP
I'm a TA (one of four) for the course Harper is talking about in this post. As they say on reddit, ask me anything. I do not guarantee I'll answer. I'll check back in in the morning.
rntz··on The Bipolar Lisp Programmer
I can only speculate at the intentions of the grandparent poster; but it's not necessarily their intention to indicate that you shouldn't repost things. It's helpful to link to old discussions of the same post so that interested HNers (like myself) can go read the comments. I know I'm often more interested in the comments than the article itself.
rntz··on What if we tested laws before passing them?
You have your Prolog backwards.

  foo(X) :- bar(X).
means that foo(X) is true if bar(X) is true, not the other way around. So your code would indicate that anything that's not a law is unconstitutional, and anything unconstitutional prohibits free exercise of religion (for example).
rntz··on Show HN: New Lisp data structure
The two most common operations on lists in typical functional programs are consing and deconsing, which are O(1). The most analogous operations on trellises are appending and removing the tail element, which are O(log n). So it seems inappropriate to propose trellises as general replacements for lists.

Indeed, I'm not sure in what situations this tradeoff of cons/decons- for lookup-speed is helpful. If I just need fast lookup, I'll use a mapping structure (hashtable, balanced binary tree, patricia trie, etc). If I need reasonable lookup speed and also standard sequence manipulations, finger trees or ropes seem like a better choice. They're more complex, but if performance is an issue, then it's probably worth it.

Also, a bug/design flaw: You can't store NILs in the terminal position:

   > (trellis 1 2)
   (1 (2))
   > (trellis 1 2 nil)
   (1 (2))
rntz··on How to represent strings, the heavy way
Read the sentence before that:

> This also makes it possible to store only a single copy of short strings, to improve memory efficiency, cache locality, and so on.

He's specifically talking about interning strings. He even links to the wikipedia article on string interning. I recall reading that Lua interns strings by default, and a quick google search seems to confirm my belief. However, with only one example, you're right: interning /all/ strings is unusual. Interning all "short" strings, his suggestion, is a more feasible heuristic, and then (if finding the length of a string is O(1)) comparing two short strings amounts to little more than a pointer comparison. I don't know whether there are any languages that do that.

rntz··on Piknik - my full screen color picker
ENOENT

(I don't have a mouse on my laptop. I have a touchpad, and it is able to scroll by swiping or circular motions, but that didn't work on the page when I tried it.)

rntz··on Piknik - my full screen color picker
I'm not able to scroll. No scroll bar appears, page-down and page-up don't work. chromium-7.0.517.41 on linux. Anyone else have this problem? Am I missing something?
rntz··on Gift HN: Anybody want a subdomain of ww.com?
baaa.ww.com CNAME baaaww.rntz.net

Thanks in advance!

rntz··on How Hacker News ranking algorithm works
That's because of the way Arc does if-expressions. In Scheme and Common Lisp, you have two conditional forms: 'if and 'cond. 'if takes three arguments (or two, with an implied nil, in CL), and is analogous to an if-then-else in other languages:

    > (if #t 'then 'else)
    then
    > (if #f 'then 'else)
    else
'cond, in contrast, takes as many branches as you like, but they're parenthesized like so:

    > (cond (#f 'a) 
            (#t (display "I can have a body here!\n")
                'b)
            (#t 'c))
    I can have a body here!
    b
In arc, there's just 'if, which is like 'cond with a lot of implicit parenthesization and else-branches:

    arc> (if t 'then 'else)
    then
    arc> (if nil 'then)         ; if no else-branch is given, nil is implied
    nil
    arc> (if nil 'a
             t   (do (prn "'do is like Scheme's 'begin or CL's 'progn.")
                     'b)
             'else)
    'do is like Scheme's 'begin or CL's 'progn.
    b
rntz··on What happens when you refuse to answer a passport control officer's questions
True, but someone who just wants to hurt someone is going to pick on whoever stands out.
rntz··on Why GNU grep is Fast
Boyer-Moore is a great algorithm, but it's for fixed-string searching. grep, in the general case, handles regular expression searching. Is there some way to extend Boyer-Moore to regular expressions that I'm unaware of? Or is GNU grep's use of Boyer-Moore limited to when the search string is just a literal?
rntz··on Why Japan Is Doomed
It doesn't excuse, but it does explain -- hence, it shouldn't be surprising. Deplorable, perhaps, but not surprising.
rntz··on Your code should be taken out back, lined up against a wall, and machine-gunned
Uh, actually, his original program (http://www.cygwin.com/ml/cygwin/2005-08/msg00542.html) did restore the stack pointer before returning from main. He "wanted to cut [the example's size] down for the sake of the mailing list", so he left that bit out.
rntz··on The Mark of a Masterpiece
It has been corrected for.
rntz··on Explaining Functional Programming to Eight-Year-Olds
insert is fold, just underspecified (what happens on 1- or 0-element lists? in what direction does the operator associate?). The only difference in comprehensibility is in the language being used to describe the operation - which is certainly a good thing to take note of if you're trying to teach FP, but it's not as if the operation itself is somehow less-comprehensible.
rntz··on On Lisp's Readability and Parenthesis Stacking
False. The I-expression:

  lambda (x y)
    display x
    + x y
corresponds to the S-expression:

  (lambda (x y)
    (display x)
    (+ x y))
rntz··on Trail blazing innovators - Use Emacs
I agree that using emacs for everything is not for everyone. But with regards to switching between buffers being cumbersome:

1. If you're not willing to change your keybindings to taste, Emacs basically isn't for you; its default bindings are terrible. I suggest binding switch-to-buffer (C-x b) and other-window (C-x o) to single, easy-to-reach chords (I use C-. and C-' respectively).

2. switch-to-buffer sucks. Use iswitchb-mode; it gives you interactive completion of buffer names with substring matching. It also lists your buffers in most-recently-used order, so switching back-and-forth between two buffers is trivial. (There's also ido-mode, which adds interactive completion to even more things with even more features.)

Basically this is the same issue that emacs has always had: the learning curve is steep and you have to invest some time and explore in order to find settings that work for you. (I'm sure you're happy with your current setup; I'm making this post more for people who might be scared away from Emacs than to try and convert you.)

rntz··on On Lisp's Readability and Parenthesis Stacking
The real reason that parenthesis-stacking is the norm is twofold:

a) Trailing parentheses just look ugly. I can't really explain why - perhaps it's merely a cultural thing, come about only because lispers are so used to looking at stacked-parenthesis code.

b) Lisp code tends to get very nested. In C or Java code, you rarely get more than 3 trailing braces in a row. In Lisp, if you trail parentheses, you regularly end up with 5 or more lines of nothing but trailing parentheses. This contributes to the ugly factor and makes for a lot of "wasted" whitespace. It's also one of the reasons 2-space indentation is the norm for lisp instead of 4-space.

Honestly, I don't think trailing parentheses makes lisp code particularly easier to read. I agree with noahlt that it's mostly the 2-space versus 4-space indentation issue.

rntz··on Git for Computer Scientists
You don't need "deep ivory-tower CS training" to have knowledge of computer science. I don't know why anyone would be offended to be called a computer scientist; it's not like being such precludes being an excellent programmer, nor does being a self-taught hacker preclude being an excellent computer scientist.
rntz··on No more confusions on tricky C declarations
This is a Good Idea, but it doesn't help you understand other people's code if they don't follow it. Hence the need for a mnemonic rule.
rntz··on No more confusions on tricky C declarations
Following the procedure as written:

         +-------+ 
         | +-+   |
         | ^ |   |
    char *foo[10][20];
      ^  ^   |   |
      |  +---+   |
      -----------+
It mentions, in rule 1, handling tokens of the form [] or [X], but not multiple occurrences of these.

This is indeed rather nitpickish of me, but on the other hand, one thing that you at least need to know in that case is in what order you read the numbers - left-to-right, or right-to-left (is foo[10][20] a 10-array of 20-arrays or a 20-array of 10-arrays?). Not mentioning this leaves one (at least, it left me) with the impression that multiple occurrences were already handled by this rule as written, which is, as demonstrated, false.

rntz··on No more confusions on tricky C declarations
Fails on nested arrays.

  char *foo[10][20];
The method described would indicate that this is a array 10 of pointers to array 20s of chars.

This is incorrect. It is an array 10 of array 20s of pointers to chars.

rntz··on Xz
Testing them all on -9 is perhaps not a fair comparison. For example, according to http://changelog.complete.org/archives/931-how-to-think-abou..., gzip -9 saved a tiny amount of space compared to gzip's default, but took significantly longer.
← PreviousPage 13 of 15Next →