<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ian Mihura on Medium]]></title>
        <description><![CDATA[Stories by Ian Mihura on Medium]]></description>
        <link>https://medium.com/@mihura.ian?source=rss-76219292d027------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*PRpBVzQj-TUfXAOoPPVU2Q.jpeg</url>
            <title>Stories by Ian Mihura on Medium</title>
            <link>https://medium.com/@mihura.ian?source=rss-76219292d027------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 21:34:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mihura.ian/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Keeping Clean Data in the CPU and Disk]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://levelup.gitconnected.com/keeping-clean-data-in-the-cpu-and-disk-0126c4187c55?source=rss-76219292d027------2"><img src="https://cdn-images-1.medium.com/max/600/1*WpRG9jsMiya5HDvZxVPREg.png" width="600"></a></p><p class="medium-feed-snippet">&#x201C;Data dominates. (...) Data structures, not algorithms, are central to programming&#x201D;&#x200A;&#x2014;&#x200A;Rob Pike</p><p class="medium-feed-link"><a href="https://levelup.gitconnected.com/keeping-clean-data-in-the-cpu-and-disk-0126c4187c55?source=rss-76219292d027------2">Continue reading on Level Up Coding »</a></p></div>]]></description>
            <link>https://levelup.gitconnected.com/keeping-clean-data-in-the-cpu-and-disk-0126c4187c55?source=rss-76219292d027------2</link>
            <guid isPermaLink="false">https://medium.com/p/0126c4187c55</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Ian Mihura]]></dc:creator>
            <pubDate>Mon, 20 Apr 2026 16:06:25 GMT</pubDate>
            <atom:updated>2026-04-20T16:06:25.074Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How to make Javascript Blazingly Fast]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://levelup.gitconnected.com/how-to-make-javascript-blazingly-fast-7ac833ca8791?source=rss-76219292d027------2"><img src="https://cdn-images-1.medium.com/max/604/1*ZxscVu0UFvECNATEtiD7kg.png" width="604"></a></p><p class="medium-feed-snippet">Javascript is slow. It&#x2019;s interpreted (just-in-time compilation) and it&#x2019;s garbage collected. But we can make it run faster.</p><p class="medium-feed-link"><a href="https://levelup.gitconnected.com/how-to-make-javascript-blazingly-fast-7ac833ca8791?source=rss-76219292d027------2">Continue reading on Level Up Coding »</a></p></div>]]></description>
            <link>https://levelup.gitconnected.com/how-to-make-javascript-blazingly-fast-7ac833ca8791?source=rss-76219292d027------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ac833ca8791</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[high-performance]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Ian Mihura]]></dc:creator>
            <pubDate>Mon, 30 Mar 2026 20:32:05 GMT</pubDate>
            <atom:updated>2026-03-31T13:13:47.886Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[CPU-Driven Circular Buffer]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://levelup.gitconnected.com/cpu-driven-circular-buffer-7bc0cfe29cc3?source=rss-76219292d027------2"><img src="https://cdn-images-1.medium.com/max/1198/1*PPq4h-QuebBAuSJJxLPJnQ.png" width="1198"></a></p><p class="medium-feed-snippet">Did you know that you can delegate the wrap-around logic of a circular buffer to the hardware?</p><p class="medium-feed-link"><a href="https://levelup.gitconnected.com/cpu-driven-circular-buffer-7bc0cfe29cc3?source=rss-76219292d027------2">Continue reading on Level Up Coding »</a></p></div>]]></description>
            <link>https://levelup.gitconnected.com/cpu-driven-circular-buffer-7bc0cfe29cc3?source=rss-76219292d027------2</link>
            <guid isPermaLink="false">https://medium.com/p/7bc0cfe29cc3</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[performance-optimization]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Ian Mihura]]></dc:creator>
            <pubDate>Mon, 23 Feb 2026 17:35:04 GMT</pubDate>
            <atom:updated>2026-02-23T17:35:04.343Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Practical SBE Parsing for Financial Data in Go]]></title>
            <link>https://medium.com/@mihura.ian/practical-sbe-parsing-for-financial-data-in-go-56196100e3eb?source=rss-76219292d027------2</link>
            <guid isPermaLink="false">https://medium.com/p/56196100e3eb</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[quantitative-finance]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Ian Mihura]]></dc:creator>
            <pubDate>Thu, 29 Jan 2026 12:44:27 GMT</pubDate>
            <atom:updated>2026-01-29T12:44:27.787Z</atom:updated>
            <content:encoded><![CDATA[<h3>SBE Parsing for Financial Data Feed in Go</h3><p>See how to setup a multicast client in Part I:</p><p><a href="https://medium.com/@mihura.ian/sbe-multicast-config-discovery-tutorial-ish-d9f40ff7def2">SBE Multicast Config Discovery [tutorial-ish]</a></p><p>With the network layer established, we turn to the SBE parser.</p><p>Deribit provides SBE (Simple Binary Encoding) XML schemas, and an integration with this library <a href="https://github.com/aeron-io/simple-binary-encoding">https://github.com/aeron-io/simple-binary-encoding</a> to generate template code in many languages.</p><p>In theory, this saves time, but the generated code is not great (I can speak only of my experience in Golang). I spent too much time battling against it, until I decided to ditch the autogenerated codecs and build them from scratch.</p><h3>Auto-generated Code Flaws</h3><p>The codecs are incomplete and inefficient. I can list the main issues I found with them:</p><ul><li>Errors: In Go, exported objects must be Capitalized. All enums are not capitalized, making the app unable to compile.</li><li>VarString and NestedField: Everything related to Variable Length fields and nested fields is incomplete.</li><li>Missing Framing Headers: The XML defines the packet length, channel ID, and sequence numbers. However, the generated code neglects this header. This is a major problem: the codecs will never line up with the buffer if these fields are not considered.</li><li>Decoding the Message Header: The Decode function requires parameters (such as schema version and package length) that are only available after the header itself is decoded.</li><li>Poor Interface Design: Useful interfaces for objects that implement Encode, Decode, and RangeCheck are missing.</li><li>Inefficiencies: The SbeMarshalling logic is not efficient at all: trying to be atomic it calls <strong>i/o</strong> for every field, it uses 2 buffers (reallocating every field to a “workbench” buffer), and it re-implements encode/decode logic perfectly present in Go’s stdandard lib.</li><li>Too May Checks: SbeMarshalling also relies on RangeCheck in every Encode/Decode, validating length and schema version. This is unrealistic for production code, where you’ll probably have a different service verifying the version changes. This decision also bloats the Encode/Decode function signatures.</li></ul><p>Now, let me not be unfair. This code-gen tool is an <strong>outstanding</strong> <strong>open source project</strong> that generates code in many languages. As everywhere in open source, the unpaid devs are doing what they can. But, unfortunately, the code is insufficient for our purpose.</p><h3>The Strengths</h3><p>While the generated code lacks polish, it’s a good blueprint. I was able to build the codecs from scratch after digging deep into the auto-generated ones.</p><ul><li>The Spec: The SBE XML schema is the source of truth, but reading raw XML is tedious. The Go files provide a readable translation of the schema, a clear map of complex types and bitmasks to Go primitives.</li><li>Fast Bootstrapping: The generated code is technically correct. If your immediate goal is to verify that you are receiving data from the exchange, the codecs are a “plug-and-play” solution.</li></ul><h3>A Better Way</h3><p>As always with pet projects, commit to building it from stdandard lib is the best approach. Considerations:</p><ul><li>Use Standard Library’s <strong>encoding/binary</strong> functions.</li><li>We can ignore Encode for now, as we’re only parsing input data.</li><li>Define a custom Coder object to manage the <strong>single buffer</strong>.</li><li>Remove all i/o operations from the Decoder.</li><li>Implement a standard interface that all objects must follow.</li></ul><p>The decoding base should be no more convoluted than this:</p><pre>import (<br> &quot;encoding/binary&quot;<br> &quot;encoding/hex&quot;<br> &quot;fmt&quot;<br> &quot;log&quot;<br>)<br><br>// Decoder struct, inspired by encoding/binary:coder.<br>type Coder struct {<br> order binary.ByteOrder // LittleEndian<br> buff  []byte           // buffer - store the full frame<br> off   int              // offset<br>}<br><br>// Decodes binary data from c.buff starting at c.off, into data according to c.order<br>// It quits if buf is too small, dumping useful data to stdout.<br>// The type of `data` will specify how many bytes to read from buffer. <br>func (c *Coder) Decode(data any) {<br> // We deletage the decoding to the standard library.<br> n, err := binary.Decode(c.buff[c.off:], c.order, data)<br> if err != nil {<br>  // if buff is too small, we probably messed up the message type<br>  log.Printf(&quot;%p:%d | %d len(%d)\n&quot;, &amp;c.buff, c.off, n, len(c.buff))<br>  log.Println(hex.Dump(c.buff))<br>  log.Fatal(&quot;error in decode: &quot;, err) // halts execution<br> }<br> c.off += n<br>}<br><br>// Every message type (objects) implement this interface<br>// so we can work with a generic messageObject<br>type StdMessage interface {<br> Decode(c *Coder)   // Decodes with binary.Decode<br> PPrint(indent int) // Pretty Print<br>}</pre><p>Message structs will not change much. In this implementation, the Decode function will delegate the work to the Coder:</p><pre>// Message Header<br>func (m *MessageHeader) Decode(c *Coder) {<br> // Decode function moves the offset of the coder, so order matters<br> c.Decode(&amp;m.BlockLength)<br> c.Decode(&amp;m.TemplateId)<br> c.Decode(&amp;m.SchemaId)<br> c.Decode(&amp;m.Version)<br> c.Decode(&amp;m.NumGroups)<br> c.Decode(&amp;m.NumVarDataFields)<br>}<br><br>// A concrete message example<br>func (m *Book) Decode(c *Coder) {<br> c.Decode(&amp;m.InstrumentId)<br> c.Decode(&amp;m.TimestampMs)<br> c.Decode(&amp;m.PrevChangeId)<br> c.Decode(&amp;m.ChangeId)<br> c.Decode(&amp;m.IsLast)<br> m.ChangesList.Decode(c) // we further delegate decoding for var-length and nested fields.<br>}</pre><p>To dynamically parse incoming messages, we need to define some sort of switch statement over the MessageHeader.TemplateId:</p><pre>// Returns a concrete StdMessage with the header attached to it<br>func (m *MessageHeader) GetConcreteMessage() (StdMessage, error) {<br> switch m.TemplateId {<br> case 1000:<br>  obj := &amp;Instrument{} // object struct<br>  obj.Header = *m // reference to the header is usefull for var-length and nested fields<br>  return obj, nil<br><br> // ... other objects<br><br> default:<br>  return nil, UnknownTemplateIdError(m.TemplateId)<br>}</pre><h3>All together</h3><p>Bring it all together in the main loop of the parser:</p><pre>func StdParser(data []byte, syncCh chan&lt;- *StdMessage) stdmsg.StdMessage {<br> // Init the new Coder<br> c := stdmsg.NewEmptyCoder()<br> c.SetBuffer(&amp;data) // It handles the buffer, so it needs the data<br><br> // Don&#39;t forget the frame header!<br> frame := stdmsg.FrameHeader{}<br> frame.Decode(c)<br><br> // For every message in the frame, until we get to the expected length<br> for uint16(c.GetOffset()) &lt; frame.PacketLength {<br><br>  // First parse the message header<br>  header := stdmsg.MessageHeader{SequenceNumber: frame.SequenceNumber}<br>  header.Decode(c) // Decode function moves the offset of the coder, so order matters<br><br>  // Then parse the concrete object<br>  msg, err := header.GetConcreteMessage()<br>  if err != nil {<br>   log.Fatal(&quot;error in stdParser:&quot;, err)<br>  }<br>  msg.Decode(c)<br><br>  syncCh &lt;- &amp;msg<br> }<br>}</pre><p>Success! Now we can receive and parse incoming SBE messages.</p><p>Now make it async: try to squeeze max amount of packets per seconds, measure bottlenecks, and have fun. Check the repo with my implementation:</p><h3>Check out the Github</h3><p><a href="https://github.com/ianmihura/sbe-multicast/">GitHub - ianmihura/sbe-multicast: Simple Binary Encode (SBE) parsing app that receives market data packets via multicast and prints them out to stdout.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S1LXZ3zj-8Sn8biSEwFftg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@wildmax?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Massimo Botturi</a> on <a href="https://unsplash.com/photos/electronic-wire-lot-zFYUsLk_50Y?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56196100e3eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SBE Multicast Config Discovery [tutorial-ish]]]></title>
            <link>https://medium.com/@mihura.ian/sbe-multicast-config-discovery-tutorial-ish-d9f40ff7def2?source=rss-76219292d027------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9f40ff7def2</guid>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[quantitative-finance]]></category>
            <dc:creator><![CDATA[Ian Mihura]]></dc:creator>
            <pubDate>Fri, 23 Jan 2026 12:24:46 GMT</pubDate>
            <atom:updated>2026-01-23T12:39:16.791Z</atom:updated>
            <content:encoded><![CDATA[<h3>Multicast Config in Linux [tutorial]</h3><p>Necessary steps and config to setup multicast in your machine. This is <strong>Part I </strong>of building a Simple Binary Encode (SBE) parsing app that receives packets via multicast. Especially useful for FIX market infrastructure.</p><p>We will be using Deribit (a crypto derivatives exchange) as our example. Find the following page with relevant documentation <a href="https://support.deribit.com/hc/en-us/articles/29392445838877-Multicast-Developer-Guide">https://support.deribit.com/hc/en-us/articles/29392445838877-Multicast-Developer-Guide</a>. Language chosen for scripts is Golang.</p><h3>Step 1</h3><p>Learn about multicast.</p><p>We need to listen to multicast messages, so we need to know what this is: something between unicast and broadcast, a server sends the same message efficiently (like a broadcast) but only to machines that are listening.</p><p><strong>BUT: </strong>Multicast works best in private networks because it is optional in IPv4, and some relays will drop this traffic. This is especially true if you (or the provider) is behind NAT gateway.</p><p>If you have more than 5 minutes, I recommend this great article: <a href="https://tldp.org/HOWTO/Multicast-HOWTO-2.html">https://tldp.org/HOWTO/Multicast-HOWTO-2.html</a>.</p><h3>Step 2</h3><p>Define the architecture.</p><p>The best option is emulating traffic locally (unless you want to pay for an AWS instance, or collocate with them in Equinix). Luckily Deribit offers some sample .pcapng captures in their developer quick-start pack, download it for free from <a href="https://support.deribit.com/hc/en-us/articles/29392445838877-Multicast-Developer-Guide">their doc guide</a>.</p><h3>Step 3</h3><p>Ping yourself via multicast.</p><p><strong>socat</strong> is a handy tool to send packets. Get familiar with it, as well as <strong>tcpdump</strong> and <strong>tcpreplay. </strong>In the process you may learn about your machine’s interfaces:</p><pre># What&#39;s your default interface<br>ip route get 224.0.0.1<br><br># Make sure it allows multicast<br>ip link show<br><br># If it does not, turn it on:<br>sudo ip link set &lt;interface_name&gt; multicast on</pre><p>In my case, the default interface is <strong>wlan0</strong>. In your case it may be <strong>eth0</strong>, or you may prefer to do this with <strong>lo</strong> (loopback). Note that if you use a real interface (not <strong>lo</strong>) it must be connected (at least to LAN), otherwise the packets will be dropped.</p><p>You may learn how to sniff packets (useful for debugging):</p><pre>sudo tcpdump -ni wlan0 udp port 6200 -X</pre><p>And successfully ping yourself via multicast:</p><pre># Listen to group 239.222.222.2 on port 6200 with any iface<br>socat -u UDP4-RECVFROM:6200,ip-add-membership=239.222.222.2:0.0.0.0 -<br><br># Send a single packet with a different terminal<br>echo &quot;hello&quot; | socat - UDP4-DATAGRAM:239.222.222.2:6200,ip-multicast-if=0.0.0.0</pre><p>If the above <strong>socat</strong> test did not work, you need to fix some config in your machine. I (use Arch, btw) had to add an explicit bypass in the firewall.</p><pre>sudo ufw allow 6200/udp</pre><p>If it does not work, try flushing (or changing) iptables, try changing sysctl net.ipv4.conf, changing iface, or even a different host. Google is your friend and time is on your side. I know I spent more time than I’m willing to admit here, producing the most unusual errors.</p><h3>Step 4</h3><p>Replaying captures.</p><p>Then you’ll want to replay the pcapng captures with <strong>tcpreplay</strong>, but in the end, that won’t work (spoiler, <strong>tcpreplay</strong> pushes to the network, and does not work if you want to multicast to yourself in the same machine).</p><p>While debugging this, you may try changing some data in the capture (mac address, dest ip, etc)</p><pre>tcprewrite -portmap=6100:6200,37608:49112 -pnat=127.0.0.1:192.168.1.132 -enet-dmac=&lt;mac&gt; -enet-smac=&lt;mac&gt; -fixcsum -infile=./sbe/rfq.pcapng -outfile=./rfq_6200_wlan0.pcapng</pre><p>Or you may want to replay your local traffic</p><pre>sudo tcpdump -i wlan0 -U port 6200 -w sample.pcap</pre><p>But in the end you’ll realize that, unless you have a separate machine (or install a VM) producing the traffic, you can’t multicast to yourself using <strong>tcpreplay</strong>.</p><h3>Step 5</h3><p>Commit to building the tool.</p><p>This is the most important step. You decide that building a basic <strong>tcpreplay</strong> must be simpler than buying another PC or installing a VM.</p><p>I built it using golang, took inspiration from this repo <a href="https://github.com/ruel/pcaplay/blob/master/main.go">https://github.com/ruel/pcaplay/blob/master/main.go</a>, here’s the final PoC</p><pre>import (<br> &quot;github.com/google/gopacket&quot;<br> &quot;github.com/google/gopacket/pcap&quot;<br>)<br><br>// Replays pcap or pcapng content to a given group<br>func ReplayUDP(file string, addr_ string) {<br> handler, err := pcap.OpenOffline(file)<br> if err != nil {<br>  panic(err)<br> }<br> packets := make([]gopacket.Packet, 0)<br> psource := gopacket.NewPacketSource(handler, handler.LinkType())<br> for packet := range psource.Packets() {<br>  packets = append(packets, packet)<br> }<br> addr, err := net.ResolveUDPAddr(&quot;udp4&quot;, addr_)<br> if err != nil {<br>  log.Fatal(err)<br> }<br> conn, err := net.DialUDP(&quot;udp4&quot;, nil, addr)<br> if err != nil {<br>  log.Fatal(err)<br> }<br> defer conn.Close()<br> for _, packet := range packets {<br>  conn.Write(packet.ApplicationLayer().Payload())<br> }<br>}</pre><p>The code fits in one screen, not half bad.</p><p>Unless you’re doing this in raw C, the implementation will more-or-less look as simple.</p><p>Then, if you’re building the full thing in Go, the listener might look something like this:</p><pre>// Listens for incoming multicast messages from an addr, uses handler_ callback<br>func ListenUDP(addr_ string, handler_ func(*net.UDPAddr, int, []byte)) {<br> addr, err := net.ResolveUDPAddr(&quot;udp&quot;, addr_)<br> if err != nil {<br>  log.Fatal(err)<br> }<br><br> if_addr, err := net.InterfaceByName(&quot;wlan0&quot;)<br> if err != nil {<br>  log.Fatal(err)<br> }<br> conn, err := net.ListenMulticastUDP(&quot;udp&quot;, if_addr, addr)<br> if err != nil {<br>  log.Fatal(err)<br> }<br> conn.SetReadBuffer(_8KB)<br> buff := make([]byte, _8KB)<br> log.Println(&quot;Listening on&quot;, if_addr, &quot;from&quot;, addr)<br> for {<br>  nBytes, src, err := conn.ReadFromUDP(buff)<br>  if err != nil {<br>   log.Fatal(&quot;ReadFromUDP failed:&quot;, err)<br>  }<br>  handler_(src, nBytes, buff)<br> }<br>}</pre><p>Calling both from main</p><pre>func main() {<br> addr := &quot;239.222.222.2:6200&quot;<br> file := &quot;./rfq.pcapng&quot;<br><br> go ReplayUDP(file, addr)<br> ListenUDP(addr, Parser)  // You need to define the Parser func<br>}</pre><h3>Success!</h3><p>Now that the Multicast UDP is working, and you can replay FIX packets, the next step is parsing.</p><p>Stay tuned for Part II.</p><h3>Advice I’ll remember next time</h3><ol><li>Read the manuals, and read real people’s articles. People have insight you don’t expect. God knows how many times AI hallucinated theories and nonexistent configs, spinning me off strange tangents.</li><li>Sleep it over. When you’re stuck between configs and articles, and nothing’s working, give it a break and come back fresh tomorrow.</li><li>Build it yourself. Especially if you want to learn. (Usually) No PoC is hard enough that can’t be churned in a few hours.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*NuGojXJtt1akPwvh.png" /><figcaption><a href="https://en.wikipedia.org/wiki/Multicast#/media/File:Multicast.svg">https://en.wikipedia.org/wiki/Multicast#/media/File:Multicast.svg</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9f40ff7def2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Black box programming]]></title>
            <link>https://medium.com/@mihura.ian/black-box-programming-5d09df3ad607?source=rss-76219292d027------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d09df3ad607</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Ian Mihura]]></dc:creator>
            <pubDate>Thu, 27 Mar 2025 18:39:03 GMT</pubDate>
            <atom:updated>2025-03-27T18:39:03.433Z</atom:updated>
            <content:encoded><![CDATA[<p>When I first learnt about “black boxes” in school, studying math, I remember thinking: “what a useless concept. Of course you can treat functions as black boxes. Anything can be a black box! But that explains nothing.” I was under the illusion that the only important part of a function was it’s inner workings.</p><p>While I wasn’t totally wrong, I definitively had the wrong intuition. It took me years until I saw the power of this simple abstraction. Of course anything can be a black box, that’s why it’s a tool so powerful.</p><p>I’d be pressed to name a single concept that changed the way I understand code, but black boxes (and interfaces) would make the short-list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/331/1*3Wa7qX-EjmD4KuZY7bxPxg.png" /></figure><h3>Black boxes</h3><p>Simply put: a black box takes in some input and spits out an output. Any procedure, function or work can be modeled using this abstraction.</p><p>For example, any operand (eg. +) takes input (2, 5) and gives an output (7). The linear formula <em>f(x)=my+c </em>takes an input (<em>x</em>) and gives an output (<em>f(x)</em>). A car takes input (gas, human driving) and gives output (it moves); an oven takes in raw food and gives cooked food; a body takes in food and likewise has outputs. Even people in conversation take input (listen) and give output (talk).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WDrsh4rNYCFcDvQAi0v7Cw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@fakurian?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Milad Fakurian</a> on <a href="https://unsplash.com/photos/white-box-on-white-table-PpgY7sjpf_0?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p>The model seems simple enough: abstract the process into it’s most basic description. Tho simple, this allows us to navigate the world effectively.</p><p>In programming we do the same: once we understand a piece of code, we abstract it behind a description. It’s not something most teachers feel the need to teach because it’s so natural, but here’s a key insight that can boost your coding: <strong>build explicit interfaces</strong>.</p><h3>Many inputs</h3><p>Programmers think that the parameters are the only input of a function, but there’s more. A procedure may have dependencies beside it’s declared parameters, implicit or explicit. For example, to make a car work we have to turn the key and push the pedals, but there’s dependencies like gas, the roads and (to some extent) the divers’ license.</p><p>Black boxes expect the world to exist in a certain state before they work. For example, in low-level coding we can’t “pass parameters”, so we use ABIs: these are contracts that tell programmers how to set registers (the context) with expected values.</p><p>In OOP, to use a class we need to initialize it (with some parameters) and then execute it (with other parameters). We could argue that these are two different black boxes, but the single black box (that’s the class) is also made up of black boxes. It’s black boxes all the way down.</p><pre>// Two calls to use one black box:<br><br>// Parameters related to content<br>User newUser = User(&quot;Bobby&quot;, 45, &quot;Spain&quot;);<br><br>// Parameters related to file format<br>newUser.save_as_csv(&quot;;&quot;, &quot;\r\n&quot;);</pre><h3>Many outputs</h3><p>In a function, the “return” is the explicit output, but there’s more. A procedure can raise or throw an exception, and this must be handled, at times implicitly. A procedure can also have side-effects: updating data outside it’s scope. Here again, the context of the procedure forms part of the output.</p><h3>All together now</h3><p>Of course it’s simpler to declare everything in one place. Juggling dependencies and implicit error types isn’t fun.</p><p>There are some efforts to set standards to this regard: in functional programming-land there’s pure functions, in normal coding there’s APIs and stateless services.</p><p>We can call the efforts to group inputs and outputs together, <strong>Interfaces</strong>. For example a function signature, or a control panel. These standards allow us to communicate concisely and explicitly the input-output of the black box. They’re necessary contracts, but not exhaustive.</p><p>Building powerful mental models requires us to know the full mapping of inputs and outputs, therefore explicit is better.</p><pre>int sum(int a, int b);</pre><h3>Build explicit Interfaces</h3><p>As Python’s <a href="https://peps.python.org/pep-0020/">PEP 20 states</a>:</p><blockquote>Explicit is better than implicit</blockquote><p>Explicit interfaces are more predictable and they document themselves, that means, they explain all that they do, without hiding things. Keeping interfaces explicit helps avoid many abstractions problems (eg. leaky abstractions and unhandled errors).</p><p>Proper naming and in-code documentation are also part of interfaces. I once found a function signature like this one.</p><pre>int sum(float a, float b);  // ??? ceil? floor? round?</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d09df3ad607" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Observability of complex systems]]></title>
            <link>https://medium.com/@mihura.ian/observability-of-complex-systems-ef096c6f063e?source=rss-76219292d027------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef096c6f063e</guid>
            <category><![CDATA[observability]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[debugging]]></category>
            <dc:creator><![CDATA[Ian Mihura]]></dc:creator>
            <pubDate>Wed, 12 Feb 2025 17:05:35 GMT</pubDate>
            <atom:updated>2025-02-12T17:05:35.390Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*no1uu9ePgBXmreGJn0RiMg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@skradi?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Sandro Kradolfer</a> on <a href="https://unsplash.com/photos/man-holding-black-binoculars-IVYZWptFt1g?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p>I first thought observability was information, raw information, accumulating data as much as I could. I thought the hard part of observability was getting the data out from the system into one place. I thought, “then I’ll be able to observe what’s happening.”</p><p>While this is not awfully wrong, I was missing the point, and not tackling the most difficult problem. My approach was running into problems:</p><ol><li>There was a limit to what I could practically save, especially with big systems. Most information just sat there, unused, while I was running out of space.</li><li>I was jumping hoops to accumulate information I didn’t necessarily need, which was quite demotivating, considering I was not really paid to develop internal observability tools.</li><li>When issues appeared in the system, I found myself doing a lot of digging in my own data. I was pushing the real work for when I needed the information!</li></ol><p>I had to re-think my approach to error tracing, so I went back to basics.</p><h3>The stack trace</h3><p>When a program fails, we get a print of the last function calls executed at the moment of failure. This is one of the (if not <em>the</em>) most useful tools for observability. Anyone in software has seen one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NbelmVUkbOVoov3h.png" /><figcaption><a href="https://developer.android.com/studio/debug/stacktraces">https://developer.android.com/studio/debug/stacktraces</a> — A stack trace is the report of the function calls (or any active stack frame) when an error happens (or any point in time).</figcaption></figure><p>When running a program we can print out every function call, we can log the ongoing stack trace, but for what? If there’s an error we then have to parse the logs for what’s really useful (<strong>tail -f</strong> if we’re lucky).</p><p>Or we can just get the relevant trace on the first try. And here lies the utility of the stack trace: we (generally) get no more than what we need. To replicate what the trace is doing we must:</p><ol><li>Make the original, raw information available (the ongoing stack trace, which the program has as it’s running).</li><li>Instantiate a useful parser/display (the current stack window is trivial to filter for. Then, every language will display the information differently).</li></ol><p>I saw what I was missing: I was doing step 1 and missed step 2! At time of error, quality, not quantity (of data/signals), matters most.</p><h3>Some examples of the rule</h3><ol><li>Save every API request in a JSON.</li><li>Create an automated script with <strong>jq</strong> to crunch the logs (given you’ll eventually use <strong>jq</strong> to visualize the JSON anyway).</li></ol><p>There’s no observability without an observability parser. This requires us to think beforehand where the relevant information will lie.</p><ol><li>Log every requests from your microservices to a central debugging database.</li><li>Make a dashboards with filters, groupings, aggregators in Graphana/Prometeus.</li></ol><p>As back-end developers, we miss the most crucial part of the process: displaying information, because we think it’s trivial. We forget: it’s ultimately a human doing the observation.</p><ol><li>Make our product for the end user (we save the application state in our DB as raw data)</li><li>Build a back-office platform (leverage the non technical product owners to screen the information the user sees).</li></ol><p>Make observability tools for others. We leverage the team to solve issues on domain specific aspects of the system.</p><h3>Summary of the rule</h3><p>Step 1 is straight forward, while technically hard at times. Step 2 requires a bit more contextual thinking, and user negotiation, especially if the user doing the final debugging is not you.</p><p>Step 2 is about what you don’t listen to. Noise is the enemy of observability, as fog is the enemy of a lookout. You want to minimize false signals, to pinpoint what’s up. Show only useful information, the person debugging will have the domain specific context.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*xykejCN2ODRDbH26" /><figcaption><a href="https://www.reddit.com/r/funny/comments/1qzgfq/my_buddy_dadproofing_his_remotes/">https://www.reddit.com/r/funny/comments/1qzgfq/my_buddy_dadproofing_his_remotes/</a></figcaption></figure><p>Imagine you’re a doctor attending a patient in a critical state. You want to know what’s going on: your observability then is literally your eyes, maybe some instruments, or the patient themself if they can still speak clearly.<br>What questions you ask is as important as what you don’t ask. To narrow down the space of possibility you have to remove signals.</p><p>We observe to keep a tap on things as they happen, for any kind of engineer, less surprises means a happier life (at least in our work life!).</p><p>Imagine you’re the president of a country that’s being invaded. You wouldn’t want to be plugged to the news, answering every phone call, trying to absorb every piece of news. You’d be better off isolating yourself from noise, inviting only key people into a “war room” and oversee operations from afar.</p><p>Leaders in every domain take the practice of distancing themselves to get a bird-eye view, to reduce noise and parse good signals from the bad.</p><h3>TL;DR</h3><p>Observability is the capacity to measure. I didn’t <em>have to</em> record everything, rather be able to know what matters, because at the end of the day, when shit hits the fan, I was scrambling to have useful tools, with simple interfaces and clear CTA (call to action).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef096c6f063e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A.I. will give you a job]]></title>
            <link>https://medium.com/illumination/a-i-will-give-you-a-job-2a14f564f211?source=rss-76219292d027------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a14f564f211</guid>
            <category><![CDATA[future]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[business]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Ian Mihura]]></dc:creator>
            <pubDate>Sun, 28 Jul 2024 22:08:34 GMT</pubDate>
            <atom:updated>2024-07-28T22:08:34.150Z</atom:updated>
            <content:encoded><![CDATA[<h3>A.I. Will Give You A Job</h3><p><a href="https://www.youtube.com/watch?v=7d-W26mqajg">Some videos</a> have been making the rounds recently, and I thought I’d contribute my two cents to the piggy. I have <a href="https://medium.com/illumination/no-a-i-wont-steal-your-job-2d068dd5c128">written about AI</a> in the past, and I wanted to give my opinion a further spin: not only will AI <strong><em>not</em></strong> steal your job, it make you <strong><em>multiply</em></strong> your potential jobs.</p><h3>AI will multiply the jobs</h3><p>How many companies do you think are trying to shove AI into their operations? Maybe an easier question: how many companies do you think are <strong><em>not</em></strong> trying to shove AI into their operations? And how many do you think are successful? <a href="https://ludic.mataroa.blog/blog/i-will-fucking-piledrive-you-if-you-mention-ai-again/#iii-weve-already-seen-extensive-gains-from-">Do you really think that 34% of companies are making strategic decisions based on AI</a>?</p><p>Odds are, the company you work at spends too much energy and money in R&amp;D something they shouldn’t be R&amp;D-ing, either because they don’t have the scale, the manpower or simply have nothing to find. Most will be diverting energy away from developing the solutions that actually matter to them, chasing ghosts that some podcast, panel or info-graph told them.</p><blockquote><em>“Back when phones first started to have touch screens, mobile apps </em><strong><em>the future</em></strong><em>, right?</em></blockquote><p>Certainly yes. The future, not the present. But, would you have developed a mobile app back then? Imagine spending hundreds of thousands on a Java applet for Nokia or Alcatel in 2009, just to be “ahead of the curve”. Ouch. Or imagine buying the first ethanol-fueled cars back in the 1990s to be “ahead of the curve”. Not a great investment.</p><p>Let’s put it another way: what makes a greater difference today to your run-of-the-mill pizzeria: having its own mobile app or having good reviews on Yelp, TheFork, and Maps? Yet, what do you think hyped pizzerias were investing in during the 2000s? I tell you what hyped pizzerias were not investing in: tomatoes and cheese.</p><p>People make terrible decisions when FOMO hits in, and companies are just people. Ok, but how will AI multiply jobs in the market? How can we not follow prey to the hype cycle, the FOMO?</p><h3>During a gold rush, sell shovels</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ru4RUt1Cz554yjWxiruCTQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@nel_ranoko?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Nel Ranoko</a> on <a href="https://unsplash.com/photos/person-holding-yellow-and-green-gardening-shovel-c23Lv2fzEyo?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p>Sell shovels! Easy, right? Well, only if we understand what “shovels” mean now, in the age of AI (hint: it’s not prompt engineering). Option 1: naturally, be Nvidia and sell hardware. That’s shovels enough for AI. But not everyone can be a hardware manufacturer (not early Nvidia investor), what’s option 2? Be the cleanup crew.</p><p>Of all the companies that are currently giving AI an honest-to-God’s try, how many will over-invest, over-implement, and over-trust these systems? And how many will make horrible mistakes, compromising their operations, data, reputation or even their existence? And when they do, who ya gonna call? 👻</p><p>Be the cleanup crew, be the guy or gal they call when the fad’s over, the bubble pops and everyone’s scrambling about figuring out why they’re paying five figures fees to OpenAI. But don’t try to be the “data scientist” if you’re not a data scientist now, rather: be the lawyer they’ll need to fix the stupid contracts AI wrote, be the copy editor that’ll need to fix the brand personality that got trashed because AI took over the social media, be the designer that’ll do the rebranding after nobody knows what the company’s about anymore, for crying out loud, be the taxi driver that actually knows the best route after AI’s taken over Maps and can’t stop hallucinating ‘alternative routes’. Selling shovels has never been easier.</p><p>And even when industries panic, professionals will be scarce because we will have spent our last years de-professionalizing and despairing on the gloomy future, instead of teaching and becoming better experts. As always, practice makes perfect, we’re not saying simply “be better”, but keep at it, now more than ever the ones that keep at it long enough will surface and be thanked, for they will have not followed the fad.</p><p>When investing, the ones that short the bubble are not only better positioned to reap the burst, but also make the bubble ever so slightly less catastrophic. So now too, those who invest in their careers will reap the benefits when the AI bubble bursts, in addition to helping the whole industry recover faster. So yeah, short the AI bubble by becoming a better professional. 📈</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a14f564f211" width="1" height="1" alt=""><hr><p><a href="https://medium.com/illumination/a-i-will-give-you-a-job-2a14f564f211">A.I. will give you a job</a> was originally published in <a href="https://medium.com/illumination">ILLUMINATION</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Have you tried restarting your computer?]]></title>
            <link>https://medium.com/@mihura.ian/have-you-tried-restarting-your-computer-464c82b12a46?source=rss-76219292d027------2</link>
            <guid isPermaLink="false">https://medium.com/p/464c82b12a46</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Ian Mihura]]></dc:creator>
            <pubDate>Wed, 15 May 2024 20:04:17 GMT</pubDate>
            <atom:updated>2024-05-15T20:25:05.377Z</atom:updated>
            <content:encoded><![CDATA[<h3>The <em>Tech Touch</em></h3><blockquote>“I’m trying to click the button, but it doesn’t work.”<br>“Refresh the page and try again.”<br>“I tried it already. Can you give it a look?”<br>I walk over to the user, refresh the page and alas, the button works.<br>“I swear I did the same thing!”<br>“I guess it’s the <em>tech touch</em>.”</blockquote><p>No, I don’t know what I did. And yes, I do believe you restarted the page as I said. The thing is, I might have the <em>tech touch</em>.</p><h3>Some people just have it</h3><p>And some people don’t. It’s not something you can fake, but it’s not something you’re born with, either. It’s strictly something you practice.</p><p>You can learn it, but you gotta hone it. <em>What</em> you learn is not as important as <em>how much time and effort</em> you dedicate. Actually, don’t learn: practice, with real environments, and shoot yourself in the foot.</p><p>OK, but really, what should you learn if you wanna have the <em>tech touch</em>? Everything. At least enough to be able to ask the right questions. Best thing I can say is: be a Jack of all trades.</p><p>But don’t try to cover too much too soon, or you’ll muddy yourself up. Don’t do as you did in high school to memorize formulas, try to learn intuition, build a mental model and <em>think as a computer:</em> before knowing how to fix something you gotta know what is broken, and to know what is broken you need to discern if something is broken. Learn how to see broken things, be keen and pay attention.</p><h3>Go deep</h3><p>Paradoxically, if you want to learn a swath of things, just pick one project and <strong>dive deep</strong>. Grab a thing you always felt curious about, webRTC, compilers, blockchain, signals, concurrency, torrent protocol, shaders, assembly langs, anything. Do it and find roadblocks. After enough of those you’ll probably be more comfortable navigating around your computer.</p><p>The <em>tech touch</em> is something that arises once you have enough comfort and experience.</p><h3>It’s just like magic</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*yJ01TDgboCcpFlqvIcXd0w.jpeg" /><figcaption><a href="https://fineartamerica.com/featured/1960s-magician-wearing-black-tuxedo-vintage-images.html">https://fineartamerica.com/featured/1960s-magician-wearing-black-tuxedo-vintage-images.html</a></figcaption></figure><p>Some people say the <em>tech touch </em>is just like magic. It feels like magic to the uninitiated, but we know it’s not magic, just like a magician knows their tricks are not magic!</p><p>But I think the<em> tech touch</em> is kinda magical. When does the magic appear? Any good magician was once an apprentice, and to become a good magician, he must have practiced. Unbeknownst to him, that’s when the real magic started to happen. A good magician doesn’t invent (or bend) laws of physics, he just gets good at them. He becomes an expert.</p><p>Then can he make you believe in magic, only after he believes it himself. He then knows how to do the trick, he can do the trick, but most of all, he has practiced the trick.</p><p>The magician is not a machine, his trick is not a strict program: he’s actually so good at it that he feels comfortable exploring. Sometimes he moves his hand a bit further out, sometimes he uses his other pocket, sometimes he changes the order of things, enough so that if something goes wrong, the trick does not fail.</p><p>Computers are usually hard problems, even when they work correctly. Knowing your way around them is like inhabiting all the magic tricks, while some of them are failing.</p><h3>Pay attention</h3><blockquote>“I cannot send the email to the client!”</blockquote><p>Where can I start debuging this? From the button that the user clicks to the SMTP server, there’s more than a dozen things that can fail.</p><p>Sometimes we have no better option than to just follow the trail, try to find logs or replay the incident on our side. But if you know your way around, you’ll find the solution faster. Having the <em>tech touch</em> is all about being able to find the solution faster (or even, which is truly magical: being able to pinpoint exactly where the problem is without looking at the system).</p><p>Well, you need to know yourself around first. This means time spend nosing around, walk the walk. But then, experience is not all, you also have to be paying attention, because you’re looking for something.</p><p>Did this happen before? Who is reporting the issue? Did I see any error notification right before or after the issue was reported? What are my colleges working on? What piece of the workflow was changed recently?</p><p>Seeing how the user interacts with it can give you a million clues: what explorer are they using? Is there anything peculiar about their workflow? How many of these do they do a day? When’s the last time they logged in the app, or restarted the machine? Might they be running an old version? Ask precise questions.</p><p>And all the while, <strong>pay attention</strong>: many times I spotted the solution out of the corner of my eye.</p><h3>Try stuff out</h3><p>Back to the first example: I truly believe the user restarted the thing as I said, but I may mean many things by <em>restart</em>: closing the tab, closing the explorer, erasing cookies. Apps and computers are state machines, refreshing them once is not the same as refreshing them 20 times, which is definitively not the same as deleting cache, restarting your PC, reinstalling, or even taking the battery out of the motherboard.</p><h3>How to copy and paste</h3><p>A note to those of us who have the <em>tech touch</em>, be patient with the uninitiated. People do not live plugged-in as we might, and we take for granted things that are definitively not obvious. I’ll close this with a short story.</p><p>While I was working as customer support, I received the strangest call: “I cannot copy and past a text.” I went over to the user and told him to show me what he was doing. He began his demonstration:</p><p>“Well, I select the text and click control+c, just like you guys told me to. Then I unplug the mouse,” he effectively unplugged the mouse, “And very carefully take it to my other computer, I plug it in, and, see! I cannot paste it here!”</p><p>“Well,” I said to myself, “Maybe there’s a good idea for a startup right there.”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=464c82b12a46" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Don’t Test too much]]></title>
            <link>https://medium.com/@mihura.ian/dont-test-too-much-90a3ecbea80f?source=rss-76219292d027------2</link>
            <guid isPermaLink="false">https://medium.com/p/90a3ecbea80f</guid>
            <category><![CDATA[code]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[business]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[tdd]]></category>
            <dc:creator><![CDATA[Ian Mihura]]></dc:creator>
            <pubDate>Wed, 08 May 2024 21:11:05 GMT</pubDate>
            <atom:updated>2024-05-08T21:11:05.632Z</atom:updated>
            <content:encoded><![CDATA[<p>Over-testing exists, let’s not delude ourselves, and it does not have to do with laziness or rookie-ness.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qFYiBfIkPbmHTYLaiCrYKQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@jstrippa?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">James Harrison</a> on <a href="https://unsplash.com/photos/black-laptop-computer-turned-on-on-table-vpOeXr5wmR4?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><h3>Cost-benefit</h3><p>Everything in engineering implies a cost-benefit balance. So <strong>tests also imply a</strong> <strong>cost</strong> we assume for a future benefit. The cost of time and energy invested in writing the test (and the time that will be invested in maintaining it), and the benefit of a faster development and debugging and better issue detection.</p><p><strong>Right test coverage is a balance</strong> between time spent and value added, considering also the criticality of the feature being tested, and the chance that the test will catch a relevant bug.</p><h3>Features are assets, code is liability</h3><p>So the old saying goes. As engineers we aim at producing value: if we want our tools to be used we make <strong>features</strong>, this is what the user cares and pays for, it’s the asset they buy.</p><p>On the other hand we write code that needs to be maintained, like an infrastructure that supports our features. Every line of code is like a liability, or future debt, that enables the features.</p><h3>Don’t let tests become liabilities</h3><p>Tests are great, they help us automate feature verification (something we should otherwise have to do manually), they help us develop fast and confidently, and at times they document behavior.</p><p><strong>But tests bring no new features to the user</strong>, thus they are kind-of liabilities.</p><p>Well, tests might not bring features to the user, but they can bring features to the developer. In this sense they are like a tool, and tools are assets. But they bring no new features to the user, and a one must keep this top-of-mind.</p><p>There’s no rule that says when tests become liabilities, other than “when they’re no longer useful”. This is a judgement that each programmer must make on the spot. But it is a valid judgement, and one we should be doing more.</p><h3>Tests are not like brakes on a car</h3><p>(So the metaphor goes: brakes on a car slow you down, but allow you to drive faster).</p><p>This is a weird metaphor. Brakes are features of the car, for the user, tests are not. Brakes are not a compromise, we don’t go slower now to go faster later. Brakes exist to go slower and that’s all, there is no investment in the future, beside keeping yourself alive.</p><p>At most tests are a brake in your deployment pipeline, as they slow down, or stop, delivery. Though I wouldn’t say this metaphor works as it is usually meant (to encourage TDD).</p><h3>Bottom line: tests make you code quicker?</h3><p>We have been taught, by what now seem like a Gang of Fanatics, that we should code everything, write our tests before we write our code (TDD) and aim at covering 100% of your code base. As if all code deserved to be tested!</p><p>They say that this will make us code quicker in the long run. Well, that is, <em>if </em>we write the correct tests.</p><p>Anyway, I think this argument misses the point. <strong>Testing the right amount is not about coding quicker, it’s about who’s paying for your code</strong>, what’s relevant for you to be doing, and how important it is that the code does not fail in said way. Great engineering considers cost and functionality first. We don’t have infinite time to re-write everything every time specs change, so be considerate with your company’s time.</p><p>P.S. if you ever feel compelled to fight someone else on how they structure their workflow, take a minute to touch some grass first.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90a3ecbea80f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>