WelsonJS: Build a Windows app on the Windows built-in JavaScript engine
github.comI saw a partial example, but not clear instructions on how to bootstrap a project. Did I miss it in the README? Or should it be obvious to me if I have some XYZ experience?
I have updated the README with the details on this. Thank you. :)
Quite amazing solution. From the .hta file you can see it was inspired by VBScript (whose most popular software is ILOVEYOU I guess).
It looks like the ultimate hack, but why not ? It's very creative and the intention is good as well: TypeScript/JavaScript is a very popular language. Though C#.NET is great as well.
It could make sense in the very long-term that Microsoft themselves explore this possibility.
Ultimately "TypeScript.NET or JavaScript.NET"
Look up WinJS sometime! It was a really neat idea that MS sadly abandoned.
+1 - that was a really cool idea that I really was hopeful would take off.
What about just straight jscript?
This stuff pre-dates .NET and quite honestly I think that’s what m$ was going for in those early days. VBScript was pretty annoying and dealing with COM objects sucked badly. Back in the day we’d build in a local VB interop with JavaScript so we could make system calls and interact with native Windows stuffs. This predates JSON so at the time we’d use XmlHttpRpc to talk to remote/hosted services.
I’ll double down on the urge to drop TypeScript. That pile of nonsense came from the classic OOP folks - “But where are my TYPEs!? How do I know what type that variable is!?” (first the Java/C++ folks then the .NET folks “solved” the brain fuzz around functional programming and dynamic types by giving you TypeScript)
Having been out of the m$ ecosystem for some time, I’m kinda surprised HTAs are still around, I’m guessing to avoid breaking things. Once .NET started taking off - I always assumed that would replace the VBScript side of things and let you build proper, elegant system interfaces for your JavaScript app. I really imagined the goal was to drop Windows forms/object controls - but I always imagined BATTLES at m$ over being able to create Windows “apps” that didn’t conform to native UI controls, couldn’t be controlled through Windows theming engines, etc. kinduva brand control battle. I always imagined some team going “NOOO, just build a web app, you’re breaking all the UI rules!!!”
> “But where are my TYPEs!? How do I know what type that variable is!?”
Someone clearly hasn’t worked in any sort of sizable code base. Come back when you are writing something spanning hundreds of JS files and where it takes you three times the time to verify that any small change isn’t a typo or wrong type off from a runtime error. TS heavily speeds up the development cycle by bringing an entire class of errors from runtime to compile time and that has nothing to do with OO and inheritance.
Simply put, TS is an infinitely better and safer language to develop in and it took the web world by storm for a reason. People didn’t decide to switch en masse for shits and giggles and you should realize that just because you have a different view does not mean that everyone else around you is wrong.
> m$
Seriously? It’s 2024, and we’re all adults. This does nothing but water down your point.
Before anyone gets the wild idea to use this, beware HTAs, VBScript, etc. are slated for removal from Windows around 2027.
HTAs are tied to MSHTML.dll (the old IE renderer) and WSH/CScript is tied to the old, slow IE javascript engine, right?
I would expect this to have very limited compatibility, and even with the transpiling, very limited performance. Or is it possible for this to somehow use Chakra, or Edge's V8 engine?
Yes, the Chakra mode is also built-in. This is because Chakra (not ChakraCore) is an engine embedded in Windows. However, it has not been thoroughly tested.
Despite being down on all the extras, I wanna reiterate - I do think this is a cool project and I dig that HTAs are still around.
Been doing this since 1999. The only thing novel I see here is the transpilers - but you know… you don’t need that. You can build HTAs with native JavaScript, CSS and HTML - and with a little VBScript mixin, directly work with Windows libs. Back in ‘99 and early 00’s I was delivering “thin-client” control panels & management tools for server farms, sensitive accounting data, among a variety of other things. It was (and likely still is) a great way to provide a web interface as a desktop app for scenarios where exposing the management interface to the open web is undesirable.
Nifty project, but IMHO the world is better off using native JavaScript without all the BS that comes with TypeScript, etc. JavaScript is so powerful and amazing, it’s a bummer to hamstring your app by using TypeScript and classic OO inheritance models that preclude the beauty and dynamics of JavaScript as a functional, prototypal language.
I think you are conflating ES6 classes with TypeScript.
Static/strong typing is not necessary in JS.
Yes, ES6 brings the OOPiness
That’s just like your opinion, man.
Just because you think that doesn’t mean it’s true. The sheer fact that TS has overtaken JS for the majority of web development says enough.
> TS has overtaken JS for the majority of web development
Has it? Or is that "just like your opinion, man"? Any citation? There's some sources that say it's more popular based on things like social mentions, etc, but that's a vanity metric. Perhaps the statement is true if you mean "web development" to be a very limited scope (like SPA using a build step), but I'm not even sure that's true then.
For new, modern projects, yes. Very much so. There is practically no reason to choose JS over TS, even for high performance projects where every byte counts and you may want stricter control over the transpilation. The ecosystem has grown to the point where other optimizations like tree shaking do far more, and the improvement in the local dev cycle is insurmountable between the two.
Obviously this doesn't apply to existing projects; you're grandfathered into the language barring a pretty big undertaking to move over, but if you go to any competent company doing modern web development on relatively new codebases, they will use TS over JS.
And if they don't, as an engineer, you should ask hard questions as to why not. Because if the answer is someone stuck in the early 2000s complaining about OO and strong typing not being needed, then that's completely missing what TS does (and especially what it did when it was released, which was pre-ES5) and how big of an impact it has to speeding up development.
I'm sorry... high performance JavaScript/Typescript?
I don’t think your comment could be interpreted as anything other than snarky and rhetorical.
Nevertheless, it is of course very well known that efficient code in JavaScript will never run as fast as in a language such as C, but choice of language is a trade off, and in whatever language you choose you may also choose to be as “high performance” as possible within it even if it’s still not as performant than if you’d chosen a different language.
> JavaScript is so powerful and amazing, it’s a bummer to hamstring your app by using TypeScript and classic OO inheritance models that preclude the beauty and dynamics of JavaScript as a functional, prototypal language.
The idea that Microsoft was attempting to turn JS into an object oriented C# clone was a very common objection in the early days of TS (especially since one of the lead developers on the project is also the primary architect of C#). That objection ended up being completely false. TS aims to type check the full gamut of existing JS, and embraces all of the language's quirks and idioms. There are people doing serious functional programming in TS with libraries like fp-ts and effect (which is basically the TS version of Scala's Zio). If this is your primary objection I would give TS a second look.
The problem i see is basicLly, youre doing forced TDD, and thats a inherent cost in quickly developing and deploying apps at the small scale where JS excels.
Ita clearly great for large orgs and interchangeable devs.
I actually use TS as a way to avoid bothering with TDD. Many of the proponents of TDD are using dynamically typed languages, and need tests to verify every tiny little assertion about their code. I remember Eric Elliot had a bunch of posts on Medium years ago denouncing TS and claiming that TDD (and testing in general) obviates the need for types.
I'll accept that there are some intelligent developers out there that are more productive without static type checking, but I personally don't understand it. If you don't have a tool analyzing your program's types, then your brain becomes the type checker. I personally would much rather focus on higher level problems. I don't even see type checking and code formatting as human level concerns anymore, and would rather have my computer do it for me, but I guess it's just a preference. Do whatever works for you.
> it’s a bummer to hamstring your app by using TypeScript and classic OO inheritance models that preclude the beauty and dynamics of JavaScript as a functional, prototypal language.
I think you have outdated view of TypeScript. Using generics and conditional types you can model the "beauty and dynamics" pretty well, without any OO pattern (if you wish so).
TS compiles down to JS, so there's no hamstringing involved. Beyond that, you don't have to use Class at all with TS, you can stay functional and the inheritance models are exactly the same as TS runs in a JS engine.
Is being a "prototypal language" not an "OO inheritance model"?
Firstly, it’s functional with closures… From there prototypal - so you can express whatever you want… the key is being functional. This was a key to the advent of JSON, but is also one of the most elegant and powerful bits of JS
You're wrong. The prototypical model of JS was inspired by the Self programming language[0], itself a descendant of Smalltalk. It is a very crude implementation for sure, but it is object programming nevertheless. Closures being present sours the purity a bit, but closures are poor man's objects[1] anyway.
Also, Smalltalk was heavily inspired by LISP[0]. The line between functional and object-oriented is quite blurry. Especially in a pure OO language like Smalltalk. The dynamic and prototypical model of JS is definitely another example of the subtle harmony of functional and OO.
I agree 100%. I firmly hold the belief that the two paradigms are just different perspectives of looking at the same thing (state and behavior). Also see https://insearchofsecrets.com/2014/08/04/lisp-smalltalk-and-...
The amount of people that think they know better in the comments is insane. TS warriors, give us a break.
> TS warriors
Ugh. Well if you will start spouting nonsense about JavaScript being better without Typescript then you can hardly be surprised when people correct you can you?
Would you complain about "airbag warriors" or "gps warriors" if you were making comments about how driving a car without them was so much better and GPS and airbags are BS?
> without all the BS that comes with TypeScript, etc. JavaScript is so powerful and amazing, it’s a bummer to hamstring your app by using TypeScript and classic OO inheritance models
Typescript is no more OO than JS is. Typescript is simply a way to document, and optionally compile time enforce, what fields objects have and what objects methods/functions take in and return.
That is all TS does. It documents what is already there so you don't make typos on field names.
Lately I'm writing a project w/o typescript and I spent an hour finding a bug the boiled down to "tilewidth" vs "tileWidth". (The code didn't explode until much later when a computed value didn't exist)
That is the type of bug TS prevents from ever happening.
> That is the type of bug TS prevents from ever happening.
A linter would do the same, way better and faster.
> using native JavaScript without all the BS that comes with TypeScript
do you think javascript was just too easy and people had to invent some bs to make it more interesting for no reason? You don't even know what you're talking about when you make the connection from ts to oop.
My experience comming into javascript is that it's a garbage language and the web stack was a joke, everything was hard for the wrong reason (css centering things kinda stuff)
All these modern tooling, though complicated, is not new in NORMAL programming and makes sense, so you cow boys learn to deal with it.
I think, based on many battles, a lot of folks in the early days that came from Java/C++ absolutely struggled with the key concepts of JavaScript, couldn’t find “features” (like strong typing) they claimed were critical for writing good software and invented ways to make the language fit their paradigm, rather than really deep dive into the language and embrace it. There were constant battles back then - and I’m sure the battles continue.
JS was certainly never a “garbage” language but the elegance is unappealing/unappreciated by entire classes of developers. I totally get the perspective, but it’s all based on a worldview that just doesn’t get functional programming
I've enjoyed vanilla JS since forever, and currently work in a TS shop, and FWIW I think you're waaaay off base. There may have been times and places where TS was heavily OO, but all the TS I come into contact with is heavily functional, class-averse, immutable by default, etc.
(In face, the Java/C++/OO-types I know strongly dislike TS because it's structurally typed. TS doesn't care a jot who extends what - as long as they have the same properties it's happy. Hard to get more un-java than that.)
The real reason that TS won is simply that large teams (e.g. hundreds) cannot effectively work together on untyped JS. If you're doing a solo project, fill your boots - use JSDoc comments, sprinkle asserts around, whatever. But the webdev world at large doesn't care about Java or OO concepts, it settled on TS because huge teams can work effectively with it.
There it is… that’s the classic argument. Large teams/codebase. I totally get the appeal, but the idea this can’t be done effectively without it is nonsense. Long before TS, we had JS apps with teams of 50-100+ working across hundreds of not up to a couple thousand files - in CVS/SVN repos (ugh). I will concede that TS does help in the larger teams/codebases but - I will contend it is not necessary if your team is composed of folks that have depth of experience working without.
Certainly we had large teams using JS before TS - back in ye olde days before modules, when everyone picked or built a smallish abstraction (e.g. jquery) and built smallish unconnected things on top of it. But now that modules are mature and thousands of files can all reference each other, types are just necessary. They don't have to be declared in TS - you can get by to various extents with JSDocs or inference - but there's no benefit to doing those things, so large teams don't.
What I am saying is, across several comments you seem to be arguing that you think TS's massive popularity is partly due to its proponents liking Java or classical inheritance, or not understanding FP or closures, or something. And that's just wildly not true. And it's also not even true that the TS world particularly favors OO. If you weren't saying those things and I misunderstood, my bad!
It’s fair that there are proponents & value props beyond those early folks that came from the Java type world.
I guess I’m tainted/jaded by the early proponents and initial rationale that was absolutely tied to - “ewwww dynamic types!?! Gross, where are my strong/static types!?”. I’ve just fought that too many times - and that was a very strong argument at the inception of TS. There certainly are value props that go beyond and more to be discovered I’m sure.
I feel like MANY if not most of the devs I work with today simply use TS cause “that’s what you do these days” - but they have no clue what the “why” is and are baffled by native JS typing - and still consider JS “garbage” as a result. Bummer. In the Scala community I hear so much hate for NodeJS because it enables JS for server-side, “where it doesn’t belong” for many of these same old reasonings about typing (even with TS!?).
So yah, there’s value there, but you don’t NEED it to write large, good software. I’m clearly just jaded by the religious debates that have gone on and on - so despite their utility, I can come across very anti to the “solutions” to IMHO shitty arguments.
TS rocks so hard for doing pure functional stuff, and its support for type algebra can be an absolute blast.
I try to avoid OO now days, and TS is my go-to language for modeling problems in the functional domain!
I've worked adjacent to TS since it was a thing and I've never heard of anyone associating it with Java or classic OO or the other stuff you've brought up. Maybe it's seen that way by some other community somewhere, but not by TS users.
I mean - it's literally just JS with types! It still has closures, and still has everything about JS one can call functional. It's not some dramatically different language - it's JS, with a large category of runtime errors changed into linter errors. (And that's why people use it - not because they think "eww gross!" about something, which is a frankly silly thing to claim.)
I hear you, but am also interested in some JS libraries or techniques that fall in the elegant category.
An elegant typed one would be Structurae [0].
I imagine/would love to see a bunch of elegant non-typed ones as well.
I love functional languages but I'm not sure how JavaScript could be considered as a functional language (at least if functional means something like haskell, or elm). Functions-as-values isn't enough, otherwise Python could be called a functional language.
Classic example of comments I've heard since the 90s.
I’d strongly encourage doing a deeper dive here. Functions in JS are objects and can have their own methods/props + scope. They’re a first class citizen.
people are stupid only you, some javascript coder of all people, knows the secret of programming, spit it out in clear terms instead of making non-argument.
> couldn’t find “features” (like strong typing) they claimed were critical for writing good software
How about reasonable scoping rules?
Pre-es6 JavaScript was a nightmare of ugly hacks needed to make the language usable. that = this and {...}() All over the place.
no one said any thing about functional vs oop. Why does every vanilla js "veteran" think types === OOP and the reason we do typescript is for OOP? How about basic things like not even have a module system (before nodejs) for Christ's sake? How about doing functional programing properly, with types?
How does the complexity of CSS make JS a "garbage language"?
> the web stack was a joke
it's a comment about the thinking behind the design of the web stack including js