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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Benjamin-Philip" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Benjamin-Philip/120/34651_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Benjamin-Philip
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="derek-zhou" data-post="6" data-topic="74708" 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/derek-zhou/48/19943_2.png" class="avatar"> derek-zhou:</div>
<blockquote>
<p>For heavily async rust code built on top of tokio, I would implement it within a port server. Basically you write a thin GenServer that call out to a managed external process and communicate with it through stdin/stdout. Yes, there will be some overhead in serialization and de-serialization, but I suppose in your problem domain the cost will be amortized, otherwise you won’t need to do the async thingy in the first place.</p>
</blockquote>
</aside>
<p>That’s a very interesting approach which I hadn’t considered. In my case I’m writing database drivers, so the cost of serde is non-trivial.</p>
<aside class="quote no-group" data-username="krasenyp" data-post="9" data-topic="74708" 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/krasenyp/48/39733_2.png" class="avatar"> krasenyp:</div>
<blockquote>
<p>I can argue against port server being simpler. With a C node you don’t have an Elixir side, it just works. No need to decide on a wire format because it’s the Erlang term format. All you need to do is use a C library. Why complicate things?</p>
</blockquote>
</aside>
<aside class="quote no-group" data-username="derek-zhou" data-post="10" data-topic="74708" 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/derek-zhou/48/19943_2.png" class="avatar"> derek-zhou:</div>
<blockquote>
<p>I guess we have different perspectives. Since I am a lousy Rust programmer, I am hesitant to mix c code and Rust code (don’t know how to debug when things go wrong). On the other hand, I can follow a tutorial to write a Tokio based server and pull in a few crates and glue them together with ease. I agree with you that the total lines of code is likely fewer for a C node implementation.</p>
</blockquote>
</aside>
<p>Like Derek mentioned, this is subjective, but I agree with Derek on this. Being primarily an Elixir/Erlang programmer, anything that makes the Rust/C side simpler is better in my book. In the case of a C-node in Rust, I would have to write a Rust wrapper over the <code>ErlInterface</code> API, which is definitely something I don’t want to get into.</p>
<p>Still, C-nodes seem like something worth investigating with potential applications later!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="385419" 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/yielding-nifs-in-rustler-for-bindings-to-async-functions/74708/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-385419" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="385419"
                     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="385420" data-post-id="385420">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Benjamin-Philip" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Benjamin-Philip/120/34651_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Benjamin-Philip
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I finally went with a Threaded NIF. See the linked Erlang Forums post for discussion I had on Yielding vs Threading.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="385420" 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/yielding-nifs-in-rustler-for-bindings-to-async-functions/74708/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-385420" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="385420"
                     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>