That seems like an easy question, but there a lot of choices which complicate it. I'm sure people have compiled CPython to WebAssembly, but I think you only get the WebAssembly imports they (or Emscripten) have chosen for you. I can't use that as an example of what I was trying to show.
It looks like py2wasm is aiming for a true Python to WASM compiler, rather than compiling an interpreter. However, I don't think it supports user-defined imports/exports yet. There's a recent issue thread about this (https://github.com/wasmerio/py2wasm/issues/5).
> how would it compare with non-wasm javascript?
I'm not sure I understand the question. If you're just using JavaScript, it just looks like JavaScript.
for the second question the example you gave is equivalent to what in plain html/js?
No. It means you only get what the person who ported CPython or py2wasm gave you. It's not a limitation in WebAssembly, and maybe they have some other (hopefully better) API than the `easy(123)` example I was trying to show.
> for the second question the example you gave is equivalent to what in plain html/js?
If I understand what you're asking, it's just:
<!doctype html><title>plain jane</title>
<script type="module">
function easy(arg) {
const div = document.createElement("div");
div.textContent = "DOM this: " + String(arg);
document.body.appendChild(div);
}
easy(123);
easy(456);
</script>that's what i meant. it's not possible until someone adds the necessary features to the wasm port of the language. makes sense of course, like any feature of a new architecture.
If I understand what you're asking
exactly that, thank you. it is easier to understand the example if there is no doubt as to what is the js part and what is wasm (it also didn't help that the code was not easy to read on a phone)
Flaunting your ignorant anti-intellectualism isn't a good look.
You do know this is 2024, you have Internet access, and you can just look shit up or ask ChatGPT to learn new things, instead of cultivating ignorance and pointlessly criticising programmers trying to raise awareness and educate themselves and other people.
In case you didn't realize it, JavaScript is essentially a dialect of Lisp, and LOTS of people know it.
If you’re trying to raise awareness of something, don’t act like the reader is stupid if they don’t already understand. Insisting that something is obvious, especially when it is not, means any reader who does not understand it will likely perceive the comment as snobby. As does including snide remarks such as “in case you’ve been living under a rock”.
> Flaunting your ignorant anti-intellectualism isn’t a good look.
Why do you assume that I personally don’t know what s-expressions are just because I agree that they’re arcane? Labelling someone as an ignorant anti-intellectual just because they disagree with something you said isn’t a good look either.
I, like most devs, know what Lisp is.
I, like most devs, just don't care.
There's no point in trying to make other people stop talking about Lisp by complaining about how proudly ignorant you are, and how you want to remain that way, so you don't want anyone else to talk about it. This really isn't the place for that, since you always have the option of not reading, shutting up, and not replying and interrupting and derailing the discussion, so other more knowledgeable and curious people can have interesting discussions without you purposefully harassing them like a childish troll.
Infantile language tribalism though, have no place in engineering and is blatant ignorance when coming from a supposed adult.
Implementations of Lisp are no more niche than other languages with managed run-times.
Lisp has been used for even operating system development: Lisp code taking interrupts, and driving ethernet cards and disks and so on.
Which member of the Lisp family are you talking about, and what do you think is the niche?
No more niche than Java, C# .NET and Python? Right...
> Which member of the Lisp family are you talking about, and what do you think is the niche?
You can combine all of the Lisp family together and still it wouldn't scratch the popularity, demand or job positions of any of the top languages.
Look, nobody denies Lisp'like languages are being used. Just like Fortran. :)
Fortran has a niche: numeric computing in scientific areas. However, even Fortran is not your grandfather's Fortran 66 or 77 any more. I had a semester of the latter once, as part of an engineering curriculum before switching to CS.
It supposedly has OOP programming in it, and operator overloading and such.
I don't know modern Fortran, so I wouldn't want to look ignorant spreading decades-old misinformation about Fortran.
Nobody is trying to make you stop talking about it. We’re trying to make you understand that the way you’re talking about it is elitist. When someone said they were confused by the syntax, you could have just explained it without judgement. Instead, you felt compelled to flaunt your membership of the in-group who understands Lisp, and try to make others feel stupid by implying that people who don’t understand it aren’t good programmers, or are anti-intellectual.
You’re doubling down on it in this comment, too, still insistent on making people feel like they’re “less than” because they don’t know Lisp:
> so other more knowledgeable and curious people
If I didn’t know Lisp, and my first exposure to it was from someone who sees this kind of toxicity as a reasonable way to speak to people, would I want to join their community?
Wouldn't (didn't!) faze me. Every community has it. The most popular languages, platforms and tools in fact bring out unbridled hostility. Probably, hostility finds a peak in the second most popular camps. :)
We have already lost people who are influenced by this sort of fluff, because those people will be turned away from Lisp by the anti-Lisp trolling about parentheses, niches and slow processing over everything being a list, and so on. There aren't enough Lisp people around to counter it.
I knew Lisp the way I know that that guy walking down the street is my neighbor Bob. But since I've never had a conversation with Bob, I actually have no idea who he is.
When I see Korean writing in hangeul, I know it is Korean writing, but can't read a letter of it (nor speak a word of Korean).
These examples are like knowing what Lisp is.
The thing I had not expected was how the knowledge in the Lisp world and its perspectives are very informative about a whole lot of non-Lisp!
Why don't you just go away and let other people have their interesting discussions without you, instead of bitterly complaining about things you purposefully know nothing about and refuse to learn? How does it hurt your delicate feelings to just shut up and not bitch and whine about discussions you're not interested in?
I think you’re assuming that all of the comments you’re talking about are written by the same person, when they’re not. I haven’t been attacking anyone, and I don’t think I’ve replied to anyone who’s tried to explain it.
> things you purposefully know nothing about and refuse to learn
Why do you still assume I don’t know what they are? I’ve already pointed out that my belief that s-expressions are arcane doesn’t mean I don’t know what they are.
As another illustration of my point, I just stumbled across this comment on another post:
> But maybe the whole "ease of use" budget is blown by using a Lisp in the first place.[0]
The fact is that Lisp syntax is understood by relatively few programmers, which meets the definition of arcane. You immediately flying off the handle when someone calmly points this out will not help your goal.
They just don't care enough to invest time in it because it is niche. And proponents tend to tirelessly spam about it from their ivory towers like it's flawless and everyone who didn't learn it is somehow inferior, somehow justifying personal attacks like yours. Classy as usual.
Online discussions always fall apart this way, and it sucks. Having had some time to think, I'm sorry for my part of it.
However, the interesting thing to me, and maybe to you is that you can create a WebAssembly binary in a lot of different programming languages. I don't know what languages you like, but Rust has a more conventional syntax, and comparable code could've looked like this:
#[wasm_bindgen]
extern {
fn easy(s: &i32);
}
#[wasm_bindgen]
pub fn run() {
easy(123);
easy(456);
}
Short examples like this always leave something out. The easy() function isn't very interesting, but it does "manipulate the DOM" by creating a new DIV and appending it to the body. Also, languages like C and Rust have a "shadow stack" and memory allocators, so dealing with memory isn't shown here.The point I was trying to make was that WebAssembly can easily cause changes to the DOM by calling imported functions. That leaves a lot of freedom to design functions that do what you want. You could make your own graphics library, audio library, text output, DOM manipulation, and so on... And it all works today. The downside is that you do need to make your own set of functions, and designing good APIs is hard. Clearly the easy() function is not a good API.
When people complain about WebAssembly not having direct access to the DOM, I'm not even sure what they mean. Most things in the DOM are done by assigning attributes or creating elements. Would having `getElementByName()`, `createElement()` and `setAttribute()` functions scratch the itch? Because you could do that today (with some clever glue code in JavaScript). What do they (you) actually want?
People can argue about how fast the transitions are between WebAssembly and the JavaScript functions, but you can work around that by packing more work per call and passing large data or strings in or out of the memory.
ps: WebAssembly's Text format (WAT) is also a bit arcane to me, not because of the Lisp syntax, but because there are multiple ways to do almost anything, and it's hard to find good examples which do things cleanly. Even since writing that post last night, DonHopkins' comments on WAForth showed me that I could've written it like this:
(module
(import "env" "easy" (func $easy (param i32)))
(func (export "run") (param) (result)
(call $easy (i32.const 123))
(call $easy (i32.const 456))
)
(memory (export "mem") 1)
)
Which is nearly the same thing as the Rust snippet above.We’re becoming annoyed not because people are trying to talk about something interesting, but because they are being intentionally insulting and condescending and then using bad faith arguments like this one when they’re called out on it.
Which of these quotes represent the commenter “trying to talk about something interesting”?
> flaunting your ignorance and your anti-intellectualism
> The point is that anyone who's distracted by the arcanity of Web Assembly Text Format obviously doesn't understand the first thing about WASM
> You do know this is 2024, you have Internet access, and you can just look shit up
> In case you've been living under a rock and didn't realize it
> but you're whining, lashing out, and attacking people who are trying to explain it, and trying to police and derail discussions between other people who are more knowledgeable and interested in it, which makes you a rude anti-intellectual asshole… Why don't you just go away and let other people have their interesting discussions without you, instead of bitterly complaining about things you purposefully know nothing about and refuse to learn? How does it hurt your delicate feelings to just shut up and not bitch and whine about discussions you're not interested in?
> And that proves my point that you're flaunting your ignorance and your anti-intellectualism. But you be you. There's no point in trying to make other people stop talking about Lisp by complaining about how proudly ignorant you are, and how you want to remain that way, so you don't want anyone else to talk about it. This really isn't the place for that, since you always have the option of not reading, shutting up, and not replying and interrupting and derailing the discussion, so other more knowledgeable and curious people can have interesting discussions without you purposefully harassing them like a childish troll.
> Look, it's pretty clear I stepped on some insecurity.
Only the last quote is mine, and I stand by it.
- I said WebAssembly can already manipulate the DOM with functions.
- He asked for an ergonomic example because StackOverflow told him it can't be done. The "we can have DOM access at home" bit seems like the start of things to come.
- I provided a concise example, and expressed skepticism that this would settle the discussion.
- He responded with sarcasm, and weirdly accused me of sarcasm.
- I reacted poorly to his bitchy and ungrateful reply.
My best guess is that the WAT format confused him. He didn't know it was a programming language, and he didn't know you could do it with other programming languages, so he got insecure and lashed out.
Do you have a better explanation for the weird transition from technical discussion to flame war and hurt feelings?
I.e. they are correct that it is arcane. What percentage of programmers today do you think have ever seen code written in any Lisp dialect, let alone understand it?