It's time for the Hacker News Bonus Round! It's that time of day where we all get the stand around and laugh at internets! Now with more characters because Mastodon!
> I know the point of this article is to demonstrate how to solve a problem but the premise is a bad one and must not be confused with sound software architecture at all. In fact it's slightly painful reading it and I really wish people would stop writing articles like this.
This means I'm doing it correctly. Like really. I'm presenting a bad idea. I'm explaining why I did it. If you walk into my blog expecting that everything be crystalline towers of absolute perfection, you are in error. Sometimes I have bad ideas and explain why they are bad. If you don't like that, not commenting is free.
> What we have here is a Rube Goldberg machine, not a cleanly solved engineering problem.
YES AND IT IS GLORIOUS! DONT YOU SEE? IT'S PERFECTLY STUPID! The best kinds of hacks are the ones that look ludicrous but are actually somewhat fine in practice.
> People have been using linked libraries to re-use code across languages since forever, it's fine.
People have been bloodletting since forever but that doesn't mean it's fine. Losing your blood juice tends to kill you unless you're careful.
> Give us a real use case not manufacture a problem for it.
Pay me then. My blog is an effort in giving people bad ideas and understanding they they work, down to the philosophy level.
> Is the definition of "how do I get promoted in a company where I don't care if it survives the next five years", not "a cleanly solved engineering problem".
I thought you people liked bad, unviable ideas. That's half of what you internets upvote. Why should you treat this any different? Is it because I have my website CSS as queer-coded and present myself as nonbinary? Subconscious bias much?
> What's more interesting is if you use same method for app plugins, now you can compile anything in WASM and as long as it have right hooks it can be used in your app as a plugin
This person gets it! This is the idea I'm trying to meme into people's subconsciouses! My evil witch powers work again! My mission of being a viral force of good continues to proceed! Trust the plan!
> I can only imagine what that person's house is like, everything plugged into a string of four-way extensions with adaptors and transformers and converters in some massive herniated tangle that would make any firefighter gasp and run for the biggest dry powder extinguisher ever manufactured.
Oh man wait until this internet sees my homelab. It's got like 7 tower computers in one room with a 15 amp breaker. I've had to balance the hardware choices with that in mind. I'd love to fill out each machine with a 5950x or something but oh god that would not work with my breaker. I made a hard rule against daisy-chaining power strips though. I've not managed to break that yet.
> This. I'd rather have to defend all my ideas than have the bad ones blindly promoted.
Tell me you're a white cis male without telling me you're a white cis male.
> I feel bad that I can't get over the fact that a Mastodon message is called a "toot".
It's because HBomberGuy nerd sniped Gargamel at the right time. They are since trying to backtrack on that, but mastodon posts will always be toots to me and you can't take that from me. I know enough about linguistics to know how language evolution works. By calling a thing a thing, I can subconsciously influence your perception of that word! I mean the alternative is calling it a "tweet" and making one of Elon Musk's trademarks less useful. Choose your pain I guess lol.
> As sad as Slack changing it’s iconic first logo
Yeah it looks like a cocktothorpe or a duckalingus circle now.
> Do you think the same people who call a question an “ask” have any problems calling a published thing a “publish”?
Sure, why not?
> Okay, can you please give me a hint as to where that is? As googling "trump fart" just leads to a lot of terrible Youtube videos.
WHAT. HOW IS THIS AN ACTUAL HACKER NEWS COMMENT. WHAT.
> The same glue that IBM and Unisys mainframes and micros have been enjoying for decades, .NET since 2002, among other examples.
I don't know why this was downvoted on Hacker News, but this is actually completely correct! This is what mainframes do! Customer code is compiled to some intermediate byte code and customers never actually compiler their code for the native CPU architecture of the mainframe. This sounds insane, but it also lets the mainframe manufacturer make radical CPU architecture changes while at the same time offering 100% compatibility so that you could hook up the new mainframe to the old one and gradually move things over WHILE THEY ARE RUNNING. Mainframes are cool shit and it's sad that they are dying out.
Then again, it was probably downvoted because it was correct.
Now for the positive comments section!
> Lovely. I was not expecting to see WASI.
> This is really cool and shows WASM's power as a glue for different programming languages (that support building to WASM). What I wonder about is how well different Rust libraries support WASM, since this seems to be a requirement for this to work, do libraries need to be careful about ensuring WASM support or is it mostly free?
It depends. Usually if the library doesn't use network sockets it's fine.
> The "proper" engineering solution might be very well "just rewrite that small part in Go", but this approach is nonetheless interesting.
> It's very clearly a toy example to demonstrate the idea, and it does so well. [...] And what _we_ have here is unfounded indignation over a perfectly fine way to solve a problem.
This person gets it. Be like this person in your orange site comments.
> I know that the use of cat isn't technically required, but I still build bash oneliners step-by-step and find starting with `cat foo` to be a helpful reminder of the format of the file.
Yeah, my cyber-brain doesn't work very well unless cat is the first entry in the pipeline when the source is a file. I know I'm kinda broken, but that's how it works for me.
> This is a toy example to demonstrate a framework to build with. But I don't think it's not a cleanly solved engineering problem. Instead of reinventing xer Rust code in Go, Xe has simply taken the functional rust code and made go run it in a cross-platform and portable manner. Minimal effort from the engineer has been expended to solve this and C was not involved for FFI definitions either.
This person really reads my shit because they use the xe/xer pronouns. They should be taken more seriously.
Also I'd more call myself a philosopher than an engineer.
> Odd. When I read the article, I thought "creating cancer" is a pretty good description of the idea that one embeds a whole f*ing JavaScript runtime and accept a 10x performance decrease on runtime just so that you can avoid copying one .so file around.
WebAssembly != JavaScript.
> Personal site with ads, seriously?
> The person is a salaried employee. They are getting paid by their employer. The web site is a personal portfolio / blog /resume site. Traditionally you're paid in attention on that sort of thing and use it to bolster salary via opportunities.
>
> Getting a few dollars here and there from a personal site's ads feels cheap and detracts from the article. Tip jar, fine. But ads no. It just feels dirty. Even if they are "ethical".
>
> From my perspective (as an employer) I see this stuff and think holy hell they'll want to stick advertising on everything. Turns me right off.
I'm just gonna paste what I put on Hacker News (probably a mistake):
Author here. I'm sorry you feel this way. The ads are an experiment to see how much money I'm leaving on the table by not doing them. As of late it is currently just enough to pay for half of my server costs per month. This combined with Patreon means that my blog is cashflow positive. It's nowhere near enough to make a living off of, but it helps me get a small passive income and pays for all of my video games.
From your perspective as an employer, this should signal that I know what I'm worth and I am more than willing to negotiate for it. If you want the ads gone, please feel free to email me a job opportunity. I'll be more than willing to seriously consider it should you meet my requirements.
> I just get a message complaining that I'm using a web blocker even though I'm not.
I have no idea what's going on there.
> I felt happy unblocking ads for their site, I've often enjoyed reading their content.
^_^ it's appreciated!
> Alternatively, you could use Bazel and have it handle the shared objects. I normally put them on an object store (e.g. GCS).
Did you tell me to go fuck myself? I believe you did. You told me to go fuck myself.
> It's not the first solution I would come up with, but the question would be: why not? Just because we're used to older and more traditional patterns, why not just to embed webassembly for low level stuff in your code?
Exactly! Science isn't about "why", it's about "why not"? Why not marry safe science if you're so obsessed with it.
> Can the library not be linked statically with cgo? It seems like this would be possible with the right comment directives. Or is there some (obvious?) issue with that that I’m missing?
Yeah I could make rust shit out a .a file, but that would still be OS and architecture dependent. `go build` doesn't have a facility for running arbitrary code at compile time. This is my attempt at working around that by vendoring the .wasm file into the repo.
> Thanks for the comparison. I was looking to add plugin support for my toy project and having it just accept WASM binary seems like a way forward
Either WASM or a Lua interpreter TBH. Lua is way more powerful than people give it credit for being.
> Though in this case I think it should be called "the gopherisation of Rust programs" as it is going to extraordinary lengths to impose a Go norm (single binary) onto Rust.
No, this was entirely a carcinization of a go program because it's my article and I write the titles. If you pay me enough, you can get to write the titles.
> This is first time I hear about ["ask" as a noun for "question"]. Where did you [see] it?
This has been more common in Indian English. It's probably best if we just accept that Indian English is its own full dialect of the language. I think that usage is valid and makes sense.
> If I read this correctly the whole point of the rigamarole was to be able to use the rust crate 'lol_html'. Is there nothing comparable in the go world? If it's that critical, why are you using go at all?
lol_html lets me handle HTML mangling with events like I want to. I just wanna scrape off all of the crud from Mastodon and turn it into slack-flavoured markdown. That seems like a decent way to do it, but I'm sure that there's a better way. I have experience with lol_html (it's how the shortcodes on my blog work) and that's why I reached for it first.
> And couldn't you have also saved a bunch of effort at the end by tweaking the rust program so that it wasn't just a one-and-done and only need one call to exec?
Then I have to ship the binary around. That makes it no longer a single binary solution.
> How was OP able to pipe the output of echo directly to the wasm binary initially?
binfmt_misc! I have it set up so .wasm files get executed with wasmtime! I intentionally chose to not explain that because it's an exercise for the reader.
> > Mastodon stores toots in HTML and presents that HTML to API consumers.
>
> What. The actual. F.
>
> How? Why? Who ever thought this was a good idea?
IDK why it was chosen, but it is sensible enough to me. The main target of ActivityPub is to render on browsers, so I guess it makes sense.
> I have no experise, but my gut feeling is that the sandboxing should still add some cost?
Yeah, I'm also told that wazero has some crazy performance gains coming that will reduce runtime even more. Can't wait to see what's in the pipeline!
> This makes me wonder if you can do fat libraries the same way fat binaries are done? Can’t find any obvious answers for cross-platform cross-architecture solutions. Darwin supports multi-architecture ones of course.
You probably can, but not on Linux. Certainly not when NixOS is in the cards.
> I recommend putting [that this is not a good idea] up at the top and quite clearly explain that.
no
> Because integrating anything in Go is such a pain in the ass gophers rewrite everything. Thus it makes perfect sense to a gopher.
Then why did I integrate Rust and Go? Think, Internet. Think.
@cadey If a person can't put together the two thoughts that:
1. this approach is evil black magic in which one should never dabble, and
2. much much worse hacks are keeping ALL of your favorite sites afloat;
then they should go back to writing micro benchmarks and arguing about which language they should use for the project they will never write.
@afontaine I'd struggle to call them the "best" comments, but they certainly are comments. I usually filter by whatever is the most hot take for my own amusement.
I'm glad the bonus rounds are fun though! I love writing them!
@cadey My view has always been that all modern CPUs do this too, dynamically recompiling x86/ARM assembly into a hardware specific instructions (uOPS)
Nvidia's denver series architectures even do this in software
And GPUs do this too, with SPIRV etc
Shipping truly native bytecode for anything is actually far more the exception than the rule