跪拜 Guibai
← All articles
Frontend · JavaScript · Windows

Fun's Declarative UI Runs on Windows 95 via a 1996 IE3 Control

By Funlang ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

This demo proves that a 2026 language can still drive a UI through a 1996 browser control, with no Chromium or Node in sight. The architectural pattern, attributes as directives and event delegation, later became the basis of z-data, a library that runs in modern browsers at 8KB.

Summary

On Windows 95 OSR2 (4.00.1111), the Fun language's lib-ui.fun builds a Form that wraps a Win32 window around an embedded IE3 WebBrowser control. The UI is written in HTML and CSS, parsed by IE3's 1996-era DOM, while events from the browser are routed back into Fun objects. A working demo, a random password generator, shows the pattern: fun:data binds a Fun variable to an input's value, fun:click and fun:key trigger Fun methods, and JScript's Fun.call invokes a native window title change through COM and user32.dll.

The binding system in lib-bind.fun works at event granularity, not keystroke granularity. Bind scans document.all during beforeShow, registers elements with fun:data, and runs Save before clicks and Load after clicks. This is a deliberate compromise because IE3 lacks reliable input events. fun:key translates Win32 key codes (F-keys, Ctrl+letter, Alt+letter) into named commands that map to methods on the Fun object, allowing a single button to respond to six different input combinations.

The article clarifies what this setup is not: no virtual DOM, no dependency tracking, and the old IE DOM (document.all, srcElement, getAttribute with a case-insensitive flag). These limitations trace to the host control, not Fun itself; the same code runs on Windows 11's MSHTML WebBrowser control. The pattern is also the direct precursor to z-data, an 8KB JavaScript library that adopts the same attribute-directive, event-delegation, minimal-runtime philosophy, now hosted in browsers via WebSocket bridges instead of COM.

Takeaways
— Windows 95 OSR2 ships with IE3; Fun's Form embeds its WebBrowser control inside a native Win32 window.
— The password generator demo runs as a single .fun file; Body() returns HTML, Style() returns CSS, and Show() writes a full page via Doc.write().
— fun:data="password,r" binds the Form variable password to the input's value, with r marking read-only; Bind syncs only before and after clicks and hotkeys, not on keystrokes.
— fun:click="Get" uses event delegation: a document-level handler reads the attribute from srcElement and calls the matching method on the Fun object.
— fun:key="Ctrl-R, &R, R, Ctrl-5, F5" maps six key combinations to the same Get method; DoHotKey translates Win32 keyCode values into names.
— JScript in the page calls Fun.call('SetCaption', this.value) over COM, which routes through the Fun interpreter and FFI to user32.dll's SetWindowText, using ANSI code page strings.
— The same code runs on Windows 11's MSHTML control, so the dependency is on IE's WebBrowser control, not on the 1995 OS.
— The fun:data/fun:click/fun:key pattern is the precursor to z-data, an 8KB JavaScript library that uses attributes as directives and events directly on the DOM without a virtual DOM.
— The full runtime is about 300KB with no Chromium, Node, or npm.
— The article identifies five architectural pieces that modern frameworks also use: native window, HTML rendering, property binding, event delegation, and cross-language callbacks.
Conclusions

Running a 2026 language on a 1996 browser control is a deliberate stress test for the Fun language's FFI and COM bridge; it shows the same five-tier architecture works across a 30-year gap.

The decision to synchronize data on clicks rather than keystrokes is a candid admission that even a modern language can't fix a host DOM that lacks input events, so the abstraction adapts to the platform's limits.

The fact that the same code runs on Windows 11's MSHTML control means the Win95 demo is not about nostalgia; it's about the longevity of a COM-based embedding interface.

Describing z-data as a 'precursor' rather than a successor reframes the Win95 work as a proof of concept that later hardened into a real library, not just a throwaway hack.

Concepts & terms
WebBrowser control
An ActiveX/COM component that embeds a full IE rendering engine into any Win32 application. In Win95, it's IE3, and it can be used to render HTML and execute JScript inside a native window.
COM (Component Object Model)
Microsoft's inter-process communication and object-sharing binary standard. Fun exposes itself to the IE3 control as a COM property, letting JScript call back into Fun code via window.external.
FFI (Foreign Function Interface)
A mechanism for one programming language to call functions written in another, typically native code. Fun uses FFI to invoke user32.dll's SetWindowText.
Event delegation
Attaching a single event listener to a common ancestor rather than each element, then using the event's target to decide which handler to invoke. The article notes this pattern was already possible in the 1996 IE3 DOM.
z-data
A minimal JavaScript data-binding library (~8KB) that uses HTML attributes as directives and event attributes as triggers, with no virtual DOM; it evolved from the fun:data/fun:click/fun:key pattern shown here.
From the discussion
Featured comments
组合搭配函数

Running your own language on Win95's native IE is genuinely fun, and the tinkering energy is maxed out. A single fun.js can run it, and the approach is both wild and clean.

See top comments, translated →
Source: juejin.cn ↗ Google Translate ↗ Backup ↗