Curiosities by Tensegritics

Archive

Extensible Macros

by cgrand (🦋 🦣 𝕏)

Like many of us I have a long and well-documented record of love/hate relationship with macros.

Despite that, the cornerstone of cljd.flutter (the ClojureDart namespace for making Flutter more palatable) is a macro: f/widget. It’s a Flutter-specific threading macro, supercharged with 15+ directives.

Making the macro user-extensible had been on my mind for a long time, but a comment by Balint Erdos on Clojurian’s #clojuredart finally triggered the implementation (the redacted part is what matters).

#14
February 28, 2025
Read more

Beyond `swap!`: Encapsulation sans Abstraction, the Transactor Pattern

by cgrand (🦋 🦣 𝕏)

As Clojure developers we love the simplicity of putting almost all application state under a single atom. You get isolation (as long as you don't deref twice) thanks to immutable (persistent) collections and transactional changes thanks to swap! combined with functional composition.

In this article I expose a pattern I name the "transactor pattern" because it borrows a lot from Datomic's transaction functions.

We've applied it both in the large (whole application state) and in the small (some hairy scheduling and planning algorithm).

#13
December 9, 2024
Read more

Restrained Datalog in 39loc

by cgrand (🦋 🦣 𝕏)

Today, as promised, a follow-up to Half Dumb Datalog in 30 loc.

In the aforementioned article we complained that it was impossible for our Datalog to not conclude that Bart Simpson is his own sibling. To fix this situation we need to introduce constraints (= and not= for a start) into our toy Datalog to be able to state that Bart's sibling can't be "equal" to himself.

Still from Monthy Python and the Holy Grail, with Arthur telling to the Black Knight "You stupid constraint. 
You haven’t got any free variables left."

#12
November 26, 2024
Read more

Loose Ends

by cgrand (🦋 🦣 𝕏)

Today, just some quick CLJD news and some things I found interesting over the last week:

  • The CVM algorithm,
  • Least Squares Circle Fit,
  • Fractional Brownian Motion applied to Signed Distance Fields.

To echo the title: at last, a video that made me understand why the direction in which you tie shoelaces matters:

#11
November 19, 2024
Read more

Maps Implementation Secrets

by cgrand (X 🦣)

Today no Datalog nor interop: let's talk data structures!

In ClojureDart we took pride in writing our own persistent collections. A design goal for our collections was to make them have a canonical layout so as to be able to leverage canonical layout and structural sharing to optimize boolean operations on them (diff, merge, mass dissoc etc.). It's yet untapped potential.

(And it's tangentially related with my ongoing obsession with "Datalog As The Engine Of Application State" 🤔.)

#10
November 5, 2024
Read more

Half Dumb Datalog in 30 loc

by cgrand (X 🦣)

Today, a follow-up to Writing the Worst Datalog Ever in 26loc, maybe even the start of a series.🍿

Our 26-loc Datalog is naive. Nothing personal, it's a technical term: each iteration in saturate rederives all the facts derived plus hopefully some new ones. The last iteration is guaranteed to be 100% redundant since by definition it's the one which derived nothing new!

Let's engineer a bad case (not that it's difficult given how purposefully unsophisticated our code is):

#9
October 16, 2024
Read more

Writing the Worst Datalog Ever in 26loc

Today to change from heavy interop and frameworks, let's do some light coding exercise and implement the most amateur datalog engine by taking any shortcut we see fit!

Still from the hitchhiker's scene in There's something about Mary. With captions with 26loc Datalog instead of 7min abs.

Don't forget when we're not busy writing silly Datalog implementations, we are available to help you with Clojure or working to get our app Paktol (The positive spending tracker where money goes up!) off the ground.

#8
October 11, 2024
Read more

Breakout Game in ClojureDart

This issue is about following the Flame’s Brick Breaker tutorial in ClojureDart.

This was prompted by Ian Chow (who just released a CLJD app onto the stores) mentioning, en passant, he struggled to port this tutorial.

We couldn’t let this slip, so here we go! This is going to be code-heavy, and not very clojurey as we were not familiar with the Flame framework.

If you are impatient, skip to the 🕹️ emojis.

#7
October 3, 2024
Read more

Always Animating

A Word From Our Sponsor: Ourselves! 🤣

We just released Paktol our first paid app (free 2-month trial) to the stores:

  • 🍎 App Store,
  • 🤖 Google Play.

Paktol is a mindful spending app that helps change your spendings habits without having to plan and categorize. It's as simple as playing "Hot or Cold"!

#6
September 17, 2024
Read more

Using Swift SDKs from ClojureDart

One of Dart’s strengths has always been host interoperability. Early on (beginning of 2017), Platform channels were used (and still are) to consume native SDKs. Although they are very useful, Platform channels come with costs tied to their message-handling design (a close comparison would be JavaScript’s Web Worker API).

More recently, Dart’s team has invested significantly in the Foreign Function Interface (FFI). They built a set of libraries to help you generate native bindings targeting Java, Objective-C, C, Kotlin, and more. Once your bindings are generated, you only need to call them using ClojureDart. The team also plans to continue working in this direction:

We’ll continue to invest in further interoperability—both in terms of completing the above-mentioned libraries and in terms of supporting Swift—over the coming releases. See the roadmap section below for details.
Source

I personally think it’s a game-changer. At Tensegritics, we generate lots of bindings for our projects. The process is as simple as:
1. Identifying a native SDK.
2. Writing some configuration for ffigen or jnigen.
3. Dumping the bindings.

#5
September 2, 2024
Read more

ClojureDart and Firebase Auth

Today a well-researched tutorial by Arnaud Bos on setting up link-based authentication with Firebase Authentication. Cloud technologies can be challenging, but Arnaud has carefully pieced together all the information you need, and he's pleased to share the results with you.

Arnaud is an experienced independent contractor, very nice and approachable. Don't hesitate to get in touch with him!

If you too like Arnaud, you'd like to write about ClojureDart here, let us know!

#4
August 20, 2024
Read more

Doing your own IO stunts!

In this issue, Baptiste shares some experience on how to deal with "cascading IO". The promised FFI stories will be for a next issue.

He also just published a short on storing user preferences in your app.

(cgrand's note: I'm responsible for the lame title pun which only makes sense in French where "stunt" and "cascade" are the same word.)

Baptiste does his own IO stunts!

#3
September 27, 2023
Read more

Drawing lines the old way

(No practical ClojureDart tips this issue, only cgrand rambling about drawing lines. Baptiste will be back soon with some FFI experience to share!)

(as usual, all code can be found on GitHub.)

Drawing lines the old way

In the previous issue, young cgrand discovered how to draw circles with cheap integer arithmetic. Now it's time to draw lines!

#2
September 13, 2023
Read more

Managing Flutter versions and drawing circles the old way

Welcome to the first installment of Tensegritics Curiosities our newsletter on ClojureDart, Clojure, algorithms and cool stuff!

Two topics today:

  • how to manage flutter versions between Clojuredart projects
  • Bresenham's line algorithm

How to manage flutter versions between Clojuredart projects (by Baptiste)

#1
August 30, 2023
Read more
Powered by Buttondown, the easiest way to start and grow your newsletter.