matrix

awb99 2024-10-31T13:33:00.250409Z

I have Noticed two things when comparing webmx to hoplon and electric: 1. Web-mx does not have a text function. This means that static text is easier to write, but dynamic text needs to be in :content which is less understandable. 2. There is are small discrepancies such as onclick on-click.

awb99 2024-10-31T17:09:38.012309Z

Question on the "me" concept: If I understand this correctly then this allows me to query the dom-tree that is managed by web-mx. That is pretty unique concept. Is this idea coming from smalltalk? What usecases did you find for this that are useful when writing Apps? I guess it allows me to do cell calculations that depend on cells of Parents or siblings. It is unique and I feel it allows to do crazy stuff. But I have no IDE what it could be. And then I have a questio nto the second map argument. So there basically the me cells are being defined. What I find curios is that a map is not guaranteed to have keys in any order. There exist SortedMaps for that requirement. I would have thought that one Has to do a topological sort to be Sure before building a model. But your code does not do that. So I guess clojurescript map when put to the reader is parsed always from top down.

kennytilton 2024-10-31T17:15:29.064589Z

"Is this idea coming from smalltalk?" Yes, me is like self in ST, ot this in JS. It is a lexical variable supplied by many macros, bound to the object that owns the Cell. Yes, it is very handy, especially because 'me' objects know their parents and their children. This means any Cell can see the entire universe, benefitting from the natural scoping of the app structure itself. eg, duplicates by name resolve naturally to the one nearest me, the one we want 99% of the time. A bit of code lets us find a different duplicate we might have in mind.

kennytilton 2024-10-31T17:18:21.488359Z

"What I find curios is that a map is not guaranteed to have keys in any order." Well, when I write a formula or watch function that needs the disabled? property of a widget, I just say (mget widget :disabled?). Why would we need the properties to be sorted?

kennytilton 2024-10-31T17:27:19.719609Z

Oh, I see the concern: "I would have thought that one Has to do a topological sort to be Sure before building a model." This was a message from god that Cells is correct: when a new instance is created, the very first thing we do is "awaken" it (by calling md-awaken). That just runs down every property evaluating any cells it finds (and btw calling any watch functions on a propert, cell-mediated or not). When a formula runs, it finds and evaluates needed other cells and even other models JIT, on the fly. Note that this often requires widgets to instantiate their children, just to get the desired widget! As I said, when this worked out of the box I knew Cells was Deeply Correct. Good question!

kennytilton 2024-10-31T17:35:24.458969Z

btw, the first time I implemented this I assumed that, as cool as Cells was, that this is where the wheels would come off. No way a dev could deal with getting things instantiated in the right order. In a sense, if you check out https://tilton.medium.com/the-making-of-cells-5ab873d1e6c7, that challenge is what led to the creation of Cells. The functional paradigm naturally ordered calculations, as long as we could have properties compute JIT if they had already been compuetd and cached.

awb99 2024-10-31T18:07:51.423499Z

Thanks Kenny!

awb99 2024-10-31T18:08:07.867029Z

Can you explain me how to do two thingsL

awb99 2024-10-31T18:09:47.598269Z

1. how can I get what reagent would ref to a dom element. So Inside a web-mx component, I need to be able to get the reference of a dom element, and then I can basically do watch the required properites and then run a function that updates the dom outside of webmx context.

awb99 2024-10-31T18:10:33.144909Z

I need this because I am using webgl renderers (so no dom impact other than the container), and I also use npm render libraries like highcharts that I need to say when they have to render where.

awb99 2024-10-31T18:11:09.913129Z

2. What I need to do is watch the dom elment, mainly to get its size.

kennytilton 2024-10-31T18:11:19.038339Z

I'll have to check, but I hope you just call mx-dom on the widget. 🙂

awb99 2024-10-31T18:11:51.621619Z

Because I am showing timeseries, and so I want to show each point in time in a 5 pixel spacing,

awb99 2024-10-31T18:12:02.366799Z

then if I have 500 pixel width, I know I have to request 500 rows.

awb99 2024-10-31T18:13:26.594469Z

And the onther thing I need to now is how I should manage multiple web-mx views inside a react view.

kennytilton 2024-10-31T18:13:34.060059Z

Getting the size of a dom element can be tricky if you are using a library that alters the size dynamically. MathJax made me work quite hard to get the dimensions of a math expression after it had rendered--but their API did support that!

awb99 2024-10-31T18:13:51.018759Z

https://www.npmjs.com/package/flexlayout-react

awb99 2024-10-31T18:14:07.429589Z

I use flexlayout-react, which basically allows the user to dynamically add components to a layout.

awb99 2024-10-31T18:14:25.370799Z

What flexlayout-react does, it handles resizing of components, and does show them in a layout

awb99 2024-10-31T18:14:34.958169Z

similar to how modern desktop operating systems work.

kennytilton 2024-10-31T18:15:26.676319Z

Oh, wow, MX inside a React component? That could be tough.

awb99 2024-10-31T18:15:37.592819Z

https://github.com/pink-gorilla/reagent-table

awb99 2024-10-31T18:15:48.739529Z

I will post some of my sub projects here.

awb99 2024-10-31T18:16:16.506309Z

https://github.com/pink-gorilla/dali

awb99 2024-10-31T18:16:31.672449Z

https://github.com/pink-gorilla/docs

awb99 2024-10-31T18:16:54.055779Z

https://github.com/pink-gorilla/options

awb99 2024-10-31T18:17:12.589369Z

https://github.com/pink-gorilla/reval

awb99 2024-10-31T18:17:32.943479Z

https://github.com/clojure-quant/quanta-studio

awb99 2024-10-31T18:18:11.515189Z

https://github.com/clojure-quant/quanta-market

awb99 2024-10-31T18:20:03.785979Z

https://github.com/pink-gorilla/re-flow

awb99 2024-10-31T18:20:17.341669Z

https://github.com/pink-gorilla/clj-service

awb99 2024-10-31T18:20:23.594589Z

Okay.

awb99 2024-10-31T18:20:26.032019Z

So:

awb99 2024-10-31T18:20:36.620799Z

I am exposing clojure functions via clj-service,

awb99 2024-10-31T18:20:47.295749Z

this allows to do a request-reply communication.

awb99 2024-10-31T18:21:05.582349Z

What clj-service does it exposes such functions via a http endpoint and via a websocket endpoint.

awb99 2024-10-31T18:21:14.427879Z

The trick is, that I allow also stateful functions,

awb99 2024-10-31T18:21:20.262959Z

whcih basically get their config.

awb99 2024-10-31T18:21:25.882969Z

With re-flow I can expose flows,

awb99 2024-10-31T18:21:34.362199Z

so basically an event stream to the browser.

awb99 2024-10-31T18:21:41.292339Z

This allows to do publish-subscribe,

awb99 2024-10-31T18:22:04.528039Z

I am working on a technical analysis framework called quanta-studio,

awb99 2024-10-31T18:22:13.005469Z

so the calculations mainly are done using techml dataset,

awb99 2024-10-31T18:22:31.681809Z

which allows me to do fast calculations huge vectors and matrizes.

awb99 2024-10-31T18:22:39.784069Z

I made a browser-extension for this,

awb99 2024-10-31T18:23:28.504119Z

https://github.com/clojure-quant/quanta-dag-algo

awb99 2024-10-31T18:23:46.898739Z

The clj side reactive mordel is in quanta-dag-algo.

awb99 2024-10-31T18:23:55.416839Z

There I can do specifications using edn files,

awb99 2024-10-31T18:24:07.787959Z

and this allows me to do calculations either historically as of a specific date,

awb99 2024-10-31T18:24:19.019549Z

or going forward dynamically as "real" time passes.

awb99 2024-10-31T18:24:53.736739Z

I have my own calendar module,

awb99 2024-10-31T18:25:01.800689Z

so basically I can work on different time streams.

awb99 2024-10-31T18:25:11.618669Z

The time streams power calculations.

kennytilton 2024-10-31T18:25:12.478889Z

Ah, it is called tag-dom. Better actually than mx-dom. mx- is pretty general. tag is historical, refers to HTML tags. Hey, I have to break out for the afternoon. More later, but the concern is that MX will need to extend the DOM created for the surrounding React component, and I think React likes to regenerate that on its own when it likes, Could get crazy re-potting the MX DOM.

awb99 2024-10-31T18:26:30.019679Z

Ever since I went to over 100.000 data-points per chart,

awb99 2024-10-31T18:26:39.039969Z

I had to basically keep all this data out of the dom,

awb99 2024-10-31T18:26:43.146819Z

and even out of the websocket,

awb99 2024-10-31T18:26:56.223119Z

because it would block the main communication for a little bit.

awb99 2024-10-31T18:27:12.595219Z

I want to extend this layout system,

awb99 2024-10-31T18:27:19.843559Z

so that I can also dynamically add new calculations.

awb99 2024-10-31T18:28:06.019419Z

I have an options-ui,

awb99 2024-10-31T18:28:22.088009Z

where simple options for an algo can be changed, that will then rerun algos that depend on that options.

awb99 2024-10-31T18:28:53.013419Z

What my goal is that I have a data-model, and a visual-model.

awb99 2024-10-31T18:29:11.737729Z

with data-model I mean data that is not going to be shown in the dom.

awb99 2024-10-31T18:29:19.606159Z

Like a huge table for example.

awb99 2024-10-31T18:29:27.820829Z

And the visual-model is what gets shown.

awb99 2024-10-31T18:29:59.310529Z

So from each cell in the data-model I will be able to generate new visual-model cells that then get shown in the dom.

awb99 2024-10-31T18:30:41.214199Z

So depending on the datatype and a module that will determine which vizualisations could possibly make sense for that type of data, it will then give me a dialog to show what I could want to show.

awb99 2024-10-31T18:31:18.911699Z

I think I am using reagent to the maximum possible right now.

awb99 2024-10-31T18:31:29.567659Z

And at some point I need to start replacing it with something else.

awb99 2024-10-31T18:31:52.180009Z

My goal is to have reproduceable notebooks.

awb99 2024-10-31T18:32:19.828299Z

But basically not focused on clojure forms, but multiple computations.\

awb99 2024-10-31T18:32:32.060129Z

So to me the nodes are sort of cells.

awb99 2024-10-31T18:35:24.316729Z

I have seen a system like what I am building in smalltalk at some point.

awb99 2024-10-31T18:35:29.993789Z

But I forgot how it was called.

awb99 2024-10-31T18:37:41.596849Z

I had a look at flutter yesterday, and yes its an amazing platform. But for what I want to do I fear it is too early.

awb99 2024-10-31T18:38:44.244659Z

I want to be able to arbitrarily let users define how to visualize the data.

awb99 2024-10-31T18:38:51.045929Z

So I am bringing sci interpreter as well,

awb99 2024-10-31T18:39:01.026269Z

so basically new ui can be defined with sci.

awb99 2024-10-31T18:39:18.666879Z

In its simplest form I use that to highlight a cell in a table in red if the value is negative.

awb99 2024-10-31T18:39:22.184039Z

To give an example.

awb99 2024-10-31T18:40:26.726009Z

And I do have one question:

awb99 2024-10-31T18:40:53.107569Z

missionary has included in there rendering system something, that detects is a dom node is moved somewhere else.

awb99 2024-10-31T18:41:06.788419Z

In which case it does not need to remove/add again.

awb99 2024-10-31T18:41:35.707929Z

They also sample the state 60 times a second, so they will do dom updates at that speed.

awb99 2024-10-31T18:41:48.264969Z

Have you ever found a need for something like that?

awb99 2024-10-31T18:43:43.561909Z

Since web-mx api is just a few hundred lines of code, I am thinking of doing something similar, but for server-side rendering.

awb99 2024-10-31T18:45:09.207469Z

Many thanks for helping me along!

awb99 2024-10-31T18:45:43.899249Z

I am not sure if I will start using Matrix or not.

awb99 2024-10-31T18:46:00.102369Z

I just know that my current design needs something new.

kennytilton 2024-10-31T22:24:46.558969Z

"Since web-mx api is just a few hundred lines of code,..." There ya go. You do not need MX you need missionary to work on the DOM. mx-web shows it is not that hard. The DOM is insanely well-documented at this point. Extending Missionary to handle DOM will be an order of magnitude (or two) easier thang getting MX to work inside Missionary and React.

awb99 2024-10-31T00:37:38.977649Z

I am trying to understand how matrix does its rendering. So what I figure is when you first Mount it run once and creates whatever is visible. When there is a change in a cell then this change leads to a recalc of the element that observes the cell. And then the refresh needs to have a link to the dom element and then update first the element itself and then perhaps it's children.

kennytilton 2024-10-31T16:01:52.812409Z

"And then the refresh needs to have a link to the dom element and then update first the element itself and then perhaps it's children." Correct. The MX proxy decides some property has changed. When this proxy property corresponds to a DOM property, a side-effect handler actually uses the DOM API to alter the DOM property.

kennytilton 2024-10-31T16:05:48.733029Z

"but dynamic text needs to be in :content which is less understandabl" Can't say I disagree with that, but that is how the DOM works once you get under the hood. And MX libraries, wherever they wrap another library, follow the principle "when in Rome do as Romans do". In my experience, things work better if we work with a library instead of subsituting what we might think is a better approach. Deviating can trip up on undocumented details of a library.

kennytilton 2024-10-31T16:10:45.405689Z

"There is are small discrepancies such as onclick on-click." Not sure on that one. As I said in another reply, I try to ape a library precisely. I wonder if sth scared me off that. Possibly I wanted to support authoring a widget either with a direct handler or one that lived at the MX abstraction? Sorry, I have been awayy doing Flutter for a couple of years, some things are fuzzy.

kennytilton 2024-10-31T16:12:09.484469Z

If you want help with using mxWeb I'll fire it up and get my cobwebs cleaned up.

kennytilton 2024-10-31T16:19:10.165269Z

"you could run the entire mx server side and client side you just need a websocket and an eventhandler." Well-spotted. The Algebra app is a Common Lisp app that ships JS over in XHR responses to events generated by straightforward JS event handlers. Works well, but for CLJS I thought it might be better to avoid the round trips. I guess a socket would be a bit more efficient, and avoid a problem I had where client events arrived in different order than generated. Not sure, I have not done much with WebSockets.

awb99 2024-10-31T00:42:31.587659Z

Which qould mean that you could run the entire mx server side and client side you just need a websocket and an eventhandler. Then the websocket protocol would basically have two operations: 1. Initial dom 2. Dom update. Andngoing back to the server 1. Dom event.