What’s Similar
O! deliberately mimics React’s core concepts and API.Functional Components
Both use functions that return virtual DOM:Hooks API
O! implements three core React hooks with nearly identical APIs:- Must be called at the top level
- Must be called in the same order every render
- Cannot be called conditionally or in loops
Virtual DOM
Both use a virtual DOM layer:Component Props
Both pass data to components via props:What’s Different
Despite the similarities, O! is much simpler and more limited.Size
O!
~1KB minified + gzippedUnder 320 lines of code
React
~40KB (React + ReactDOM) minified + gzippedHundreds of thousands of lines of code
- Simple diffing algorithm
- Only 3 hooks
- No error boundaries, context, refs, etc.
- Minimal optimizations
Template Syntax
O! uses tagged templates instead of JSX:| Feature | O! | React |
|---|---|---|
| Syntax | x`...` tagged template | JSX requires Babel/TypeScript |
| Transpiler | None needed | Required |
| Attribute quotes | Must use double quotes | Optional |
| Event names | Lowercase (onclick) | camelCase (onClick) |
| Boolean attrs | disabled="true" | disabled or disabled={true} |
Diffing Algorithm
The reconciliation approach is fundamentally different: O! (simple position-based):- Compares nodes by position (array index)
- Creates new nodes if tag/text doesn’t match
- No move operations
- Very inefficient for list reordering
- Uses keys to track elements across renders
- Can detect moves, reorders, and insertions efficiently
- Batches DOM updates
- Highly optimized for performance
API Completeness
O! implements only a tiny subset of React’s features:Hooks - O! has 3 of 15+
Hooks - O! has 3 of 15+
O! provides:
useStateuseReduceruseEffect
useContextuseRefuseMemouseCallbackuseLayoutEffectuseImperativeHandleuseDebugValueuseDeferredValueuseTransitionuseIduseSyncExternalStore- And more…
Component Types - O! only supports functions
Component Types - O! only supports functions
O! supports:
- Functional components
- Class components
React.memo()for memoizationReact.forwardRef()React.lazy()for code splitting
Advanced Features - O! has none
Advanced Features - O! has none
React exclusive features:
- Context API for state management
- Portals for rendering outside hierarchy
- Suspense for async rendering
- Error boundaries
- Refs for DOM access
- Fragments (
<>...</>) - Strict mode
- Profiler API
- Server-side rendering
- Concurrent rendering
- Automatic batching
Events
O! uses native browser events:- Cross-browser consistency
- Event pooling (optimization)
- Additional features
Property Setting
O! sets properties directly on DOM nodes:- Knows which props are attributes vs properties
- Handles special cases (style objects, etc.)
- Normalizes values across browsers
Developer Experience
O!
- No DevTools
- No error messages
- No warnings for common mistakes
- Minimal documentation
- No TypeScript types
- No testing utilities
React
- React DevTools browser extension
- Helpful error messages
- Warnings in development mode
- Extensive documentation
- TypeScript support
- Testing libraries (React Testing Library)
What’s Missing in O!
Beyond the differences above, O! completely lacks:State Management
- No Context API
- No Redux integration
- Each component manages its own state in isolation
Ecosystem
- No router (React Router)
- No form libraries
- No UI component libraries
- No build tool integration beyond ES modules
Production Features
- No server-side rendering (SSR)
- No static site generation (SSG)
- No code splitting
- No lazy loading
- No performance optimizations
- No error recovery
TypeScript
- No type definitions
- No JSX type checking
- No prop type validation
When to Use O! vs React
Choose the right tool based on your needs:Use O! For
✅ LearningUse React For
✅ Production ApplicationsPerformance Comparison
While no formal benchmarks exist, the theoretical performance characteristics:| Scenario | O! | React |
|---|---|---|
| Initial render (small) | Similar | Similar |
| Initial render (large) | Slower | Faster |
| Simple updates | Similar | Faster |
| List reordering | Much slower | Much faster |
| Deep tree updates | Slower | Faster (batching, optimizations) |
| Memory usage | Lower (simpler structures) | Higher (more features) |
| Bundle size | Much smaller (~1KB) | Larger (~40KB) |
Philosophy Comparison
The libraries have different design philosophies: O! Philosophy:“It’s really an exercise in minimalism, and nothing more.”
- Smallest possible implementation
- Educational value over production readiness
- Simple code that’s easy to understand
- No abstractions beyond the core concepts
- Production-ready and battle-tested
- Rich ecosystem and tooling
- Performance optimizations
- Developer experience
- Backwards compatibility
- Extensive documentation and support
Learn More
To understand why O! was created and how it works:The Worst React Ever
Read the author’s blog post about creating O! and what it teaches about React-like libraries.
Next Steps
- How It Works - Deep dive into O!‘s internals
- Limitations - Understand what O! cannot do
- Quickstart - Start building with O!
O! proves that the core concepts of React (virtual DOM, hooks, functional components) can be implemented in under 320 lines of code. It’s a testament to React’s elegant design, even if O!‘s implementation sacrifices everything else for simplicity.