Live data from Hacker News

VanJS – A no-JSX framework based on vanilla JavaScript

vanjs.org

121–130 of 178 posts

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#121
post #115

The author seems to be chasing the small size trophy at any cost...to the point where he's using "var" instead of "const" because it saves a few bytes. Not indicative of someone serious...

No offense. What exactly is the cost of using "var" instead of "const"? You seem to pretend it to be a big deal.

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#122

Is there a reason they compare bundle sizes with for example jquery when every framework ends up importing jquery anyways, since animations are a headache and are often readily available already with jquery?

> when every framework ends up importing jquery anyways

Evidence?

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#123
post #115

The author seems to be chasing the small size trophy at any cost...to the point where he's using "var" instead of "const" because it saves a few bytes. Not indicative of someone serious...

The author works as a back end engineer @ Google. I appreciate his "outsider" approach as it is quite a bit simpler than other UI libraries & even reactive state management libraries such as Nanostores. I'm sure if he were in a different development role, his technique would be refined to account for full stack development use cases.

I don't mean to throw any shade on Tao. He is very talented & his approach is beneficially novel. I just don't think he as much experience what life is like as a full stack (or front end) developer as many here.

I forked his work to create relementjs & rmemo. Tao didn't want to support server side reactivity & I heavily use it. Also, Andrey (maintainer of Nanostores) didn't want to add my PR for autosubscriptions due to the complexity cost that would be added to Nanostores...So I wrote my own set of libraries. I hope library simplicity trends more because it is very nice to work with simple libraries.

Tao's approach is sound. He just relies on the DOM to manage the reactive state, so SSR reactivity would require a different approach. I ended up using WeakRef, which is significantly smaller than the approach used by traditional reactive state management libraries.

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#124
post #106

Earlier quoted context omitted.

It is really an odd flex. As soon as you need a transpiler, which many modern JS devs are going to want and need for the benefits they provide (Typescript being huge) then using JSX seems a benefit not a problem to solve.

Not needing to use a transpiler is genuinely the thing that excites me most about VanJS. If you're not a daily JavaScript developer, any form of transpiler / build mechanism seems almost guaranteed to break in the gaps between when you are working on a specific project. The projects I have that are transpiler/build free are SO MUCH more pleasant for me to intermittently hack on!

Sure, I think that's a very real consideration, but if you're not a daily JS developer, I'm not sure why you'd use a function-call syntax to build up a template either. Something like Alpine.js where you just mark up your server side HTML is a lot easier than putting a bunch of logic into JS to build up a template. Or you could use lit-html or a million other things. This is an idea that's been done a million times but never catches on because it's not better than the alternatives.

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#125
post #110

Earlier quoted context omitted.

What would the alternative be? How can you design a UI without nesting things?

Too much nesting usually signals that you should decompose it to smaller components. Same as with regular code and functions — overly deep nesting screams bad code. Honestly, JSX is just a verbose way of calling functions / constructing objects, which is probably OK if it was a language of its own (XML/HTML) — and even then, JSON/YAML won over XML — but makes little sense being embedded in a language which had functi…

Well said! You got the point.

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#126
> 道可道,非常道

> (A rule that can be told by words, is not the rule that should universally apply)

I'm curious where the dev got that translation or if they made it themselves. I have translated it before like "No method that can be explained is universally applicable" but I haven't seen many other translations like that.

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#127

Earlier quoted context omitted.

It is really an odd flex. As soon as you need a transpiler, which many modern JS devs are going to want and need for the benefits they provide (Typescript being huge) then using JSX seems a benefit not a problem to solve.

JSX does seem to fit that niche better than any other alternative I've tried. It pulls off a rather remarkable trick of avoiding the "uncanny valley" that you usually get from starting with a language and contorting it to do something different. JSX manages to feel just about right: it's plain-old-HTML when you want it to be, and plain-old-Javascript when you need an out. Still... I wouldn't mind writing in a truly s…

Jsx never achieves plain-old-html in my view. is legal but
isn't.

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#128
One huge benefit to VanJS is it's simplicity. It is far easier to fork than most other UI component libraries. I did it writing relementjs & rmemo. I encourage others to fork it as well. VanJS is well written. You get a reactive state management library (on the browser side) & a UI renderer in In case anyone is interested, here are my forks.

https://github.com/relementjs/relementjs

https://github.com/rmemo/rmemo, which exports https://github.com/ctx-core/ctx-core/tree/main/rmemo. Note that rmemo also supports server side reactivity.

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#129
post #108

After reading the tutorial at https://vanjs.org/tutorial I was about to open an issue suggesting that they include constants with the SVG and MathML namespace, so that this: const {circle, path, svg} = van.tagsNS("http://www.w3.org/2000/svg") const {math, mi, mn, mo, mrow, msup} = van.tagsNS("http://www.w3.org/1998/Math/MathML") Could be expressed like this instead: const {circle, path, svg} = van.tagsNS(van.SVG) con…

Oh wow, didn't know ChatGPT could de-obfuscate code!!

It does a good job to give some analysis on malicious code snippets

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#130
post #87

I don’t know why they’re selling lack of JSX as a feature. React works without JSX too. It’s just (very convenient) syntactic sugar.

JSX is redundant, at best. VanJS demonstrated ordinary JavaScript syntax is as good as JSX, if not better. How can something feel sugar-ish if it's actually more verbose than ordinary JS code? Plus, you can't really execute JSX code in browser's developer console.

> How can something feel sugar-ish if it's actually more verbose than ordinary JS code?

I personally find XML much easier to parse than a lot of nested callbacks and I especially like that content is always inside tags, rather than another argument as part of the library's functions. p("Hello, world") is readable enough, but as soon as you start adding html attributes, it becomes less legible to me:

li(a({href: "https://vanjs.org/"}, "VanJS"))

vs.

VanJS" rel="nofollow noreferrer">https://vanjs.org/">VanJS

I'm certain some people probably prefer the former over the latter, but I much prefer how JSX/XML reads. I can immediately tell where the content starts and in formatted code, I think it's a lot easier to see visually where things start and end, because of closing tags, instead of just a parentheses.

Post reply on HN