4 ms·
Hyperscript is an experimental scripting language designed for the web
- ksec 6y ago>hyperscript is an experimental scripting language designed for the web, inspired by HyperTalk >hyperscript is a companion project of htmx html: https://htmx.org https://htmx.org Previous Discussions Htmx – high power tools for HTML https://news.ycombinator.com/item?id=23330881 https://news.ycombinator.com/item?id=23330881 Htmx 1.0.0 Release https://news.ycombinator.com/item?id=25232719 https://news.ycombinator.com/item?id=25232719 Htmx 1.2.0 Release https://news.ycombinator.com/item?id=26128229 https://news.ycombinator.com/item?id=26128229
- mastrsushi 6y agoWhy not just make it a JS Framework? Does the world really need to learn another separate language just for making web pages?
- deleted 6y ago[deleted]
- blacktriangle 6y agoIn this case the idea that 100% of the app lives in the HTML document seems like the reason just another JS framework wouldn't accomplish their goals.
- mastrsushi 6y agoJust another framework vs just another programming language. If the project lives in HTML, it doesn't matter what language it's written in. So it would be reasonable to choose one that developers are already familiar with.
- slver 6y agoTechnically all JS also lives in the HTML document. All JS is either in HTML attributes, in HTML script blocks, or referred to from HTML script blocks. The HTML page was always the boss. There's simply no reason for what's done here. Also, reminder, one reason why we like external assets is because they don't change (as often) while the HTML document is often dynamic (and hence not cacheable).
- j4yav 6y agoI would personally love to use something other than JS for making web pages, so there is at least me.
- easton 6y ago"Why not just make it a Java Framework? Does the world really need to learn another separate language just for making web pages?" -- someone in 199x when hearing about how we were going to have JavaScript for the front-end. If you aren't writing your backend in JavaScript (and most projects aren't), then you have to learn another language anyway (until WebAssembly can sweep me off my feet, anyway), so it might as well not be JavaScript. Although hyperscript isn't production ready yet, for making things move around on a template-generated web page, JS seems to add a ton of complexity compared to something like this.
- tannhaeuser 6y agoI guess it's the other way around as in "does the world really need to learn a programming language for making plain old web pages"? Tbh I don't know if hyperscript is the answer though, adding yet another language construct (with hard-coded, opinionated semantics) into the mix when we have already HTML/SGML, CSS, and lots of microsyntax. I guess the ship has sailed when JavaScript entered the scene at which point HTML has basically stalled, but the basic vision - that regular users or at least prosumers should be able to make generic content documents without resorting to a Turing-complete language - is as old as markup languages and SGML itself. SGML with HyTime in particular is able to deliver generic or project-specific behaviors of the kind demo'd on the hyperscript page (plus much more) through extension vocabularies and HTML templating without introducing new ad-hoc syntax at all.
- drunkpotato 6y agoHappy to see HyperTalk-inspired innovation on the web! It looks cool. How did you decide what verbs and nouns to support? Also, thanks for the twinge of HyperCard nostalgia you gave me!
- recursivedoubts 6y ago:) glad to bring some joy to an old hypercard dev the verbs are largely ad-hoc, using HyperTalk as a jump off and then trying to think about how to modify the language for the DOM (e.g. CSS literals) and simplify things for script writers (e.g. async transparency)
- fouc 6y agohttps://hyperscript.org/comparison/ https://hyperscript.org/comparison/ <div _="on click transition opacity to 0 then remove me">Remove Me</div> Inspired by HyperTalk, of HyperCard fame.. hyperscript is a companion of htmx (which is the successor of intercoolerjs)
- rntksi 6y agoExamples which use "mouseover" to explain something usually forgets that we use smartphones too
- deleted 6y ago[deleted]
- yepthatsreality 6y agoHyperscript is a cool attempt at providing declaration to HTML and UI development in general. 90% of what happens in a UI is ubiquitous across software. Buttons are clicked, images are positioned. Not going to wax on, but recently spent some time on boarding a new hire. Level 1 developer. The amount of time I spend explaining things like async processes, prototypal inheritance vs class structure, how to debug anything, etc. are all problems because our documents aren’t explicit enough. I think a more declarative language (in respect to UI) that maintains simplicity will cut through the cruft of a lot Of modern JavaScript exhaustion. Very cool project from the HTMX crew.
- slver 6y ago> 90% of what happens in a UI is ubiquitous across software. Buttons are clicked, images are positioned. Thing is, there are countless fun ways to reimagine basics like "buttons are clicked, images are positioned". But that's not an app. And the long tail of everything you need in order to get from clicking buttons to a useful app is what makes a "real" language like JS (and in bigger projects TS) necessary. Unfortunately a lot of what is presented is already enabled by JS, if you don't get hung up on things like do you separate tokens with spaces or dots.
- yepthatsreality 6y agoI don’t think hyperscript disables more complex cases if you need it, but it’s just that most of the time you don’t. Most of the nuance will be in the design at the css level. Everything else is an abstraction of a form or a list.
- slver 6y agoFun 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 6y 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 6y 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 6y 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 6y 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
- cosmotic 6y agoNot the best description; that perfectly describes javascript from 1995.
- insraq 6y agoThat name is unfortunate because there's already a hyperscript: https://github.com/hyperhype/hyperscript https://github.com/hyperhype/hyperscript which is completely different (which I am quite enjoying for constructing virtual dom in pure js)
- hutrdvnj 6y agoLooks like Ruby for the frontend.
- dang 6y ago_hyperscript: A jQuery and JavaScript Alternative - https://news.ycombinator.com/item?id=26873682 https://news.ycombinator.com/item?id=26873682 - April 2021 (126 comments) also Show HN: _hyperscript – an async-transparent scripting langauge for the web - https://news.ycombinator.com/item?id=26475376 https://news.ycombinator.com/item?id=26475376 - March 2021 (3 comments)
- brundolf 6y agoI'm always interested in and supportive of novel languages (especially for the web) With that said: on click repeat until event stop add .pulse then settle remove .pulse then settle end There's a trait that you sometimes see with languages that are trying to be... very "human-readable"[1] where they do things like: 1) Remove as many "delimiting characters" as possible 2) Introduce a lot of bespoke keywords so that code reads as much "like english" as possible The thing is... this does read very much like human language, but that doesn't necessarily mean it's more readable. It's very hard to mentally decompose the above code into its parts, for one thing. What can come after "on click"? Any arbitrary code? Only a certain subset, of which "repeat" expressions (?) are one member? Can you use "add" and "remove" on anything other than CSS classes? Is ".pulse" the only "argument" being passed to add and remove, or are "then" and "settle" further arguments? Or are they special-case keywords that can come after any statement? Or only after "add" and "remove"? Why is a "then" clause needed when we're already in an imperative context? Is "settle" another keyword, or a function we're calling? I'm sure all of these questions are answered in the docs. But as a new user of the language there's going to be a much bigger learning curve compared to other languages, because you have to go through and re-learn the very most fundamental language constructs and the rules around their usage, instead of leaning on your existing knowledge (or what can be inferred based on syntax alone, because not much can be). Adding that up-front cost isn't intrinsically wrong, but it is a cost, so you've have to have a good reason for it. In a language like this, where the major value-proposition seems to be "minimum overhead to just jump in and start wiring simple UI constructs in a readable way", that cost seems to directly sabotage the main purpose of the language. And the main benefits I can see are typing fewer characters and having code read "like english". Compare this with Elm, which goes out on a similar syntactic limb (minimal punctuation, radically different syntax constructs than what people are used to (it'd be familiar to Haskellers, but alien to JS programmers, its primary market)). But in Elm's case: 1) It's a language built specifically for very large and scalable projects (that is the benefit of super-strict types and purity, after all), so there's the assumption that an up-front learning investment is worth it 2) The unusual syntax choices are, for the most part, central to achieving the language's goals at a deeper level (not just achieving a certain aesthetic) This is all speculative on my part when it comes to Hyperscript itself; I haven't tried it out myself, maybe it's not as much a problem in practice as it seems like it could be. But I feel like people often go unaware when they're introducing these sorts of costs in a new language, so I wanted to take the opportunity to raise the point for discussion. [1] This is a very loaded term, but we'll set that aside
- recursivedoubts 6y agohi there, I'm one of the developers for hyperscript some aspects of the language that HN might find interesting: * events are really easy to work with (both responding to or sending them) * there are DOM-specific literals in the langauge: https://hyperscript.org/expressions/#css https://hyperscript.org/expressions/#css * the runtime is async-transparent, so you (mostly) don't need to worry about asynchronous code (the runtime works everything out) https://hyperscript.org/docs/#async https://hyperscript.org/docs/#async * event-based control flow: https://hyperscript.org/docs/#event-control-flow https://hyperscript.org/docs/#event-control-flow * a debugger, written in hyperscript of course: https://hyperscript.org/docs/#debugging https://hyperscript.org/docs/#debugging While hyperscript is designed for small, embedded functionality like toggling classes, we are experimenting with ways to add more complex behavior with, er, behaviors: https://hyperscript.org/docs/#behaviors https://hyperscript.org/docs/#behaviors The language is very young and speculative compared with htmx, but we've been happy with how it's turned out so far...