β€’

tech

Software complexity, engineering, and AI

Software becomes complex when multiple systems need to communicate. That's the art of software engineering. AI can't code all for you, but it's a great assistant if prompted right.


Sandro Maglione

Sandro Maglione

Software

Where is the complexity in code, really? πŸ€”

Answer: connecting multiple independent systems πŸ‘€

Single environment and limited use cases are easy, any AI already automates that. The value is found in making multiple pieces work together.

Let me explain what I mean πŸ‘‡


AI builds websites. Well...

I recently built a browser script (javascript). Well, I didn't do it exactly, the "AI" did all the work πŸ’πŸΌβ€β™‚οΈ

The scope is limited: browser API, reading and changing the DOM, javascript only 🀝

There is no more value in these tasks. A few prompts and tweaks, and shipped without any issues.

That's the same for single-system requirements, e.g. only browser (no external request) or only server (no database connection).

It's just like working solo on a project: no communication overhead, no misunderstanding, no contract required between people.

Communication is hard

It all falls apart with multiple systems:

  • Client sends correct request, verifies correct response, handle miscommunication
  • Server connects to database, timeouts, streams

The art of software engineering is found in connecting multiple complex systems πŸ—οΈ

AI is not there (yet?)

Case in point: local-first sync engine

Last week I published an article about a local-first sync engine architecture (no code).

Multiple clients sending real-time requests to a central server (socket connection), using and storing different formats at different steps of the communication.
Multiple clients sending real-time requests to a central server (socket connection), using and storing different formats at different steps of the communication.

My point is: you cannot ask to an AI "make a local-first sync engine" and expect that it figures out every step (in code as well).

Because there is no strictly a "valid answer" πŸ’πŸΌβ€β™‚οΈ

Software engineering is about tradeoffs

The sync engine in the article handles real-time updates by syncing using web workers+socket.

But that's not necessary for all apps, not even all local-first apps. Not even for a sync engine πŸ™Œ

Sync engine = Something that syncs changes between systems

Adding "real-time" is a new requirement, which introduces new tradeoffs, and new complexity (e.g. sockets, streams, real-time database updates).

These are all added "systems". This is the definition of "complexity". AI is not (yet) good at this, and that's where you bring value 🫑

Figure out the complexity, and fill the blanks

AI is still great in single systems, or when given strict instructions about how systems connect.

You first design the architecture of the whole system (chatting with AI), and then use AI to code each system in isolation ✨

Example: I am working on a simplified sync architecture, without real-time updates (planning to publish the code πŸ”œ).

I discussed syncing and authentication with Grok. Based on my ideas and my guidance, I asked the AI to find pitfalls and propose solutions.

Narrow down the problem by giving specific instructions of how the system looks like, and ask for possible pitfalls and blind spots.
Narrow down the problem by giving specific instructions of how the system looks like, and ask for possible pitfalls and blind spots.

Once I had an idea of the system as a whole, I can then ask the AI to sketch the shape of the API, the database schema, queries, and more:

Once I defined the architecture, I can use AI again to sketch each single system and how they communicate.
Once I defined the architecture, I can use AI again to sketch each single system and how they communicate.

I don't expect AI to then code everything without guidance πŸ‘€

There are too many variables in a complex system (e.g. what libraries I am using, what runtime, what server stack, what database).

But, I still find value in AI when working on smaller problems.


If you didn't yet, check out the full article on my sync engine: How to implement a Sync Engine for the Web πŸš€

Many people asked for the actual code. As mentioned, I am working on a simplified architecture for a web sync engine, code coming soon πŸ”œ

Meanwhile, the Effect Days are approaching, see you there soon πŸ‘€

See you next πŸ‘‹

Start here.

Every week I dive headfirst into a topic, uncovering every hidden nook and shadow, to deliver you the most interesting insights

Not convinced? Well, let me tell you more about it