TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Building a fast Electron app with Rust

248 点作者 hellerve大约 7 年前

24 条评论

actf大约 7 年前
I really like where the author went with this. Everytime I read something like this though I can&#x27;t help but think how we as developers really need a better low level, UI framework for cross platform applications. What the author has done here is a cool idea, but ultimately this still feels flawed, and like it&#x27;s a workaround to the difficulties of writing a cross platform UI. Everytime I read something like this I can&#x27;t help but think about how great a low level, cross platform C (or C ABI) library would be (think something like libuv but for UIs). Such a library would abstract away the OS specific system calls of the UI while still providing the ability to easily do things like: * Create a window * Draw to the screen * Declaratively (i.e. html like) add UI widgets to a scene * Apply CSS like styling (like QML, JavaFX, or XAML) * Use native file dialogs, menus, notifications, etc * Statically link as a single dependency<p>I don&#x27;t even think something like this necessarily needs to provide native UI elements, rather it just needs to be a more performant, easier to use, smaller, version of electron that could easily be used from any language. It needs to provide common UI elements like buttons, textboxes, divs, grid layouts, etc, but judging by the popularity of electron - I don&#x27;t think those necessarily need to use native elements.<p>Qt is close to this, but it feels heavyweight and in my opinion its biggest flaw is that it&#x27;s difficult to link to an application and setup a development environment for. Tk is kind of like this, but way too limited. JavaFX is a really good example, and would be perfect if it wasn&#x27;t Java only (same with WPF but it&#x27;s C# only). Right now the closest attempt to something like this that I know of is <a href="https:&#x2F;&#x2F;github.com&#x2F;andlabs&#x2F;libui" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;andlabs&#x2F;libui</a><p>I think libui could even be a starting point for such a library, but the library I&#x27;m thinking of would need some type of declarative UI support (i.e. html like, maybe even support for a subset of html), built in support for styling, and less of a focus on using native widgets. I really wish somebody would build something like this.
评论 #16612751 未加载
评论 #16612720 未加载
评论 #16612703 未加载
评论 #16614371 未加载
评论 #16615477 未加载
评论 #16615440 未加载
评论 #16613004 未加载
jayflux大约 7 年前
&gt; Given this goal, you might be surprised to learn that Finda is built with Electron, a framework that’s often decried for being the opposite of fast.<p>I thought the criticism was more about its memory usage, not that it wasn’t fast.
评论 #16611548 未加载
评论 #16611523 未加载
lynaghk大约 7 年前
Author here.<p>For more background on product development about Finda, there are notes on my personal website here: <a href="https:&#x2F;&#x2F;kevinlynagh.com&#x2F;datatron&#x2F;" rel="nofollow">https:&#x2F;&#x2F;kevinlynagh.com&#x2F;datatron&#x2F;</a><p>I started this as a UI research project to try and replace OS X Finder with a keyboard-only UI. A strong inspiration was the Helm Emacs package.<p>My initial prototype was in ClojureScript&#x2F;Electron, and I was exploring far more features like inline preview, and a command&#x2F;argument (verb&#x2F;noun?) builder system.<p>However, after showing my prototype to a few friends, they were all much more interested in the fast search and window switching capabilities, so I decided to cut scope, focus the project on those features, and get something out the door.<p>This is my first Rust project, and I&#x27;ve been thrilled with the language and that community in terms of great libraries, documentation, and their willingness to help beginners like myself.<p>p.s. Sorry I&#x27;m late to the party, I pushed this blog post online immediately before going to sleep for the night =P
评论 #16629924 未加载
matthewmacleod大约 7 年前
I think it’s cool that people are playing around with this sort of thing.<p>The truth is, though, I don’t understand why this architecture is attractive in this case. This is essentially a thin front-end UI on top of a fast cross-platform backend. That’s a great structure - but why not make the UI <i>native</i> for each platform?<p>Calling into a Rust backend from Swift, or from whatever UI framework you use on Linux or Windows, is going to be just as easy as with Neon. At the moment, you are including <i>vast</i> amounts of code and using a large amount of memory to display a very small amount of text on-screen. It seems very inefficient for such an otherwise elegant application!
评论 #16611252 未加载
评论 #16612124 未加载
评论 #16611247 未加载
评论 #16611288 未加载
评论 #16612554 未加载
评论 #16611253 未加载
评论 #16611255 未加载
评论 #16611777 未加载
tybit大约 7 年前
I noticed the atom team are trying something similar with an experiment called X-ray <a href="https:&#x2F;&#x2F;github.com&#x2F;atom&#x2F;xray" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;atom&#x2F;xray</a><p>It will be nice if this becomes a thing, I think it’s more likely that electron apps become significantly more performant than that everyone starts rewriting their apps in QT, for better or worse.
评论 #16611166 未加载
krzat大约 7 年前
I&#x27;ve been playing with Flutter recently and their approach may dominate UI toolkits in the future.<p>They took low level rendering API from Chrome (Skia) and build simple but fast layout engine around that. Already works pretty well on mobile and there are some experiments on desktops: <a href="https:&#x2F;&#x2F;github.com&#x2F;rxlabz&#x2F;flutter_desktop_markdown_reader" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rxlabz&#x2F;flutter_desktop_markdown_reader</a><p>Rust people could maybe do the same with Webrender from servo.
评论 #16611338 未加载
评论 #16611285 未加载
评论 #16612723 未加载
评论 #16611745 未加载
alfonsodev大约 7 年前
&gt; The architectural tl;dr is that Electron is used as a user interface layer, with a Rust binary handling everything else.<p>Interesting, but the major complaint about electron that usually pops in HN is about memory consumption. Is it that avoided in this case?
评论 #16611174 未加载
dreta大约 7 年前
You can&#x27;t seriously justify introducing massive library into your code just to display some text, and use a few native calls. If it works for you, that&#x27;s great, but if anybody needs an example of why the software you use is so terrible these days, even though we had huge leaps in technology, look no further.
评论 #16611657 未加载
hardwaresofton大约 7 年前
I wonder how this approach will combine&#x2F;contrast with compiling rust to wasm directly -- I&#x27;m under the impression that the benefits would be similar.<p>I absolutely believe building electron apps is the future -- why would you struggle with the M*N effort of building different UIs when you can get comfortable with a paradigm that you already know that works relatively predictably across OSes and is constantly being improved (HTML+CSS).<p>Unfortunately, one of the big problems left to get tackled (I think?) is the lack of native system accessiblity features that are more advanced than what the web can&#x2F;does offer.<p>So excited to see this idea getting attention -- I really want to work on a cross-platform app with neon + rust in the future, and see if we can finally get past the gripe of memory usage for electron apps so that people can stop bashing them.
评论 #16614854 未加载
minus7大约 7 年前
Is it really so hard to write a native GUI for three OSes if you must?
评论 #16612325 未加载
评论 #16611331 未加载
评论 #16612653 未加载
评论 #16611193 未加载
cheez大约 7 年前
&gt; 1) I want the option to port Finda to Windows and (I can’t believe I’m saying this) Linux, since beta testers asked if they could buy a version for their respective platforms.<p>Anyone else reading this: Linux support is required for any tech-related thing. Many times I have sold licenses into a single person using Linux who then has their company come back to buy 10s or 100s of licenses.
评论 #16612183 未加载
LeoNatan25大约 7 年前
Just to show how well this works, the attached GIF on that site uses OS X Mavericks, now 5 years old.<p>I also like how they only considered one real alternative, which is &quot;XCode&quot; (incorrectly capitalized). What about Xamarin &#x2F; Mono? What about qt? With those, they don&#x27;t even need to upgrade their outdated OS. Instead, they chose the worst of all worlds, both development and user.<p>The state of development in 2018 is ridiculous.
评论 #16611498 未加载
评论 #16611954 未加载
Humphrey大约 7 年前
I wonder if there is a use-case for a simplified lightweight edition of Electron that uses the system webviews instead of Chromium.<p>Obviously this would be much less capable, require cross platform testing, and limit node usage. But for a project like this that barely does anything fancy in the front-end, it would solve the size and memory issues.
评论 #16613953 未加载
评论 #16611755 未加载
charlieflowers大约 7 年前
I thought this was intriguing, so I installed it.<p>Doesn&#x27;t work at all for me. Running finda shows the instruction screen. Try to use it by typing, and the window goes completely white.<p>I can use ctrl-\ to bring the white window up and down, but nothing else works.<p>I had to find the launchd process in Activity Monitor to kill it so I could uninstall.
评论 #16614763 未加载
评论 #16613895 未加载
评论 #16612552 未加载
tracker1大约 7 年前
I think it&#x27;s wild that the browser has become the UI layer in so many applications... CSS + HTML simply make things more consistent in a way that no other toolkit ever has. On the flip side, it&#x27;s sad that every app now packages the entire jungle (so to speak).<p>I know that this is what Adobe Air was supposed to be, and part of me would love to see something akin to Chrome&#x27;s autoupdate mechanisms for an Air-like platform around Electron&#x27;s base that could be shared. That doesn&#x27;t get around performance issues, but would at least mean some reduction.<p>I think it&#x27;s a great option to have, but still concerning in some ways. I also think that React-Native will probably grow to be easier to create more native-like cross platform apps over time. Definitely interesting times.
snarfy大约 7 年前
Whenever I find myself wanting to build an app that is electron&#x2F;chromium&#x2F;webkit frontend + C++&#x2F;C#&#x2F;Rust&#x2F;Go backend I can never justify it over building a web app + web api instead. If you want to run it locally there is a one line docker command to do it.
评论 #16611935 未加载
评论 #16613926 未加载
mamcx大约 7 年前
This is only possible because the browser on desktops is &quot;fast&quot;.<p>I try the same idea with Android&#x2F;iOS. In iOS, all fly, but man... android is super-slow.<p>I can&#x27;t believe it myself, so I downloaded several demos of html-based apps and the results hold.<p>I totally will kill for a webview-like control on android that I could reliable use and be almost 80% as fast as on iOS..<p>Now I implementing the UI on both, and seriously is harder than I expected... Never imagine the Apis were that bad...
swsieber大约 7 年前
OK. Dream time. I&#x27;d love to build a cross platform app &#x2F; ui toolkit with support for pluggable backends. The first two would probably ncurses and electron if I were building it. (I&#x27;d do it rust for its excellent Web assembly story and perfeomance.)
评论 #16613914 未加载
tixocloud大约 7 年前
Thanks for sharing this.<p>I’ve been dabbling with Electron to build a data analysis tool app but have been slightly concerned about speed. I am glad to hear how quick it’s running for you and getting ideas on how I can make my app faster.<p>Thanks!
BlackLotus89大约 7 年前
Interesting that nobody seems to talk about the software itself and maybe it&#x27;s alternatives.<p>I for once welcome the concept of something like Finda and am looking for alternatives for me.<p>&gt; Finda finds things — windows, browser tabs, code editor buffers, browser history, apps, files, etc.<p>Finda looks and acts like a normal launcher. The concept isn&#x27;t new, but fast good launchers are rare. When we look at the Finda-Page (I didn&#x27;t download the demo since I don&#x27;t use Mac OS) we can conjecture how it works and there are a few things that bother me.<p>It seems to always run in the background and listen for inputs. It&#x27;s cross platform so it will probably have it&#x27;s own file indexer.<p>This all seems to add up to a rather large memory consumption.<p>Anyway right now I&#x27;m still using the dmenu [1] launcher and am looking at many alternatives, most of which haven&#x27;t been updated in some time.<p>First the ones that haven&#x27;t been updated in some time<p>dmenu2 [2], interrobang [3], and lighthouse [4].<p>All nice launcher, but here comes my current favourite rofi [5]. Not only is it an active project, but it defines itself as window switcher and launcher (so what finda kinda does). Combined with it&#x27;s extendable nature it seems to be a solid launcher. Bookmark functionality is for instance given with the buku [6] integration. But I&#x27;m still looking for the best solution. Here is the feature list I&#x27;m looking for: program launcher, simple calculator (through bc or python), file locator (maybe through locate), bookmark manager (firefox preferably). Other things like quick (online) search, clipboard management or the whole slew of other features provided Finda and panther and whatnot would just be extra. Does anyone of you have a nice lightweight solution?<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;stilvoid&#x2F;dmenu" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;stilvoid&#x2F;dmenu</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;muff1nman&#x2F;dmenu2" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;muff1nman&#x2F;dmenu2</a><p>[3] <a href="https:&#x2F;&#x2F;github.com&#x2F;TrilbyWhite&#x2F;interrobang" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;TrilbyWhite&#x2F;interrobang</a><p>[4] <a href="https:&#x2F;&#x2F;github.com&#x2F;emgram769&#x2F;lighthouse" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;emgram769&#x2F;lighthouse</a><p>[5] <a href="https:&#x2F;&#x2F;github.com&#x2F;DaveDavenport&#x2F;rofi" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;DaveDavenport&#x2F;rofi</a><p>[6] <a href="https:&#x2F;&#x2F;github.com&#x2F;jarun&#x2F;Buku&#x2F;" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jarun&#x2F;Buku&#x2F;</a><p>- bl
评论 #16614805 未加载
angel_j大约 7 年前
what is require(&#x27;Native&#x27;)?
pughmans大约 7 年前
I hate javascript so this might be good.
holydude大约 7 年前
The other problem is that most electron apps are incredibly big. I do not want to download 150mb single purpose apps. The memory hog is not the only it&#x27;s also the battery drain most electron apps suffer from.<p>If you compare Finda to something like voidtool&#x27;s Everything it&#x27;s night and day.
评论 #16612553 未加载
评论 #16611177 未加载
tzahola大约 7 年前
Cool! Still waiting for “building an electron app that uses less than 200 mbyte of RAM” though.