DEV Community

Discussion on: The Evolution of Signals in JavaScript

Collapse
 
ecyrbe profile image
ecyrbe

Hello Ryan,

Since we are in the evolution of things, i'd like to emphasize that all those javascript concepts where heavilly inspired by a pioneer c++ library : Qt

Indeed, all this is 30 years old at least. Advanced notions of signals where developped by trolltech who created Qt C++ widget library.

It's worth noting that signals in solid js are called Properties in Qt world and that Observable/Observers used to implement those Properties where called Signal/slots in Qt.

Here is a link to Qt Bound properties for the curious.

Collapse
 
richeyryan profile image
Richey Ryan • Edited

It seems like Bindable Properties were only released in QT 6 which was released in 2020. Is there some other reactive construct in QT that predates this? I'm always curious to see how these concepts have evolved over time, particularly if its in a language like C++ which is less permissive than a language like JavaScript.

Collapse
 
rajeev profile image
Rajeev J Sebastian

Signals and slots have been the cornerstone of Qt programming since atleast Qt 3 or even earlier. I moved from Wx to Qt simply to take advantage of signals and slots back in 2002 and by then it was quite well developed (used macros and a custom C++ pre processor)

Thread Thread
 
vivainio profile image
Ville M. Vainio

They are called ”signals” in Qt but they are a different thing. Qt signals are just places where you can hook callbacks, not observable values.

Thread Thread
 
rajeev profile image
Rajeev J Sebastian

In that case I would need to send a complaint to my English teacher.

Jokes aside, in Qt, signals come with values. The receiver of a signal receives the changed value.

Signals represent an observable attribute of any object in Qt, and allow to decouple the receiver from the sender.

Collapse
 
ecyrbe profile image
ecyrbe

Bindable properties where there in Qt5, Qt6 added them to lower level code.
So at minimum since 2012.

But, Properties where there since Qt 3 so 2001 and i was doing property binding whith them at the time, they where just not published with the lib, but it was a pattern known to those using Qt.

But like other have said, Xerox that pioneered ui was also doing them in the 70's

Collapse
 
boonyasukd profile image
Boonyasuk Dheeravongkit

Like I previously mentioned in Evan You's twitter thread, Observable-based reactivity is dated back to the dawn of modern GUI we know today. Back in the '70s, people at Xerox PARC created GUI with Smalltalk and introduced ValueHolder: a class that holds a mutable value and notifies its dependents whenever its value changes. Its invention came as to make their GUI interactive.

So no, Qt isn't, in any shape or form, a pioneer in this space.

AFAIK, many languages took after Smalltalk and provide Observable-based reactivity, though its use is no longer confined in UI development realm. Many languages introduce the concept as pairs: Observable/Observer, Listenable/Listener, etc.

If you like to read more on how Smalltalk approaches this subject, you can read more here.

Thread Thread
 
stojakovic99 profile image
Nikola Stojaković

In short, everything old is new again. People often keep thinking that their favorite technology / tool they use on the daily basis was the one which brought the innovation. But just like with many other things in life, timing is important too, not just the innovation.

Thread Thread
 
trusktr profile image
Joe Pea • Edited

Good timing indeed! Surplus.js showed us that signals + JSX are a great DX. Then Solid.js had a stab at it, and for various reasons, the community took off. Although reactivity isn't new, this is the first time that it landed within the JSX era of web development. React Hooks look like signals and effects, and they were keen on the DX, but the way they work isn't signals and effects.

As the article hints, Meteor Tracker is a good prior art on signals and effects history in JS (although not using the same terminology). The really magical thing about Meteor is that their "signals" and "effects" are database connected: you use variables in your frontend template, and those values can come directly from a backend DB. In many ways it is still revolutionary. What's gonna be the next revolutionary full JS stack?

Collapse
 
trusktr profile image
Joe Pea • Edited

Qt QML first appeared in 2009 (and surely was based on older ideas), and like Solid JSX is a declarative-reactive tree-defining language where when any variable in a QML expression changes (dependencies, aka Signals), the expression re-runs and that part of the tree is automatically updated. To explain with QML syntax, but hypothetically manipulating DOM objects, it looks like this:

form {
  input {
    type: "number"
    value: someValue + otherValue
  }
}
Enter fullscreen mode Exit fullscreen mode

In this hypothetical QML-to-DOM example, the expression someValue + otherValue re-runs if either variable change (much like a "controlled input" in React, Preact, Solid, etc).

Some comments have been hidden by the post's author - find out more