Hacker News new | ask | show | jobs
by chinedufn 2881 days ago
As in an example app?

If you don't need server side rendering you can have one Rust file but you also need a JS file to initialize the WebAssembly module. So just one file isn't reasonably possible.

For a server side rendered app you need to have a cargo workspace with 3 crates (they can be in the same repo so not a huge deal).

One crate is a `cdylib` that you compile to WebAssembly to serve your app to the client. This is a light wrapper around your actual application.

One crate is your actual application.

And one crate is your server, which is also a light wrapper around your actual application.

That server side rendering structure can be found here - https://github.com/chinedufn/percy/tree/master/examples/isom...

But in terms of a super minimal example without server side rendering.. I'll be working on adding one (along with updating the current example)!

1 comments

what i want to see is to have all logic to be centered around features, and have a framework compile the server side and client server out of one logical piece of code, if that even makes sense.

a bit like in the old days of php when you'd have the serverside code and html rendered in their, but this time nearly everything is running on the client unless the client can't be trusted.

you could have some kind of ring system, where something can never run on the client right up to always run on client, but all in one file.

but maybe that's nasty.

ASP.NET does this, you use its components and it generates client side javascript. In a more functional way, there's another language that does this caled Opa! http://opalang.org/
yes, like runat="server" kinda thing.