GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Conversation

Notices

  1. Embed this notice
    mcc (mcc@mastodon.social)'s status on Wednesday, 28-May-2025 08:25:43 JST mcc mcc

    #BabelOfCode 2024
    Week 11 (??)
    Language: Textual Wasm

    Confidence level: Medium high

    PREV WEEK: https://mastodon.social/@mcc/114524697727786286
    RULES: https://mastodon.social/@mcc/113676228091546556

    I'm now doing the puzzles slightly out of order.

    "Wasm" is a bytecode VM that runs in web browsers as an alternative to JavaScript. Oddly for a modern VM, it's designed to be targeted by C.

    A thing I've heard repeatedly claimed, both excitedly and with eye-rolls, is that Wasm's human readable form is "a LISP". I want to know what that means.

    In conversation about 11 days ago from mastodon.social permalink

    Attachments

    1. No result found on File_thumbnail lookup.
      mcc (@mcc@mastodon.social)
      from mcc
      I have been too busy to do AOC this year and will be all month So I'm thinking I'm going to do AOC 2024, *in 2025*, under the following rules: - One challenge per week. - I don't have to perform a challenge every week. The goal is to finish by the start of December. - I have to do a different programming language every time. - C, C++ and Objective-C are not eligible languages. - If I make an honest attempt at a language and fail, I may retry in Go (but only Go) (I need to learn Go)
    2. No result found on File_thumbnail lookup.
      mcc (@mcc@mastodon.social)
      from mcc
      #BabelOfCode 2024 Week 9 Language: Ada (Spark?) Confidence level: High PREV WEEK: https://mastodon.social/@mcc/114463342416949024 NEXT WEEK: https://mastodon.social/@mcc/114582208242623432 So I start reading the manual for Ada. I think: This is *great!* This has all these features, conveniences etc I was wishing for for years in C++, and didn't get until I jumped to Rust. I might have been using this for games in 2010 if I'd dug into it then! Then I start writing an actual Ada program. It turns out to be basically a pain in the ass.
    • Embed this notice
      ✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Wednesday, 28-May-2025 08:25:41 JST ✧✦Catherine✦✧ ✧✦Catherine✦✧
      in reply to

      @mcc wasmtime generates code that is competitive with C on computation-heavy workloads. wasm-interp is just the reference interpreter

      In conversation about 11 days ago permalink
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Wednesday, 28-May-2025 08:25:42 JST mcc mcc
      in reply to

      I check out Wabt and try to build it, and… oh. There's… no cmake, on this machine. I hadn't needed it until now. Oh! What a peaceful and innocent life I have lead, since first I set up this laptop.

      In conversation about 11 days ago permalink

      Attachments


      1. https://files.mastodon.social/media_attachments/files/114/582/286/069/657/559/original/1db3c303e2395fbe.png
      clacke@libranet.de is my main likes this.
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Wednesday, 28-May-2025 08:25:42 JST mcc mcc
      in reply to

      It seems I can assemble³ with:

      wat2wasm source.wast -o exec.wasm

      And execute with either, from wabt:

      wasm-interp simple.wasm -r add -a i32:1 -a i32:2

      Or if I have wasmtime:

      wasmtime --invoke add simple.wasm 1 2

      I don't know why I'd bother with wasmtime if I have wasm-interp. Is wasmtime faster?

      ³ Assume simple.wasm contains, code from MDN:

      (module
      (func $add (param $lhs i32) (param $rhs i32) (result i32)
      local.get $lhs
      local.get $rhs
      i32.add)
      (export "add" (func $add))
      )

      In conversation about 11 days ago permalink
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Wednesday, 28-May-2025 08:25:43 JST mcc mcc
      in reply to

      On initially cracking open the MDN guide¹, *so far* it kind of seems like it only means "It's structured as an S-expression". That's a bit disappointing. It's an understandable decision, as S-expressions make parsing easy— I've used this shortcut myself— but also, it seems this is preserving *only* the part of LISP people hate most. What do people complain about the most? What do LISP heads complain the most about other people complaining about? *It's the parentheses*.

      ¹ https://developer.mozilla.org/en-US/docs/WebAssembly/Guides/Understanding_the_text_format

      In conversation about 11 days ago permalink

      Attachments

      1. Domain not in remote thumbnail source whitelist: developer.mozilla.org
        Understanding WebAssembly text format - WebAssembly | MDN
        from MozDevNet
        To enable WebAssembly to be read and edited by humans, there is a textual representation of the Wasm binary format. This is an intermediate form designed to be exposed in text editors, browser developer tools, etc. This article explains how that text format works, in terms of the raw syntax, and how it is related to the underlying bytecode it represents — and the wrapper objects representing Wasm in JavaScript.
      clacke@libranet.de is my main likes this.
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Wednesday, 28-May-2025 08:25:43 JST mcc mcc
      in reply to

      It's not actually clear what file extension you're supposed to use for textual wasm files. The Sublime plugin claims this language is called "WAST" and as such suggests .wast. I guess I'll go with that. MDN calls the format "WAT". I wonder if there's subtle commentary there.

      It's also a *little* nonobvious how to assemble and run this stuff. Wasm was originally intended to be loaded from JavaScript. Both MDN and help on mastodon² suggest a toolset named WABT.

      ² https://mastodon.social/@mcc/114581638222018210

      In conversation about 11 days ago permalink

      Attachments

      1. No result found on File_thumbnail lookup.
        there.it
        description

      2. https://files.mastodon.social/media_attachments/files/114/582/268/633/846/644/original/5c398aba2f97e286.png
      3. No result found on File_thumbnail lookup.
        mcc (@mcc@mastodon.social)
        from mcc
        How can I build and run textual WASM at the Linux command line? Google for a textual wasm compiler turns up blog posts about how to write a textual wasm compiler. That's not what I wanted. I have a sense the command line execution engine is "wasi", but apt-cache search wasi doesn't turn up anything obvious. Is this what I want? https://github.com/WebAssembly/wasi-sdk
      clacke@libranet.de is my main likes this.
    • Embed this notice
      ✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Wednesday, 28-May-2025 08:26:18 JST ✧✦Catherine✦✧ ✧✦Catherine✦✧
      in reply to

      @mcc also wasmtime has features like "bindings" and "real multithreading" and "knows how to do various types of I/O", basically everything you need to run a production app (or yowasp.org)

      In conversation about 11 days ago permalink

      Attachments

      1. No result found on File_thumbnail lookup.
        YoWASP
        Unofficial WebAssembly-based packages for Yosys, nextpnr, and more
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Wednesday, 28-May-2025 08:29:50 JST mcc mcc
      in reply to
      • ✧✦Catherine✦✧

      @whitequark Bindings to what?

      In conversation about 11 days ago permalink
    • Embed this notice
      ✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Wednesday, 28-May-2025 08:50:47 JST ✧✦Catherine✦✧ ✧✦Catherine✦✧
      in reply to

      @mcc to whatever code you want; you can add host functions written in Rust that your Wasm code can call. i don't think wasm-interp offers anything like this (I believe it just exists to validate the spec)

      In conversation about 11 days ago permalink
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Wednesday, 28-May-2025 08:50:47 JST mcc mcc
      in reply to
      • ✧✦Catherine✦✧

      @whitequark Can I run wasmtime in a mode where only things that would be legal in a browser are legal?

      In conversation about 11 days ago permalink
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Wednesday, 04-Jun-2025 08:46:00 JST mcc mcc
      in reply to

      So. Creeping along with this. I am posting tihs from a bus.

      Learned some more about "textual WASM". Two things I learned. One. It is LISP but also it is Forth. You write it as structurally an S-expression but the commands you write in that S-expression are, as it happens, instructions to a stack machine. This surprised me, but apparently Hotspot was a stack machine, as was the C# CLR as it was based on Hotspot, as is wasm because it was based on… Hotspot. Apparently this works well for JIT.

      In conversation about 4 days ago permalink
    • Embed this notice
      ✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Wednesday, 04-Jun-2025 08:46:00 JST ✧✦Catherine✦✧ ✧✦Catherine✦✧
      in reply to

      @mcc Hotspot isn't really a stack machine. *Java bytecode* is written for a stack machine, as is Wasm machine code, which works out well because it's compact: you don't encode (almost) any temporary indices, like you would have in LLVM

      the moment you load it, you transform it into a register representation in memory. not literally every implementation does it, but most do not actually execute it with a data stack

      In conversation about 4 days ago permalink
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Wednesday, 04-Jun-2025 08:46:01 JST mcc mcc
      in reply to

      Been reading the docs and I have a LOT to say but

      I've been using this lovely, friendly guide to figure out how to write WASM assembly

      https://developer.mozilla.org/en-US/docs/WebAssembly/Guides/Understanding_the_text_format

      (The spec https://webassembly.github.io/spec/core/_download/WebAssembly.pdf is a little hard to work with)

      And saw this really alarming note implying the guide hadn't been updated since 2020 (is that when Mozilla fired everyone?)

      Can anyone recommend how I'd find out what has changed in Wasm between 2020 and 2025? Assume I'm targeting wasmtime and can be cutting edge.

      In conversation about 4 days ago permalink

      Attachments


      1. https://files.mastodon.social/media_attachments/files/114/586/804/106/858/631/original/1ce0e5986629103b.png

    • Embed this notice
      ✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Wednesday, 04-Jun-2025 10:54:58 JST ✧✦Catherine✦✧ ✧✦Catherine✦✧
      in reply to
      • mega

      @mega @mcc there is the caveat that both wasm and java have the separate concept of locals, which is why i said "temporaries"; you still have to do liveness analysis for locals-locals if you want high quality codegen

      In conversation about 4 days ago permalink
    • Embed this notice
      mega (mega@chaos.social)'s status on Wednesday, 04-Jun-2025 10:55:00 JST mega mega
      in reply to
      • ✧✦Catherine✦✧

      @whitequark @mcc Also (maybe relevant for the JIT comment): the stack at any given point *is* the set of live variables.

      If you calculate a kind of "virtual stack" for a given basic block you will end up with the amount of elements that it pops from the stack (phi nodes/basic block arguments/whatever you want to call them) and the amount of elements it adds to the stack at the end of its execution (values that will be consumed by another block).

      In conversation about 4 days ago permalink
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Wednesday, 04-Jun-2025 10:56:20 JST mcc mcc
      in reply to
      • ✧✦Catherine✦✧
      • mega

      @whitequark @mega if i am writing/generating code why would i use the stack for live variables instead of the locals, or vice versa?

      In conversation about 4 days ago permalink
    • Embed this notice
      ✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Wednesday, 04-Jun-2025 10:58:34 JST ✧✦Catherine✦✧ ✧✦Catherine✦✧
      in reply to
      • mega

      @mcc @mega the stack machine that JVM and Wasm have, and the SSA form that LLVM has, are literally equivalent (they are different ways to serialize the same IR, essentially; with the caveat that Wasm forbids irreducible control flow)

      if you have your code in SSA/CPS form you would find it easy to emit stack bytecode, if you do not, it is most convenient to use locals (and the runtimes are aware of this and optimize for it)

      In conversation about 4 days ago permalink

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.