Building an Open Source Rust-based Common Library/Framework for All Platforms (Desktop/Mobile/Web) Apps

I am a big fan of the Rust language for many years, and I think the time is ripe and the language, platform and framework is matured enough to start my first project.

Specifically, I’d like to use Rust to develop a CMS system with the following features:

  • A full-stack CMS system from database to business logic to web. This means the developer does not need to write any JavaScript. A goal of the web application feature is the site should be Progressive Web Application (PWA)-compliant as well.

  • In addition, the CMS should also provide RESTful APIs JSON output for data retrieving and saving from native applications, including all Apple platforms (iOS, macOS, etc.) and Android apps. That means the developer will only need to code in Swift or Kotlin for view / layout development in the respective platforms.

  • Code Reusability and Code Sharing with Apple platforms and Android apps. This means that all data structures and business logic will be shared and re-used across the entire stack: server-side, mobile applications and web application. (I did some research and saw that Rust code can indeed be compiled for iOS and Android - but have not tested.) This means the entire system is written in Rust, and developer will only need to -minimally- develop the view/layout in Swift or Kotlin, for Apple and Android platforms, respectively.

I’ve seen the Rocket framework and I’m quite impressed. It can serve the following needs:

  • object-mapping to RDBMS/PostgreSQL - I can use Diesel
  • CMS (the majority of code will be written in Rust)
  • Restful APIs (for interoperability with native apps) - handled by Rocket
  • HTML templating - handled by Rocket
  • Web Server - handled by Rocket (?) or otherwise can front it with nginx

Does a matured CMS system based on Rust actually exist?

Otherwise, do you guys think it is worthwhile developing a open-source CMS based on Rust / Rocket / Diesel?


I think it is too early to build a CMS with rust. Also there are plenty of options in market for CMSs in other languages. The problem with CMS is that many people start writing their own and you end up with a saturated market consisting of bloated CMSs

In my opinion, any rendering of html on the server side is the past technology, except the case of initial web page prerendering for SPA. React (or other solid SPA framework) over web API + react-snap if prerendering is required is the way to do things today. It means Rust should focus on efficient construction of web APIs only.

SPAs don’t fit in every case. There are some cases where people still want server rendered stuff


This will be a hard sell. Even a simple CMS[^1] is not something I’d write in Rust right now and expect to be shipping something before summer.

What does Rust bring to the table here? I think the underlying programming language is not nearly as significant as you make it out to be. Code Reusability across web/iOS/Android you can get by using JavaScript—I’m only half kidding. And if your CMS needs to have a way to let people add content in a way that humans like, you’ll probably spend at least as much time on the frontend as developing the backend.

If you want to do something innovative, I think there are some grander aspects to focus on. I’ve recently seen postgraphile, which generates a GraphQL backend based on your Postgres schema. This is something that is finally using all fancy Postgres features that a typical web app doesn’t (e.g., row-level security, views, SQL functions for computed values, triggers, etc.). I’m not saying this will solve all your problems, of course it won’t, it’s just an example for something that recently surprised me in a good way.

[^1]: please note the S stands for System :slight_smile:

1 Like

No. The ease of use and maturity of CMSes in other languages (namely Erlang/Elixir) makes it a pointless exercise to implement in Rust.

I’ve built something like a DMS (Data Management System) rather than a CMS. I’m using rust + postgres in the backend and ELM in the front-end.

The code is in github. I’m rewriting the whole thing(in a private repo) taking into account the learning I’ve gain with using rust and elm, such as more idiomatic code and minimize the use of Clone. I will release the rewrite soon together with a new cool name which I haven’t finalized.

At first, I wanted to use diesel, but then it didn’t fit my requirement so I ended up writing an orm just for this project.

1 Like

Could you please share these cases ?

I’ve changed the title of this thread from “Open Source CMS based on Rust” to “Building an Open Source Rust-based Common Library/Framework for All Platforms (Desktop/Mobile/Web) Apps”. My original title was quite misleading and caused some readers to think that all I want to do is an CMS.

Let me explain my motivations a little more…

Currently, we have to take care of separate source code bases for server-side, web and mobile platforms. Communications is done via RESTful and handling of data structures need to be taken care of (serialized then de-serialized) on the client platforms. It is very tedious and time consuming to write the code, test, debug to make it work perfectly.

I need to decide on a single language/platform for code reusability across many OS/devices (Apple, Android, Web). (And, NO - I won’t choose JavaScript!) I’m thinking of Rust because of it’s advanced concurrency features for high performance and optimized applications.

Some people have tried it and it seems to work:

Are you guys familiar with Opa - they call it “One Language to Rule Them All”? I’d like something like that across all platforms, include generating the data structure and business logic native code for Apple (iOS, macOS, tvOS, watchOS) and Android devices. Imagine, the database models, data structure, etc. are written only once. This reduces testing and debugging. The only thing left to do in the platform’s respective languages (Swift/Objective-C and Kotlin/Java) would be the view and layouting.

Up to this point, I’m not talking about the CMS yet. We first need to solve the problem of code redundancy, lengthy development and testing. Data structures and it’s handling/processing should be written only once and be compiled into all platforms. Communications should be transparent between server-side and clients (instead of using RESTful APIs). Do you guys think it make sense to use Rust to achieve this purpose? This could be a library/framework (Rust dependency) by itself (not the CMS).

With code reusability taken care of, developers can save time doing redundant testing of RESTful communications and data handling/processing. Developers can focus on creating the mobile apps and web apps.

The CMS which I’m talking about will be built upon the foundation of this “write once, share the same code base and deploy anywhere”. This CMS will allow developers to build apps for mobile devices and web apps. For mobile apps, communications will be seamless (Swift or Kotlin view code just need to hook up to the methods written in Rust). Web apps will have JavaScript automatically generated by Rocket (ie. no need to code in JavaScript).

1 Like

It would be similar to framework in scala world. Quite powerful. If you pursue similar idea with rust, keep in mind that backend still needs to emit APIs to enable other languages, partners and customers once your service gets success. Check what udash provides for this.

In my opinion, currently it is quite hard to trade typescript with react for rust or even scala-js in frontend. And typescript with react quite portable across end user devices.

I looked at Udash. It seems that it is only for web. It does not cover other native platforms like Apple (iOS, macOS, etc.) and Android. My proposal is a library/framework which will provide seemless communications to those Apple and Android apps. The APIs for other languages will become a bonus.

As you mentioned TypeScript (I’m not so familiar with this), what is the relevance of this when the Rocket framework can take care of the web needs?

Not only. It cross compiles to JVM and JS. The combination of these plus some packaging tools cover apple, android, etc in addition to web.

I can’t find anything that it compiles to JVM. And, even if so, how would it be native to iOS?

Rocket is server side code, afaik. Seamless end user interactions including offline cases still need to be developed, and typescript is a language which does many things right (mainly typesafety, code contracts, etc.) on top of traditional JS, which can serve UI part on any current end user device.

Scala compiles to JVM and JS. The framework is for scala.

How would rust be native to iOS or would be native to Web browser? Your goal is to write an app once on one language and execute on many target devices. Whatever execution runtimes or interpreters are used is the second question. The referred lib in scala or similar in typescript are current possible and pragmatic options to achieve this goal. There are probably other options. I am not sure if rust is capable or pragmatic choice now. That was my point in the initial reply.

I’ve used typescript and react, while I agree typescript did a lot of improvements to javascript, I can still feel the clunkiness of having a runtime errors, and you can still have nulls. However using elm, it gives me the same level of confidence as you would have with rust. There is no runtime errors, no nulls, and the type system is closely similar to rust.

SPAs take longer to develop. Also there are instances where you don't have any reactivity. Consider cases where you have large amount of content or some traditional form-filling stuff.

I mean, "compile to native", eg. GitHub - kennytm/rust-ios-android: Example project for building a library for iOS + Android in Rust.
(Rust can compile to iOS/Android native)

Udash (Scala compiles to JavaScript/Web native)
Vaadin (Java comiples to JavaScript/Web native)

Therefore, if Rust can compile to JavaScript/Web native, the need is satisfied. The entire Web development is done in Rust +HTML/CSS. No JavaScript at all. I think Rocket can fulfill this.

1 Like

You have a point. CMS is too complex to develop. Building a “Static Site Generator” (like JBake or Jekyll) is a great start. Then, the CMS can be built on top of that in future.

There is another major thing in my proposal: to build a common library/framework, a “write-once, deployable everywhere” to iOS/macOS/Android/Web, etc. It is about writing the data structure, handling/processing, etc. - only once.

To start with, why not contribute to one of the widely used Rust web projects: