Live data from Hacker News

A Javascript journey with only six characters

jazcash.com

41–50 of 123 posts

Re: A Javascript journey with only six characters

#42
post #41
post #36

The article does not explain how it gets the {}, which is used to get the Object constructor string. Other than that it's very clear.

It does, see the "fill" step: «So now we have acquired the following extra characters: c,o,v,(,),{,[,],}, .».

Those characters are only inside a string, not as executable code.

Re: A Javascript journey with only six characters

#44
post #33
post #32

Earlier quoted context omitted.

For what it's worth, Brendan Eich is a joke for technical reasons as well, like creating JavaScript.

That's un-called for.

I don't like him because he's fat.

http://a.abcnews.com/images/Social_Climber/GTY_brendon_eich_...

No other reason.

I just can't support the immoral glutton lifestyle.

Re: A Javascript journey with only six characters

#45
post #42
post #41

Earlier quoted context omitted.

It does, see the "fill" step: «So now we have acquired the following extra characters: c,o,v,(,),{,[,],}, .».

Those characters are only inside a string, not as executable code.

But you can execute strings...as it says in the article.

Re: A Javascript journey with only six characters

#46

This is an extreme demonstration of the validity of a delightfully snarky blog post by Robert Harper on how dynamic typing is actually static typing using a unitype: https://existentialtype.wordpress.com/2011/03/19/dynamic-lan... A string is a Boolean is a number is a function, and braindead conversions can happen without anyone noticing. How does one keep their sanity using a language like that?

What the OP takes to the extreme is a property of weak typing, not dynamic typing.

These properties are separate issues. A language is either statically typed or dynamically typed, and it is also either strongly typed or weakly typed.

In a statically typed language, types are attached to variables. In a dynamically typed language, types are attached to values. Do note that many languages don't fit 100% into either category. (Note that the blog post you linked to calls types attached to values classes, but that distinction often isn't made so clearly.)

A weakly typed language performs implicit type conversions as it deems necessary, while a strongly typed language does no implicit type conversions. Most languages don't fit 100% into either category. Usually languages that are considered to be strongly typed still allow you to add integers to floating point numbers, for example.

It is possible for a dynamically typed language to be so strongly typed that it won't do any implicit type conversion, ever. Such a language would not allow you to, say, add an integer and a floating point number without explicitly converting one to the other.

It is also possible for a statically typed language to be so weakly typed that it implicitly converts types everywhere. Such a language might do the exact same things the OP uses, like converting a function to a string of its source code when adding it to a string.

Re: A Javascript journey with only six characters

#47

It's too bad that people were willing to ostracize Brendan Eich for not being a cookie-cutter silly-valley progressive. Oculus is facing that now. It's the new mccarthyism.

It's too bad that people are willing to use their money and influence to negatively affect specific groups of people. Both Eich and Luckey made personal choices that negatively affected users of their products. As a response, these users, and people who support them, have decided to reject them.

Re: A Javascript journey with only six characters

#48
post #40

This doesn't make me want to use JS. The power of JS is in two things, it's in every major browser and it doesn't completely suck. JS syntax kind of sucks. The power in JS is that it's dynamic and lets you send functions around, but defining functions is much uglier than defining a lambda in Ruby: -> {anything goes here} or ->(a,b,c) {anything goes here} The problem with Ruby is that you then have to .() the lambda v…

ES6 lets you define functions like a => a * 2 Or (a, b, c) => a * b ^ c

That's succinct, but less clear than the Ruby version, imo, as you don't have any scope indicators required for the function body.

JS:

  let f = (a,b,c) => a * b ^ c;
  f(2,3,4);
vs. Ruby:

  f = ->(a,b,c) { a * b ^ c }
  f.(2,3,4)
Ruby's shorter and clearer. But, when you use the Ruby lambda more than once in the code, you lose the brevity advantage, because of the "extra" dot. But, in Ruby I use methods more than lambdas, which would be:

  def f(a,b,c) { a * b ^ c }
  f(2,3,4)
Post reply on HN