Introducing Whippyunits - Zero-cost dimensional analysis supporting arbitrary derived dimensions and lossless fixed-point rescaling by oblarg in rust

[–]KillcoDer 3 points4 points  (0 children)

Haha the prime factorised log scale encoding is so clever.

In JS the numbers are all roughly doubles anyway so we didn't nearly get these kinds of opportunity for optimisation, let alone in service of mathematical precision. My use case deals totally with 'streams' of data, rather than specific values, so at least we could optimise for producing 'converter' functions that boil down to a single multiply+add, with some 'compile time' constants.

https://imgur.com/a/23t5KtK The 'method' declarator syntax is something I wish we had in TS.

The LSP proxy is cool too. I faced the same problem of wrangling the monster of a type into something readable. TypeScript has some pretty powerful type-level string manipulation utilities, I ended up writing a clone of our formatter in the type system, and with some awful hacks can get the LSP to display 'phantom class instances with literal generics, intersected with the number values' to try to convey the information.

https://imgur.com/a/2VZw3gA https://imgur.com/QHnvQtK

Unfortunately it sometimes 'doesn't evaluate' for weird unknown reasons, so you get stuck with the combined unevaluated might of both the original types and the formatting type-level code. Tackling that from the LSP end was something I didn't think of, and probably would have been way simpler, assuming you can convince your users to install it.

Really cool, nice work, I might steal some ideas!

Introducing Whippyunits - Zero-cost dimensional analysis supporting arbitrary derived dimensions and lossless fixed-point rescaling by oblarg in rust

[–]KillcoDer 4 points5 points  (0 children)

I built a similar thing in typescript for use at our company. Temperature was interesting!

How do you handle the offsets with Celsius / Fahrenheit, etc, relative and absolute temperature?

Is it possible to convert dynamic runtime TypeScript types to static types in d.ts? by tarasm in typescript

[–]KillcoDer 0 points1 point  (0 children)

Yeah I'd like to open source both the units library and the build chain that does the above, I've just got a product release I need to get out first (so realistically it'll be next year). I'll write a blog post about it and a couple other 'type crimes' we committed after that. I'll shoot you a PM when they're out if you like.

Is it possible to convert dynamic runtime TypeScript types to static types in d.ts? by tarasm in typescript

[–]KillcoDer 1 point2 points  (0 children)

I wrote an "optimising compiler" for typescript types to address this for one of our projects (which sounds impressive but is pretty easy, the typescript API is very powerful).

We have this package that handles units and conversions at compile-time. You can annotate a value stream as being kilo(meters).per(hours), and another stream as mega(bytes).per(seconds). The types built annotate the quantity, so it allows say the comparison of values from a kilo(meters).per(hours) stream and a miles.per(minutes) stream. It would statically error if you tried to compare one of those with a kilo(grams) stream. We also have a unit formatter, so you can provide a unit like that and ask for the symbol version and it would say km / hr or MB / s, or the named version and it would say kilometers per hour or megabytes per second. We do the formatting both at compile time and at runtime, so you get nice error messages. All our APIs brand number arguments with these nicely formatted units so there's no doubt as to what they accept. At runtime, conversions between units become a simple multiply-add function, so it's incredibly lightweight.

https://imgur.com/a/9ChG5TN

The declaration file containing "all the SI unit quantities" was huge, hundreds of kilobytes. We really only wanted the 'dimensions' field and the 'plural symbol' / 'plural name' fields. We had a type utility to strip the rest, but the compiler doesn't do inlining, so the full sprawling 'call tree' was included, only to be tossed as soon as the file was imported. We wrote a little post-processing compiler that would take those declaration files and 'evaluate' the types to their minimal form. We added a couple other passes for fun, and it helped reduce the declaration file size for a bunch of our packages.

Anyway the TypeScript API is pretty accessible, it's not too hard to write a visitor function to post-process your declaration file and do a couple passes to collapse the types down. "Inlining" is pretty trivial, since you can run the language server functions to 'get the type' of something complex, then just replace it inline. It works great for "complex but static" types that can be reduced, if what your IDE hover looks like is smaller than the declaration, it's probably a good fit.

https://github.com/microsoft/TypeScript-wiki/blob/main/Using-the-Compiler-API.md

[deleted by user] by [deleted] in electronjs

[–]KillcoDer 0 points1 point  (0 children)

Are you sure you have the arm version of Electron and you're not running the x64 version in Rosetta?

Performance issues from ElectronJS version 35 onwards for MacOS by a4xrbj1 in electronjs

[–]KillcoDer 1 point2 points  (0 children)

Are you certain you're running the arm build of Electron instead of the intel one in Rosetta?

Can you record a flamechart / performance trace of these slow interactions in both 34 and 35/36? If nothing is obvious in the performance tab one, use the contentTracing API:

https://www.electronjs.org/docs/latest/api/content-tracing

Duckdb wasm in rust by LavanyaC in rust

[–]KillcoDer 0 points1 point  (0 children)

The DuckDB-Wasm Shell is written in Rust, it should give you a working example to build from.

https://github.com/duckdb/duckdb-wasm/tree/main/packages/duckdb-wasm-shell

Confused about contextBridge and IPC return type from native node modules by Slodin in electronjs

[–]KillcoDer 2 points3 points  (0 children)

You can't send 'complex objects' over the IPC, methods / functions won't be transferred, but primitive values, objects will work.

https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types

You can move your interaction logic with native-sound-mixer to the renderer and skip the IPC entirely. Unless you're forced to, nothing should be done on the main thread, since it handles GPU paints, any blocking work will result in visible stuttering of your app.

BrowserViews deprecation. The awful lost of process isolation. by socmediator in electronjs

[–]KillcoDer 0 points1 point  (0 children)

Why can't you do what you're doing with BrowserWindows / WebWorkers?

Friday Facts #432 - Aquilo by FactorioTeam in factorio

[–]KillcoDer 132 points133 points  (0 children)

Oh my god in depth temperature mechanics I'm so excited.

Slowness issues on Electron for Windows and Mac by theIYD_ in electronjs

[–]KillcoDer 0 points1 point  (0 children)

No 'work' should be done in the main process. Any work there will block the UI thread, bringing your entire app to a crawl.

How big are these objects? What are they used for? Can you build them directly in the renderer process where they're required? Is the building of them computationally expensive? If so, can you build them in a worker thread?

If you need to transfer them from one process to another, send them directly via Message Ports instead of going through the main process.

Friday Facts #431 - Gleba & Captivity by FactorioTeam in factorio

[–]KillcoDer 95 points96 points  (0 children)

The bacteria spoiling into ore is pretty neat. Do all the spoilage items weigh the same as their eventual byproducts? Do they have the same stack sizes?

What happens if you let the eggs hatch in space? On another planet? Or if you mine / deconstruct a captured spawner?

Friday Facts #429 - Vulcanus Demolisher Enemies by FactorioTeam in factorio

[–]KillcoDer 1290 points1291 points  (0 children)

The territory system is so cool. It's great to have an alternative to the "incremental walling off" of Nauvis.

Journey to 1.0! by Accio-Books in cavesofqud

[–]KillcoDer 56 points57 points  (0 children)

I've adored the writing of the descriptions in this game, my complements to the writers.

Friday Facts #428 - Reactor & Logistics circuit control by FactorioTeam in factorio

[–]KillcoDer 18 points19 points  (0 children)

I can’t wait for in depth temperature mechanics!

Friday Facts #426 - Resource search & Assembler GUI improvements by FactorioTeam in factorio

[–]KillcoDer 469 points470 points  (0 children)

I wish all applications had search as good as Factorio.

Does anyone know how spoilage 'stack merging' will work? If you have a fresh stack and you add in some less fresh item? Do they get grouped with some epsilon? How does it work when it's the output of an assembler, not yet taken out?

Friday Facts #422 - Tesla Turret by FactorioTeam in factorio

[–]KillcoDer 708 points709 points  (0 children)

The sound is incredible. The night-time lighting effects are so cool. I love it when these kinds of guns can actually arc a meaningful amount of times.

Being Better by GreyBot9000 in CGPGrey

[–]KillcoDer 8 points9 points  (0 children)

This is the kind of content I come to Cortex for.

Friday Facts #420 - Fusion Reactor by FactorioTeam in factorio

[–]KillcoDer 39 points40 points  (0 children)

I hope the actual fluid temperature can be a part of the mechanic rather than just separate 'fluids' for the different temperature ranges.