sharkbrainguy

Joined 18 years ago

Karma
402
Submissions
140
Member since
Jun 23
I'm a developer, animator, standup comedian in New Zealand.

http://www.gerardpaapu.com/

[email protected]

View on Hacker News

Recent submissions

Comment · 13 years ago
Comment · 13 years ago
Comment · 13 years ago
Comment · 13 years ago
I think you've excluded the middle here, (#1.5 perhaps) one who thinks that your code is worthless/dangerous and does not call you a loser.

It can be true that a piece of software is a poor replacement for an existing tool.

It can be true that recommending it as a replacement for that tool is dangerous.

You can make these judgements about a piece of software without an incident like this happening. What's important here, is how you behave once you've made these judgements.

Comment · 13 years ago
I don't think a critique of the code in question is especially relevant to the main point of the article, i.e. the practice of mocking open-source projects.

Debating the technical merits of this particular project can't really address that.

Comment · 14 years ago
If you're after a standard library for Javascript, you could do worse than including es5-shim. Which has the advantage of being a library that (partially) implements a standard: Ecmascript 5.

    > es5-shim.js and es5-shim.min.js monkey-patch a
    > JavaScript context to contain all EcmaScript 5
    > methods that can be faithfully emulated with a
    > legacy JavaScript engine.
It provides Array::map, Array::filter, Array::reduce as defined in Ecmascript 5 along with String::trim and others, as well as replacing buggy implementations.

Previous versions of es5-shim included shims for things that cannot be correctly or completely shimmed in ES3 but those have since been separated and I now recommend including es5-shim in basically all web projects to get closer to a modern javascript in most browsers.

Comment · 14 years ago
Clearly jQuery isn't providing a lot of the things they are looking for in a standard library, as it is focussed on DOM manipulation and Ruby.js attempts to provide core types like Enumerables and Time.
Comment · 14 years ago
You can achieve the same effect without using eval, which his many known problems in terms of security and performance.

        function render(tpl,data){
            function lookup (obj, keys) {
                return (keys.length === 0) ? obj
                :  lookup(obj[keys[0]], keys.slice(1));
            }

            var matches = tpl.match(/\{[^\}]+\}/g),
                max = matches.length,
                i, rep, keys;

            for (i = 0; i < max; i++) {
                keys = matches[i].slice(1, -1).split('.');
                rep = lookup(data, keys);
                tpl = tpl.replace(matches[i],rep);
            }

            return tpl;
        }

        alert(render("{a} is all that i've {b.a} {b.b} {b.c}", {
            a: "this",
            b: {
                a: "ever",
                b: "really",
                c: "needed"
            } 
        }));
Comment · 14 years ago
No, Javascript is not "just scheme" with a few bad design decisions. They have significant differences.

Scheme has:

  call-with-current-continuation http://people.csail.mit.edu/jaffer/r4rs_8.html#IDX509
  Tail Call Optimisation
  A numeric tower http://people.csail.mit.edu/jaffer/r4rs_8.html#SEC50
  A Code/Data equivalence and therefore macros
  Ports
Javascript has:

  Prototypal inheritance
  Every 'object' is mutable bag of string indexed properties
There's a pile of differences, even just at the semantic level before you get into the syntax or the equivalence semantics.

I understand that if you take a specific subset of javascript, you can write code as-though it has some scheme semantics (minus call/cc and TCO), but that's true to a similar extent of any language with lexical scope, closures and anonymous functions.

Comment · 14 years ago
I have the same reaction,

because I prefer this:

    Q: "How much will lunch cost?"
    A: "$20"
To this:

    Q: "How much will lunch cost?"
    A: "Either $0 or $200"
Comment · 15 years ago
Comment · 15 years ago
Pandoc does that already http://johnmacfarlane.net/pandoc/

Pandoc is written in haskell but there's c bindings to it https://github.com/toyvo/libpandoc so you can use it from anywhere.

Comment · 15 years ago
I would also love an invite: @gmail.com

edit: Invite Received! Email redacted! Thanks alot

Comment · 15 years ago
Here's javascript, the other languages are left as an exercise.

    function Kitten(width, height, color) {
        var img, g, w, h;

        w = parseInt(width,  10);
        h = parseInt(height, 10);
        g = color ? "" : "g/";
        img = document.createElement('img');
        img.src = "http://placekitten.com/" + g + w + "/" + h;
        img.width = w;
        img.height = h;

        return img;
    };

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton