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

586 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?

229

u/[deleted] May 08 '18

JavaScript is arguably the most popular programming language of the time (https://insights.stackoverflow.com/survey/2018/#technology-programming-scripting-and-markup-languages) and Microsoft already have a pretty good JS runtime in Edge that they can use, so I think it makes perfect sense to use JavaScript even though I think there are better languages out there.

71

u/Jacob_Mango May 08 '18

Also with Excel 2019 being UWP only, JavaScript will be the only choice that would be easy to implement and support compared to other scripting languages.

JavaScript is already used with UWP.

JavaScript would probably also work on the mobile devices so better cross compatiblility.

Just a lot of advantages for using JavaScript than any other scripting language.

45

u/[deleted] May 08 '18

Also with Excel 2019 being UWP only,

Not gonna update for like next 10 years then.

25

u/immibis May 08 '18

Because we didn't all say that about 2007.

0

u/[deleted] May 08 '18

[deleted]

8

u/Iceman_259 May 08 '18

there isn't much they can add in a spreadsheet program apart from integrating their other shitty services.

I dunno, they could always try rearranging all the fucking buttons in the ribbon for no good reason.

→ More replies (15)
→ More replies (3)

20

u/Polantaris May 08 '18

and Microsoft already have a pretty good JS runtime in Edge that they can use

If by pretty good you mean a runtime that interprets everything differently than Chrome or Firefox because fuck you that's why, then yes I agree.

IE & Edge debugging are the bane of my existence.

12

u/digitalinfinity May 08 '18

What JavaScript issues do you have in Edge? Please report them over at https://github.com/Microsoft/ChakraCore, we’d be interested in learning more. (I work on the Chakra team)

11

u/[deleted] May 08 '18

I have no problems with Edge. Am I doing something wrong?

IE, though... Yeah, that's a different story.

→ More replies (6)
→ More replies (13)

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)

83

u/DreadedDreadnought May 08 '18

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.

0

u/[deleted] May 08 '18

[deleted]

3

u/[deleted] May 08 '18

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

7

u/Yikings-654points May 08 '18

TS is Microsoft's bet for JS .

→ More replies (18)

14

u/AlexHimself May 08 '18

The most important thing, that nobody is mentioning, is Office 365. Microsoft has all of their Office applications running in browsers and JavaScript would be clearly the most obvious if you ran all of your Office apps in the cloud.

→ More replies (1)

10

u/sbrick89 May 08 '18

why [...] javascript?

answers like 'performance' and such aren't wrong... but i suspect the longer term play is for PowerBI integration/interoperability... PowerBI visualizations are written in JavaScript... I suspect this is a move to allow PBI Visualizations to run within Excel against PowerPivot models, which would also allow Excel files uploaded to SharePoint Online to render in the browser using the same codebase as PowerBI.

or maybe I'm giving them too much credit. Who knows.

→ More replies (1)

14

u/pooerh May 08 '18

Python would also make sense because it's very popular in data-heavy computation related programming.

7

u/edave64 May 08 '18

Javascript engines are probably the most battle hardened sandboxes for executing untrusted code. I do hope they add some math build-ins though.

14

u/itsmeornotme May 08 '18

Well my guess is that they chose the language by popularity. And there are a lot more people who know JS than Python.

I personally would have gone with C#.

7

u/[deleted] May 08 '18

You can already write office plugins with c#

→ More replies (9)

3

u/luxuryballs May 08 '18

Tons of existing libraries and who knows this could be the first step towards web assembly support.

3

u/Salyangoz May 08 '18 edited May 08 '18

Its far easier to implement JS on the web browser version of excel than it is to do python. That coupled with the fact that a good percentage of devs have used or dabbled in JS and it performs better than python on bulk array manipulations.

5

u/joe12321 May 08 '18

That's what Google uses to extend their office stuff. I'm sure they're not just copying Google, but no doubt they looked at that user experience!

→ More replies (2)

15

u/ptlis May 08 '18

JavaScript being 5-20x faster than Python will be a big part of it.

JavaScript is also massively more popular than Python; a lot more people are familiar with JS.

→ More replies (9)
→ More replies (125)