<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="119682" data-post-id="119682">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="kelvinst" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kelvinst/120/10173_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  kelvinst
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>That’s really cool! Have you tested it?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="119682" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/webassembly-and-elixir/11025/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-119682" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="119682"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="119685" data-post-id="119685">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="wanton7" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/wanton7/120/14151_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  wanton7
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>There is Enigma VM as well. It might support WebAssembly in the future <a href="https://github.com/archseer/enigma" class="inline-onebox" rel="noopener nofollow ugc">GitHub - archseer/enigma: An Erlang VM implementation in Rust · GitHub</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="119685" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/webassembly-and-elixir/11025/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-119685" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="119685"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="119721" data-post-id="119721">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="msand" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/msand/120/14405_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  msand
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I haven’t tested it yet, but looks very interesting. I was looking into running multi-core logic in the browser recently, and have the emscripten pthreads examples working fine, but it requires allowing shared-array-buffer, which kind of opens up spectre / all the speculation bugs, perhaps a bit more than necessary (and it’s only available behind flags atm).</p>
<p>I was thinking perhaps someone would’ve used BEAM with message passing between Web Workers rather than shared memory, to get scalability without opening up bugs in the hardware architecture. But seems this hasn’t really caught on properly yet.</p>
<p>There was discussion about a rust rewrite in 2017 <a href="https://groups.google.com/forum/#!topic/erlang-programming/_LUC8XbsIv4" class="inline-onebox" rel="noopener nofollow ugc">Redirecting to Google Groups</a><br>
i’m happy someone is working on it at least <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="119721" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/webassembly-and-elixir/11025/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-119721" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="119721"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="119739" data-post-id="119739">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="peerreynders" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/peerreynders/120/5826_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  peerreynders
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="msand" data-post="14" data-topic="11025">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/msand/48/14405_2.png" class="avatar"> msand:</div>
<blockquote>
<p>message passing between Web Workers</p>
</blockquote>
</aside>
<p>Being thread-based, Web Workers are heavyweight (compared to BEAM processes) and data transfer between them isn’t particularly fast (thread hop delay 1- 15ms) - which likely explains the focus on <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer" rel="noopener nofollow ugc">SharedArrayBuffer</a>.</p>
<p><strong>Edit</strong>: It seems <a href="https://developers.google.com/web/updates/2018/10/wasm-threads" rel="noopener nofollow ugc">threads for WebAssembly</a> start <a href="https://youtu.be/zgOGZgAPUjQ?t=958" rel="noopener nofollow ugc">web workers without the overhead of 4MB for each V8 isolate for JS</a> and share wasm modules.</p>
<p>Google seems to be working on developing a web standard scheduler/task processor for browsers.</p>
<p>See further:</p><aside class="quote quote-modified" data-post="9" data-topic="16611">
  <div class="title">
    <div class="quote-controls"></div>
    <img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/peerreynders/48/5826_2.png" class="avatar">
    <div class="quote-title__text-content">
      <a href="https://forum.elixirforum.com/t/are-browser-based-client-applications-important/16611/9" rel="nofollow">Are browser-based client applications important?</a> <a class="badge-category__wrapper " href="/c/general-programming-archived/17" rel="nofollow"><span data-category-id="17" style="--category-badge-color: #9A7773; --category-badge-text-color: #FFFFFF;" data-drop-close="true" class="badge-category --style-square " title="Now archived - please use the new polyglot forum…"><span class="badge-category__name">General Prog (Archived)</span></span></a>
    </div>
  </div>
  <blockquote>
    JavaScript Concurrency and the DOM - Kristofer Baxter and Malte Ubl 
<a href="https://youtu.be/XyVQfqmx2CI" class="onebox" target="_blank" rel="noopener nofollow ugc">https://youtu.be/XyVQfqmx2CI</a> 
There is an <a href="https://youtu.be/XyVQfqmx2CI?t=403" rel="noopener nofollow ugc">interesting segment</a> describing how the performance gap between mobile phones at extreme ends of the spectrum will keep growing primarily because the low end is simply getting cheaper rather than more performant. 
It also <a href="https://youtu.be/XyVQfqmx2CI?t=809" rel="noopener nofollow ugc">references</a> a project called clooney: 
<a href="https://github.com/GoogleChromeLabs/clooney" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/GoogleChromeLabs/clooney</a> 
Now this has nothing to do with lightweight processes as it simply wraps <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers" rel="noopener nofollow ugc">Web Workers</a> …
  </blockquote>
</aside>

<p>So I suspect that adapting the BEAM scheduler for the browser environment is a non-trivial port and one has to wonder whether the resulting size of the WebAssembly asset may constrain its usefulness.</p>
<blockquote>
<p>You need to implement a fault-tolerant, scalable, soft real-time system with requirements for high availability.</p>
</blockquote>
<p>… and while concurrency is an obvious goal on the browser, I don’t think anybody is giving <em>fault tolerant</em> or <em>high availability</em> much thought or value.</p>
<hr>
<p>For the time being WebAssembly for the browser seems to have a role that is similar to NIFs for the BEAM. So it makes sense that C, C++, and Rust are the officially supported languages, while everything else is considered (highly) experimental.</p>
<blockquote>
<ul>
<li><a href="https://youtu.be/zgOGZgAPUjQ?t=37" rel="noopener nofollow ugc"><strong>Not</strong> a replacement for JS</a></li>
</ul>
</blockquote>
<p>Making the browser do things, <em>scripting the browser via the various browser APIs</em>, is still the domain of ECMAScript.</p>
<p><a href="https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts#Porting_from_CC" rel="noopener nofollow ugc">Web Assembly Concepts</a>:</p>
<blockquote>
<ol start="3">
<li>By itself, WebAssembly cannot currently directly access the DOM; it can only call JavaScript, passing in integer and floating point primitive data types. Thus, to access any Web API, WebAssembly needs to call out to JavaScript, which then makes the Web API call. Emscripten therefore creates the HTML and JavaScript glue code needed to achieve this.</li>
</ol>
</blockquote>
<p>(There are future plans to <a href="https://github.com/WebAssembly/gc/blob/master/README.md" rel="noopener nofollow ugc">allow WebAssembly to call Web APIs directly</a>).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="119739" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/webassembly-and-elixir/11025/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-119739" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="119739"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #14"></div>
  </section>
</div>
    <div class="postbit" id="119766" data-post-id="119766">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="msand" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/msand/120/14405_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  msand
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thanks for the links! I was also thinking of the possibility of message passing between workers more like sending messages over the network, and running beam processes inside each worker. Fault tolerance and ability to update code in runtime are interesting for some use cases I have in mind at least. And I have at least one p2p experiment I’d like to try where high-availability would be useful as well.<br>
Rust has relatively good bindings to almost all the apis exposed by browsers now: <a href="https://rustwasm.github.io/wasm-bindgen/api/web_sys/" rel="noopener nofollow ugc">https://rustwasm.github.io/wasm-bindgen/api/web_sys/</a><br>
While things like RTCQuicTransport are obviously missing, but that can be worked around anyway, as there’s the escape hatch of calling into js and having access to all the apis from there.<br>
At least for the kinds of experiments I’m thinking of, the size of the assets for the vm wouldn’t matter too much, as those would be updated relatively rarely and could be cached quite well.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="119766" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/webassembly-and-elixir/11025/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-119766" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="119766"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #15"></div>
  </section>
</div>
    <div class="postbit" id="126009" data-post-id="126009">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="richardpringle" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/richardpringle/120/8029_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  richardpringle
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>What about running wasm modules on the beam? I think that would be useful for portability of code. For instance, it would be great if I could get the fault-tolerance guarantees of the BEAM by running a containerized version of something in the beam itself (something like SQLite for example).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="126009" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/webassembly-and-elixir/11025/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-126009" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="126009"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #16"></div>
  </section>
</div>
    <div class="postbit" id="126014" data-post-id="126014">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="blatyo" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/blatyo/120/4554_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  blatyo
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Conduit Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>When I was at CodeBEAM SF, I learned there was a group of people (not sure who), who were looking at porting the BEAM to Rust, so they could take advantage of Rust’s ability to compile to WASM. However, it sounded like it was in very early stages and there were some complexities in how the BEAM made some dynamic calls (if I remember correctly). I wouldn’t be surprised if it’s a couple years before it sees the light of day if ever.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="126014" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/webassembly-and-elixir/11025/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-126014" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="126014"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #17"></div>
  </section>
</div>
    <div class="postbit" id="126015" data-post-id="126015">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="blatyo" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/blatyo/120/4554_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  blatyo
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Conduit Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="richardpringle" data-post="17" data-topic="11025" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/richardpringle/48/8029_2.png" class="avatar"> richardpringle:</div>
<blockquote>
<p>What about running wasm modules on the beam? I think that would be useful for portability of code. For instance, it would be great if I could get the fault-tolerance guarantees of the BEAM by running a containerized version of something in the beam itself (something like SQLite for example).</p>
</blockquote>
</aside>
<p>I don’t know that it’s impossible, but I feel like it wouldn’t be very performant. I don’t think the BEAM is optimized to perform the types of operations that are necessary to run WASM code.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="126015" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/webassembly-and-elixir/11025/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-126015" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="126015"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>