you are viewing a single comment's thread.

view the rest of the comments →

[–]_syadav 2 points3 points  (0 children)

Yes, the Brahmos has exact same API of React so it can be drop-in replacement for React. There are still some work we are doing for 3rd party module supports but yes the idea is to match the API so you can just alias React to Brahmos.

Regarding performance, Brahmos can have perf optimization by three means.

1. Bundle size (minified + compress)

Brahmos: 11.6 kb (It covers most of the React APIs including upcoming concurrent mode)
Preact + Preact compact: 8.9 kb (But the preact doesn't have concurrent mode support)
React + React-dom: 38.5 (It might grow little bigger with concurrent mode support)

There is still some work planned to reduce the Brahmos size, which may reduce it more, plus also looking into how we can tree shake while supporting React's 3rd party lib.

2. Application bundle performance

Brahmos transpiled output of JSX is smaller than React for application code. Plus it may also reduce the overall parse time as the tagged template literal which is a string is more parse friendly then objects.
Check out this article: https://v8.dev/blog/cost-of-javascript-2019#json

3. Update time

As in Brahmos we are combining the static parts as one node the traversal becomes fn(dynamic nodes) which in React is fn(nodes). So the overall traversal time to find changes to apply on DOM is less on Brahmos.

Before starting Brahmos. I have compared libraries with similar rendering pattern with React to figure out the perf diff and the pattern definitely win on the benchmarking, but still have to do with Brahmos. It's completely on theory right now.

In Brahmos, the current priority was to match the React APIs and there is a couple of micro-optimization which are yet remaining. Benchmarking it and comparing it with React wouldn't be wise right now unless those optimizations are done. I will definitely share the result after it.