News for hackers. Stuff that matters.
Re:An Object is not a Hash by ender7 on Tuesday October 09, 2012 @02:17AM (#4630249)
The people waiting for the programming community to suddenly wake up and realize how wrong they were about Javascript all these years remind me of all the people still waiting for Castro to die.

By the time it happens, it won't actually mean anything because something else, something equally despised and impure will have taken its place.

Perhaps a better question might be why are such languages more popular than their more ideologically pure cousins? What need are they filling that "better" languages cannot? Be careful if your answer is "they're beginner's tools for mediocre programmers" -- the JS community is home to some extremely talented programmers who are all there by choice alone.

Re:An Object is not a Hash by blub on Tuesday October 09, 2012 @03:04AM (#4630352)
Trying to make one's tools better is always worth it. Typescript is to me the most exciting thing to have happened to JS, better than all the so called libraries that have to be declared inside a function (!!) so that the scope doesn't get completely screwed up.

The JS community is not an argument for JS I feel, because it does not have a track record of providing reliable software. Most libraries are new and a lot of devs are very lax with security or code robustness. If you use a library/tool you're not sure what you're getting - see the semicolon situation or the npm directory deletion.

Re:An Object is not a Hash by lloeki on Tuesday October 09, 2012 @04:47AM (#4630581)
> the so called libraries that have to be declared inside a function (!!)

This scope trick (and really, the whole JS language situation) always reminded me of the "closures vs. objects" koan:

http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/m...

Re:An Object is not a Hash by Avshalom on Tuesday October 09, 2012 @08:51AM (#4631203)
as a note this works in JS too.

  var mariner= {};

  mariner.new = function(){
      var self = {};
      var maxhp = 200;
      var hp = maxhp;
      
      self.heal = function(deltahp) {
          if (hp + deltahp < maxhp){
              hp = hp + deltahp;
          } else {
              hp = maxhp;
          }
      }
      self.sethp = function(newhp) {
          if (newhp < maxhp){
              hp = newhp;
          } else {
              hp = maxhp;
          }
      }
      self.gethp = function(){
          return hp;
      }
      
      return self; 
  }

  var m1 = mariner.new();
  m1.sethp(100);
  m1.heal(13);
  alert(m1.gethp());
(shamelessly stolen from http://lua-users.org/wiki/ObjectOrientationClosureApproach)
Re:An Object is not a Hash by lmm on Tuesday October 09, 2012 @05:56AM (#4630740)
I think JS is in a unique position because of its availability in the browser. Sadly I can't see any good way to get languages I like into the browser.
Re:An Object is not a Hash by tincholio on Tuesday October 09, 2012 @08:11AM (#4631054)
>why are such languages more popular than their more ideologically pure cousins?

That has a pretty simple answer, it's because it was the only language available in the browser (and no, Java applets never really took off).

Had it been Ruby (unlikely given the timeline) or Python or even Perl instead, the situation would probably be much better today.

Re:An Object is not a Hash by acdha on Tuesday October 09, 2012 @11:55AM (#4632240)
Or, alternately, we'd all be griping about still having to use Python 1.x until people stopped using IE. It's only been the last year or so that you could start thinking about sufficiently large percentages of your users to be running current browsers.