<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: David Anyatonwu</title>
    <description>The latest articles on DEV Community by David Anyatonwu (@david_anyatonwu_c3d0ac6c3).</description>
    <link>https://dev.to/david_anyatonwu_c3d0ac6c3</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4019591%2F80a2c55d-3abe-4f59-a213-533f50020d8a.jpg</url>
      <title>DEV Community: David Anyatonwu</title>
      <link>https://dev.to/david_anyatonwu_c3d0ac6c3</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/david_anyatonwu_c3d0ac6c3"/>
    <language>en</language>
    <item>
      <title>Giving TypeScript a Rust-Powered Turbo Button with FFI</title>
      <dc:creator>David Anyatonwu</dc:creator>
      <pubDate>Thu, 03 Sep 2026 11:26:10 +0000</pubDate>
      <link>https://dev.to/david_anyatonwu_c3d0ac6c3/giving-typescript-a-rust-powered-turbo-button-with-ffi-man</link>
      <guid>https://dev.to/david_anyatonwu_c3d0ac6c3/giving-typescript-a-rust-powered-turbo-button-with-ffi-man</guid>
      <description>&lt;p&gt;TypeScript is excellent for building applications quickly. Rust is excellent when you need predictable performance, low-level control, or memory-efficient computation.&lt;/p&gt;

&lt;p&gt;Foreign Function Interface—usually shortened to FFI—allows us to combine both. Our application can remain in TypeScript while selected operations run inside a compiled Rust library.&lt;/p&gt;

&lt;p&gt;Let’s build a small native function that calculates the mean of a large array of numbers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating the Rust Library
&lt;/h2&gt;

&lt;p&gt;Create a new Rust library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;cargo new signal-math --lib
cd signal-math

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Configure Cargo to produce a native dynamic library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="c"&gt;# Cargo.toml&lt;/span&gt;

&lt;span class="nn"&gt;[package]&lt;/span&gt;
&lt;span class="py"&gt;name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"signal-math"&lt;/span&gt;
&lt;span class="py"&gt;version&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"0.1.0"&lt;/span&gt;
&lt;span class="py"&gt;edition&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"2024"&lt;/span&gt;

&lt;span class="nn"&gt;[lib]&lt;/span&gt;
&lt;span class="py"&gt;crate-type&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"cdylib"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A &lt;code&gt;cdylib&lt;/code&gt; is a dynamic system library designed to be consumed by another language. Depending on the operating system, Cargo will produce a &lt;code&gt;.so&lt;/code&gt;, &lt;code&gt;.dylib&lt;/code&gt;, or &lt;code&gt;.dll&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;Now add our exported function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/lib.rs&lt;/span&gt;

&lt;span class="nd"&gt;#[unsafe(no_mangle)]&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;extern&lt;/span&gt; &lt;span class="s"&gt;"C"&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="nb"&gt;f64&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;usize&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;f64&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="nf"&gt;.is_null&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;||&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nn"&gt;f64&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;NAN&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;values&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;unsafe&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nn"&gt;std&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from_raw_parts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;

    &lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="nf"&gt;.iter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="py"&gt;.sum&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;f64&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nb"&gt;f64&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three details make this function accessible from TypeScript:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;pub&lt;/code&gt; makes the function public.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;extern "C"&lt;/code&gt; gives it the C calling convention.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#[unsafe(no_mangle)]&lt;/code&gt; preserves the exported name as &lt;code&gt;mean&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rust cannot prove that the pointer supplied by TypeScript is valid, so converting it into a slice requires an &lt;code&gt;unsafe&lt;/code&gt; block. The goal is to keep this unsafe boundary as small and carefully checked as possible. The &lt;a href="https://doc.rust-lang.org/nomicon/ffi.html" rel="noopener noreferrer"&gt;Rustonomicon’s FFI guide&lt;/a&gt; provides more detail about these boundaries.&lt;/p&gt;

&lt;p&gt;Build the library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;cargo build --release

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The generated file will be one of the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Linux:   target/release/libsignal_math.so
macOS:   target/release/libsignal_math.dylib
Windows: target/release/signal_math.dll

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Calling Rust from TypeScript
&lt;/h2&gt;

&lt;p&gt;Deno provides a native &lt;code&gt;Deno.dlopen()&lt;/code&gt; API for loading dynamic libraries directly from TypeScript.&lt;/p&gt;

&lt;p&gt;Create &lt;code&gt;app.ts&lt;/code&gt; in the project directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;libraryName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;linux&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;libsignal_math.so&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;darwin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;libsignal_math.dylib&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;windows&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;signal_math.dll&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}[&lt;/span&gt;&lt;span class="nx"&gt;Deno&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;build&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;os&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;libraryPath&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s2"&gt;`./target/release/&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;libraryName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;library&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Deno&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dlopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;libraryPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;parameters&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;buffer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;usize&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="na"&gt;result&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;f64&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;measurements&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Float64Array&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="mf"&gt;12.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mf"&gt;18.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mf"&gt;21.7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mf"&gt;15.9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mf"&gt;19.3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;]);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;library&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;symbols&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;measurements&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;BigInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;measurements&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Mean: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;finally&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;library&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;deno run --allow-ffi app.ts

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result should be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Mean: 17.52

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;Float64Array&lt;/code&gt; gives Rust a contiguous block of 64-bit floating-point values. TypeScript passes its buffer and length across the boundary, while Rust interprets that memory as a slice.&lt;/p&gt;

&lt;p&gt;Deno requires the &lt;code&gt;--allow-ffi&lt;/code&gt; permission because native libraries run outside its normal security sandbox and inherit the process’s system access. Only load libraries you trust. See the official &lt;a href="https://docs.deno.com/runtime/fundamentals/ffi/" rel="noopener noreferrer"&gt;Deno FFI documentation&lt;/a&gt; for its supported native types and security considerations.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Boundary Is the Important Part
&lt;/h2&gt;

&lt;p&gt;The calculation itself is simple. The interesting engineering happens at the boundary between the languages.&lt;/p&gt;

&lt;p&gt;TypeScript and Rust must agree on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Function names&lt;/li&gt;
&lt;li&gt;Calling conventions&lt;/li&gt;
&lt;li&gt;Parameter sizes&lt;/li&gt;
&lt;li&gt;Return types&lt;/li&gt;
&lt;li&gt;Memory layouts&lt;/li&gt;
&lt;li&gt;Pointer validity&lt;/li&gt;
&lt;li&gt;Resource ownership&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;FFI does not translate arbitrary Rust or TypeScript objects automatically. It works best with C-compatible values such as integers, floating-point numbers, pointers, byte buffers, and carefully defined structs.&lt;/p&gt;

&lt;p&gt;For complex data, a common pattern is to serialize it into JSON, MessagePack, or another binary format before crossing the boundary. This is easier to maintain than exposing deeply nested native structures, although serialization introduces some overhead.&lt;/p&gt;

&lt;h2&gt;
  
  
  Avoid Tiny Native Calls
&lt;/h2&gt;

&lt;p&gt;Calling Rust through FFI has a cost. It would be inefficient to cross the boundary once for every number in an array.&lt;/p&gt;

&lt;p&gt;Prefer this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;average&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;library&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;symbols&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;values&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;BigInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;values&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Over an API shaped like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;values&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;library&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;symbols&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;processOneNumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Batching work into fewer calls makes the native boundary worthwhile. Good candidates include image processing, compression, cryptography, parsing, simulations, and large numerical operations.&lt;/p&gt;

&lt;h2&gt;
  
  
  FFI Is Powerful, but It Changes the Safety Model
&lt;/h2&gt;

&lt;p&gt;Rust is memory-safe only while its safety requirements are respected. Once raw pointers arrive from another language, Rust cannot automatically guarantee that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The pointer is valid.&lt;/li&gt;
&lt;li&gt;The buffer is large enough.&lt;/li&gt;
&lt;li&gt;The memory remains alive during execution.&lt;/li&gt;
&lt;li&gt;Both languages agree on its layout.&lt;/li&gt;
&lt;li&gt;The memory is released exactly once.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A production library should therefore validate inputs, document ownership rules, prevent Rust panics from crossing the FFI boundary, and expose the smallest possible native interface.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Rust and TypeScript do not have to compete for ownership of an application.&lt;/p&gt;

&lt;p&gt;TypeScript can handle APIs, user interfaces, orchestration, and rapidly changing business logic. Rust can provide a focused native engine for operations where performance or low-level control genuinely matters.&lt;/p&gt;

&lt;p&gt;FFI becomes the narrow bridge between them. Keep that bridge small, explicit, and well-tested, and you can gain Rust’s native capabilities without giving up TypeScript’s development experience.&lt;/p&gt;

</description>
      <category>performance</category>
      <category>programming</category>
      <category>rust</category>
      <category>typescript</category>
    </item>
    <item>
      <title>A befitting title</title>
      <dc:creator>David Anyatonwu</dc:creator>
      <pubDate>Wed, 26 Aug 2026 08:00:03 +0000</pubDate>
      <link>https://dev.to/david_anyatonwu_c3d0ac6c3/a-befitting-title-c5d</link>
      <guid>https://dev.to/david_anyatonwu_c3d0ac6c3/a-befitting-title-c5d</guid>
      <description>&lt;p&gt;Test posts. this is s detailed post of a  whatevery and whatever.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>A befitting title</title>
      <dc:creator>David Anyatonwu</dc:creator>
      <pubDate>Thu, 06 Aug 2026 08:00:06 +0000</pubDate>
      <link>https://dev.to/david_anyatonwu_c3d0ac6c3/a-befitting-title-190j</link>
      <guid>https://dev.to/david_anyatonwu_c3d0ac6c3/a-befitting-title-190j</guid>
      <description>&lt;p&gt;The is just a test.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Facing Gravity: Why Our Tests Need Reality</title>
      <dc:creator>David Anyatonwu</dc:creator>
      <pubDate>Tue, 04 Aug 2026 09:57:20 +0000</pubDate>
      <link>https://dev.to/david_anyatonwu_c3d0ac6c3/facing-gravity-why-our-tests-need-reality-20jd</link>
      <guid>https://dev.to/david_anyatonwu_c3d0ac6c3/facing-gravity-why-our-tests-need-reality-20jd</guid>
      <description>&lt;p&gt;Gravity does not negotiate with your test doubles. When an application relies on heavy mocking for internal repositories, it is operating on faith rather than physics.&lt;/p&gt;

&lt;p&gt;The symptom is a test suite that passes in CI while the production environment combusts. The root cause is coupling so tight that components cannot exist without their artificial life support systems.&lt;/p&gt;

&lt;p&gt;Reject the mock religion. Embrace integration testing with real, ephemeral databases that test actual constraints, missing indexes, and invalid queries. Fix the coupling, not the mock.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>database</category>
      <category>testing</category>
    </item>
    <item>
      <title>A befitting title</title>
      <dc:creator>David Anyatonwu</dc:creator>
      <pubDate>Wed, 29 Jul 2026 16:30:04 +0000</pubDate>
      <link>https://dev.to/david_anyatonwu_c3d0ac6c3/a-befitting-title-56fj</link>
      <guid>https://dev.to/david_anyatonwu_c3d0ac6c3/a-befitting-title-56fj</guid>
      <description>&lt;p&gt;hello world&lt;/p&gt;

</description>
    </item>
    <item>
      <title>A befitting title</title>
      <dc:creator>David Anyatonwu</dc:creator>
      <pubDate>Mon, 27 Jul 2026 12:43:10 +0000</pubDate>
      <link>https://dev.to/david_anyatonwu_c3d0ac6c3/a-befitting-title-40c9</link>
      <guid>https://dev.to/david_anyatonwu_c3d0ac6c3/a-befitting-title-40c9</guid>
      <description>&lt;p&gt;A befitting body for a post&lt;/p&gt;

</description>
    </item>
    <item>
      <title>A befitting title</title>
      <dc:creator>David Anyatonwu</dc:creator>
      <pubDate>Mon, 27 Jul 2026 11:47:06 +0000</pubDate>
      <link>https://dev.to/david_anyatonwu_c3d0ac6c3/a-befitting-title-4fbj</link>
      <guid>https://dev.to/david_anyatonwu_c3d0ac6c3/a-befitting-title-4fbj</guid>
      <description>&lt;p&gt;Test blog post from Beacon&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Another befitting title</title>
      <dc:creator>David Anyatonwu</dc:creator>
      <pubDate>Fri, 24 Jul 2026 08:00:02 +0000</pubDate>
      <link>https://dev.to/david_anyatonwu_c3d0ac6c3/another-befitting-title-dl5</link>
      <guid>https://dev.to/david_anyatonwu_c3d0ac6c3/another-befitting-title-dl5</guid>
      <description>&lt;p&gt;&lt;strong&gt;Testing a scheduled post&lt;/strong&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Shalom first DevTo Post</title>
      <dc:creator>David Anyatonwu</dc:creator>
      <pubDate>Thu, 23 Jul 2026 21:46:34 +0000</pubDate>
      <link>https://dev.to/david_anyatonwu_c3d0ac6c3/shalom-first-devto-post-jm6</link>
      <guid>https://dev.to/david_anyatonwu_c3d0ac6c3/shalom-first-devto-post-jm6</guid>
      <description>&lt;p&gt;This post is for Shalom  &lt;/p&gt;

&lt;p&gt;This post was made from David new company named Beacon, the best social media scheduling platform inn the world&lt;/p&gt;

</description>
    </item>
    <item>
      <title>A befitting title</title>
      <dc:creator>David Anyatonwu</dc:creator>
      <pubDate>Thu, 23 Jul 2026 20:20:42 +0000</pubDate>
      <link>https://dev.to/david_anyatonwu_c3d0ac6c3/a-befitting-title-464c</link>
      <guid>https://dev.to/david_anyatonwu_c3d0ac6c3/a-befitting-title-464c</guid>
      <description>&lt;p&gt;This is post will be made to both devto accounts. Hopefully&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Another befitting title</title>
      <dc:creator>David Anyatonwu</dc:creator>
      <pubDate>Thu, 23 Jul 2026 20:00:05 +0000</pubDate>
      <link>https://dev.to/david_anyatonwu_c3d0ac6c3/another-befitting-title-24le</link>
      <guid>https://dev.to/david_anyatonwu_c3d0ac6c3/another-befitting-title-24le</guid>
      <description>&lt;p&gt;&lt;strong&gt;Testing a scheduled post&lt;/strong&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>A befitting title</title>
      <dc:creator>David Anyatonwu</dc:creator>
      <pubDate>Thu, 23 Jul 2026 19:44:59 +0000</pubDate>
      <link>https://dev.to/david_anyatonwu_c3d0ac6c3/a-befitting-title-28mo</link>
      <guid>https://dev.to/david_anyatonwu_c3d0ac6c3/a-befitting-title-28mo</guid>
      <description>&lt;p&gt;Testing posting to devto&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
