6 ms·
Bare: Run JavaScript Everywhere
- sirjaz 2y agoThis looks like a great way to get away from electron. Build js apps for the desktop without the overhead of electron
- freeone3000 2y agoWhat does this offer as an alternative to node? I’m looking at the supported platforms page and the list is essentially the same as the node ones… does it have a wasm target? An embedded target? What’s new here?
- noddingham 2y agoMy first thought was maybe they are following the advice of instead of creating something new, just clone something successful and riff on it. As you pointed out it's hard to determine why Bare other than it isn't Node.
- mjgoeke 2y agoMobile? afaik node.js doesn't run on mobile. If that's the case the 'copy' doesn't do a good job of highlighting the big value prop.
- SahAssar 2y agoThere is nothing stopping node from running on mobile and IIRC quite a few apps embed it as a part of electron or similar frameworks. If i understand correctly bare can instead use much smaller engines like quickjs (and maybe libjs), but I'm not sure how the stdlib situation is for those.
- kasperisager 2y agoBare supports both QuickJS (https://github.com/holepunchto/libqjs https://github.com/holepunchto/libqjs) and JerryScript (https://github.com/holepunchto/libjerry https://github.com/holepunchto/libjerry), yes, allowing it to run on much more constrained devices than what Node.js is capable of. I'm running it on my MediaTek-based LTE router, for example, using JerryScript.
- maxloh 2y agoFrom their README [1]: Bare itself only adds a few missing pieces on top to support a wider ecosystem of modules: 1. A module system supporting both CJS and ESM with bidirectional interoperability between the two. 2. A native addon system supporting both statically and dynamically linked addons. 3. Light-weight thread support with synchronous joins and shared array buffer support. Everything else if left to userland modules to implement using these primitives, keeping the runtime itself succinct and bare. [1]: https://github.com/holepunchto/bare#architecture https://github.com/holepunchto/bare#architecture
- tomw1808 2y agoI somehow do not get it, quite possibly a knowledgegap on my side - is that another runtime such as bun? What's the difference? Isn't the problem always just ios for cross platform - is bare running on iOS? Can you shed some light on this?
- hidelooktropic 2y agoSame. The "runs on mobile" part I assume is Android only? How do I develop something for iOS that uses Bear? Seems like a limitation they wouldn't be able to lift but maybe I'm missing something Update: from home page > Built for Mobile > Embedding a JavaScript runtime on mobile is easy with Bare Kit. Bare Kit allows you to create "worklets" or isolated Bare threads which expose an IPC with bindings for Android and iOS. With React Native, you install `react-native-bare-kit` and create a `Worklet` instance passing the JavaScript you want to run.
- kasperisager 2y agoBare supports both iOS and Android, yes. Bare Kit provides some convenient abstractions for integrating Bare with native application frameworks like Swift UI and the Android service architecture, but plain Bare runs just fine on iOS and Android out of the box. There's even prebuilt binaries for both platforms.
- kasperisager 2y agoBare runs on iOS, yes. The tricky part with iOS in particular is loading of native addons. Bare solves this through https://github.com/holepunchto/bare-link https://github.com/holepunchto/bare-link which is capable of generating XCFrameworks on-demand that can then be linked with and signed as part of the application bundle.
- h1fra 2y agoThe marketing website is so confusing, and the name doesn't help. There is nothing that node can't do in the few presented bullet points, so really I'm confused. Maybe it's the size of the runtime?
- heeton 2y agoI still can’t tell if this is an April Fool’s joke or not.
- kasperisager 2y agoThe point of Bare isn't to do what Node.js already does. If that had been the case we'd just have continued using Node.js. The point of Bare is that on its own it can't really do anything. To do actually useful stuff, you have to resort to userland modules and those can evolve independently of Bare itself. Contrast that with the Node.js standard library which is tied to a particular version of Node.js and brings with it tons of legacy that's still there for the sake of backwards compatibility. Bare has none of that, not just because it's newer but because it ships with nothing but a handful of solid fundamentals that we don't expect will evolve much, if at all.
- tigen 2y agoAs someone who isn't well versed in this Node ecosystem, why is omitting a standard library a separate project? It sounds like something you'd do as a Node feature, or variant of Node, or some command line switch or env var or whatever else is needed to avoid whatever it is you are trying to avoid.
- kasperisager 2y agoThere's no way to not bring along the entire Node.js standard library when you're using Node.js. It also doesn't provide a way to fully abstract over the underlying JavaScript engine, which Bare needs to be able to support swapping out the underlying JavaScript engine without any code changes. See https://news.ycombinator.com/item?id=43559532 https://news.ycombinator.com/item?id=43559532 for more on that.
- hakaneskici 2y agoI found their GitHub repo more useful for technical details: https://github.com/holepunchto/pear/ https://github.com/holepunchto/pear/
- vidyesh 2y agoThat is pear. This is bare https://github.com/holepunchto/bare https://github.com/holepunchto/bare
- jamil7 2y agoOh nice, I once built a very simple version of something like this to be able to run a whole lot of existing JS code on mobile.
- maxloh 2y agoIt seems that Bare is also built on top of V8 and libuv, much like Node.js. Bare is built on top of https://github.com/holepunchto/libjs, which provides low-level bindings to V8 in an engine independent manner, and https://github.com/libuv/libuv, which provides an asynchronous I/O event loop. (from their README) Moreover, you actually need Node.js and npm to install and run it. You need another JavaScript runtime as a prerequisite to install this JavaScript runtime… npm i -g bare (also from their README) I don't get it – is it worth it to choose Bare over a more established and welly-maintained solution?
- kasperisager 2y agonpm allows for simple distribution of the prebuilt binaries, but is by no means a requirement and neither is Node.js. It's just a convenient way to ship things; npm is an excellent package manager!
- kasperisager 2y agoThis is the thing I'm working on, happy to answer questions! It's always an honor getting roasted on Hacker News.
- gavinray 2y agoSome background context that might be useful for other readers wondering what they're looking at: 1. One of the core contributors on this is an individual who has essentially been the driving force for P2P applications in JS-land (the "hyper" stack, like hyperswarm and hyperdrive). See: https://github.com/mafintosh https://github.com/mafintosh See previous discussion on the "dat" protocol, built on top of the aforementioned (https://news.ycombinator.com/item?id=22909998 https://news.ycombinator.com/item?id=22909998). 2. To that end, the target userbase is something like an "It-Just-Works P2P Developer". You want a cross-platform solution that allows you to host networked applications on your device, in JS. I'm not very knowledgeable about this domain. I built a small "dat" application years ago.
- seivan 2y ago[dead]
- supersuryaansh 2y agoI have been developing with bare for a while now, normally our app takes 45 MB to run with Node but the same app runs 10 MB lower in Bare. For 10 instances of our app, it is easily 10x10 = 100 MB of saving with Bare.