- MCP server with stdio transport for local use - Search episodes, transcripts, hosts, and series - 4,511 episodes with metadata and transcripts - Data loader with in-memory JSON storage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
117 lines
7.8 KiB
Plaintext
117 lines
7.8 KiB
Plaintext
Episode: 1847
|
|
Title: HPR1847: Client Side C- WTF Is Wrong With You?
|
|
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr1847/hpr1847.mp3
|
|
Transcribed: 2025-10-18 10:04:51
|
|
|
|
---
|
|
|
|
This episode of HPR is brought to you by Ananasthos.com, get 15% discount on all shared hosting
|
|
with the offer code HPR15, that's HPR15, better web hosting that's honest and fair at Ananasthos.com
|
|
Hello everybody my name is Sig Poops and you are listening to another edition of Hacker Public Radio.
|
|
This episode is entitled Client Side C, WTF is wrong with you.
|
|
Well I'll tell you what's wrong with me, it's Client Side C, which is all up in my business right now.
|
|
What do you, Client Side C, this sounds crazy, there's an LLVM backend called M.Scriptin that actually produces JavaScript from your C program or your C++ program.
|
|
So that's pretty cool, you're porting something written in C or C++ to the client side of JavaScript, the browser running JavaScript.
|
|
Some of you may be wondering in addition to how you may be wondering why, that's kind of a complex question, why should we run C on a browser or a non-native code on a browser.
|
|
This is my personal opinion, I kind of you see as a universal assembler, I know it's not an assembler but it's everywhere and every architecture has it.
|
|
And if we can put this on the browser as well this would be nice, through compiling some compiling mechanism to JavaScript.
|
|
And that's exactly what M.Scriptin does, it takes your C code, your C++ code, and as far as I can tell, I don't know if this is the exact mechanism, a composite to something that's very close to, that's closer to JavaScript.
|
|
And then that is interpreted by a mechanism commonly known referred to as ASM.js.
|
|
And so yeah, you're compiling to a bit of code that's been interpreted on the browser.
|
|
So that's pretty cool.
|
|
And M.Scriptin wasn't really on my radar until, I don't know if my friend who is organized and I guess maintains this effort to port MAME, that's the arcade machine emulator to JavaScript.
|
|
And I was like, we were hanging out and he wanted to see if his page, his main project worked on my telephone.
|
|
And I was like, well this seems impossible really to port something in C or C++ to JavaScript.
|
|
And that's a huge effort is what that is. And I can't believe you're undertaking it and he's like, well we use M.Scriptin, which I had never heard of.
|
|
And I was like, I'm scripting, what is this? And yeah, it's like, yeah, it can compile C and C++ to JavaScript.
|
|
So I went home, excited as hell to research what is called M.Scriptin.
|
|
And I was like, well I can port my psychogenesis sprite editor to it.
|
|
And I had to go with that and it failed miserably because well because my sprite editor has a lot of loops, it's land of the loops my sprite editor.
|
|
Every object has a loop to it.
|
|
It's a bit much and the fundamental difference between JavaScript and C is in JavaScript you do not have an infinite loop.
|
|
You don't have heavy loops, you don't wait basically.
|
|
If you have something waiting in the event queue of JavaScript, I'm sorry, it will halt.
|
|
And you'll get a message saying this script has stopped working or something like that.
|
|
If you're in Firefox, you can message like that.
|
|
So instead of writing a main loop, that changes for every GUI object that you're doing or using, I decided to port my intendo emulator over.
|
|
It's this intendo emulator I wrote on YouTube a few years ago and it only has one loop, one big loop.
|
|
And so that's good, that works for JavaScript.
|
|
You can check out my app at feedasilva.com slash web ness.
|
|
That's in the show notes.
|
|
And there's a guest book in there, sign it with your browser and tell me if it works or not.
|
|
So how do you install in scripting? That's a good question.
|
|
You go to the inscription wiki, which is in the show notes.
|
|
There you'll find how to download and install in scripting.
|
|
There's a little something you download for Windows OS X and Linux for the portable SDK that you install.
|
|
It'll say for Linux and Mac OS X, you can download the portable in scripting SDK for Linux and OS X.
|
|
That's the name of the file, that's in the show notes.
|
|
And uncompress that.
|
|
You'll get a directory called emsdk underscore portable.
|
|
Before you do anything with this, there is a couple things that you need.
|
|
You need node, node.js, python, 2.7, I believe, or just python.
|
|
And let's see what the dependencies did you need.
|
|
I think those are the major dependencies.
|
|
Seemake, if you don't have it already.
|
|
So go to the directory emsdk underscore portable and run emsdk space update.
|
|
Then you run emsdk space install latest.
|
|
This is going to take a long time.
|
|
You might as well do something that takes a long time, like baking a potato, going to sleep and waking up the next morning, installing Debian.
|
|
Something that takes a while.
|
|
And once that's done, you type emsdk activate latest.
|
|
And then you should be able to do things.
|
|
You need to put the proper path.
|
|
And so if you source, if you type source, space.slash emsdk underscore env.sh.
|
|
That'll set up your path for you.
|
|
So you can run emcc, if you want, for the see compiler.
|
|
And whatnot.
|
|
So now you have the tools.
|
|
I'm going to talk about c here, not c++, because I have experience with c.
|
|
And I'm scripting.
|
|
I don't have any experience running c++.
|
|
With them scripting.
|
|
So you have everything you need.
|
|
Emcc is your compiler, much like gcc.
|
|
And it will take c programs.
|
|
And then if you specify dash o, something like index.html, it'll generate index.html, which contains the website code, interacts with the DOM, as well as index.js.
|
|
And create that as well.
|
|
And then index.html.mian, which I believe is the data segment of your program.
|
|
So now we need some graphics to draw on that canvas.
|
|
I'm scripting comms with sdl.
|
|
I'm not sure if it's 1.2 or 2.0, but you can call sdl 1.2 calls.
|
|
And that should be run.
|
|
You can lock a service right to the pixels manually and unlock a service.
|
|
And it will be act pretty, pretty flawlessly and draw whatever you write to the service on the canvas screen.
|
|
So that's cool.
|
|
You need to have a loop or maybe a stack of loops or something.
|
|
You have to have a main loop for something for JavaScript to do.
|
|
If you run the function M script and set main loop with the arguments, your function, a number, maybe 10.
|
|
This is the microseconds.
|
|
And then one, if you're emulating an infinite loop.
|
|
The middle number there is what in scripting does is it puts a bit of code in the JavaScript event queue.
|
|
That gets run every 10 microseconds.
|
|
That's the number that you put in there.
|
|
That's right.
|
|
That should work for you.
|
|
So the Nintendo emulator that I'm running has to detect when you press the power button.
|
|
That way it'll stop drawing buzz and go to the emulator main loop.
|
|
So how I do that is with a simple command called masmint, which you can give it as an argument.
|
|
Some JavaScript code.
|
|
Have that return something.
|
|
And then deal with that as if it were an integer that you're returning.
|
|
And so that's what I do.
|
|
I pull, I guess, whether the Nintendo is on or off and run the correct script or the correct parts of the program.
|
|
So yeah, I think this is it.
|
|
And I hope you have fun with emsdk.
|
|
Let me know.
|
|
Bye bye.
|
|
You've been listening to heckaPublicRadio at heckaPublicRadio.org.
|
|
We are a community podcast network that releases shows every weekday Monday through Friday.
|
|
Today's show, like all our shows, was contributed by an HPR listener like yourself.
|
|
If you ever thought of recording a podcast, then click on our contributing to find out how easy it really is.
|
|
HeckaPublicRadio was founded by the digital dog pound and the infonomicon computer club.
|
|
And it's part of the binary revolution at binwreff.com.
|
|
If you have comments on today's show, please email the host directly.
|
|
Leave a comment on the website or record a follow-up episode yourself.
|
|
Unless otherwise stated, today's show is released on the creative comments, attribution, share a light, 3.0 license.
|
|
Thanks for watching.
|