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 What Color Is Your Function?
Actually, you can call both ways - from statically typed to dynamically typed and back. This is the premise of the work done in Racket on contracts, and more generally of the "gradual typing" movement. Harper's "unityped" term suggests exactly how this can work. An untyped function takes arguments that are all of one type, and returns one of the same type (that type being the "dynamic" type that includes every possible value, and thus is useless for static checking).

To call an untyped function from typed code, simply cast all your arguments to this type (trivial, since it contains anything), and check its return value has the type you expect (throwing an error if it's of the wrong type). To call a statically typed function from untyped code, simply check the types of all the arguments you wish to pass to it (throwing an error if they don't match its signature), and cast the returned value to the dynamic type (again, trivial).

I'm glossing over a very important difficulty, which is that you can't dynamically check something of a function type -- if I'm handed a function, how do I know at runtime whether it's of type `int -> int`? I can't! So the solution is to "wrap" this function with a contract that delays checking until the function is actually called, at which point you can check the argument is an `int` and the result is an `int`.

rntz··on What Color Is Your Function?
Go's "good, pragmatic engineering" solution to the problem - lightweight threads, channels, and the communicating sequential processes model - is built on the back of decades of academic research, including programming languages research.

And now for some computer language geekery:

Go solves one "code color" problem (concurrency/asynchrony), by hard-coding the solution into the language. Go programs are written in a particular monad (the "Go" monad, if you will), and so have one color. Indeed, monads originally arose in the study of the semantics of imperative languages; to be imperative is to be inside a particular monad. This is exactly the "async monad spreading through your code" problem taken to its logical conclusion: just put everything in the same monad!

This hard-coding solution has very concrete advantages. For one, you don't need to think about separate colors and how to transition between them, combine them, define them, etc. (IOW, monads are complex; by picking one, you reduce cognitive load.) For another, it's easier to optimize your implementation and tooling for that monad (lightweight threads, useful tracebacks).

But PL academics aren't satisfied with this solution, because it only solves one color problem, and it solves it non-composably: you can't put the solution in a library, you have to invent a whole new language for it. That's the holy grail (some) PL research is chasing. It's a question of concrete benefits in the here-and-now versus abstract benefits in the hopeful-future. But it pays to remember that today's concrete benefits are yesterday's green-field research.

rntz··on Billie Holiday and the Federal Bureau of Narcotics’ Early Fight for Survival
How can you simultaneously claim that nobody speaks well of Anslinger, and that he is lionized? That seems flatly contradictory.
rntz··on Why Men Love War (1984)
Of course people who live happy, modern, peaceful, productive lives do not deserve our scorn.

The problem is not that there is something wrong with living an ordinary life, in following the comfortable and society-approved paths of success; the problem is that for many people, that is not enough. There is (so the story goes) something in many of us that yearns for chaos, for a purpose beyond the ordinary, even for violence and death. No more do these people deserve our scorn.

How do we satisfy this desire? War is one solution, but clearly not a good one.

rntz··on Rise of the Scientific Programmer
You are always running someone else's code. It starts the moment you boot up your machine.
rntz··on Lists and Lists (1996)
Worse is better is about much much more than exposing versus not exposing implementation details.

Exposing implementation details is also not quite the same thing as a leaky abstraction (although they can coincide). eqv? can be both, if you regard "cons" as an abstraction of a mathematical pair. OTOH, if you regard cons as allocating a mutable pair object, then it is neither.

Providing a function to trigger garbage collection is exposing an implementation detail, but not leaking abstraction.

It's harder to come up with examples of leaky abstractions that don't in some sense expose implementation details. I'm not sure they exist.

rntz··on Lists and Lists (1996)

    data Sexp = Int Int | Nil | Cons Sexp Sexp
    megasum Nil = 0
    megasum (Int i) = i
    megasum (Cons l r) = megasum l + megasum r
rntz··on Lists and Lists (1996)
Yes, in some sense 'eqv? is leaking abstractions.

Lisp is historically less concerned with not exposing implementation details than more modern language traditions. The attitude is: the hacker might need it, throw it in! For example, the ability to compare pointers directly (rather than some expensive traverse-the-whole-datastructure comparison) makes it possible to implement hash-consing, a clever optimization technique.

(It's also no more of an abstraction leak than, say, Python's "is" operator.)

rntz··on Show HN: Code Words, a quarterly publication about programming
I can't tell whether you intend to agree or disagree with the quote. Your tone suggests you are disagreeing, but your content to me seems to be in agreement.

(I am the article author.)

rntz··on Introducing Spider 0.1
I can't speak for Smalltalk or Miranda, but not everything in Haskell is a function, and not everything in Lisp is an expression.

The case in Haskell is obvious: 2, "foo", (Data.Set.singleton 3); none of these are functions. Functional programming isn't about "everything is a function", it's about (among other things) making functions first-class, and using higher-order functions to build powerful abstractions. (There are also a lot of other things associated with FP, incl. but not limited to: immutability, purity, powerful static type systems, focus on "plain old data" over OO hierarchies, laziness, etc). If you want a language in which everything is a function, you want the untyped lambda calculus.

The case in Lisp is a little less obvious; I've been meaning to write a blog post about this. But consider:

    (let ((x 0)) x)
Is `((x 0))` an expression? No. It's a list of binding-pairs.
rntz··on Haskell Is Exceptionally Unsafe (2012)
> I think that Call-by-push-value can help us with both recovering the benefits of laziness as well as reasoning about effects.

I would be very interested to hear why you think that, or just have some links on the subject. In particular it's not clear to me how CBPV helps us reason about effects.

rntz··on Haskell Is Exceptionally Unsafe (2012)
> Lets consider the rather remarkable backflips Standard ML and OCaml had to perform in order to make FP work with strictness and impurity.

What backflips are these?

Apart from the value restriction (which is a real albeit minor inconvenience; I find it about as annoying in practice as Haskell's monomorphism restriction, and each can be removed in principle, at the cost of making it harder to reason about the semantics/cost of using a variable), I'm honestly not sure what you have in mind.

On a tangent, I'm not sure when statically-enforced purity (as opposed to purity-by-default) and pervasive laziness (as opposed to laziness-as-a-tool) became culturally defining features of FP. The original FP language, Lisp (and even its "this FP stuff is great, let's have some more" cousin Scheme) is impure and strict. I'm grateful to Haskell for trying to answer the question "just how far can we push these purity and laziness ideas", but I don't think that complete purity or laziness are necessary features for FP. They're just tools in its toolbox. But then, I have always been inclined to pluralism.

rntz··on Curry-Howard, the Ontological Ultimate
As a type system, purely formally speaking, Java is... well, it's just kind of OK.

It has parametric polymorphism. It gets subtyping & co-/contra-variance right -- for generic types only, not arrays, and requires explicit annotations ("extends", "super"). It can express higher-order functions. Its primary formal weakness compared with, say, Haskell98 or SML, is the lack of higher-kinded types (ignoring for the moment the issue of Haskell-style typeclasses or ML-style modules & functors), which is a pretty big weakness but not a game-killer (see: Rust, Elm).

But pragmatically, it's a pain in the ass to work with. (Possibly this has improved since I worked with it. I hope it has!) It has a weird "everything must be an object" view of the world; it requires a file for every type I wish to define (barring nested classes, and anonymous classes - the latter of which is a notable but late improvement). Expressing HOFs is possible, but very unpleasant (AIUI it's gotten better lately). And just to top it all off, it doesn't have type inference, which just makes everything a chore.

The way I see it, Java is playing catch-up with the innovations introduced by more forward-thinking languages. It seems doomed to being forever a middle-of-the-road language. Which is... well, it's just kind of OK.

But it's not gonna inspire devotion, and people who worked with it when it really did suck (perhaps it still does, I dunno) are gonna remember that and hate it.

rntz··on Curry-Howard, the Ontological Ultimate
Fair point.
rntz··on Curry-Howard, the Ontological Ultimate
No, you don't. But the question at hand isn't using a dynamically vs. a statically typed language, it is, given that you are in a statically typed language, is a Java-style one sufficient?

Indeed, this is one of the benefits of dynamically typed languages: you're not restricted to any particular type discipline; you don't have to worry that the type system of the language you're in is too restrictive.

OTOH, if you want it to be easy to write reusable code, having static typeclasses with type inference can be quite useful. You could write a monad transformer stack in a dynamically typed language, but you can't always write code that's generic across any monad without explicitly passing around an object that represents the monad in question. (Racket's "units" might be a reasonable solution to this problem, though.)

rntz··on Curry-Howard, the Ontological Ultimate
Parsing, at least, absolutely can benefit from a powerful type system: consider Haskell's Parsec library, which uses monads & monad transformers to express a powerful parser combinator system.
rntz··on Curry-Howard, the Ontological Ultimate
This comment by Matthias Felleisen's is a very polite and well-considered position from an academic on the dynamically-typed side of the spectrum: http://existentialtype.wordpress.com/2014/04/21/bellman-conf...

Harper himself can't be relied on to be so cordial, unfortunately.

rntz··on Refactoring Ruby with Monads
`#and_then` is the monadic bind operation `>>=`; applicatives don't have this operation in general.
rntz··on Building a better and more diverse community
> Why don't you group humans into 'suffered lots of disadvantage', 'suffered a medium amount', 'suffered none'.

First, how does one directly measure disadvantage suffered? It's not a trivial thing to do. Hacker School doesn't have a lot of resources. Measuring race/gender/etc. is easy and correlates strongly with disadvantage. It's also a hard measure to "game" or fake.

Second, race/gender/etc. problems are (as pointed out) systemic in our society and in programmer culture specifically. That is to say, there are cultural habits, assumptions, attitudes, institutions, etc. which disadvantage people for no other reason than being nonwhite/nonmale. One thing that is enormously helpful in fixing these kinds of problems is simply having more nonwhite/nonmale people in the culture.

Helping a person who was disadvantaged by a mere quirk of fate helps only them. Helping someone disadvantaged by their race or sex helps them and helps everyone like them, in the long run. It reduces stereotype threat; it wears away at unfortunate cultural assumptions and attitudes; it provides positive role models; etc. etc.

Third, and most speculatively, I think these are the kind of problems that an organization like HS is particularly well-positioned to tackle. I believe that (e.g.) simple poverty and other forms of "brute disadvantage" are serious problems in our society (and indeed there still are some lingering class prejudices against poor people, so it's not an entirely "brute" disadvantage either). But I don't think that HS is likely to substantially help these problems by, say, merely offering grants to poor people. Poverty is too big, too general a problem to solve that way. But racism and sexism in programmer culture is a problem where HS actually has a shot at making a (small) difference.

rntz··on Speak up
It's not relevant what it's intended to do, but what it does. If it makes long conversations hard, that's a con. (OTOH, if it avoids heated exchange, that's a pro. I don't really have a strong position one way or the other.)
rntz··on Intuitive hygienic macros (2009)
The article is about a macro system that gives you hygiene by default but allows you to capture when you want it.

I'm not using a mature blogging platform.

rntz··on Intuitive hygienic macros (2009)
Article author here. I don't actually remember why I found syntax-rules confusing, although I can make a couple of guesses:

1. Doing simple things with syntax-rules is simple, and that's most of what you use syntax-rules for, but it is actually possible to do very powerful things with it (Oleg Kiselyov has done terrifying things with it, for example). However, doing this is rather involved and complex.

2. Perhaps I preferred the conceptual simplicity of the lisp model that "a macro is just a function that returns an s-expression". syntax-rules is "yet another language" to learn (albeit a very simple one), while macros just reuse the lisp functions you already know.

I hadn't seen Chicken's "implicit-renaming macros" until now, so thanks for the link!

rntz··on Intuitive hygienic macros (2009)
I published it on 2009-03-03. Dates are listed at http://www.rntz.net/index.html but not in the articles themselves; I guess maybe I should fix that (not sure where a good place to put the date would be).

I don't feel that separate function/value namespaces really solves the problem of hygiene. It just makes it less likely to come up in practice. It's an 80% solution: pragmatic but unsatisfying.

rntz··on Option and Null in Dynamic Languages
Yes, that is what I meant. And yeah, it is weird behavior. (I think of "d[k] = v" as "setting the key k to the value v", so that's why I said "setting a key". Perhaps "binding a key" would be clearer?)
rntz··on Option and Null in Dynamic Languages
I list Common Lisp & its behavior in Appendix C at the end of the article. Multiple-return-value is definitely better than just returning NIL, but I still dislike it; it doesn't actively prevent you from confusing NIL with absence, so "the obvious way to do it" can still be the wrong way. A good CL programmer won't fall into this trap, but the article is in large part about how some languages/interfaces default you into good programming by requiring you to distinguish success from failure, and others don't.

Another way of seeing the same thing is: Type-theoretically speaking, MRV is using a product type (two values) to emulate a sum type (one value of two possible forms); why not just use a sum type?

rntz··on Option and Null in Dynamic Languages
Author of the article here. The Python solution using lists-as-options is actually even simpler:

    def values_in(keys, d):
        return [x for key in keys for x in getOpt(d,key)]
Using lists as options is a neat trick I hadn't thought of when writing the article. Unfortunately, no dynamic language uses this idiom (or really any other non-exception option-like patterns) natively.
rntz··on With 'The Machine,' HP May Have Invented a New Kind of Computer
The article mentions that

> Fink has assigned one team to develop the open-source Machine OS, which will assume the availability of a high-speed, constant memory store.

I have to ask: if this is open-source, where is it? Perhaps my google-fu is weak, but I can't find anything but news articles talking about "The Machine".

EDIT: Aha, found mention in some articles that it "will be made" open source. Future tense. That makes more sense.

rntz··on My Conversation with “Eugene Goostman”
In Turing's original paper, the Test is intended to be a "new form" of the question "can machines think?". It is explicitly a test of the machine's intelligence, not of humans'.
rntz··on Thinking in Types
Could you explain what you mean here by initial/final encoding, and why you say OO favors final encodings but initial encodings generate type information? I'm familiar with the notions of initial algebra, and slightly less so with final coalgebras, but I don't quite see what you're getting at.
rntz··on Webservers shouldn't have direct access to keys
This proposal is very similar to Plan 9's "factotum" scheme (see http://qedragon.livejournal.com/99938.html for a nice explanation with reference to Heartbleed; factotum is similar to a generic ssh-agent or gss-proxy), except proposing that the daemon run as a separate user, which is a reasonable extra layer of security that deals with some remote-code exploits.
← PreviousPage 11 of 15Next →