Hacker Newsnew | past | comments | ask | show | jobs | submit | onsclom's commentslogin

I made my own WASM demo @ https://microui-wasm.vercel.app/ and it's only 14.6 kB compressed!

Will share source code if someone is interested, but key bits:

- had a small JS glue layer using CanvasRenderingContext2D to render

- made a `wasm32-freestanding` build to lower the wasm bundle size, which meant shimming the bits of the libc microui uses


Your demo seems to constantly consume 100% CPU at all times.


Ooh interesting. What is your machine and browser? On chrome with my m1 macbook it takes less than 1ms to compute and render each frame, but I am noticing some things I can optimize from the performance flame graph! I will say, I find chrome to be way more efficient for ctx2d things than firefox or safari.


Chrome on Linux suffers from this too. The issues are standard for all naive immediate GUI libs:

- constant repainting (while literally nothing changes) -> constant CPU load

- some libs can skip repaints but have no concept of damage area

- bad handling of high-dpi (which also can change dynamically)

- constant repainting behaves even worse on laptops which announce 180 Hz refresh interval, which means that it drains the battery 3 times faster than 60 Hz


> - constant repainting (while literally nothing changes) -> constant CPU load

This doesn't explain a 100% CPU usage since requestAnimationFrame is vsync-throttled and rendering such a simple scene will do the per-frame work in a fraction of a frame duration.

And FWIW I cannot reproduce the issue in both demos (in Chrome on macOS). The sokol demo has a per-frame load of about 0.3ms per 8.333ms frame, and the demo hosted on vercel.app about 0.7ms, both pretty much within expecations.


Firefox on Linux.


I don't necessarily hate Lua, but I prefer C and Raylib for game dev. Lua is garbage collected, dynamically typed, strays far from standard syntax patterns, and has less existing tooling than C.

I see why people might hate Lua. Especially for game dev!


Lua is extremely popular for game dev though?


Luajit is often faster than C. The qualities you described above actually make it great for game dev.


A JIT is a double edged sword, it _can_ make your code faster, i remember in the early days of smartphone gaming, developers often had to manually "warm up" the JIT to prevent stutters during gameplay

It still is an issue nowadays https://discussions.unity.com/t/app-needs-warmup-first-slow-...

Similar story with the GC, it's nice to have, until it causes you problems (wich it will), so you end up having to avoid using it and instead rely on manual techniques

JIT and GC aren't the panacea people make them out to be


True using a JIT without understanding it is not a panacea. Same as a GC. Same as malloc and free (you're often much better off with arena allocators).

Most JITs let you tune when and how they inline. It's also worth knowing how they works and what they can/can't inline.

You linked to monojit. Luajit is a whole other beast. I'd argue it's superior to anything in JS/JAVA/C# land (and I say that as someone with a reasonable understanding of the JVMs C2 JIT).

As an aside with low latency GCs like the JVM's ZGC trading manual memory management for no memory related security vulnerabilities is pretty appealing.

Like everything in programming it's a trade off.


this is the way to go!

making a move should automatically copy the new url to your clipboard. you can still keep the ascii charm by server side rendering the ascii chess board as an og description.


made a non-ascii of this where nice og images of the board are generated!

https://correspondence-chess-production.up.railway.app/


`const foo = function() {}`


I'm guessing you don't consider VSCode an IDE? I'm curious, what features do you use in IDEs that are missing in VSCode?


I am not considering VSCode as a IDE. Because Microsoft, the creator of VSCode, does not consider VSCode as IDE.

They have a IDE called Visual Studio and it is different from VSCode


Implicit reactive `let` statements make the code harder to understand for humans AND the compiler. This new explicit state pattern even simplifies designing. Now reactive state can work outside of components and across files as you would expect. It was tricky in all three ways.


Make sure you opt in to use runes!

You can do it project wide or per component: https://svelte-5-preview.vercel.app/docs/runes


> The easiest way to opt in to runes mode is to just start using them in your code.

Opt-in is optional, no?


Whoops, I missed that. Good catch! I'm not sure how tln's problem is happening then.


Instead of finding reactive dependencies at compile time, `$effect` and `$derived` automatically track dependencies at runtime. This might feel like it would result in a performance decrease, but it is what SolidJS has been doing. And SolidJS is #1 in most performance benchmarks!


Fair points, though React has hugely complex runtime magic. SolidJS's compiler magic is just as simple while also having much a simpler runtime.


To be fair, assignments to variables still update the state of your component. `count += 1` will still update the state of your component. I think what you meant is that you now need to explicitly declare `count` as state. Personally, I think the magic of Svelte is that assignment part. And now the magic of Svelte works across files and even inside regular `.ts` and `.js` files!


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: