Hacker News new | ask | show | jobs
by dumindaxsb 1803 days ago
I honestly don’t know where this will lead. Probably all of this is just for nothing. The world has enough UI libraries already. Duh!.

I decided to make my own mini jQuery years ago because I wanted a lightweight library. Also, I wanted to stay close to the native DOM API & vanilla JavaScript. Looking back, it paid really well. Then React & Vue JS happened.

In my opinion, the reactive UI approach bought a huge productivity improvement from the perspective of the developer. Also, it enabled a lot of beginner developers to navigate the programming landscape more easily.

However, this shift also moved people away from the core stuff that’s happening under the hood. As a result, sometimes we have to struggle a lot to find solutions within the library’s limits, which are sometimes hilariously dead simple & performant to implement with native APIs.

CalDOM tries to solve this by being 100% interoperable with the native DOM. I hope this will be helpful for developers with similar requirements.

3 comments

> I honestly don’t know where this will lead.

The best approach for myself has been implementing the thing I use to some degree as a learning exercise. Not as in "production ready and feature complete" but rather as an exploration of the major mechanisms and basically playing around. It's fun!

Some library like this is going to blow up in popularity eventually. Virtual DOMs are often unnessary abstractions, Svelt introduces it's own whole compilation step, and libs like Vue, Ember, and Angular are just too big.

There is clearly a need for a lightweight (on the order of 3kb seems good) "framework" that embraces everything the modern browser lets you do as natively as possible, basically the new jQuery, or maybe more accurately the new Backbone.js.

What is the audience for this lightweight framework you have in mind? Devs supporting server-rendered sites with minimal JavaScript?

In that scenario I can understand how the build step could introduce complexity, but I'm a bit surprised to see Svelte lumped in with the others simply because it introduces a compiler. If size is a concern, it's hard to beat Svelte emitting framework-less vanilla JavaScript (whether as a complete single-page app, or as piece-meal components you sprinkle throughout a more minimal site).

My desire for such a system is driven by wanting to have a fully interactive development environment that I can work with from inside the browser. Something like the Figwheel/Clojurescript setup without all the moving parts that is accessable directly from the browser console. Svelte fails in this regard since the entire system is not available at runtime.
But Clojurescript is a JS compiler too...?

Regarding the in-browser experience, does Figwheel do something that browser extensions for React/Vue don't do? These tools allow you to inspect component state, replay events, etc. Not exactly sure how much IDE we're talking about here (for example, GitHub Codespaces comes to mind).

I guess I'm just confused at exactly who the audience is that you have in mind. What you're describing here sounds like the opposite of a minimal, native-friendly framework.

Clojurescript is at least available at dev time thanks to figwheel.

Vue and React do bring along the whole runtime and allow introspection, but have abstracted away the browser to a great degree.

The problems really break down like this:

Clojurescript: Doesn't run natively in the browser, requires too much tooling, interactive development during development but doesn't make it into production.

React/Vue: layer of abstraction over native browser APIs, also unacceptably large

Svelte: Not available at runtime

Flippantly, the audience is me, but I'm trying to better put into words why I want this. The idea is to get closer to the experience of developing CL with SLIME/Emacs, where you really are poking around on an active living system. I find that form of development to be the most productive, and it seems like the browser + inspector console is a great potential place for such development with the right set of libs. I want a library that is fully available at run time yet small enough that you can send it into production. And I want to to fully embrace web standards for good or ill rather than try and fix the web via layers of abstraction. Last, I want it to have a very minimal surface area so the whole thing fits in your head, think something like Backbone.js where you could read the whole things annotated code in a day and wrap your head around it.

I appreciate your replies, you've helped me at least try and better refine what I'm thinking of.

No problem, glad I could help - that does clarify where you're coming from. Interestingly, when Brendan Eich was creating JavaScript, he actually intended to make it more like Scheme before his supervisors pushed him to make the syntax more like Java. So I think your thought process is inline with his original intentions.

When you say minimal surface area and "whole thing fits in your head," I can't help but think of the Alpine.js API. Although I'm still mixed on how I feel about Alpine, I can't deny how beautifully simple the API & docs are for it.

I also wonder whether web assembly could play a part in what you're suggesting. It's a part of the web platform, would potentially help with providing robust in-browser tooling... even the S-expressions of human-readable .wat files look rather Lisp-like, albeit too low-level for most frontend work. But I don't know wasm that well, just thinking out loud.

Petit-vue, from vue's author, addresses this already. No virtual dom, weigth a few kb.
You either

* write stateful UIs (native, jQuery)

* have a Virtual DOM (React, Vue)

* use a template language that is JIT or AOT compiled (Angular, Svelte)

Those are your choices.

I swear React has rotted the brains of a generation of web developers. We've been keeping state out of the DOM with POJsOs before there even were popular frameworks.
If only there was a reactive handlebar
https://ractive.js.org/ ?

(A predecessor to Svelte)

Ember
Some good points, especially about framework abstractions sometimes turning certain otherwise trivial things into hilariously overcomplicated piles of "why".

Good luck with your lib.

Thank you! :)