Menu

Bridge: Write Logic Once, Compile Everywhere | Cahyanudien Blogs
🖼️

Bridge: Write Logic Once, Compile Everywhere | Cahyanudien Blogs

DEV Community·Cahyanudien Aziz Saputra·6 months ago
#BIKgMsbd
#wecoded#bridge#logic#price#float
Reading 0:00
15s threshold

Sometimes the problem isn’t complexity.

It’s repetition.

The Problem I Keep Hitting

In almost every project, I end up writing the same logic twice.

Validation rules

Price calculations

Data transformations

Once in backend (PHP),

and again in frontend (TypeScript).

It’s not hard.

But it’s fragile .

One change → forget to sync → subtle bug.

And over time, that duplication becomes technical debt.

The Idea

What if the logic itself was the source of truth?

Not PHP. Not TypeScript.

Just logic .

So I started experimenting with a small language:

function calculateTax(price: float, rate: float): float { let tax = price * rate return tax }

Enter fullscreen mode

Exit fullscreen mode

Then compile it into:

PHP (for backend)

TypeScript (for frontend)

Node.js (for shared tooling)

That became Bridge .

What Bridge Actually Is

Bridge is not a framework.

It’s a CLI compiler .

Input: .bridge file

Output: real code (PHP / TS / Node)

No runtime.

No magic.

Just transformation.

Why Not Just Use JSON…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.