mathstodon.xyz is one of the many independent Mastodon servers you can use to participate in the fediverse.
A Mastodon instance for maths people. We have LaTeX rendering in the web interface!

Server stats:

2.8K
active users

#howtothing

0 posts0 participants0 posts today

Yesterday, one year ago... (Still wondering how many people actually have read or tried out any of these)

mastodon.thi.ng/@toxi/11134859

Mastodon Glitch EditionKarsten Schmidt (@toxi@mastodon.thi.ng)#HowToThing #Epilogue #LongRead: After 66 days of addressing 30 wildly varied use cases and building ~20 new example projects of varying complexity to illustrate how #ThingUmbrella libraries can be used & combined, I'm taking a break to concentrate on other important thi.ngs... With this overall selection I tried shining a light on common architectural patterns, but also some underexposed, yet interesting niche topics. Since there were many different techniques involved, it's natural not everything resonated with everyone. That's fine! Though, my hope always is that readers take an interest in a wide range of topics, and so many of these new examples were purposefully multi-faceted and hopefully provided insights for at least some parts, plus (in)directly communicated a core essence of the larger project: Only individual packages (or small clusters) are designed & optimized for a set of particular use cases. At large, though, thi.ng explicitly does NOT offer any such guidance or even opinion. All I can offer are possibilities, nudges and cross-references, how these constructs & techniques can be (and have been) useful and/or the theory underpinning them. For some topics, thi.ng libs provide multiple approaches to achieve certain goals. This again is by design (not lack of it!) and stems from hard-learned experience, showing that many (esp. larger) projects highly benefit from more nuanced (sometimes conflicting approaches) compared to popular defacto "catch-all" framework solutions. To avid users (incl. myself) this approach has become a somewhat unique offering and advantage, yet in itself seems to be the hardest and most confusing aspect of the entire project to communicate to newcomers. So seeing this list of new projects together, to me really is a celebration (and confirmation/testament) of the overall #BottomUpDesign #ThingUmbrella approach (which I've been building on since ~2006): From the wide spectrum/flexibility of use cases, the expressiveness, concision, the data-first approach, the undogmatic mix of complementary paradigms, the separation of concerns, no hidden magic state, only minimal build tooling requirements (a bundler is optional, but recommended for tree shaking, no more) — these are all aspects I think are key to building better (incl. more maintainable & reason-able) software. IMO they are worth embracing & exposing more people to and this is what I've partially attempted to do with this series of posts... ICYMI here's a summary of the 10 most recent posts (full list in the https://thi.ng/umbrella readme). Many of those examples have more comments than code... 021: Iterative animated polygon subdivision & heat map viz https://mastodon.thi.ng/@toxi/111221943333023306 022: Quasi-random voronoi lattice generator https://mastodon.thi.ng/@toxi/111244412425832657 023: Tag-based Jaccard similarity ranking using bitfields https://mastodon.thi.ng/@toxi/111256960928934577 024: 2.5D hidden line visualization of DEM files https://mastodon.thi.ng/@toxi/111269505611983570 025: Transforming & plotting 10k data points using SIMD https://mastodon.thi.ng/@toxi/111283262419126958 026: Shader meta-programming to generate 16 animated function plots https://mastodon.thi.ng/@toxi/111295842650216136 027: Flocking sim w/ neighborhood queries to visualize proximity https://mastodon.thi.ng/@toxi/111308439597090930 028: Randomized, space-filling, nested 2D grid layout generator https://mastodon.thi.ng/@toxi/111324566926701431 029: Forth-like DSL & livecoding playground for 2D geometry https://mastodon.thi.ng/@toxi/111335025037332972 030: Procedural text generation via custom DSL & parse grammar https://mastodon.thi.ng/@toxi/111347074558293056 #ThingUmbrella #OpenSource #TypeScript #JavaScript #Tutorial

New #ThingUmbrella releases & example: This week's releases included updates to thi.ng/system, a minimal and declarative way to compose an app from multiple components, build their dependency graph and manage their lifecycle (async start/stop) in the correct (topological) order. The computed graph (DAG) can then also be serialized to GraphViz format for visualization/debugging/documentation purposes with a single line of code (see readme)...

Even though I've been using this system in dozens of projects, it occurred to me there wasn't any example project yet demonstrating this approach, so I finally fixed that:

github.com/thi-ng/umbrella/tre

The demo is purposefully minimal and the source code is (hopefully) much more interesting than the result. In addition to showing how the app components are defined, this example also shows another powerful pattern I've been using in my own tools:

Using thi.ng/atom as central app state and thi.ng/rstream pubsub as central event bus, to both of which various system components can attach topic based subscriptions (aka event and/or change handlers). Since each of these reactive subscriptions are normal rstream subs, they can all be forming graphs of child subs and be filtered/transformed and synchronized via hundreds of composable operators in the thi.ng/rstream and thi.ng/transducers packages — and — these rstream values can also be directly embedded in thi.ng/rdom created reactive UI components/elements/attributes. Some of these techniques are shown in this new example as well... Hope it's helpful to some of you!

Been debugging boids & behavior combinations all evening! Happy to say, I think all force contributions are fixed now (classic off-by-one error was leading to an initially subtle but increasingly obvious directional bias), and I can focus again on experimenting with some new amazing emergent behaviors... Aside from that, maybe this also qualifies for #Genuary2024 (Day 1: Particles)?!

Btw. This is just a variation of this #ThingUmbrella example project:

demo.thi.ng/umbrella/boid-basi

...which was created as part of last year's #HowToThing series:

mastodon.thi.ng/@toxi/11130843

Continued thread

A short overview of end-of-2023 state of thi.ng(s) (thi.ng/umbrella only!):

96 releases done in 2023 (i.e. every 3.6 days on average)

188 projects/packages (+12 this year)
151 example projects (+32 this year)

3,865 source files
144,432 lines of code
54,155 docs/comments (37% or 2.66 lines of code-to-comment ratio)
198,587 total SLOC

Readme files (for all 188 packages):

49,580 total words
189,978 lines

A lot of activity this year was spent on adding/improving documentation & creating new examples to illustrate general usage patterns. From August till October I published 30 chapters of #HowToThing aka heavily commented code examples & mini-tutorials, incl. ~20 new example projects which are now part of the monorepo. Just like the overall project scope, these chapters covered anything from audio synthesis, data transformations, DSLs, geometry, generative art/design, GIS, image processing, Mastodon client, reactive UIs (NOT using React!), shaders, other visualizations and more... Check out the hashtag to view them (full list is also part of the thi.ng/umbrella readme).

#ThingUmbrella #OpenSource #Gratitude #ProjectStatistics #YearInReview #IndyDev #Fundraising

2/3

One of the best SIMD intro articles I've ever come across thus far. Very nicely explains all the core concepts and operations, lots of sketches/diagrams... Noice! 👏

mcyoung.xyz/2023/11/27/simd-ba

Btw. If you're using TypeScript/JavaScript, you can play with some of these concepts/ops directly from the REPL using thi.ng/simd. This package uses WASM behind the scenes, but doesn't expose the full set of available SIMD instructions (it's a lil' bit more highlevel...)

Also see recent #HowToThing post and practical example about it here:
mastodon.thi.ng/@toxi/11128326

mcyoung.xyzDesigning a SIMD Algorithm from Scratch · mcyoung
#SIMD#Tutorial#Rust

Almost a week ago I said I'm pausing #HowToThing for a while, but that doesn't preclude adding new examples regardless, e.g. this new one illustrating matrix-based image color adjustments (basic color grading) using floating point pixel buffers via thi.ng/pixel and color matrix building blocks (incl. concatenation to produce a single color transform matrix for an arbitrary number of adjustments) via thi.ng/color...

Due to lack of time and to keep it simple, there's no image chooser for now (though might still add one...)

Demo (example #146):
demo.thi.ng/umbrella/pixel-col

Source code:
github.com/thi-ng/umbrella/blo

#HowToThing #Epilogue #LongRead: After 66 days of addressing 30 wildly varied use cases and building ~20 new example projects of varying complexity to illustrate how #ThingUmbrella libraries can be used & combined, I'm taking a break to concentrate on other important thi.ngs...

With this overall selection I tried shining a light on common architectural patterns, but also some underexposed, yet interesting niche topics. Since there were many different techniques involved, it's natural not everything resonated with everyone. That's fine! Though, my hope always is that readers take an interest in a wide range of topics, and so many of these new examples were purposefully multi-faceted and hopefully provided insights for at least some parts, plus (in)directly communicated a core essence of the larger project:

Only individual packages (or small clusters) are designed & optimized for a set of particular use cases. At large, though, thi.ng explicitly does NOT offer any such guidance or even opinion. All I can offer are possibilities, nudges and cross-references, how these constructs & techniques can be (and have been) useful and/or the theory underpinning them. For some topics, thi.ng libs provide multiple approaches to achieve certain goals. This again is by design (not lack of it!) and stems from hard-learned experience, showing that many (esp. larger) projects highly benefit from more nuanced (sometimes conflicting approaches) compared to popular defacto "catch-all" framework solutions. To avid users (incl. myself) this approach has become a somewhat unique offering and advantage, yet in itself seems to be the hardest and most confusing aspect of the entire project to communicate to newcomers.

So seeing this list of new projects together, to me really is a celebration (and confirmation/testament) of the overall #BottomUpDesign #ThingUmbrella approach (which I've been building on since ~2006): From the wide spectrum/flexibility of use cases, the expressiveness, concision, the data-first approach, the undogmatic mix of complementary paradigms, the separation of concerns, no hidden magic state, only minimal build tooling requirements (a bundler is optional, but recommended for tree shaking, no more) — these are all aspects I think are key to building better (incl. more maintainable & reason-able) software. IMO they are worth embracing & exposing more people to and this is what I've partially attempted to do with this series of posts...

ICYMI here's a summary of the 10 most recent posts (full list in the thi.ng/umbrella readme). Many of those examples have more comments than code...

021: Iterative animated polygon subdivision & heat map viz
mastodon.thi.ng/@toxi/11122194

022: Quasi-random voronoi lattice generator
mastodon.thi.ng/@toxi/11124441

023: Tag-based Jaccard similarity ranking using bitfields
mastodon.thi.ng/@toxi/11125696

024: 2.5D hidden line visualization of DEM files
mastodon.thi.ng/@toxi/11126950

025: Transforming & plotting 10k data points using SIMD
mastodon.thi.ng/@toxi/11128326

026: Shader meta-programming to generate 16 animated function plots
mastodon.thi.ng/@toxi/11129584

027: Flocking sim w/ neighborhood queries to visualize proximity
mastodon.thi.ng/@toxi/11130843

028: Randomized, space-filling, nested 2D grid layout generator
mastodon.thi.ng/@toxi/11132456

029: Forth-like DSL & livecoding playground for 2D geometry
mastodon.thi.ng/@toxi/11133502

030: Procedural text generation via custom DSL & parse grammar
mastodon.thi.ng/@toxi/11134707

#HowToThing #030 — Procedural, rule-based & stochastic text generation using a custom DSL, parse grammar (via thi.ng/parse) and abstract syntax tree transformation (via thi.ng/defmulti).

Since it's #NaNoWriMo & #NaNoGenMo [1], I'm closing out this first season of 30 #HowToThing's with a related topic & maybe someone even finds it useful/interesting... 😉🤷‍♂️

This example is in principle inspired by @galaxykate's oldie & goodie #Tracery, but is using a super simple custom text format instead of JSON to define variables and template text. Variables are expanded recursively and I've also added features like dynamic, indirect pointer-like variable lookups to derive variables based on current values (useful for conditionals & context-specific expansions), hidden assignments, chainable modifiers... I've included 5 different "story" templates (incl. comments) showing various features. Just press "regenerate" to create new random variations...

Similar to the previous #HowToThing, I'm hoping this example also shows that approaching use cases like this via small domain-specific languages with proper grammar rules, does not require much ceremony and is often more amenable to change during prototyping (and later also more maintainable!) than just regex bashing approaches...

The parser grammar itself is explained in the thi.ng/parse readme. As usual, the grammar was created/prototyped with the Parser Playground[2], which we developed from scratch during the first thi.ng livestream[3] (2.5h video)...

Demo (example project #145):
demo.thi.ng/umbrella/procedura

Source code:
github.com/thi-ng/umbrella/tre

If you have any questions about this topic or the packages used here, please reply in thread or use the discussion forum (or issue tracker):

github.com/thi-ng/umbrella/dis

[1] github.com/NaNoGenMo/2023/
[2] demo.thi.ng/umbrella/parse-pla
[3] youtube.com/watch?v=mXp92s_VP4

#HowToThing #029 — One for the #Forth friends: Minimal livecoding playground for animated 2D geometry generation (incl. SVG export) using a Forth-like DSL (domain-specific language) based on thi.ng/pointfree, thi.ng/pointfree-lang and various geometry related operations using thi.ng/geom. A short screen recording is included to demonstrate overall usage. This is a cutdown version of a prototype tool, originally from 2019...

Even though the language is "Forthy", the underlying thi.ng/pointfree implementation does _not_ use a VM, but instead compiles words to vanilla JavaScript using normal functional composition (or reductions) and each word is passing data & state via a single shared stack context object (with the usual dual data & return stacks and an environment object with var bindings). The language supports quotations, local variables, combinators etc.

I _highly_ recommend consulting the detailed readme docs for the above packages to familiarize yourself with the basic principles & language features/syntax. If you do have some prior #Forth knowledge, many aspects should feel familiar (apart from the geometry DSL terms)...

Also worth pointing out that the editor/interpreter in this small example is not super forgiving re: error handling and might easily crash when live coding. The point of this demo is not about providing great UX, but to illustrate how the basic thi.ng/pointfree language infrastructure can be easily extended/adapted/integrated...

Demo:
demo.thi.ng/umbrella/pointfree

Source code:
github.com/thi-ng/umbrella/tre

(Note: The source code of the actual language bindings for the geometry operations is not shown here, but available in the `lang.ts` file, linked above...)

#HowToThing #028 — Randomized, space-filling, nested 2D grid layout generator using thi.ng/layout & thi.ng/transducers

Already gave a glimpse of this yesterday[1]. This example uses the new `StackedLayout` generator to create random multi-column base layouts and allocate cells of varying sizes (column/row spans). Depending on size, each cell also has a probability to produce nested child layouts in its place (up to 4 levels). The example also shows how the layout gen can be queried to determine & allocate any remaining empty space(s) at the bottom of each nesting level (since it's highly likely that there's such)... The result is a completely space-filling grid layout (which the new thi.ng website will likely be based on too, obviously with some of the more sane/usable/responsive configurations...)

Demo (reload for random config):
demo.thi.ng/umbrella/layout-gr

Source code:
github.com/thi-ng/umbrella/blo

If you have any questions about this topic or the packages used here, please reply in thread or use the discussion forum (or issue tracker):

github.com/thi-ng/umbrella/dis

Ps. It's also #ReleaseMonday — check main thi.ng/umbrella readme for latest updates/changelogs... 🚀

[1] mastodon.thi.ng/@toxi/11131735

As usual, deep in the blurry spectrum between outright and intended utility (aka layout algorithm), dataviz (tree depth) and art. I love them all, and as so often, the extrema are just a tiny param change away from each other! Pushing toward art territory often a great way to uncover issues and debug an algorithm. E.g. I had originally issues with propagating size changes of nested cells back up to their parent/ancestors (solved now)...

(Ps. also a teaser for next #HowToThing... probably out tomorrow)

#HowToThing #027 — Boid/flocking simulation with spatial indexing, configurable behaviors and neighborhood queries to visualize proximity.

Key packages:

- thi.ng/boids: n-dimensional boid simulation with highly configurable behaviors
- thi.ng/timestep: deterministic fixed timestep simulation updates with state interpolation
- thi.ng/geom-accel: 2D hash grid spatial indexing and neighborhood region queries

The new thi.ng/boids package is still in alpha (still working on the API and how the package interfaces with others), but I've been using the underlying implementation for _maaany_ projects since ~2005... The agent/boid behaviors can be highly customized via the given parameters (which can also be dynamically adjusted). As usual with thi.ng packages, the visual representation of the boids is kept completely separate from the sim. The package really only deals with the latter and essentially only processes points in space (and directions, velocities)... However, it's also this separation, which makes it more useful for many different scenarios.

Demo:
demo.thi.ng/umbrella/boid-basi

Source:
github.com/thi-ng/umbrella/blo

If you have any questions about this topic or the packages used here, please reply in thread or use the discussion forum (or issue tracker):

github.com/thi-ng/umbrella/dis

Ps. It's also #ReleaseFriday — check main thi.ng/umbrella readme for latest updates/changelogs... 🚀

#HowToThing #026 — Shader meta-programming techniques (functional composition, higher-order functions, compile-time evaluation, dynamic code generation etc.) to generate animated plots/graphs of 16 functions (incl. dynamic grid layout generation) within a single WebGL fragment shader.

Today's key packages:

- thi.ng/shader-ast: DSL to write (fully type-checked) shaders directly in TypeScript and later compile them to GLSL, JS (and other target languages, i.e. there's partial support for Houdini VEX and [very] early stage WGSL...)
- thi.ng/shader-ast-stdlib: Collection of ~220 re-usable shader functions & configurable building blocks (incl. SDFs primitives/ops, raymarching, lighting, matrix ops, etc.)
- thi.ng/webgl-shadertoy: Minimal scaffolding for experimenting with fragment shaders (supports both normal GLSL or shader-ast flavors/compilation)

If you're new to the Shader-AST approach (highly likely!), this example will again introduce a lot of new concepts, hopefully in digestible manner! Please also always consult the package readmes (and other linked examples) for more background info... There're numerous benefits to this approach (incl. targetting different target langs and compositional & optimization aspects which are impossible to achieve (at least not elegantly) via just string concatenation/interpolation of shader code, as is much more commonplace...)

This example comes fresh off the back of yesterday's new easing function additions (by @Yura), though we're only showing a subset here...

Demo:
demo.thi.ng/umbrella/shader-as
(Check the console to view the generated GLSL shader)

Source code:
github.com/thi-ng/umbrella/tre

If you have any questions about this topic or the packages used here, please reply in thread or use the discussion forum (or issue tracker):

github.com/thi-ng/umbrella/discussions

#HowToThing #025 — Sampling, fitting, transforming & plotting 10k data points per frame using a whole bunch of underexposed thi.ng packages:

- thi.ng/colored-noise: using violet noise as fake data source
- thi.ng/matrices: fitting/transformation matrix creation
- thi.ng/simd: WASM-based batch processing
- thi.ng/malloc: Memory management for WASM/SIMD data buffers
- thi.ng/hiccup-canvas: 2D canvas visualization

As noted in the comments, the SIMD batch processing here is to illustrate the overall usage and handling. In this specific example, the main bottleneck is the actual canvas drawing step (esp. in Firefox, which in this case is ~3.75x slower than Chrome [latter easily manages 60fps]). The SIMD step could handle magnitude(s) more points per frame, also on FF...

As an aside, this is now already the 140th (!!!) fully documented small example project, bundled as part of the thi.ng/umbrella monorepo... Please do tell me at which point the prejudice of not having enough starting points & info about these packages will be fading into oblivion... 😅

Demo:
demo.thi.ng/umbrella/simd-plot

Source:
github.com/thi-ng/umbrella/tre

Also big thanks to Maximillian Schulte for sending me off on this topic (as a tangent) via an issue on GitHub... I've been meaning to create more examples for these above packages for a while! Last but not least, hat tip & nerd sniping @demofox re: colored noise... 😎🤩