LearnNewsExamplesConnect

Neo.mjs vs Angular

Neo.mjs is a multi-threaded Application Engine: the component tree, the state and the logic of your application live in an App Worker, a VDom Worker computes the DOM changes, and the main thread only applies them. Angular is a framework that runs on that main thread and requires a complex, mandatory build process even for development. Neo.mjs needs none: in its development mode the browser runs your source files as native ES modules. It is a self-contained runtime, MIT-licensed and with zero runtime dependencies, which ships a buffered grid that scrolls 100,000 rows, forms, the calendar, timeline, scheduler and Gantt views and dock layouts that span browser windows, across four development and deployment environments up to thread-optimized production bundles.

That engine is the Body of Neo.mjs. Its Brain is an Agent OS, in which AI maintainers from rival labs keep persistent memory, review each other's work and maintain the engine in public. The two meet in the Neural Link: an agent connects to a running Neo.mjs application, inspects its component tree and state, and changes them live. What Is Neo.mjs? covers the Brain; this article covers the Body.

This article provides a focused comparison between the engine and Angular. While both are used to build modern user interfaces, they employ fundamentally different architectural and rendering strategies to achieve their goals. We will explore their approaches to rendering, reactivity, and DOM updates, highlighting the trade-offs between Angular's Main-Thread-bound, build-centric model and Neo.mjs's holistic, worker-based paradigm.

Core Similarities: Building Modern UIs

Both Neo.mjs and Angular share common ground in building modern user interfaces:

  • Component-Based Architecture (with a distinction): Both architectures promote building UIs as a composition of reusable components. However, Neo.mjs extends this concept with Neo.core.Base, allowing any class-based entity (like controllers, models, or routers) to leverage the powerful class system, even if they don't directly render UI. This contrasts with frameworks where non-visual logic might often be shoehorned into component structures.
  • Declarative UI: Developers describe what the UI should look like for a given state, and the engine handles how to update the DOM.
  • Reactive Programming: Both leverage reactive programming principles. Angular heavily uses RxJS for reactivity and change detection. Neo.mjs uses its own fine-grained reactivity system based on Neo.core.Config and Effect, which conceptually aligns with the "signals" pattern for highly efficient, granular updates.
  • Comprehensive & Opinionated Solutions: Both solutions provide a structured and opinionated way to build applications, offering extensive out-of-the-box solutions. However, their nature of opinionation differs, as explored in "Rigidity vs. Flexible Structure."

Key Differences: Architectural & Rendering Strategies

This is where the two architectures diverge significantly, each offering unique trade-offs and advantages.

1. Overall Architecture: Main Thread vs. Worker-Based

  • Angular: Main Thread Focused

    • Angular applications run predominantly on the Main JavaScript Thread of the browser. All component logic, change detection, VDOM reconciliation (if used), and direct DOM manipulation occur on this single thread.
    • Implication: While Angular is highly optimized (e.g., with Ahead-of-Time (AOT) compilation and Ivy renderer), complex computations, large state updates, or extensive component trees can still block the Main Thread, leading to UI jank and unresponsiveness. Angular's change detection mechanism, even with optimizations, can become a bottleneck in very large applications.
  • Neo.mjs: Worker-Based (Main Thread + App Worker + VDom Worker)

    • Neo.mjs's defining feature is its multi-threaded architecture. Application logic (component instances, state, business logic, vdomEffects) runs in a dedicated App Worker, separate from the Main Thread. The VDOM diffing occurs in a VDom Worker.
    • Communication between workers and the Main Thread happens via asynchronous message passing.
    • Benefit: This architecture keeps the Main Thread almost entirely free and responsive, preventing UI freezes even during heavy computations or complex application logic. It inherently leverages multi-core CPUs for parallel processing, leading to superior UI responsiveness and performance under heavy load.

2. Rendering & Reactivity: A Hybrid, Off-Thread Approach

  • Angular: Main-Thread Rendering & Zone.js Change Detection

    • Angular uses templates compiled into renderable instructions. Its change detection relies on Zone.js to monkey-patch asynchronous APIs, which broadly detects when an application's state might have changed.
    • This triggers a change detection cycle on the main thread. While highly optimized, this can still be a bottleneck, and developers often need to manually implement the OnPush strategy to improve performance.
  • Neo.mjs: Off-Thread Rendering & A Two-Tier Reactivity System

    • Neo.mjs uses a Virtual DOM defined by plain JavaScript objects, with the entire diffing process happening in a dedicated VDom Worker. This keeps the main thread free from heavy rendering calculations.
    • Scoped VDOM (Encapsulation & Performance): Neo.mjs's VDOM is scoped by default. When a parent component renders, its children are represented by simple {componentId: '...'} placeholders. This provides two key advantages: 1) Performance: A parent's update never processes the complex VDOM of its children, keeping update payloads extremely small. 2) Encapsulation: It is architecturally impossible for a parent to accidentally manipulate a child's internal VDOM structure, enforcing clear ownership.
    • Atomic Insertion: For insertions, the Main Thread receives a VNode structure and uses DomApiRenderer to build the entire new DOM subtree in memory, completely detached from the live document. This fully constructed fragment is then inserted into the live DOM in a single, atomic operation.
    • Two-Tier Reactivity vs. Zone.js: Instead of Zone.js's broad detection, Neo.mjs uses a precise, two-tier system:
      1. Classic Components (Imperative "Push"): For the 100+ components in the core library, changes to reactive configs trigger afterSet hooks. These hooks perform surgical, imperative updates directly to the component's VDOM.
      2. Functional Components (Declarative "Pull"): For modern functional components, the createVdom function is wrapped in an Effect. When its dependencies change, only this function is re-executed to generate a new VDOM structure.

    This hybrid system provides the architectural robustness needed for a massive component library and the modern developer experience of functional components, all while being performant by default.

3. Component Model & State Management

  • Angular: Modules, Components, Services, Dependency Injection

    • Angular applications are structured around NgModules, components (with templates and decorators), and services. Dependency Injection (DI) is a core concept for managing dependencies and state.
    • State Management: Often relies on services for shared state, or third-party libraries like NgRx (RxJS-based state management).
  • Neo.mjs: Class-Based & Functional Components, State Providers

    • Neo.mjs offers a dual component model. Developers can use a robust class-based system (Neo.component.Base) for complex, stateful components, or leverage modern, lightweight functional components via the defineComponent() API.
    • This functional approach uses hooks like useConfig() for state, providing a clean, declarative way to build UI while benefiting from Neo.mjs's underlying fine-grained reactivity.
    • State Management: Features integrated state providers and a unified config system for managing and sharing bindable data across the component tree, often simplifying cross-component communication compared to traditional DI or prop passing.

4. Developer Experience: Prescriptive Tooling vs. Unparalleled Flexibility

  • Angular: The "Straightjacket" - A Prescriptive, Build-Heavy Workflow

    • Angular is famous for its highly opinionated and prescriptive nature. It dictates specific patterns (e.g., NgModules, decorators, strict DI) and relies heavily on its CLI for a mandatory and often complex build process (Webpack, TypeScript compilation, AOT compilation), even for development.
    • Implication: This leads to slower development server startup times, requires source maps for debugging, and can introduce a steep learning curve. While this rigidity can enforce consistency, it often limits flexibility and makes it challenging to deviate from "the Angular way."
  • Neo.mjs: "Structured Freedom" - A Zero-Builds, Direct Workflow

    • Neo.mjs champions a "zero builds" instant development mode. Developers work directly with native ES Modules in the browser, eliminating the need for transpilation or bundling during development.
    • Benefit: This offers unparalleled speed and debugging clarity. Code changes are reflected instantly. Developers work directly with the real code in the browser's dev tools, eliminating the need for source maps and vastly simplifying debugging.
    • While Neo.mjs provides a robust architecture, it offers significant flexibility within that structure (e.g., plain JS for VDOM, choice of functional or class components), allowing developers more freedom without sacrificing consistency.

5. Component Mobility: Portals vs. True Persistence

A critical architectural difference emerges when dealing with moving components around the UI, especially those with internal state (like a playing <video> or a complex third-party widget).

  • Angular: The CDK Portal

    • Angular uses its Component Dev Kit (CDK) cdkPortal and cdkPortalOutlet to solve a common CSS layout problem: rendering a component's DOM subtree in a different physical location in the DOM (e.g., a modal at the end of <body>). This is a rendering trick.
    • The component's logical position in the Angular tree remains the same, but its DOM is "teleported" elsewhere.
    • The Limitation: If the component that defines the portal is destroyed (e.g., via *ngIf), its state is destroyed. The portal's content is completely recreated from scratch. A playing video would jarringly restart.
  • Neo.mjs: True Mobility by Design

    • This is not a special feature in Neo.mjs; it is a natural consequence of the architecture.
    • Because component instances are stable and persistent, moving a component is a controlled data operation. A developer programmatically modifies the items arrays of the relevant containers, then calls update() on the closest common ancestor. This signals the engine to perform a single, efficient reconciliation that correctly identifies the component move. While calling update() on a higher-level ancestor would also work, targeting the closest one is a best practice that minimizes the scope of the update, showcasing the engine's focus on performance and developer control. This explicit, batch-friendly approach is a core architectural feature, not a hack.
    • The engine recognizes that the component's DOM node already exists. It issues a single, efficient moveNode command to the Main Thread.
    • The Benefit: The existing DOM node, with all its internal state, is simply unplugged from its old parent and plugged into the new one. A playing video continues to play, uninterrupted. This enables a level of UI fluidity and state preservation that is architecturally impossible in a single-threaded model where component identity is tied to its place in the template.

Other Considerations:

  • Rigidity vs. Flexible Structure: Angular is often perceived as a "straightjacket" due to its highly opinionated and prescriptive nature, dictating specific patterns (e.g., NgModules, decorators, strict DI) that can limit flexibility and make it challenging to deviate from "the Angular way." Neo.mjs, while also a comprehensive platform, offers a different kind of opinionation. Its core architectural choices (worker-based, unified config system, Neo.core.Base for any class-based entity) provide a robust structure, but within that structure, it offers significant flexibility (e.g., plain JS for VDOM, choice of functional or class components, integrated features reducing external dependencies), allowing developers more freedom without sacrificing consistency.

  • TypeScript: Angular is built with TypeScript and strongly encourages its use. Neo.mjs is written in plain JavaScript but supports TypeScript usage.

  • Learning Curve: Angular has a reputation for a steeper learning curve due to its opinionated structure, extensive concepts (modules, decorators, DI, RxJS), and reliance on its CLI. Neo.mjs has fewer concepts to learn: classes, reactive configs and components, written in plain JavaScript without a CLI or a build step. The engine runs the workers, so application code never has to manage them.

  • Ecosystem & Maturity: Angular has a large, mature ecosystem backed by Google, and its component libraries for grids, docking and multi-window support come from separate projects. Neo.mjs ships them in one install: more than 450 classes, maintained and released together. Its community is smaller, and its answers are integrated rather than assembled.

  • Dependency Management (Batteries Included): Angular projects often involve a large node_modules directory and can lead to complex dependency trees and version conflicts. Neo.mjs, in contrast, is a "batteries included" platform. It literally has zero real runtime dependencies outside of its own core. This native ES Module approach and integrated engine, significantly reduces this complexity, offering a much leaner and more controlled dependency management experience.

Conclusion: Why Neo.mjs Offers a More Modern and Flexible Architecture

Angular is a powerful and widely adopted framework. Neo.mjs builds the same applications with fundamental architectural advantages: higher performance, a UI that stays responsive under load, and a more streamlined developer experience.

  • Unblocked Main Thread & Inherent Performance: Neo.mjs's unique worker-based architecture fundamentally shifts application logic off the Main Thread. This ensures the UI remains fluid and responsive, even during heavy computations, leading to inherently higher performance ceilings without the need for extensive manual optimizations.
  • More Precise and Efficient Reactivity: By using a surgical, effect-based system instead of broad, zone-based change detection, Neo.mjs is more performant by default and requires less manual tuning from the developer.
  • Superior Developer Experience: The "zero builds" development mode offers a significantly faster, simpler, and more transparent development workflow compared to Angular's mandatory and complex build process.

For the applications Angular teams build today, from everyday business apps to data-heavy dashboards, Neo.mjs is a compelling and technically superior alternative: the components, data layer and tooling in one install, zero-build development, applications that span several browser windows, and a Neural Link through which your coding agent works inside your running app. Start with the Getting Started guide.