Native & Low-Level Engineering

Managed runtimes are the right default for most software, and most of the time the correct advice is to keep using yours. This page is about the minority of components where the constraints are different enough that a native binary is the engineering answer — and about being able to tell the difference, which is the part that actually saves money.

The decision, on engineering grounds

"Native or managed" is not a matter of taste. It is a set of measurable properties, and for any given component either they matter or they do not:

  • Runtime dependency. A native binary has no runtime to install, version, patch or license on the target machine. On a server you control, that is worth very little. On a thousand devices in cabinets you will never physically visit, or in an appliance image, or on a customer's locked-down host where installing a framework requires a change request, it can be the entire decision.
  • Startup time. Process start measured in milliseconds rather than hundreds of milliseconds. Irrelevant for a service that starts once and runs for a year. Decisive for something invoked per event, per connection, or on a watchdog restart loop.
  • Resident memory and deployment footprint. A few megabytes rather than tens or hundreds. On a host with 16 GB this is noise. On an edge box with 512 MB running four other things, it is the difference between shipping and not shipping.
  • Deterministic resource behaviour. No garbage collector pause at an inconvenient moment, and memory use that is a function of what the program does rather than of collector policy. This matters far less often than people claim — but when you are holding thousands of long-lived sockets, or must respond inside a hardware timeout, it matters absolutely.
  • Codebase longevity. A C or Object Pascal codebase from 2010 generally still builds. Ecosystems that move faster deliver more per year and ask for more maintenance per year in return. For a component expected to run untouched for a decade, that trade runs the other way than it does for a product under weekly development.
  • Direct access to the machine. Sockets at the level the protocol actually needs, exact control of byte layout on the wire, and calling into a vendor's C API without a binding layer between you and the bug you are chasing.

When native is the wrong answer

Stated plainly, because a supplier who only ever recommends the thing they sell is not giving you advice:

  • Your business logic layer. If it changes weekly, needs a large library ecosystem, and is maintained by a team you can hire for, write it in whatever that team is good at. The productivity difference is real and it is not on native's side.
  • Anything where the bottleneck is the database or the network. Most services are. Rewriting a component that spends 95% of its time waiting on I/O will not make it meaningfully faster, and I will say so rather than take the work.
  • When it would strand the component. One native component inside an otherwise managed system is normal and healthy. Five, maintained by nobody after I leave, is a liability I helped create. The scope of what should be native is part of the engagement, and it should be as small as the constraints allow.
  • When your team already works in Go or Rust. Both are excellent for most of what this page describes, and if that capability is already in-house, use it. The cases where I am still the right call are usually the ones involving an existing Pascal codebase, a vendor C API with awkward semantics, or a device protocol that has to be reverse-engineered from behaviour rather than read from a specification.

What I build

Dependency-free services and daemons

Single-binary services with no runtime underneath: Windows services and Linux daemons, clean startup and shutdown, signal handling, supervision under systemd, log output that something else can rotate, and configuration that does not assume a person is present. Deployable by copying a file.

Small binaries on constrained and edge hardware

Components that run next to the equipment rather than in a data centre — industrial PCs, appliance images, small ARM boards in a cabinet. Cross-compilation and a reproducible build, static versus dynamic linking decided deliberately, and behaviour under the conditions that define edge deployment: no console, no operator, an unreliable uplink, and power that goes away without warning. A component that cannot survive an unexpected power cut mid-write is not finished.

Binary protocol implementation

Protocols implemented against the wire format itself: exact byte layout, endianness, alignment and packing against C structures, framing, checksums, sequence and retransmission handling. This includes the common and unpleasant case where the specification is incomplete or wrong and the real protocol has to be established from captures and from device behaviour. Fixtures built from real traffic, so that the parser is tested against what the hardware sends rather than against what the document claims it sends.

Low-level networking and TCP bridges

Connection handling for links that are genuinely unreliable: outbound-only tunnels for devices behind NAT with no inbound route, multiplexing many logical streams over one transport, keepalives tuned below the shortest NAT timeout in the fleet, reconnect with bounded backoff so a server outage does not produce a reconnect storm, and half-open connection detection — because a socket that is dead but not closed is the failure mode that makes a system look healthy while it silently carries nothing.

Native backends on Linux

Server processes compiled to native code and deployed on ordinary Linux hosting or in containers, using mORMot2 where a full service framework is warranted: interface-based SOA, ORM over PostgreSQL, ECC-signed JWT authentication. That case is large enough to have its own page — see Delphi Backend Architecture.

Interfacing with vendor C APIs

Calling hardware SDKs directly, including the parts that make them awkward: header translation, calling conventions, structure packing, memory ownership rules that the documentation states imprecisely, and 32-bit-only COM or DLL dependencies that need an out-of-process surrogate rather than a 64-bit wish.

How it fits into your system

The usual shape of these engagements is one native component inside a system that is otherwise .NET, Java, Go or Python. That is a normal architecture and the integration boundary is a deliberate part of the work — nobody on your team should have to learn Object Pascal to use what I deliver.

  • A shared library behind a clean C ABI — .dll or .so, consumable from C#, Java, Python, Go or anything else with an FFI. Flat function signatures, explicit memory ownership at the boundary, no exceptions crossing it, and a versioning rule so that upgrading the library does not break the host.
  • A separate process behind an HTTP or message boundary — usually the better choice, because a crash in the native component cannot take your application down with it, and the two can be deployed and rolled back independently.
  • A sidecar or agent that owns the device-facing side and presents your application a clean internal interface, keeping protocol ugliness in one replaceable place.

What "finished" means for a native component

Native work is easy to deliver in a state that appears to work. The things that decide whether you can still operate it in three years:

  • A reproducible build. From a clean checkout, on a machine that is not mine, by a script — not by a person pressing a key in an IDE.
  • Defined crash behaviour. What happens on an unhandled fault, what gets written down before the process dies, and how it comes back. A native component that dies silently is worse than a managed one that dies loudly.
  • Observability from outside. Structured logs, counters and a health endpoint, so the component can be diagnosed by someone who cannot attach a debugger and does not have the source open.
  • Documented boundaries. Threading model, memory ownership, and what is safe to call concurrently — written down, because these are exactly the rules that cannot be inferred from a header file.
  • Handover. The reasoning, not just the code. If the next engineer cannot understand why the retry interval is what it is, they will change it.

Typical starting points

  • We need a component on hardware that has no room for a runtime.
  • We have to talk to a device over a binary protocol and the documentation does not match what it sends.
  • Our devices are behind customer NAT and we cannot ask for a VPN or a port-forward.
  • Our service takes too long to start and it is invoked constantly.
  • We need to call a vendor C SDK from .NET and the wrapper we have is unstable.
  • We need one native piece inside a system that is otherwise Java, and nobody in-house writes native code.

Book a free 30-minute technical call

Bring the constraint rather than the solution — the memory ceiling, the startup budget, the device that will not cooperate, the host you are not allowed to install anything on. Half the value of that call is establishing whether you need a native component at all, and that answer is free either way.

Book a free 30-minute technical call

Tell me what is broken.

No sales call. You describe the problem, I tell you whether it is something I can solve and roughly what it takes. If it sits outside what I do, I will say so on that call.

Book a free 30-minute technical call