News for hackers. Stuff that matters.
Re:JavaScript Conquered the Web, Now It’s Taking Over the De... by qwer on Monday September 12, 2016 @04:37PM (#12483417)
DSLs are actually common in javascript. JQuery, one of the most popular libraries in all of javascript is mostly a DSL for DOM manipulation. Lodash/underscore is mostly a DSL for list manipulation.

Admittedly, JS doesn't have operator overloading, but I personally think that's a good thing.

Re:JavaScript Conquered the Web, Now It’s Taking Over the De... by falcolas on Tuesday September 13, 2016 @11:14AM (#12488970)
We apparently have a very different definition of DSLs. Both jQuery and Lodash are, to me, libraries with lots of functions. A DSL, to me, would be a change in the underlying language being interpreted.

i.e.

    describe file("foo") do
      it { should exist }
      it { should be_owned_by "root" }
    end
vs.

    _.map(["a"], function(s) {alert(s)})
Re:JavaScript Conquered the Web, Now It’s Taking Over the De... by spion on Tuesday September 13, 2016 @11:33AM (#12489158)

  describe("something", () => {
    it(should(exist))
    it(should(be_owned_by, "root"))
  });
Also

  _.map(["a"], s => alert(s))
Or just

  _.map(["a"], alert)
Re:JavaScript Conquered the Web, Now It’s Taking Over the De... by qwer on Wednesday September 14, 2016 @01:25AM (#12494412)
Except your rspec example isn't a change to the underlying language is it? Also, Check out mocha for the JavaScript equivalent.

Also, when you use only one function of lodash, you can't call it a language, but there are chains and flows for creating powerful pipelines for collection processing.

Re:JavaScript Conquered the Web, Now It’s Taking Over the De... by goatlover on Monday September 12, 2016 @05:22PM (#12483806)
Operator overloading in Python made the Pandas library possible where you can treat a DataFrame syntactically like you can in R, which is really nice for data science.
Re:JavaScript Conquered the Web, Now It’s Taking Over the De... by qwer on Monday September 12, 2016 @06:39PM (#12484256)
"Made it possible", or "made it look like R"? add() vs. + is just a mild inconvenience IMO compared to the inconvenience of overloading abuse that I normally see ( like sqlalchemy IMO). I'd personally rather know what to expect from an operator.
Re:JavaScript Conquered the Web, Now It’s Taking Over the De... by goatlover on Monday September 12, 2016 @07:27PM (#12484503)
Also, it adds up (no pun intended). You're right that add() vs. + for a simple case when you only do it a few times is no big deal. But it is a bigger deal when you do it a lot, and the arithmetic can be a little more complicated.

We could by analogy apply this argument to adding integers and floats together. It's more convenient to use the + operator for that, but someone could argue that an add() function is just a minor inconvenience, so why bother overloading the + operator?

That is until you have to use it hundreds of times.

Re:JavaScript Conquered the Web, Now It’s Taking Over the De... by goatlover on Monday September 12, 2016 @07:19PM (#12484445)
It's not just arithmetic, it's also being able to use comparison operators to filter, which is really convenient. What languages like R do at the syntactic level is make the programming language closer to math, where you can do things like add vectors or multiply matrices using simple operators.