r/programming • • May 08 '18

Excel adds JavaScript support

https://dev.office.com/blogs/azure-machine-learning-javascript-custom-functions-and-power-bi-custom-visuals-further-expand-developers-capabilities-with-excel
2.4k Upvotes

585 comments sorted by

View all comments

125

u/HadesHimself May 08 '18

I'm not a professional programmer or anything, more of a hobbyist. Can anyone explain why the Microsoft office team has chosen for JavaScript? It seems like a strange choice to me.

So this is essentially to 'replace' VBScript. So then a language like Python would be my first choice? It's popular, has a a simple syntax. While JavaScript is a language that is often criticized and not even designed for stuff liked this. Anyone ELI5?

81

u/StillNoNumb May 08 '18 edited May 08 '18

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)

-1

u/Agent281 May 08 '18 edited May 08 '18

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?

11

u/slikts May 08 '18

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.

3

u/Agent281 May 08 '18 edited May 09 '18

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.

→ More replies (1)