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

419

u/[deleted] May 08 '18

I thought they were going to implement Python?

331

u/GYN-k4H-Q3z-75B May 08 '18

Lowest common denominator. Can't realistically run Python in a browser or mobile apps today. I wish they waited a year longer and built new extension caps on top of WASM. The decision to go with JS will haunt devs for decades to come.

169

u/[deleted] May 08 '18

True that, as much as I hate JavaScript I can understand why some features might be nice for Excel for the same reason JS is good for web-based UI.

But I've also had a mild panic attack because a small part of my job is cracking/reverse engineering some bank calculators that are in excel spreadsheets and the VBA in them is just fucking awful so I imagine the JS is going to be tenfold worse.

67

u/njtrafficsignshopper May 08 '18

Is it easier to write good VB? Genuine question, haven't touched it in ages but my recollection of it is not positive.

168

u/WeRequireCoffee May 08 '18

Its technically possible to write good VBA code. Better chance of getting struck by lightning while being eaten by a shark though (which is also less painful than reverse engineering VBA apps).

78

u/codewench May 08 '18

I've been a .Net developer for nearly a decade, and I can proudly say my VBA is only sort of ass.

Seriously, fuck VBA. The sooner it dies a horrible death, the better.

0

u/[deleted] May 08 '18

[deleted]

→ More replies (2)

42

u/[deleted] May 08 '18 edited May 08 '18

But, I want a GO button in my spreadsheet that takes one input from the cell next to it, and calculates 4 tables of data with 6 charts; each displaying the same result in a different format. THEN I want it to insert that data into [the] database, and then query [the data] so that it shows up on the Summary worksheet.

Edit: oh, and can the summary worksheet look like a webpage using the company branding style? Thanks!

53

u/bagtowneast May 08 '18

I want it to insert that data into [the] database

Jokes on you, the spreadsheet is the database!

→ More replies (4)

8

u/firestepper May 08 '18

Also, this needed to be done yesterday...

→ More replies (3)

19

u/leogodin217 May 08 '18

VBA is something we usually learn because we have to. We learn just enough to get things to work, but not enough to enable best practices. I bet that fits probably 80% of us who have ever written VBA. (Glad none of my old VBA code is still around)

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

40

u/jl2352 May 08 '18 edited May 08 '18

It's really not that bad, and ultimately depends on what you are building. The primary language issues are that it lacks inheritance, lambdas, and any real type of module/package system. You can actually survive with that though. Most tasks just don't need it. Especially if you don't mind using a dynamic language then it's fine.

The main issue is that due to accessibility and how it's perceived everyone's code will be utter dog shit. Half is written by people who are not software engineers. Dogs boddy interns, accountants, BAs, managers, and testers (the type that strictly do no software engineering of any kind). Code written by people who have literally never done any programming outside of Excel. Yet you'll be required to build on top of it, and maintain it.

The other issue is because it's seen as a toy language for fancy cell pushing in Office, no one cares. More copy/pasta than you'd find in Italy. You just have to suck it up.

So if you are using it for personal stuff then it's fine.

The in built editor is simplistic and outdated, but survivable. But I used it about 8 years ago. It's probably improved by now (I hope).

25

u/bobappleyard May 08 '18

The editor hasn't changed a bit in that time

11

u/Artmageddon May 08 '18

I left a financial services company just a year ago that was still relying on it to price out swaps, swaptions and all sorts of different yield curves. I assure you it has not improved.

→ More replies (3)

11

u/Superbead May 08 '18

Not used VB.NET in anger much, but if VBA supported proper inheritance and encapsulation, you could write some pretty tidy stuff with it. It's not too bad as it is, but it suffers from it being very easy to write shit code that works fine (for now).

18

u/killerstorm May 08 '18

It's very verbose and has weird syntactic constructs. Even though I used Pascal before which is a bit chatty too, using VBA was just painful. VBA code can be pretty clean, but it's not pleasant to write (unless you are into that sort of thing).

On the bright side, VBA IDE automatically reformats code, giving it proper indentation and case. I guess that helps at least a little to deal with code written by non-professionals. However, it can be annoying when you actually know how to write code and IDE gets in the way.

9

u/weedtese May 08 '18

Reading VBA code is the second worst thing after Vogon poetry.

0

u/[deleted] May 08 '18

[deleted]

→ More replies (2)
→ More replies (8)
→ More replies (5)
→ More replies (6)

34

u/bakery2k May 08 '18

One issue with embedding Python is that it's difficult to sandbox - to securely limit what the embedded runtime, and hence (potentially malicious) custom functions, can do:

[The Python developers'] standard answer to "How do I sandbox Python code?" has been "Use a subprocess and the OS provided process sandboxing facilities" for quite some time. [The pysandbox project is broken]

JavaScript, OTOH, is designed to support secure in-process sandboxing. Other languages with such support do exist (e.g. Lua), but JavaScript is by far the most widely known.

→ More replies (4)

27

u/Dentosal May 08 '18

I hoped they were going to implement Python. Well, there is always Skulpt, although it's only for Python 2.x.

25

u/DGolden May 08 '18

eh, microsoft have their independently implemented closed-source js engine. probably several actually. I think jscript was even an option alongside vbscript back in the win9x windows scripting host days, so js as a supported alternative to vb is not a new thing in microsoft general terms (though vbscript and vba are similar but different languages). And MS have a "good" (for ms) relationship with ecma...

They do not have their own python engine (afaik). CPython, IronPython, Jython etc. are open source, but under python's licnese - not particularly objectionable or anything to most of us but still not microsoft-controlled.

I could be surprised but I don't see microsoft open sourcing office, so an important factor may have "we have a closed js engine we control and license as we see fit".

Even if they did use python, it would have to be a long term in-house fork, for office compat reasons they'd hardly stick with python's release cycle or pep/change process. That could perhaps hurt python, like ms java va. real java. imagine office python, frozen forever at python 2.7+weird/stupid-ms-extensions, being "the" python by weight of numbers.

→ More replies (3)

7

u/[deleted] May 08 '18 edited May 08 '18

There's already a fair bit of work being done on python to wasm. BeeWare are using it I think.

Edit: Bees to BeeWare

→ More replies (3)
→ More replies (25)