It wouldn't surprise me if you could do this with a RP2350, connecting GPIOs to the same location as the 65C02 does on the breadboard and even running emulated 6502 code.
It's totally not the same thing of course. A whole lot of transistors and clock speed go to making that feat possible.
In the web at least it was returning 500, I guess that the desktop/mobile apps make some check in intervals. When the backend returned 500 the app thought that the current login could not be authenticated and logged out everybody
I think some will aggressively log out even on 500s. If you log out 500s that's not the same as logging out failed network requests. The server has to actually send a response, so while it will erroneously log out sometimes, in a reliable api, or one that sends errors in 200s but is otherwise reliable, it won't be so often that a whole lot of users give up. Plus some API middlewares will default to hiding error response codes for security and always send 500 no matter what the upstream response code (this assumes the error codes aren't needed by the devs because they can look at the logs).
I've seen logging out on failed network requests, but that is highly annoying and frequently occurs and typically just a coding mistake.
I really like this approach, however I have a use case where the application user id that made the operation must be saved in the audit table, unfortunately, I cannot see how to do that with a pure SQL solution.
we do that by setting a local variable before the query and then reading that in the triggers:
```
SET LOCAL foo.who_id = 'some-uuid';
UPDATE table
SET ...
```
```
-- function to make getting the setting easier
DROP FUNCTION IF EXISTS get_who_id (text);
CREATE OR REPLACE FUNCTION get_who_id (default_value text DEFAULT null::text) RETURNS text AS $get_who_id$
DECLARE
who_id text;
BEGIN
BEGIN
who_id := current_setting('foo.who_id');
EXCEPTION
WHEN SQLSTATE '42704' THEN
RETURN default_value;
END;
IF (length(who_id) = 0) THEN
RETURN default_value;
END IF;
return who_id;
END
$get_who_id$ LANGUAGE plpgsql VOLATILE;
```
```
CREATE OR REPLACE FUNCTION some_table_audit () RETURNS TRIGGER AS $some_table_audit$
DECLARE
who_id text;
BEGIN
who_id := get_who_id(null::text);
...
```
Identifiers changed, but hopefully will give you the idea.
I've experiment with a very similar solution and it felt a bit dirty but so far it seems to be working just fine. I have made an integration for auditing with sqlmodel which I intend to share, but it is kind of rough and I was a bit stuck trying to clean it up. The idea is that you add e.g. a HeroHistory model derived from HeroBase and a HistoryMixin that creates the triggers and relationships to have an Audit log of the Hero table.
As a complete layman in WebAssembly I always struggled to understand what are the use cases. I think what I don't understand is what the _Web_ part exactly means, is a browse thing? Or could be used to more general use cases?
Webassembly is a language-agnostic, non-proprietary bytecode, intended both to be used online and natively.
Like Flash, Silverlight and Java, it allows the embedding and running of binary applications in the browser (although currently this also requires a Javascript shim to allow access to the DOM.) Unlike those, however, Webassembly is not intended to be used only by a single language. You can compile C, C++, Rust, and many other languages to Webassembly and run them both in the browser and as native applications.
Web "means" it's portable and sandboxed, so theoretically you can run untrusted from the web and it only has access to what you expose.
This stacks with DOM sandboxed APIs so you get same level of isolation in the browser as JS but better perf and a memory model more suitable to other languages.
Outside of browser you still get sandboxed low level VM suitable for running C and other low level languages. Eg. you could compile a C module for say node and ship it compiled as WASM
WebAssmebly is not web specific. And it's not assembly.
I think the best way to think of it is that "WebAssembly" is a great marketing name, but what it does is be a modern-day JVM: a byte code language that can run anywhere.
WebAssembly is a game changer. Why? Because it removes the need for JS, and is more performant. Couple that with a secure sand box to run your apps and you have a new distribution model, somewhere between a full native app and a completely online web app.
You have also removed the shackles of JS and provided an environment to which you can compile and you get the ability to port a lot of libraries and code to the new platform. How does this help? One, you can use other languages to write apps for the web. Two, you can use existing libraries to help develop your app. Three, by having a permission system to access system resources in a secure way, you can incorporate native application features and performance into your web app. Think about stuff like direct printer access, USB access, etc.
As someone who doesn't mind the "shackles" of JS, from what I have seen so far, apps written in WebAssembly are up to two times slower than their JS counterparts. DOM access is abysmal, and from what I've seen in the wild, no one has written a serious business critical application using it yet.
What does webassembly do today, and what experience does it provide over javascript? I get the sandbox and distribution, but again, those advantages mostly apply to JS as well.
> from what I've seen in the wild, no one has written a serious business critical application using it yet.
There are lots of such applications, including:
* Figma
* Unity games on the Web
* Google Earth
* AutoCAD
* Aside from entire applications, crucial features in things like Zoom and Google Meet (filters, backgrounds, etc.).
WebAssembly won't replace JavaScript - it's for different things. Wasm lets you port native code to the Web, and it lets that type of code run very fast. That's even without SIMD and multithreading - with those things, wasm is even faster.
you can crosscompile from other languages to wasm. so you could have a codebase written in C for example, you crosscompile + bind to a minimal JS part. now your app works in a browser.
As far I understand the Rosetta2 is not an emulator, but a layer that translate x86/x64 binary code to M1 binary code, it does not emulate a x86 machine in the system.
There is also an emulator layer. It's used as a fallback when the much faster ahead-of-time binary translator can't work. The emulator is generally not a good experience -- if you have to use it, you really want to go native asap.
Examples where it is required is any kind of self-modifying code, such as JITs and the like. Since IDEA is a java application that ships with it's own JRE, the aot translator can only translate the JRE parts and when the execution first jumps to freshly written memory the system bails to the emulator. Since the emulator is an order of magnitude (probably more...) slower than native, and the entire IDE runs on JIT, this is very bad.
Some time ago I helped build a software that heavily used some python GIS libraries (GDAL, rasterio, etc) and we needed a UI for some windows users. We chose cefpython[1] to the job, as we could interface easily between the python and JS parts. The development experience is not so polished as of Electron though.
Nonetheless, is a great project and not so difficult to use, although not perfect, it worked perfectly for our needs.
[1] https://youtube.com/playlist?list=PLowKtXNTBypFbtuVMUVXNR0z1...