<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Joep Schuurkes (Posts about counterstring)</title><link>https://smallsheds.garden/</link><description></description><atom:link href="https://smallsheds.garden/categories/counterstring.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2026 &lt;a href="mailto:site@joep.slmail.me"&gt;Joep Schuurkes&lt;/a&gt; 
&lt;a href="https://creativecommons.org/licenses/by-sa/4.0/" rel="nofollow" target="_blank"&gt;
&lt;img alt="Creative Commons BY-SA License" style="border-width:0;margin: 0px 0px 4px 0px;" src="https://licensebuttons.net/l/by-sa/4.0/80x15.png" /&gt;
&lt;/a&gt;
</copyright><lastBuildDate>Sun, 04 Oct 2026 11:27:22 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Benchmarking counterstring implementations in TypeScript</title><link>https://smallsheds.garden/blog/2025/benchmarking-counterstring-implementations-in-typescript/</link><dc:creator>Joep Schuurkes</dc:creator><description>&lt;div&gt;&lt;p&gt;Earlier this year I posted about how I &lt;a href="https://smallsheds.garden/blog/2025/using-fake-it-till-you-make-it-to-implement-counterstring/"&gt;implemented a counterstring function&lt;/a&gt; using "fake it till you make it". I also posted about &lt;a href="https://smallsheds.garden/blog/2025/comparing-counterstring-implementations-in-typescript/"&gt;different ways&lt;/a&gt; to implement counterstrings. In this post, I want to share how those different implementations compare performance-wise.&lt;/p&gt;
&lt;p&gt;To do this, I used both &lt;a href="https://github.com/tinylibs/tinybench"&gt;Tinybench&lt;/a&gt; and &lt;a href="https://vitest.dev/guide/features.html#benchmarking"&gt;vitest bench&lt;/a&gt; (which uses Tinybench). The results are basically the same, but their default output is slightly different.&lt;/p&gt;
&lt;h2&gt;The nine implementations&lt;/h2&gt;
&lt;p&gt;Before I present the results, I should describe the different implementations and how they differ from each other. The &lt;a href="https://codeberg.org/joeposaurus/counterstring/src/commit/04883b7bb2f3e99f7be81ffa58e4ac5f934d276b/src/alt-counterstrings.ts"&gt;actual code of each implementation&lt;/a&gt; is available on Codeberg. Here I'll only mention what makes each implementation interesting compared to the others:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://smallsheds.garden/blog/2025/benchmarking-counterstring-implementations-in-typescript/"&gt;Read more…&lt;/a&gt; (8 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>counterstring</category><category>programming</category><guid>https://smallsheds.garden/blog/2025/benchmarking-counterstring-implementations-in-typescript/</guid><pubDate>Sat, 22 Feb 2025 23:00:00 GMT</pubDate></item><item><title>Comparing counterstring implementations in TypeScript</title><link>https://smallsheds.garden/blog/2025/comparing-counterstring-implementations-in-typescript/</link><dc:creator>Joep Schuurkes</dc:creator><description>&lt;div&gt;&lt;p&gt;In my previous post &lt;a href="https://smallsheds.garden/blog/2025/using-fake-it-till-you-make-it-to-implement-counterstring/"&gt;"Using 'fake it till you make it' to implement counterstring"&lt;/a&gt; I mentioned the implementation I included there, wasn't my initial implementation:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I did something less performant with reversing an array, because I had looked at PerlClips's source code. How that came about and what I learned from it, is for another blog post.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is that blog post.&lt;/p&gt;
&lt;p&gt;As a matter of fact, I currently have &lt;a href="https://codeberg.org/joeposaurus/counterstring/src/commit/04883b7bb2f3e99f7be81ffa58e4ac5f934d276b/src/alt-counterstrings.ts"&gt;9 different implementations&lt;/a&gt; of counterstring in TypeScript. Including two that are not mine: one is from &lt;a href="https://www.satisfice.com/download/perlclip"&gt;PerClip&lt;/a&gt; but translated to TypeScript by me, the other is &lt;a href="https://www.eviltester.com/blog/eviltester/chrome-extensions/2019-02-19-counterstring-snippets/#counterstring-generation-function"&gt;EvilTester's implementation&lt;/a&gt;. There are some interesting lessons to take, both from comparing the code of the different implementations, as from comparing the differences in performance. The &lt;a href="https://smallsheds.garden/blog/2025/benchmarking-counterstring-implementations-in-typescript/"&gt;performance-part of the comparison&lt;/a&gt; will have to wait for my next post, though.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://smallsheds.garden/blog/2025/comparing-counterstring-implementations-in-typescript/"&gt;Read more…&lt;/a&gt; (10 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>counterstring</category><category>programming</category><guid>https://smallsheds.garden/blog/2025/comparing-counterstring-implementations-in-typescript/</guid><pubDate>Sat, 18 Jan 2025 23:00:00 GMT</pubDate></item><item><title>Using "fake it till you make it" to implement counterstring</title><link>https://smallsheds.garden/blog/2025/using-fake-it-till-you-make-it-to-implement-counterstring/</link><dc:creator>Joep Schuurkes</dc:creator><description>&lt;div&gt;&lt;p&gt;Last week I implemented &lt;a href="https://www.satisfice.com/download/perlclip"&gt;PerlClip&lt;/a&gt;'s &lt;a href="https://www.satisfice.com/blog/archives/22"&gt;counterstring&lt;/a&gt; in TypeScript. A counterstring is a string that tells you how long it is. For example a counterstring with length 9 looks like this: &lt;code&gt;*3*5*7*9*&lt;/code&gt;. Each number tells you the position of the asterisk following the number. My main goal with this project is to learn more about front-end development.&lt;/p&gt;
&lt;p&gt;Before I could start doing any front-end stuff, however, I needed to write a function that correctly generates counterstrings. Since I approached it in a way that I really enjoyed, inspired by Llewellyn Falco &lt;a href="https://youtu.be/O1h9ho2G85Q?t=155"&gt;"Fake it till you make it"&lt;/a&gt;, I figured it would make a good first post about this project.&lt;/p&gt;
&lt;p&gt;The idea behind "fake it till you make it" is simple. Start with an implementation covering a single case ("fake it") and then pull it apart little-by-little until it becomes an actual program ("make it"). As Llewellyn explains in the video, the value of this technique is that it's a lot easier to start from a working example and proceed from there than it is to get complete requirements.&lt;/p&gt;
&lt;p&gt;I did approach counterstring from the opposite direction, though, as Llewellyn did with Fizzbuzz in the video. Llewellyn starts with FizzBuzz length 20, so a case covering all the logic. Then he refactors it using different techniques, such as separation and encapsulation. While I started with counterstring length 0, the most simple case, and then worked my way up to larger lengths.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://smallsheds.garden/blog/2025/using-fake-it-till-you-make-it-to-implement-counterstring/"&gt;Read more…&lt;/a&gt; (4 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>counterstring</category><category>programming</category><category>small steps</category><guid>https://smallsheds.garden/blog/2025/using-fake-it-till-you-make-it-to-implement-counterstring/</guid><pubDate>Sat, 04 Jan 2025 23:00:00 GMT</pubDate></item></channel></rss>