Live data from Hacker News

KindScript – A kinder JavaScript experience

github.com

11–20 of 29 posts

Re: KindScript – A kinder JavaScript experience

#11
post #8

Rather than simplify Javascript and protect beginners from themselves, why not start with a language that is both powerful and protective and yet easy to learn, like Pascal - learn the basics there in a more structured language? Lazarus is a free, cross platform IDE for Pascal and an excellent place to start: http://www.lazarus-ide.org/

There's two things to getting people into programming - giving them tools they can learn with and making them care about it. You do the second by letting them accomplish things they actually want to do. Until you can script webpages or make Minecraft mods in Pascal, it's not very good at the second half of the equation.

Re: KindScript – A kinder JavaScript experience

#12
I want a Javascript that does this right:

    var m = {};
    m["__alpha__"] = 10;
    m["__bravo__"] = 20;
    m["__proto__"] = 30;
    for(var k in m) console.log(k);
Result (in current JS):

    __alpha__
    __bravo__
EDIT: To be clear, I want a Javascript that is consistent. Imho, the fact that __proto__ is a property is a hack. Also, I suspect that a lot of software written in Javascript is susceptible to injection bugs/attacks by using the string "__proto__" as input in various places.

Re: KindScript – A kinder JavaScript experience

#13
post #12

I want a Javascript that does this right: var m = {}; m["__alpha__"] = 10; m["__bravo__"] = 20; m["__proto__"] = 30; for(var k in m) console.log(k); Result (in current JS): __alpha__ __bravo__ EDIT: To be clear, I want a Javascript that is consistent. Imho, the fact that __proto__ is a property is a hack. Also, I suspect that a lot of software written in Javascript is susceptible to injection bugs/attacks by using th…

Why would you like to add anything to the __proto__ property? One way would be to write, like this:

  {
    const m = {}

    m.__alpha__ = 10
    m.__bravo__ = 20
    m.__defineGetter__('__proto__', () => 30)
    
    Reflect.ownKeys(m).forEach(key => console.log(key))
  }
EDIT: I can't format ...

Re: KindScript – A kinder JavaScript experience

#14
post #12

I want a Javascript that does this right: var m = {}; m["__alpha__"] = 10; m["__bravo__"] = 20; m["__proto__"] = 30; for(var k in m) console.log(k); Result (in current JS): __alpha__ __bravo__ EDIT: To be clear, I want a Javascript that is consistent. Imho, the fact that __proto__ is a property is a hack. Also, I suspect that a lot of software written in Javascript is susceptible to injection bugs/attacks by using th…

Why would you like to add anything to the __proto__ property? One way would be to write, like this: { const m = {} m.__alpha__ = 10 m.__bravo__ = 20 m.__defineGetter__('__proto__', () => 30) Reflect.ownKeys(m).forEach(key => console.log(key)) } EDIT: I can't format ...

To make my point clear, here is a question. What is wrong with the following function that counts the number of unique strings in a list of strings?

    function count_unique_strings(l)
    {
        var m = {};

        l.forEach(function(s)
        {
            m[s] = true;
        });

        var count = 0;
        for(var k in m) ++count;

        return count;
    }
To see why this function is incorrect, run it with the following input:

    console.log(count_unique_strings(["alpha", "bravo", "bravo", "charlie"]));
    console.log(count_unique_strings(["alpha", "bravo", "bravo", "__proto__"]));

Re: KindScript – A kinder JavaScript experience

#15
post #11
post #8

Rather than simplify Javascript and protect beginners from themselves, why not start with a language that is both powerful and protective and yet easy to learn, like Pascal - learn the basics there in a more structured language? Lazarus is a free, cross platform IDE for Pascal and an excellent place to start: http://www.lazarus-ide.org/

There's two things to getting people into programming - giving them tools they can learn with and making them care about it. You do the second by letting them accomplish things they actually want to do. Until you can script webpages or make Minecraft mods in Pascal, it's not very good at the second half of the equation.

Precisely correct! Adding authenticity and relevance to the first major learning experience is crucial for appealing to a wide array of beginners, especially people who don't necessarily see programming as a first-order joy.

Re: KindScript – A kinder JavaScript experience

#16
post #12

I want a Javascript that does this right: var m = {}; m["__alpha__"] = 10; m["__bravo__"] = 20; m["__proto__"] = 30; for(var k in m) console.log(k); Result (in current JS): __alpha__ __bravo__ EDIT: To be clear, I want a Javascript that is consistent. Imho, the fact that __proto__ is a property is a hack. Also, I suspect that a lot of software written in Javascript is susceptible to injection bugs/attacks by using th…

var m = Object.create(null);

Problem solved.

Re: KindScript – A kinder JavaScript experience

#17
post #12

I want a Javascript that does this right: var m = {}; m["__alpha__"] = 10; m["__bravo__"] = 20; m["__proto__"] = 30; for(var k in m) console.log(k); Result (in current JS): __alpha__ __bravo__ EDIT: To be clear, I want a Javascript that is consistent. Imho, the fact that __proto__ is a property is a hack. Also, I suspect that a lot of software written in Javascript is susceptible to injection bugs/attacks by using th…

var m = Object.create(null); Problem solved.

That solution doesn't cast javascript in a positive light.

Why should you need to know that much about the guts of the language just to create an associative array that works properly?

Re: KindScript – A kinder JavaScript experience

#18
post #4

Looks like this wasn't ready to be revealed, like someone accidently made the repo public. The website is currently not public so I'm not going to try anything yet but as a co-foudner at an CS Ed-tech startup I'm going to keep my ears perked. MS has put out some really nice JS products recently.

Does that explain why the SSL cert on https://kindscript.com is for a Libyan domain? (https://yelm.tdev.ly)

Note: The https url to kindscript.com is listed on the git repo.

Re: KindScript – A kinder JavaScript experience

#19
post #12

I want a Javascript that does this right: var m = {}; m["__alpha__"] = 10; m["__bravo__"] = 20; m["__proto__"] = 30; for(var k in m) console.log(k); Result (in current JS): __alpha__ __bravo__ EDIT: To be clear, I want a Javascript that is consistent. Imho, the fact that __proto__ is a property is a hack. Also, I suspect that a lot of software written in Javascript is susceptible to injection bugs/attacks by using th…

What you want is to use is a map, not a JavaScript object. Here you go:

    const m = new Map();
    m.set("__alpha__", 10);
    m.set("__bravo__", 20);
    m.set("__proto__", 30);
    for (let k of m.keys()) {
       console.log(k);
    }

Re: KindScript – A kinder JavaScript experience

#20

Earlier quoted context omitted.

var m = Object.create(null); Problem solved.

That solution doesn't cast javascript in a positive light. Why should you need to know that much about the guts of the language just to create an associative array that works properly?

JavaScript objects aren't associative arrays. They inherit property values from their prototype. Not just __proto__, but hasOwnProperty, etc. If you want to abuse objects in this way, it makes sense that you need a special approach to opt out of inheritance.

A better approach is to just use Map.

var m = new Map();

Post reply on HN