4 ms·
The reactive programming language one is really interesting. A compiler ought to be able to compile "normal" straight-line code into conventional efficient code
by jerf 4y ago
The reactive programming language one is really interesting. A compiler ought to be able to compile "normal" straight-line code into conventional efficient code. It's hard to know how that sort of thing would "pollute" the rest of the code, though, like, will every program turn into a rat's nest of dependencies such that it's just impossible to manage or what? Hard to tell without trying, especially since developing such a language would also require significant effort into developing a standard library and best practices to go with it even if the language was in hand today. And one hell of a debugger. Circular dependencies are a problem, too; I'm inclined to ban them but that's probably beyond what a type system can help you with, or at least, any type system I currently know, so it's going to be an adventure.
Still, there's a lot of things that would be more useful with such a language. In-memory highly-correct cache invalidation would become trivial code to write. In fact I think the cache would actually update itself live. Out-of-memory cache invalidation might be pretty easy. Certain auditing things would be easy. UIs would probably take some work to get right but would be interesting, at the very least. Game programming would also be interesting; a lot of game patterns would be incorporated into the language at that point.
Probably need to be lazy; I suspect proactively recalculating everything all the time would be a bad idea. Haskell has pushed lazy programming a long way, but "re-thunkifying" a previously calculated cell would be a new frontier.
Come to think of it, while I think the performance could be improved and you'd want to lift up to a full language eventually, I think a good Haskell programmer could bash together a prototype of this in a few days and start playing with it. It's going to need a lot of playing with before someone casts it into concrete as a language specification and corresponding compiler and runtime.
- cmontella 4y agoI'm attempting to build such a language (you can find a link in my profile if you're interested. I don't want too much attention yet since I'm planning on a first release later in the year). You're right it can become difficult to follow code when it's not presented in a linear fashion. The flip side though is that you can write code in smaller chunks that can do a lot, so you write far fewer lines overall. The other thing is that it opens the door to more advanced tooling than we're used to as developers: things like time travel debugging, saving program state and querying it, or running hypothetical execution paths to find the best one. Bret Victor is famous for demoing prototypes of these debugging tools in one of his talks, and they are finally becoming real. My language turns out to be very fun to write UIs and games in, so I'm glad you honed in on those two examples. Actually one way to view it is that it's a programming language with a game engine as a runtime. But robotics is the primary application I'm targeting. In fact I had to choose between lazy and eager evaluation, and I've chosen eager because I want latency guarantees. With a lazy evaluation scheme, I was unsatisfied with the windup that would occur in some situations that would totally blow performance. And we don't have to recalculate everything all the time; we only have to recalculate the paths that have an input change. This may lead to recalculating everything, but most of the time we only have to focus on the execution path that is "dirtied" by the updated input. Anyway if you want to test drive such a language as you're imagining, send me an email and I'll give you a tour/demo. The language isn't really user-friendly yet so there are some pointy edges that make it unusable to new users at this time (which is the main reason I don't want more attention on it until that is resolved.)
- JonChesterfield 4y agoYou might like optimistic evaluation for this. Once you've got a thunk, send it into a thread pool. When you need the result, it's either been handled in the background already or you compute it on demand (and ideally cancel the in progress copy).
- imaltont 4y agoI think the Lisps, and especially Common Lisp, in addition to Smalltalk gives you a lot of the things you mention here. That interactive development environment where you can compile any code at any time is almost a given in these, with example programs such as GNU Emacs and Nyxt, that can be reprogrammed on the fly in release mode too. It is pretty interesting to look at and play with, if you fire up something like Emacs + Slime/Sly and SBCL for Common Lisp or the bundled IDE for a Smalltalk such as Squeak or Pharo.
- martinflack 4y agoSpecifically, for reactive "spreadsheet-like" code in Lisp, Kenny Tilton's Cells project comes to mind: https://github.com/kennytilton/cells https://github.com/kennytilton/cells
- alan-crowe 4y agoThe reactive programming idea reminded me of Ken Tilton and "Cells", which exploits the flexibility of CLOS (the Common Lisp Object System) to create a reactive programming language on top of Common Lisp. https://github.com/kennytilton/cells https://github.com/kennytilton/cells and he has slides from a talk https://github.com/kennytilton/cells/blob/main/Lisp-NYC-2018-02v1.pdf https://github.com/kennytilton/cells/blob/main/Lisp-NYC-2018... to give context.
- rwmj 4y agoThe reactive language was how I thought Mathematica notebooks should work when I first encountered them, and I was very disappointed to find out they don't. Maybe there's a Jupyter extension to do it?
- leowbattle 4y agoI don't know much about Mathematica but doesn't Dynamic work a bit like that?
- nerdponx 4y agoThe Julia notebook called Pluto.jl is reactive! But unfortunately is otherwise very limited compared to Jupyter Lab. Reactivity in Jupyter would probably have to be provided by the kernel, not by the Lab frontend.
- conductr 4y agoOP's Excel example made me think of Power Fx and the Power Fx Host https://powerapps.microsoft.com/en-us/blog/power-fx-open-source-now-available/#:~:text=your%20turn https://powerapps.microsoft.com/en-us/blog/power-fx-open-sou... https://github.com/microsoft/power-fx-host-samples/tree/main/Samples/ConsoleREPL https://github.com/microsoft/power-fx-host-samples/tree/main...
- asiachick 4y agoMy experience with reactive systems is they work well for small projects but once the data gets large the overhead of being reactive kills perf.
- yencabulator 4y agoFor what it's worth, Svelte https://svelte.dev/ https://svelte.dev/ is a Javascript-to-javascript compiler that adds reactive statements to the language (by using the $ label): $: b = a + 1 Since it's a compiler, it knows what inputs were used in that statement, and what outputs were mutated. The statement is re-run every time its inputs change. This is then used to make a web development environment where "react to input changing" is much more natural than with e.g. React.
- aidos 4y agoMobx works fairly well like this and in our case we use it for the UI where it works well. At the centre you have your pure data and then a bunch of transformations on the way out to your interface (eg, you have a list of all cars, but you have a computed function of all cars available for sale sorted by price). Then at the top, only stuff that’s actually currently used for rendering needs to be computed at keep hot.