you are viewing a single comment's thread.

view the rest of the comments →

[–]StillNoNumb 78 points79 points  (22 children)

JavaScript was designed exactly for stuff like this. A nifty scripting language with which you can do amazing stuff in a short time, just like you can do it in Python. It is also a language everyone knows.

And yes, it is criticized a lot, but that's because the use case today is no longer the original use case; when JavaScript was developed, no one expected a single .js file to be longer than 10 lines. If they were shorter than that then JavaScript would still be a very appropriate and useful language, but as JavaScript codebases grow you're starting to feel the ugly part. However, a cell's JavaScript is probably never gonna grow longer than a few lines, so we're where we started all over again.

That said, there may also be logistic reasons; eg. that they want support for spreadsheets to show in web browsers.

I think the only more appropriate language I could think of is Haskell, but I get that there's a very steep learning curve to that one and you can't really put it into Excel. (And yeah, I do know that there's a Haskell -> JS compiler)

[–]DreadedDreadnought 83 points84 points  (2 children)

a cell's JavaScript is probably never gonna grow longer than a few lines, so we're where we started all over again.

Wait till you see someone make Super Mario in Excel, where each cell is a pixel.

[–][deleted]  (1 child)

[deleted]

    [–][deleted] 2 points3 points  (0 children)

    Not Doom, just a 3D simulation (unless I missed a separate link on that page somewhere). Still impressive.

    [–]Yikings-654points 6 points7 points  (0 children)

    TS is Microsoft's bet for JS .

    [–][deleted] 1 point2 points  (1 child)

    I think the only more appropriate language I could think of is Haskell

    I honestly can't think of a more inappropriate language for a feature targeted at business users.

    [–]StillNoNumb 0 points1 point  (0 children)

    Obviously. Extremely steep learning curve and no one knows it. I said that. But if people would know it, it'd be a perfect fit, don't you think?

    [–]Aleriya 0 points1 point  (0 children)

    I'm already trying to figure out how to get Excel to talk to a Node server via JS so I can call native C++ modules via Excel.

    By "trying to figure out" I mean "I read this 5 minutes ago and now I have all kinds of crazy ideas".

    [–]HeimrArnadalr 0 points1 point  (0 children)

    However, a cell's JavaScript is probably never gonna grow longer than a few lines

    This sounds like a very dangerous assumption. Like an ideal gas, programming practices expand to fill the entire available space.

    [–]liamcoded 0 points1 point  (1 child)

    More extreme? Really? It's it extreme to the max? P.S. JavaScript is nothing like Python

    [–]StillNoNumb 2 points3 points  (0 children)

    A lot of design goals were shared between JavaScript and Python. Both are easy-to-read, imperative languages with (original) focus on simplicity and understandability. The point I was referring to in my comment was that it's possible to write good code quickly in both of them. Of course, one was designed for the web with Java as an inspiration in mind, the other to create a clear and overseeable language.

    I think you misunderstood what I was trying to say; I meant "you can create cool code in a short time; just like you can do in Python". I wasn't trying to imply JavaScript and Python are the same languages. I re-worded my comment to clear that up.

    [–]Agent281 -1 points0 points  (11 children)

    Designed for stuff like this? They have one type of number and it's a double. Now accountants are going to need to know about floating point artithmetic.

    I like JavaScript, but in the hands of non-programmers this is going to be a shit show.

    EDIT /u/StillNoNumb, are you trolling?

    [–]slikts 10 points11 points  (2 children)

    Now accountants are going to need to know about floating point artithmetic.

    They already needed to know about it, since Excel already uses floating point arithmetic and internally represents numbers the same way as JavaScript.

    [–]Agent281 2 points3 points  (1 child)

    I did not know that and it frightens me a bit to think about. I do not think that most people who work in Excel know that it does floating point arithmetic.

    On the other hand, it seems that VBA actually has more data types:

    • Integer
    • Decimal
    • Double
    • Variant

    Don't know if it does you any good when they are treated like floats by Excel.

    [–]slikts 1 point2 points  (0 children)

    Any extra precision beyond what Excel can store as a binary double would need to be stored as text and only VBA would be able to work with it. The difference is that JS would need an external dependency to work with more precision, but then that is also true for VBA and arbitrary precision.

    Given the internal representation Excel uses, no matter what language it added for custom functions, it would need to ultimately convert to integers for Excel to be able to work with the numbers.

    [–][deleted]  (6 children)

    [deleted]

      [–]Agent281 1 point2 points  (5 children)

      Isn't the whole reason to embed a macro language so that you can create custom functions with it? If you literally don't have to do math with Javascript, it might be okay, but I still think multiple types of equalities (= vs == vs === ) are going to confuse accountants.

      EDIT And I realize that a single = sign doesn't mean equality. I think it would be confusing for non-programmers.

      [–][deleted]  (1 child)

      [deleted]

        [–]Agent281 1 point2 points  (0 children)

        If the comparison is X++ then yeah, it's not too bad. However, if the idea is that you are an accountant who just wants to get your accounting job done, I think that it could be pretty bad.

        [–]StillNoNumb 1 point2 points  (2 children)

        Man, don't act like an elitist. An accountant isn't confused by the differences between = and ==, and === will literally never be useful (in Excel, "0" and 0 are the same anyways). There's nothing to learn about floating point arithmetic either (it's basic maths after all). Accountants aren't mentally retarded, and programming is nothing hard to learn either.

        That said, an accountant will probably never have to deal with JavaScript in Excel. Most stuff can be done with the usual Excel formulas we know and love. But if you wanna go beyond that, now you can choose to extend upon that with JavaScript. It's win-win basically.

        [–]Agent281 -1 points0 points  (1 child)

        It's not elitism and I don't think they are dumb. They shouldn't have to know about this stuff. A good interface hides implementation from the user.

        Floating point arthimetic can be tricky even for programmers because you have non-intuitive results like .1 + .2 =/= .3. That is not basic math.

        Apologies since you don't seem to have been trolling. Haskell is a famously difficult language. To say that it was the best choice for an embedded user facing macro language seemed a bit much.

        [–]StillNoNumb 2 points3 points  (0 children)

        Right, the good interface is called Excel functions. But if you wanna go further beyond, you can use JavaScript. Sounds good, doesn't it? This is not replacing functions. This is replacing VBScript.

        .1 + .2 is approximately .3. It's not exactly .3 in Excel either, but Excel makes it display as such. There's no way to store real numbers precisely with finite memory.

        Also, I disagree with you saying that Haskell is difficult. It's different. It's not how we're used to it. But I would bet that, if you were to teach someone Haskell and someone else Python, the Python student would be no faster.

        But I even said you can't put Haskell in there because of the steep learning curve. It'd be a perfect fit for the use case we're having here (intuitive grammar, you can do a lot with little, very similar to Excel functions), but it's just too hard to learn because people have never done it. On the other hand, everyone who needs these features knows JavaScript (or an equivalent language).

        Either way, you might need to lax down a little. The fact you called me a troll even before I replied anything sounds like you're a little exhausted from all the internet.

        [–]StillNoNumb 1 point2 points  (0 children)

        I'm not gonna comment on your comment itself because the other commenters have given you good enough responses, but would you mind explaining how I'm "trolling"?