4 ms·
Fun idea, but inline scripting only works for the simplest things. I could write my handlers inline with JS as well, but I really would rather not. Maybe a big
by slver 5y ago
Fun idea, but inline scripting only works for the simplest things. I could write my handlers inline with JS as well, but I really would rather not.
Maybe a bigger question is why not have this as a JS library, but its own language. Because it's kind of almost there (here using jQuery):
<button _="on click toggle .big-text">
Toggle the "big-text" class on me on click
</button>
<button onclick="$(this).toggleClass('big-text')">
Toggle the "big-text" class on me on click
</button>
- czechdeveloper 5y agoWith just vanilla JS, it's actually shorter, so yes. It has very limited use <button onclick="this.classList.toggle('big-text')"> Toggle the "big-text" class on me on click </button>
- recursivedoubts 5y agothe on* attributes only handle the standard DOM events, and I wanted a way to write inline handlers for the custom events fired by htmx then I realized I didn't want to deal w/ async/await or setTimeout, and off I went...
- slver 5y agoThe pattern used here: "foo then bar" is identical to JS promises, I notice. Of course, it's more elegant when you don't have to wrap it in functions. But it hardly warrants an entire language I think.
- recursivedoubts 5y agothe "then" isn't necessary: it's an optional bit of syntax taken from HyperTalk, equivalent to the optional semi-colon in javascript for async transparency the hyperscript runtime looks at the results of every expression and, if it is a promise, resolves the promise before allowing the parent expression to continue evaluating so you don't actually need to think about (or know) if an expression returns a promise or not, the runtime takes care of it for you, a very unique feature that does require a runtime. And if I'm gonna make a runtime, I'm gonna make a language too it's also slow as molasses, if you are trying to write a bitcoin miner, for example but for front end scripting, it usually doesn't matter and the convenience is worth the runtime costs at least that's the theory lets find out
- slver 5y agoIt’ll help people understand the language if you remove optional words tbh. Hypertalk is HyperTalk, but the world isn’t written in it for a reason. Good luck. Btw Lua is also implicitly async like this as well.
- recursivedoubts 5y agooh, it gets worse: not only is "then" optional, but "the" is also optional in many places: set the window's location to the target's href and note the "'s" possessive expression hyperscript is a funky language, for sure :) Can you link me to some docs on the lua's transparent concurrency model? All my searches are turning up explicit concurrency stuff. Hyperscript is unique (as far as I know) in that it resolves asynchronicity (Promises) at the expression level, without explicit syntax.
- slver 5y agoI could guess about "the". But seriously, this is much clearer: "set window location to target href" And this is even clearer: "window.location = target.href" Adding the flourishes of human language is kinda cute, It can also be useful in speech recognition when we can't help but speak like we normallt speak. But code is a written specification, and specifications benefit from being clear, succinct, and for there to be "one clear & right way" of doing something. Just my take.
- slver 5y agoRegarding Lua async-by-default execution: https://stackoverflow.com/questions/49764681/how-exactly-does-lua-asynchronous-calls-in-roblox-work https://stackoverflow.com/questions/49764681/how-exactly-doe...
- recursivedoubts 5y agohmm, the responses there make it look like lua has co-routines (which are explicit) and are async-transparent when calling C++ functions, but not generally implicit like hyperscript so, a step in the right direction, but not a fully async-transparent runtime like hyperscript thank you for the link