๋ณด์ผ๋Ÿฌํ”Œ๋ ˆ์ดํŠธ ๊ฐ€์ ธ์˜ค๊ธฐ๋ฅผ ์ž‘์„ฑํ•˜๋Š” ๋ฐ ์ง€์ณ์„œ Block: Run Python, JS, Lua๋ฅผ ํ•˜๋‚˜์˜ ํŒŒ์ผ๋กœ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค.

์ž‘์„ฑ์ž

์นดํ…Œ๊ณ ๋ฆฌ:

โ† ํ”ผ๋“œ๋กœ
DEV Community ยท O-O1112 ยท 2026-08-20 ๊ฐœ๋ฐœ(SW)
Cover image for I got tired of writing boilerplate imports, so I built Block: Run Python, JS, and Lua in a single file

O-O1112

๐Ÿ’ก The Problem: The Import / Glue Code Headache

A while ago, I was practicing importing modules across different projects. I wanted to use Python for its rich data science libraries and Node.js for its async web performance.

Normally, if you want Python to pass a simple calculated array or dictionary to JavaScript, you have to:

  1. Spin up a local FastAPI / Flask server or write to a temporary JSON file.
  2. Setup fetch() in Node.js, handle ports, serialization, and CORS.
  3. Write 50+ lines of glue code just to share a single variable.

Coming from a visual block-coding mindset (where you snap blocks together and data flows naturally), I thought:

“Why can’t I just write <py> and <js> in the exact same file, and let the variables flow automatically?”

So I built Block Engine.

โšก How Block Works

In Block, you write native language blocks separated by tags (<py>, <js>, <lua>, <php>, <server>).

The underlying orchestrator (built with high-performance C# / .NET) automatically serializes and injects variables across runtime boundaries via an in-memory State Pipeline:

<py>
# Python stage: Prepare initial dataset
user = "O-O1112"
dataset = [10, 20, 30, 40, 50]
print(f"[Python] Loaded {len(dataset)} items for {user}")
</py>

<js>
// Node.js stage: High-performance aggregation
const avg = dataset.reduce((a, b) => a + b, 0) / dataset.length;
console.log(`[Node.js] Computed average: ${avg}`);
var bonus = 50;
</js>

<lua>
-- Lua stage: Lightning-fast validation
final_score = avg + bonus
print("[Lua] Final Computed Score: " .. tostring(final_score))
</lua>

Enter fullscreen mode Exit fullscreen mode

๐ŸŽฏ Running it:

block demo.blkp

Enter fullscreen mode Exit fullscreen mode

Output:

[Python] Loaded 5 items for O-O1112
[Node.js] Computed average: 30
[Lua] Final Computed Score: 80.0
โœ” State Pipeline synchronized across 3 runtimes in 320ms.

Enter fullscreen mode Exit fullscreen mode

๐Ÿš€ Key Features

  • Zero-Glue State Pipeline: Variables declared in Python are instantly accessible in JS and Lua without manual JSON parsing.
  • Native Ecosystem Compatibility: Direct access to your existing host pip, npm, and luarocks libraries.
  • Zero-Install NPX Execution: You can run any .blkp file directly in terminal without manual installer setup:
  npx block-engine-runner demo.blkp

Enter fullscreen mode Exit fullscreen mode

  • Modular Imports: Supports <import src="modules/data.blk" /> and custom runtime definitions with <define lang="sim" cmd="node" />.
  • Open Source: Released under the MIT license.

๐Ÿ”— Links & Resources

I would love to hear feedback and thoughts from the DEV community on this state-pipeline approach! What languages would you like to see chained next?

์›๋ฌธ์—์„œ ๊ณ„์† โ†—