News for hackers. Stuff that matters.
Re:Should JavaScript be split into two languages? Google pro... by xscott on Sunday October 27, 2024 @02:23PM (#41964500)
Look, it's pretty clear I stepped on some insecurity. That wasn't my intent, but it happens, and I should be more careful. Then your "is this sarcasm ..." reply pissed me off. You were childish and aggravating, and after trying to put together a short/ergonomic runnable example in response to your supposedly earnest question, you aggravated me. So I was childish and tried to be aggravating in return. I should know better.

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.
Re:Should JavaScript be split into two languages? Google pro... by hu3 on Sunday October 27, 2024 @04:26PM (#41965390)
If you think people who chose not to learn a language you like are insecure it tells more about you than about them.
[dead]
Re:Should JavaScript be split into two languages? Google pro... by reshlo on Sunday October 27, 2024 @06:50PM (#41966340)
> people who become hostile when you try to talk about something interesting

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.

Re:Should JavaScript be split into two languages? Google pro... by xscott on Sunday October 27, 2024 @07:36PM (#41966562)
Are you replying to the correct person(s)? :-)

Only the last quote is mine, and I stand by it.

Re:Should JavaScript be split into two languages? Google pro... by reshlo on Sunday October 27, 2024 @09:59PM (#41967186)
I listed those quotes to rebut your assertions that we’re being hostile towards a group of people who are merely trying to talk about something interesting, not to imply attribution of all of the quotes to you. I chose the general phrase “the commenter” because it would not have been correct to say “you”, as I was aware you were not the source of many of them.
Re:Should JavaScript be split into two languages? Google pro... by xscott on Sunday October 27, 2024 @10:22PM (#41967267)
I can see where you're coming from, but my intent was to talk about the very first interaction that started all of this nonsense:

- 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?