r/javascript • • Apr 16 '24

JavaScript Signals standard proposal

https://github.com/proposal-signals/proposal-signals
6 Upvotes

19 comments sorted by

4

u/tony_bradley91 Apr 16 '24

This would be pretty gross feature creep into the language- codifying MVVM into the spec.

I get a similar pit in my stomach at any mention of JSX being added to the standard.

This really should stay in user land

1

u/fagnerbrack Apr 17 '24

JSX shouldn’t be JavaScript, it should be an HTTP media type sibling to HTML rendered by the BROWSERS not some shitty slow JS code or hacked server components that talk via some cryptic JSON assembly

5

u/anonymous_sentinelae Apr 16 '24

Stop spamming this bullshit

2

u/fagnerbrack Apr 17 '24

U mad bro?

5

u/fagnerbrack Apr 16 '24

If you want a TL;DR:

This proposal introduces signals to JavaScript, aiming for a common direction akin to Promises/A+, focusing on ecosystem alignment for potential standardization. Originating from collaborations among authors of frameworks like Angular, Vue, and React, it seeks to define core semantics rather than developer-facing APIs, intending signals for underlying framework construction rather than direct application use. Early prototyping and integration into frameworks are planned before progressing beyond Stage 1, emphasizing suitability and benefits over existing framework-provided signals. Signals aim to simplify UI state management, offering an infrastructure for efficient state synchronization without the repetitive boilerplate, demonstrating potential through examples contrasting traditional JavaScript with proposed signals usage. The document outlines interoperability, performance, dev tools support, and standard library benefits as motivations, with an extensive API sketch provided for further development.

If you don't like the summary, just downvote and I'll try to delete the comment eventually 👍

Click here for more info, I read all comments

-1

u/[deleted] Apr 16 '24

Cool idea! Since you're aiming for ECMAScript, make sure it's a JavaScript polyfill. All of the polyfill's source code files are TypeScript files (`*.ts`). It looks like you've done some but not all of the conversion in the repo. Just wanted to point it out though.

1

u/acemarke Apr 16 '24

Like any other meaningful library, the polyfill is written in TS, and then compiled and built to JS files during the publishing step:

1

u/[deleted] Apr 16 '24

Righto, another reason not to trust the proposal in my opinion. If you cannot write ECMAScript standardized javascript, and instead rely on a transpiler, you should not be modifying the standard.

0

u/acemarke Apr 16 '24

Um... that seems like a pretty confusing statement.

All meaningful modern JS ecosystem libraries are written in TypeScript, for type safety. For that matter, it's fairly common to not do much in the way of "transpiling" in the sense of "converting the JS syntax to an older backwards-compatible equivalent" - it's just about stripping out the types at publish time.

But either way, that has no bearing on the validity of the proposal for a new data type to be considered for adding to the language. The polyfill is being written as a library to prove out concepts and API definitions. Long-term, that may get added internal to the engine side. But until then, it makes sense to write that library like you would any other JS-ecosystem library: using TypeScript for correct types and to work well with the rest of the ecosystem that expects TS types to be available when you use that library.

1

u/jessepence Apr 16 '24

Lol, I really appreciate your positive attitude, but you're a little off-base here. This dude doesn't actually do anything of importance himself. He just spams all the programming subreddits with his AI gibberish.

Look at who owns the repository. This is as official as it gets. It's a collective effort with major contributions from the Angular, Wiz, Solid, Svelte, Ember, and Vue teams.

Also, if this hasn't been enough of a wake-up call, TypeScript is a first class citizen in the JS world these days. It's a pretty critical part of the EcmaScript process with all stage 3 proposals being implemented in TS first.

1

u/[deleted] Apr 16 '24

TypeScript is definitely not a first class citizen. It's a proprietary Microsoft library meant to hold the hands of C#, .NET, and Java devs when they begin working in a dynamically typed language such as JavaScript in the name of making it "easier to work with" instead of actually learning how to read and write JavaScript.

0

u/jessepence Apr 16 '24

Cool story, bro. I think you slightly misspelled "Ah, I see how I was mistaken! Thank you for correcting me. I suppose that maybe I don't know better than the actual members of TC39 about the current state of JavaScript, so perhaps I shouldn't act like some grand arbiter of the language."

Have a good day! 🙂

1

u/[deleted] Apr 16 '24 edited Apr 16 '24

I wasn't mistaken, this proposal has no legs. Next time don't assume the TC39 members know the problem they are "solving" when it's just more syntactic sugar bloating the language. This sort of logic is why we have frameworks. It doesn't belong in the Lang. The "arbiters" should know better, but they obviously don't care.

1

u/iTouchTheSky Apr 16 '24

Now we just wait for it to be shared again in 1 week or so

1

u/fagnerbrack Apr 17 '24

Or complain with Reddit so they bring back the freaking warning on duplicates

2

u/shgysk8zer0 Apr 16 '24

I'm familiar with the proposal since before it advanced to stage 1. Seems pretty useful for a specific set of things that many devs don't worry about unless they're working on a framework or are thinking like engineers (basically thinking about complexity and efficiency). But the proposal is basically a way of momoization and lazy evaluation... Which can be pretty awesome when you need it.

For example, let's suppose you had a simple one for some URL and a derived one (I forget the term... "computed"?) for a response upon fetch()ing that URL. This would allow reuse of the same response up until the URL is changed.... Almost magically!

0

u/definitive_solutions Apr 16 '24

So we'd be finally getting a global state in JS? I hate feature creep in languages but frankly I think this is long overdue. It has my complete support 💪

1

u/fagnerbrack Apr 17 '24

Not a “global state” for everything but yeah for UI, sure. JS already has a global state for everything but not a structured access to it.

1

u/definitive_solutions Apr 17 '24

Yeah, it has global memory access, but not a coherent API to work it. You're correct. One usually has to roll out their own implementation and that's cumbersome.