locci's comments

locci | 14 years ago | on: Functional Programming Doesn't Work (and what to do about it)

The same argument could be made about structured programming: "Why should I restrict my programs to have one entry point, one exit point and a single flow?"

The answer is "Because it helps you to manage complexity in the long run".

To continue the "just add a simple global" analogy: after a while you add another, then you peek from a completely different function inside the global variable, modify it if the day is odd and soon you have made a mess of your program. In this case globals are simply a patch to an outdated design.

"It [all the restrictions] says a lot about what functional programming isn’t (it has no assignment, no side effects, no flow of control) but not much about what it is. The functional programmer sounds rather like a mediæval monk, denying himself the pleasures of life in the hope that it will make him virtuous. To those more interested in material benefits, these “advantages” are totally unconvincing."[1]

But the new kinds of glue functional programming brings about are usually worth the squeeze (for some kind of programs in some kind of situations, maybe).

[1] http://www.cse.chalmers.se/~rjmh/Papers/whyfp.pdf

locci | 14 years ago | on: Bruce Eckel on JavaScript

FWIW, javascript implementations all behave very similarly surprisingly. There are some quirks of course, like JScript not accepting trailing commas, not allowing array like access to strings and leaking out the names of named function expressions, or like some nastiness in IE behaviour with the global object and window.

Especially considering the history of javascript, it's a miracle we're having it this good. Not so much with the DOOM.

locci | 14 years ago | on: Ask HN: What's your most-used function that you wrote yourself?

I completely agree with you, but I would use "foo === undefined" for locals and "this/window.foo === undefined" for globals. You can also test for "== null", if you don't care for null values.

Of course due to a bug in the old (v3) spec, you could redefine the builtin undefined as well as some other builtins like NaN and Infinity, but you shouldn't really be doing that and the spec at least is now fixed.

In the meanwhile, to fight that, this is a commonly used pattern for browsers: (function(window,undefined) {

// code //

})(this);

locci | 14 years ago | on: JSON users: Avoid CSRFs by not using top-level arrays

Because [] is not syntactic sugar for new Array. The code the article wrote about doesn't work in any implementation that I know of. I think the ESv3 spec wasn't very clear: "Create a new array as if by the expression new Array()." But the implementations (always?) did the right thing, and the ESv5 spec is more clear: it adds "where Array is the standard built-in constructor with that name."

locci | 15 years ago | on: Peacetime CEO/Wartime CEO

While I agree that Facebook is commonly perceived as "star which smart people gravitate towards nowadays", I really fail to see why that is.

Did suddenly all the techies buy in the "social" buzzword? I don't really think so: what infrastructural and, in general, technical challenges would Facebook be facing which aren't faced at Google too?

I tend to perceive Google as the technical innovator, bringing magic (1 gB email??? watching the world from above??? and free???) to the real world, whereas Facebook, despite it's cool API and Cassandra, is just vendor lock in.

But I digress: maybe the problem is that Google's already solved the problem leaving no space for new ideas?

Why would Facebook appeal more smart techies?

page 2