Hacker News new | past | comments | ask | show | jobs | submit login
JScript (wikipedia.org)
15 points by _yoqn on Aug 29, 2021 | hide | past | favorite | 18 comments

One cool thing we’ve lost in browsers today is the ability to switch between scripting languages. Old IE versions let you use JScript or VBScript by mentioning the language as an attribute in the script tag. And it actually worked: you could mix different languages on the same HTML page (not necessarily a good idea but great flexibility).

Imagine if we could specify JavaScript or TypeScript in the script tag for today’s browsers?

well that was only possible in IE, because IE used the Active Scripting https://en.wikipedia.org/wiki/Active_Scripting tech, which meant that any scripting languages that implemented the Active Scripting interfaces could be used in IE, and also WScript (https://en.wikipedia.org/wiki/Windows_Script_Host).

In the implementations part of the wikipedia page https://en.wikipedia.org/wiki/Active_Scripting#Implementatio... you can see there were a number of available scripting languages for use on IE. For some reason it doesn't mention the ones from ActiveState - the current ActiveState python doesn't seem to be Active Scripting enabled but back when this technology was useful it was - maybe it just provided the python version mentioned on the wikipedia page with some extras though.

on edit: added missing word.

It's also a great way to fragment the ecosystem. Firefox supports micropython, Chrome supports TypeScript, Safari supports a subset of AppleScript, and suddenly a page working depends on browser and OS again. JS is a painful least common denominator that still varies too much, but at least it mostly is a common denominator.

Edit: That said, maybe webassembly is a way forward.

Imagine a world where Brendan Eich had said "I can't do a good job in two weeks, just embed Python".


"Vugu: A modern UI library for Go+WebAssembly"

> Imagine if we could specify JavaScript or TypeScript in the script tag for today’s browsers?

JavaScript really should follow Python’s lead here and allow but ignore type annotations. I believe TC39 already reserved the lexical space for it.

In theory this was nice, but having actually dealt with it in production IE had all sorts of weird bugs with it. Mixing JScript & VBScript (much less PerlScript!) in ASP was even worse, the order of execution of the different language blocks was not specified and could change in a point release or even between installations. In practice both in the browser and on the server Microsoft's multiple language support wasn't really suited to mixing them.

But ASP pages have nothing to do with IE the browser since that was a server-side technology. I mixed JScript and VBScript without problems for a long time in an application I maintained.

Theoretically it could still be done, but by doing so you completely break compatibility with any browser which doesn't support it; I'm pretty sure no non-Trident-based browser ever supported VBScript. Unless some other scripting language gains wide acceptance somehow, I'll be sticking with plain ol' JavaScript for the foreseeable future.

> JScript supports conditional compilation, which allows a programmer to selectively execute code within block comments.

I found this bit to be of particular interest. Why would anyone want to selectively execute code within a comment block? That seems to me to be a Bad Idea™

Early method of making the script run one way in IE and another way in a different browser, also had some predefined variables for handling versions and whatnot. You may remember the same feature but for HTML: <!--[if IE 6]>

Obviously modern HTML tags with fallbacks, @supports in CSS, and proper feature detection instead of hardcoding are the better approach nowadays since everyone finally agreed to follow the standards reasonably closely and you don't need version specific hacks rather just checks that something is supported.

Okay that definitely makes more sense. I use those IE conditional comments to this day in email templates (for Outlook).

You know you have a problem when you need to alter web standards in order to let programmers get around your alterations of web standards.

As a new HTML coder back in the day these conditional comments were really odd to me. Thankfully we don't have to deal with that much anymore although IE 11 is still out there, lurking.

C supports conditional compilation, where it's great for supporting multiple architectures and operating systems.

well sometimes people want to selectively run code in a dev instead of a prod environment. I wouldn't say it's a bad idea, it is a possibility we sometimes need that it would be preferable that we did not need and we should try to get away from needing quickly if we find ourselves in that situation.

I still support this in one of my applications alongside its twin VBScript. It's becoming difficult now though as a lot of the Microsoft documentation on Active Scripting is disappearing.

To me, JScript has always been and will always be nothing more than “that thing that tries and fails to execute when I double-click a JS file on a new system.”

don't forget J++

R.I.P JScript.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact