Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I work on a web scripting language that abstracts away asyc/await:

https://hyperscript.org/docs/#async

we call it "Async Transparency"

It lets you write code like this:

  fetch /some-url as json
  put the result's content into me
where fetch is an async call, but you don't have to await it or anything or mark it as being an async fuction, whathaveyou

effectively, we de-color the language:

https://journal.stuffwithstuff.com/2015/02/01/what-color-is-...

my feeling is that async concerns are too low level for light scripting



How would you allow running the fetches in

    fetch /some-url as json
    fetch /some-other-url as json

    do_stuff_with(result1, result2)
in parallel?


hyperscript is focused on the common cases for light front end scripting, so right now there isn't syntax for doing operations in parallel.

If I needed that I would kick out to javascript and use Promise.all() to return an expression that hyperscript could then sync on

the wheelhouse for hyperscript is stuff like:

  on load
    wait 5s
    transition my opacity to 0
    remove me
where you don't have to do any async or callback stuff for what are, at root, async operations.


I don't get it then; your fix to promises being complicated is to remove the ability to perform asynchronous actions. That's cool for a small scripting language I guess, but absolutely impractical for anything serious.


hyperscript is designed for small, embedded front end scripting needs: toggling classes, listening for events from its sister project, https://htmx.org, etc. It isn't a general purpose programming language for use, for example, on the server side in a node-like environment.

you can still perform things asynchronously by wrapping any expression or command in an `async` prefix:

https://hyperscript.org/commands/async/

but there isn't a mechanism for resolving all of them

although, now, come to think of it, the following would work:

  set results to {result1: somethingThatReturnsAPromise(), result2: somethingElseThatReturnsAPromise()}
That would work out because under the covers the hyperscript runtime calls a Promise.all() on those field values before it continues. Kind of a hack, but it would work.

Anyway, again, hyperscript is a DSL targeted at small front end scripting needs rather than being a large scale concurrent systems programming language.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: