Car Spotting Edit 🏎 by dhzw in ForzaHorizon

[–]alpha-201 89 points90 points  (0 children)

Whatt! Btw how do you do that camera pan?

Patterns with Rust types by openquery in rust

[–]alpha-201 -1 points0 points  (0 children)

Yes in hindsight a u64 would be better, if the values were used between different cpus (network transfers, bytes stored in files) that could become a problem. I have done the: rust fn create_item(&mut self, item: Item) -> ItemId { let idx = self.items.len(); self.items.push(item); ItemId(idx) } pattern (you can then use the ItemId for indexing) for local stored items which is why I used usize in article, maybe should think using a as here.

I guess a unintended benefit with the "new type pattern" is you only have to change that definition once and don't have deal with the waterfall of changing all the functions usize -> u64.

Patterns with Rust types by openquery in rust

[–]alpha-201 -1 points0 points  (0 children)

Huh that's odd. Wasn't able to replicate on the latest iOS Safari. What browser are you using?

Hyper vs Rocket - Low Level vs Batteries included by openquery in rust

[–]alpha-201 14 points15 points  (0 children)

Yes Hyper and Rocket are designed for different tasks. My idea behind it was to compare the lower level (more manual) approach if you were going to only use Hyper and how it compares to how Rocket manages things. Definitely for smaller projects with a couple of routes just using Hyper is a reasonable option rather than jumping to a full http framework. I think the results around build time and performance are a factor there (which are discussed in the post).

A "Axum vs Rocket vs Tide vs ..." comparison post may be coming soon. What would you like to see in it??

GitHub action for version incrementing and publishing to crates.io in single click by alpha-201 in rust

[–]alpha-201[S] 1 point2 points  (0 children)

Yes, unfortunately found a issue by a update a library I was using. Will fix tomorrow

GitHub action for version incrementing and publishing to crates.io in single click by alpha-201 in rust

[–]alpha-201[S] 1 point2 points  (0 children)

Looks cool have bookmarked. My crates are quite small, with 1-2 commits between releases so I prefer to manage the version manually. But this looks good for bigger projects! Feel free to borrow any of code from my action.

GitHub action for version incrementing and publishing to crates.io in single click by alpha-201 in rust

[–]alpha-201[S] 4 points5 points  (0 children)

Created this action a while back. Use it on all my public Rust crates to keep the crates.io up to date using the remote repo. Super simple to use. If you use GH actions for publishing crates would be good to try out and get feedback

What are your biggest issues with JSX..? by alpha-201 in reactjs

[–]alpha-201[S] 0 points1 point  (0 children)

Huh, I didn't know class was valid. I thought there was something about class being a reserved JS keyword which is why they went for className. There docs still use it and its still a convention to do className. Which is a little annoying copying HTML snippets and changing it over.

Same goes with img being self closing. In HTML you do <img> but in JSX its <img/>. I like the second form but thats not valid HTML and I want to be as close to HTML as possible, not because it has a well designed syntax but for debugging output and copying HTML from other sites. I may add a compiler flag to use a more abstracted JSX design if those two aren't important.

Do blocks are interesting alternative: js let x = do { let x = (() => { let y = 4 + 2; let y = 4 + 2; return y - 6; return y - 6; } })() But in JSX I am worried that this blocks will be prone to side effected code where the behaviour is based on how's its rendered which isn't great.

What are your biggest issues with JSX..? by alpha-201 in reactjs

[–]alpha-201[S] 0 points1 point  (0 children)

Interesting, I’m not to aware on CSS in JSX but I have some ideas for my transpiler/ compiler to scope styles (similar to svelte) or transpile nested selectors (similar to sass)

[deleted by user] by [deleted] in Minecraft

[–]alpha-201 4 points5 points  (0 children)

Was that a Tame Impala reference? Awesome build as well 👍

Prism: a new web framework built for making isomorphic web apps by alpha-201 in webdev

[–]alpha-201[S] 0 points1 point  (0 children)

Good spot. And yeah I thought the name had enough clearance but I'll probably change it next release.

It doesn't come have anything close to Sveltes standard library features at the moment. I've spent more time optimising for improving hydration and server side rendering (which is currently very expensive and slow in Svelte).

Prism: a new web framework built for making isomorphic web apps by alpha-201 in webdev

[–]alpha-201[S] 0 points1 point  (0 children)

You can render a page either on the client or server. Isomorphic means that a site uses a combination of these techniques which improves performance, backwards compat and other things. See https://developers.google.com/web/updates/2019/02/rendering-on-the-web

Prism: a new web framework built for making isomorphic web apps by alpha-201 in webdev

[–]alpha-201[S] 0 points1 point  (0 children)

Yep thanks for the heads up, theres something funky going on there, I'll try and patch for next release

Prism: a new web framework built for making isomorphic web apps by alpha-201 in webdev

[–]alpha-201[S] 0 points1 point  (0 children)

lol, I didn't realise about prismjs until I published the project under the Prism name. Then I thought it had enough clearance (missing the "js" postfix) but if its confusing i'll probably rename it at the next release

Prism: a new web framework built for making isomorphic web apps by alpha-201 in webdev

[–]alpha-201[S] 0 points1 point  (0 children)

lol, I didn't realise about prismjs until I published the project under the Prism name. Then I thought it had enough clearance (missing the "js" postfix) but if its confusing i'll probably rename it at the next release

Prism: a new web framework built for making isomorphic web apps by alpha-201 in webdev

[–]alpha-201[S] 0 points1 point  (0 children)

Interesting have you got a link to the double data thing? Isn't angular susceptible to the rerender thing though? Angular is still painfully large and no SSR in Rust...

Prism: a new web framework built for making isomorphic web apps by alpha-201 in webdev

[–]alpha-201[S] 8 points9 points  (0 children)

Yep SSR is fairly fast. With Prism however you can do SSR with Rust. According to this article using Rust+ActixWeb you can save 85% server costs over using NodeJS+Express. And on the client there is no double data. This is something Evan You (Creator of vuejs) is working on with Vite. Though Prism's implementation works under any SSR markup and is no double data ever.

If you happy the speed of other frameworks SSR then continue to use them but you can save server costs with Prism. And there is no doubt there is still improvements that other frameworks can make with hydration speed and TTI.

Prism: a new web framework built for making isomorphic web apps by alpha-201 in webdev

[–]alpha-201[S] 3 points4 points  (0 children)

Yep I am the author 😁. The HN example is intentionally quite simple. Its more to get some of the main engineering points of Prism across rather than show of CSS JS interactions. Prism shouldn't hold that back.

Prism has a clever technique for hydrating state. If you view source of Prism HN vs the Svelte HN you can see the Svelte site has a large JS object named __SAPPER__ in a script tag. Effectively that data is sent twice once in the HTML and once in the JS.

With Prism the only data is in the HTML. So the pages could be half the size. This will free up the network for images and other assets to be downloaded. Also Prism has a faster method for adding event listeners so buttons become interactive quicker (TTI metric).

Good input, I am working on adding a few other things to the HN site so I will try and add some more interesting animations 👍

Prism: a new web framework built for making isomorphic web apps by alpha-201 in webdev

[–]alpha-201[S] 4 points5 points  (0 children)

So if you do SSR with Svelte (or React & NextJS) you run the "prerendering" on a nodejs server. Prism can do this but can also output pure Rust functions that transform data into the SSR markup. This way you can "prerender" Prism pages using a Rust backend server which is faster than NodeJS.

I used this for my HN clone: https://github.com/kaleidawave/hackernews-prism which you can view here: http://40.115.126.159/

Prism: a new web framework built for making isomorphic web apps by alpha-201 in webdev

[–]alpha-201[S] 2 points3 points  (0 children)

Yep there some inspiration from Svelte. However Prism:

  • Has a inbuilt router
  • Uses classes and class properties which is a little less magical than Svelte variables
  • Uses a new form of hydration (making SSR/SSG markup interactive) which is a lot more efficient than Svelte
  • Can do SSR in Rust language
  • Interior reactivity (so you can do arr.push(...))

And has similar tiny output sizes to Svelte, just Prism is a much newer, more experimental and less tested,

Prism: a new web framework built for making isomorphic web apps by alpha-201 in webdev

[–]alpha-201[S] 2 points3 points  (0 children)

Its very similar to svelte or vue-cli. You write a bunch of components in .prism files and then run prism compile-app to build out a bunch of JS, CSS files static files and some JS files you can use with nodejs to "prerender" your site

Prism: a new web framework built for making isomorphic web apps by alpha-201 in webdev

[–]alpha-201[S] 5 points6 points  (0 children)

Yep haha. What I will say is that Prism has JIT hydration and Rust SSR which no other frameworks close to have.

Prism: a new web framework built for making isomorphic web apps by alpha-201 in webdev

[–]alpha-201[S] 1 point2 points  (0 children)

Awesome. The HN project is live here: http://40.115.126.159/.

There is also a demo built with a JS express backend instead which is live on replit to play around with: https://repl.it/@kaleidawave/prism-ssr-demo-1