Tauri: Rust-based Electron alternative releases beta
tauri.studio
tauri.studio
https://dev.to/tauri/announcing-tauri-beta-more-efficient-cr...
See https://github.com/tauri-apps/wry
Edit: s/IE or Edge/Edge
If your html/css/is has to work correctly in EdgeHTML, Safari Webview, and Blink, you are limited to the lowest common denominator features.
Electron with Chromium has the largest feature set out of all of those.
A lot of the big electron apps I’m aware of are the same (slack, notion, discord, etc).
AFAIK, if you're writing a greenfield Electron app, it's best to do as little as possible in the renderer side, and as much as possible in the Node.js side, because the Node.js side has things like native threads and mmap(2), and everything running within the Node.js process can share that state, but things on the renderer side have to use it through RPC.
I would assume that this project is similar, but with arbitrary Rust code in place of Node.js (is that right?)
In that case, it doesn't matter how featureful the renderer is, as you're just using it as a GUI framework with a declarative view-model format. Just like a XAML or QML, but it's HTML+CSS.
As such, idiomatically, you won't be using fancy browser APIs like threads or WebRTC within the renderer; instead, you'll be using native code on the "app side" and then passing the renderer data. The features of Tauri itself are "whatever native libraries you want to bring into your Rust binary." (Plus whatever conveniences it already builds in, of course.)
Think of it like this: let’s say you’re creating an Electron equivalent to Mathematica. You have a big native blob of maths evaluation code. Where are you going to run it — in the renderer (as Emscripten WASM) or in a worker thread of the native app (as a native static library or DLL)?
Or let’s say you’re doing an Electron BitTorrent client. Where are you going to handle the network connections and do the file management and... basically everything the app does? Well, in this case, you have no real option: the renderer can’t open raw TCP sockets. You’ve got to do it native. (But it would have been the better choice anyway, for IOPS reasons—localStorage + virtualized attachment downloads don’t buy you very much disk concurrency.)
A less clear-cut case is a game engine. The answer there depends on whether you can get a handle to the renderer’s Canvas from your native code. If so, then the choice is obvious: native game engine, draw to renderer’s canvas. If not, it might still be more CPU efficient to go native: you might be able to approximate that over RPC if your game has a bandwidth-efficient wire protocol representation of its render command stream (as e.g. most 2D tile based games do.) Only if neither of these work would putting the game engine into the renderer be optimal.
I don't know the extend of WebView in Electron is it something common?
Edit: This is not something you run into with electron. It's the reason electron apps are so big, they bundle the whole browser engine.
Specifically:
1. Can I place it into a native window handle (e.g. HWND on Windows)?
2. Can I create a new window, but use the parent application's event loop without modification?
Thanks
Are you asking for them to make an entirely different product?
I hear you though. It's, IMO, a core tool missing from my Rust toolbelt.
If anyone is interested, it would be much easier to create those bindings to Rust. I'm super interested (and i would probably create a Rust SDK anyway) and there's a lot of other bonuses that neither Electron or Tauri can offer (as i target it not to be "just" a web-based app platform, but something that also had the soul of web browsers, by forming networks, addresses, etc).
If anyone is curious, there is more disclosure in another answer on this same thread.
i would love to give new all of those cool new languages that need a platform to thrive: Rust, Zig, Crystal, (and while not new) Python, a chance to have a 360 ecosystem, so we can stop being hostage of just Javascript being used.. and no, WebAssembly is definitely not it, as in the end it will give Javascript access to FFMPEG and the likes making it more prominent and ubiquitous
If it’s an electron alternative, is it too much to ask to show an image of a webapp running on a desktop (preverably a variation of every OS) front and center on the landing page?
I’d like to see it working immediately, without needing to watch any videos.
I agree it’s confusing and not clear on the homepage or from the hacker news title. I was expecting something like an electron framework using servo.
Not that I don't also acknowledge the need for that, but my application is dramatically faster in Firefox than Chrome, yet we're stuck packaging a suboptimal experience in the desktop app because Chromium is our only option.
I might as well just ship a website at that point, almost everything that makes Electron appealing comes from shipping your own rendering engine.
> why would I want to trade control over how my app is render for ~100MB of disk space?
it depends how much you respect your users
That's irrelevant, just because I can't do some things on iOS doesn't mean that I shouldn't do them under desktop OS' too.
Just one example: file system watching, if I need to do that with Electron I'll just use `chokidar` and have it working in no time, plus I can share whatever frontend code with the backend too, good luck doing the same with Tauri (given the current state of things anyway).
> it depends how much you respect your users
I don't know what kind of users you've got but mine care about me iterating quickly on the app, care about having new features, care about having a faster app. Most of them would consider trading any of that for ~100MB of disk space stupid.
As I said, if disk space is all you care about you might as well just ship a website.
That doesn't make sense to me, you are still using a browser at the end of the day. Sure you can save some memory by not bundling Node (at the cost of making even reading a file much more difficult), but that's not orders of magnitudes.
But I think that would save much less memory than people think. A bare-bones hello-world Electron app consumes about ~100MB of RAM (rough figure since it depends on many factors), maybe you can bring that down to ~20MB by sharing a common browser instance (I doubt it, a Chrome tab takes like ~50MB for me right now), but if your app uses 1GB+ of memory that has way more to do with how the app is coded than by having to spawn another instance of the browser. Basically you won't get a memory hungry app consuming 10x less memory by running it as a website.
Have one, real Multithreaded +, more efficient backend, will reduce memory and offer better performance.
Wails is also an alternative that does just that. Shared Web UI engine + Go compiled backend.
AFAIK Electron requires 1 Node instance (you can disable it for renderer processes and you can have 0 WebWorkers or only WebWorkers with Node.js disabled) which consumes like ~50MB or something like that, which probably accounts for stuff other than Node.js too, if the app you are using require multiple Node processes that use huge amounts of memory they are just badly written.
> Have one, real Multithreaded +, more efficient backend, will reduce memory and offer better performance.
You can't just share Node.js across multiple apps, Tauri just doesn't bundle it at all, which is a whole different story with mostly downsides from my point of view.
Ins't the easy answer. Each time a dev want to ignore valid comments.
I have the following electron app running: Spotify, Figma, VS Code, Discord, Slack. They all use more than 1 helper. Consuming between 600mb to 3.5gb.
Slack is much better than it was. But I wish they switch to something like Tauri or Wails in the future.
Is 600mb too much for VS Code? I guess it depends on what you are doing with it and which extensions you have installed etc., if you are running a pretty bare-bones installation and seeing 1GB+ memory usages in VS Code please open an issue in their issue tracker and tag me (same username as in HN).
> Slack is much better than it was.
And that didn't happen by switching to the website approach, I think you'll be disappointed if any of these apps end up switching to Tauri or Wails without significantly improving their code too. Which is why I'd predict no major player will jump ship.
Calling an app junk to justify is argument is unconvincing. Its still a widely used app that works as good as the competition. In the case of slack, their optimisation endeavour seems to cost them quite a lot. But sure I don't have the number. If they would have start the project in Tauri or Wails at the beginning, would that saved them the refactoring? I don't now. But we will need more team using that kind of alternative to gain the knowledge and real benefit.
At this point I rewriting a toy project from electron to wails and its great. But well, it's only a toy project.
That sounds like a lot, you are probably running some heavy extensions or too many of them I guess, could you post a screenshot of the "process explorer" window for your instance of vscode?
> Calling an app junk to justify is argument is unconvincing.
I couldn't care less about what you think about Electron, that's just what I think.
Im working on something not quite the same thing but that deal with all this, and being able to ship with a web rendering engine and not using whatever its on the system is actually better giving all the power, bindings, compromise you can make that you are unable when you can only deal with a abstract wrapper to every web rendering engine out there.
Lower memory footprint but with much less features and a generic "no sir, cant do such a thing.." as a answer to users that will need important features to ship applications with this.
I agree that Electron is user hostile in the way it uses memory, but there's an answer in between the Electron and what Tauri is offering here.
Tauri could have a embedded engine and yet propose a better architecture and better use of memory in consequence. The best of both worlds.
In Chrome for instance, each tab is equivalent to a app, giving is a whole isolated process and yet it doesnt kill your machine even with many tabs open.
If every little desktop widget loads its own browser engine, most of that RAM will be spent on redundant copies of Chromium.
If your Electron app is something that you expect users to run almost exclusively, then no problem. If it's just another little client app for some service, please consider a solution that would reduce its memory footprint.
It makes sense to use frameworks like Electron if they enable new capabilities for your app, and Electron is very good at that, bundling Node.js with it, which allows you to share code between frontend and backend and tap into the same ecosystem of packages, plus chances are you already know Node.js, Tauri is enabling 0 of this, at least presently.
Actually better results even, because under macOS for example the webview is provided by Safari, but if you are using Chrome/Firefox as your browser of choice and you are using a Tauri app now you are using 2 browsers effectively, while if you ship a website you can use that website with whatever browser you prefer.
Tauri's website is way, way worse. Tauri uses unnecessary jargon where Electron's site uses simple, more direct language.
Electron:
> Build cross-platform desktop apps with JavaScript, HTML, and CSS
Tauri:
> Build smaller, faster, and more secure desktop applications with a web frontend
"web frontend" vs. "JavaScript, HTML, and CSS"
Electron and Tauri have icons with labels.
Electron:
> Web technologies, Open Source, Cross Platform
> Automatic updates, Native menus & notifications, Crash reporting, Debugging & profiling, Windows installers
Tauri says:
> Brownfield, FLOSS, Bundle
> Security, Patterns, Cross-platform
https://tauri.studio/en/docs/about/intro
> Tauri is a toolkit that helps developers make applications for the major desktop platforms - using virtually any frontend framework in existence. The core is built with Rust and the CLI leverages Node.js making Tauri a genuinely polyglot approach to creating and maintaining great apps.
Electron doesn't have an equivalent "about" page, but instead has this paragraph on its home page:
> It's easier than you think: If you can build a website, you can build a desktop app. Electron is a framework for creating native applications with web technologies like JavaScript, HTML, and CSS. It takes care of the hard parts so you can focus on the core of your application.
"virtually any frontend framework" "polyglot" vs. "takes care of the hard parts"
this means your app has hundreds of javascript versions to target
FLOSS also means a different thing from Open Source because of the "Libre" aspect.
I don't see why being different is considered bad here, as its whole shtick is that it's an alternative.
Shout out to all of the hardworking people behind Tauri. ♥
I think problem is that it is over polished and slick not unpolished.
maybe make this text a bit more explicit? I'm guessing maybe you're using a message passing layer to keep the processes separate?
I'm a bit surprised the new website doesn't mention this at all. The Github repo does.
Can we just stick with "best tool for the job"?
Rust for performance-critical systems and, say, typescript for front-end? Using a single language for everything is a wet dream that always ends up in complexity and more work as you're fighting the "native" ecosystem.
You don't need to offer a perspective on everything, and I prefer the critiques I read to be well-founded.
Isn't typescript contract?
This is not really about JS, if I want to replace JS I'll pick a language with similar characteristics that make it successful. Similar to how you replace C++ with rust, another language that gives you control of memory. For app developments they are simplicity and a focus on domain modelling with a good type system (this is typescript teritory), NOT memory safey.
And don't tell me that rust's type system is powerful too, yes, but it's also complex and the focus isn't domain modelling. Like C++ and golang's type systems, it's there to aid the compilers/borrow checker, not developers.
Example of such language in my other comment: kotlin, F#
> the focus isn't domain modelling, like C++ and golang's type systems
Could you please explain what you mean by this? I've honestly not heard this argument before so I'd be interested what domain modeling Rust doesn't encourage/support that, e.g. Go does.
Really, almost any GC'ed language out there is a better pick for this sort of task (except the ones that are poorly designed for this, like Go).
You speak of "unnecessary complexity" like the complexity was just pulled out of thin air for the purpose of making Rust harder; no, the complexity is inherent to building a functioning application, the difference is whether it lives in your head or it lives in the compiler. Personally I'd rather the compiler handle things like bookkeeping, moving memory around, checking that the types and cardinalities are right, and ensuring errors are handled rather than repeatedly having to debug those things at runtime in an extremely slow and punishing feedback loop.
Its necessary for system programming, and as we can see people talk about it whenever C++, C, OSes, Browsers, Games, etc.. are being talked about because it works really well in those domains.
But when you are building a UI, C#, Kotlin, Swift, Typescript and even Java are much more productive with good speed, safe (even safer than Rust), and with language constructions that map really well to this domain.
Rust achieved a very good set of features, but unfortunately the price is its complexity, which is a burden you don't need to take when you are creating UI's.
Sure you and i (im mostly a C++ dev) can use it to make UI's, but unless you are creating something really complex that needs every drop of performance and memory, like big Games or a Photoshop, you don't need this productivity and HR tax(its much harder to find people in C++ and Rust) that languages like Rust and C++ ask of you.
There's no such a thing as one language to rule them all, and Rust will not the best candidate for domains it was not designed for. Swift for instance is much better at this and with a very good performance, where it would also be a good fit for a Photoshop clone or a browser.
Rust will make a great UI language once the ecosystem has matured and async has gotten polished more. If upgrading the "Webpack" of the future meant just resolving compiler errors, we would be in a much better world. Same goes for upgrading dependencies on the frontend, which at my company becomes a blocker every 2 weeks or so due to the NPM security advisories being released, accompanied by the total lack of visibility into the dependencies' interplay that the Node ecosystem gives you.
In my case i'm comparing it with languages that are also powerful, safe, fast and more well designed for this kind of scenario, which JavaScript or Python aren't.
But if i had just two picks, between JavaScript or Rust, of course i would choose Rust without blinking. But once there is more options.. (in this case you can read my comments above).
And i agree with you, that if you sum it all, maybe you get more productive (as in ready to ship) in Rust than with JavaScript.
C# - requires an obscure runtime (Mono) on most platforms
Kotlin - suffers from JVM's infamous GC pauses and startup time
Swift - not open source (not SwiftUI, the good part)
TypeScript - mostly same problems as JavaScript
Java - same problems as Kotlin
No one has managed to do open source cross-platform development well yet IMO. I'd be happy to be proven wrong.
F#: https://safe-stack.github.io
To watch:
Kotlin NATIVE
Scala NATIVE
Note that even with Scala's complexity, the language's focus is first and foremost domain modelling & expressiveness.
Rust is first and foremost, a language for memory safety and raw performance, it just happens to have some level of expressiveness. Nothing wrong with that either.
One difference is to be able to ditch Javascript and use a native language(Swift is the first one) to talk directly to webkit.
The other difference is that the apps are "managed" as Chrome manages the renderer process, so in the end you have one manager process and one service process for each app and many process for the UI apps.
The problem with Electron is that for each app, it will need many processes, and if you have more than one Electron app running, it will eat all the resources.
With the architecture proposed, it will be more light as there will be just one instance of the manager processes, and unlike Electron they would not be isolated as they are all centrally managed, also the fact that it wont need to use JS, will also put less pressure on memory resources.
It also uses RPC so that every app have a API that can be callable by others. This in turn can make it form a "network of apps" where the applications can consume the apis of the other apps installed. The RPC service is local first, but can fetch things in the "cloud" if the application needs to.
For me this is my take on what "Web 3.0" should look like.
I have a 0.1 version here and i'm just finishing the final touches before launching it..
Edit: Also i forgot to mention that the distribution of the application and resources(database and files) is over torrent with DHT routing, so you can share a unique address and serve your own applications over internet without depending on domains or a third-party hosting it for you.
Do you need / want any help?
Then for each application: You have a "service process" which is instantiated and is always running, this process asks for the manager to create its rpc service server. Then every rpc call is routed to it.
This application service process is already coded by the developer so he defines what every api does and also how it respond to resources like pages, images, videos, etc.. (it also uses RPC by default to route resources.. but its through HTTP/2 giving its gRPC/Protobuf)
This process, totally in control of the dev code also can hijack its own application launches, so its in charge of app launching and killing (from its own scope)
Then theres the UI process which is akin to renderer and its also coded by the dev, where the renderer is in Swift so totally customizable (Imagine being able to control the C++ renderer events, lifetime, frames, etc.. of the chrome renderer process; in this case you do, with Swift), giving you have a lot of power.
The developer control, codes and ship the service and the ui app. Once its installed, even without any UI, all other applications can consume its services over its RPC api, because there is a 'service process' running and serving those requests (imagine being able to deal with twitter or a google search api (all local and with the same tech) from your app that is specialized in something else)
> Do you need / want any help?
Yes of course! How can i reach you?
And you can always just use some of the other GUI toolkits that have been coming out recently.
Tell me what it is, show me what it looks like, provide a "Hello, World!" API example for opening a window on the front page. Stop contributing to landing pages that jerk the consumer around.
They've got a point. Time to cut through the hype, get straight to the point and show some screenshots to catch their eyes.
If you can't manage that, the tab gets closed with in 5 seconds. Even if it has the Rust buzzword. (Because that trick always works on HN)
But of course, there is not much to see, it's just a window with a web view inside of it.
https://guijs.dev/ https://github.com/samirdjelal/bidirectional/ https://github.com/mmpneo/simple-obs-stt
It's not for "people like me," it's for everyone. In terms of volume of traffic you're going to get, no one else cares about this stuff.
Here's an example of one of my projects where I do just that: https://www.planimeter.org/grid-sdk/ Literally! I tell people what my team has built. I show them a screenshot. I then provide API examples. Mine could be better if I provided screenshots per API example, too. Everyone can improve.
Your audience is technical, they don't want a non-technical pitch. Tell me it's faster than Electron, show me RAM usage comparisons, etc.
Avoid putting things in people's face before they've gotten to know you. You're not trying to be a food blog throwing pop-ups in people's faces about how they need to subscribe to your newsletter. You're trying to be a competitor to Electron.
Here's what their website tells me what they do:
> Build cross-platform desktop apps with JavaScript, HTML, and CSS
Ah! OK. I'm interested. And see how specific they are? Don't be vague. Don't say "web front-end," what do you mean? React? They then show me screenshots! Of what big companies built!
Then. They provide a Getting Started section. Not great, could be better. I want to see how it's used. But this is the bar. Be better than that bar.
Edit: Even Electron's site provides Getting Started at the end.
We say "web frontend" because that's as descriptive as we can be really. We support any web framework that runs in a browser. As for screenshots of big companies' apps, we don't have any major companies that have adopted Tauri yet, as we just came out of alpha, but we will add a section like that as soon as we can.
It's difficult for us to demonstrate how Tauri is used in short snippets that could fit at the beginning of the Getting Started section. Electron's site doesn't have any code snippets either, just snippets for installing via npm and some example apps.
It also doesn't help that we chose a language that isn't popular. But you all need to think about how decision making like that massively effects adoption.
You won't learn these lessons quickly, they take years, so ignore people who say you need to experiment and research what works. The biggest issues you'll face is that no one will tell you what's wrong unless you're faced with it in threads like this on HN or other places where you'll meet consumers.
The worst part of it is, these are the obnoxious glaring details. There might be massive decisions you make that consumers can't pinpoint for you. Thought-leaders don't often describe those details because of survivorship bias.
What I can see this team failing at, too, is that you need an anchor client. You're spending all this time on BS that doesn't mean anything at all.
Specifically, at GitHub, they already had users using Atom, which made for a great way to advertise Electron. It was Atom!
You need to essentially find whales (Read: engineering leaders at businesses) and make the product good enough for one of them to say, yeah I'll use this over Electron, and if they're an attractive user, pump them on your front page. Find a way to make a deal with them so that you can funnel developers to their hiring channels.
When you create entities in the engine, all you have to do is specify what fields you want networked, and the game engine automatically serializes deltas for you on that field as they change.
It takes care of more advanced field networking like prediction as well.
You focus on making things, not making them networkable. If you want that, you just say it's networked. That's it.
Similar idea with news. The objectives of profit and conveying meaningful information aren't necessarily aligned.
Disregarding the subjectivity of 'meaningful,' the advice 'know your target audience' is good from both a product design and marketing presentation stand point.
Maybe it is possible to have a landing page that people leave much more quickly but that is more successful. Maybe it is possible to keep your audience informed without them watching for very long.
It's not that the site is 'marketing speak', it's just that it's a 3/10 on communications.
Even two sentences at the top would help.
I've spent a minute on it and I'm not sure what it is.
It's a way to make apps, but it doesn't have a front end? I don't even know what that means.
Even though the project itself sounds very promising, because "Rust" and "Electron alternative".
But how can I know if it really is an Electron replacement if I'm not even sure if I can create native context menus or integrate it into the SysTray?
Then provide screenshots/code samples for each item in the feature list.
That sounds like a solution. Or just add some screenshots/code samples to what is already implemented in the roadmap.
Also, I liked the way they presented their roadmap.
> ...the Tauri-team incubated and maintained WRY, which creates a unified interface to the system webview (and other goodies like Menu and Taskbar), leveraging WebKit on macOS, WebView2 on Windows and WebKitGTK on Linux.
Besides, all of the relevant engines are WebKit variants, so you're not targeting Trident or Gecko or anything.
Bear in mind that a lot of popular "apps", like Slack, Discord, etc., are web apps anyway, so there's a decent chance that the "support more than one of them" problem is already solved anyway, meaning you don't have to spend any more development time but you get huge increases in performance and responsiveness.
I want people to be direct about how my projects need to improve, because I know how it doesn't meet my standards, but I don't know how it fails to meet other people's standards, which is more important if you're concerned with adoption.
See my other post in this thread for an example.
That's the first paragraph on the About page. Landing pages have multiple purposes and need to address different types of viewers, not just the neckbeards. The marketing speak is likely more for convincing IT manages this is a legit project and does not have common "deal breakers".
If this is the case, it's an excellent reason to not use Tauri. Making their decisions based on what IT managers want to read rather than what developers need to do their job? Good luck with that, might work in some bubbles but the rest of the world is trying to be productive.
yarn add @tauri-apps/cli
yarn tauri init
yarn tauri build
I'll admit you'll probably have a couple extra configuration steps in there. But I found it much easier to get started than with Electron and the resulting app seems pretty slick.Answering my own question, https://github.com/tauri-apps/wry , so looks like it loses one of the advantages of Electron in that you control the exact browser in use. Maybe that's incorrect. Who knows? Web site appears to not exist to provide such important details.
https://github.com/tauri-apps/tauri/blob/dev/ARCHITECTURE.md could lose a few thousand words, but this seems to be the real starting off point