<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Home on John Costa</title>
    <link>https://johncosta.tech/</link>
    <description>Recent content in Home on John Costa</description>
    <generator>Hugo</generator>
    <language>en-uk</language>
    <lastBuildDate>Fri, 03 Apr 2026 21:00:28 +0000</lastBuildDate>
    <atom:link href="https://johncosta.tech/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Impulse</title>
      <link>https://johncosta.tech/places/impulse/</link>
      <pubDate>Fri, 03 Apr 2026 21:00:28 +0000</pubDate>
      <guid>https://johncosta.tech/places/impulse/</guid>
      <description>&lt;p&gt;My favourite corner shop.&lt;/p&gt;
&lt;p&gt;I always get my elixir of wakefulness from here!&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Bacaro</title>
      <link>https://johncosta.tech/places/bacaro/</link>
      <pubDate>Fri, 03 Apr 2026 20:45:13 +0000</pubDate>
      <guid>https://johncosta.tech/places/bacaro/</guid>
      <description>&lt;p&gt;The best restaurant in &lt;a href=&#34;https://en.wikipedia.org/wiki/Woking&#34;&gt;Woking&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s a family owned, Italian restaurant, with amazing pasta and superb service.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s my #1 recommendation for food in Surrey.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Just Code</title>
      <link>https://johncosta.tech/gists/just-code/</link>
      <pubDate>Fri, 03 Apr 2026 20:29:14 +0000</pubDate>
      <guid>https://johncosta.tech/gists/just-code/</guid>
      <description>&lt;p&gt;Just Code. Making this is fun, you should do it often.&lt;/p&gt;
&lt;p&gt;Just Code.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Coding Review Process</title>
      <link>https://johncosta.tech/blog/coding-review-process/</link>
      <pubDate>Fri, 03 Apr 2026 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/blog/coding-review-process/</guid>
      <description>&lt;h2 id=&#34;evaluate-the-commits-you-make&#34;&gt;Evaluate the commits you make.&lt;/h2&gt;
&lt;p&gt;Do this as you code and commit. Paying attention here, spending an extra 5 minutes to deeply understand the changes you made - and refreshing your mind on previous commits - will save time and potential headache ten-fold later down the line.&lt;/p&gt;
&lt;h3 id=&#34;questions-to-ask-yourself&#34;&gt;Questions to ask yourself&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Does each commit make sense where it is?&lt;/li&gt;
&lt;li&gt;Are the names of functions and variables correct?&lt;/li&gt;
&lt;li&gt;Are the &lt;em&gt;diffs&lt;/em&gt; in the right place and in the correct order?&lt;/li&gt;
&lt;li&gt;Does each commit compile and pass the tests?&lt;/li&gt;
&lt;li&gt;What impact does each commit have?&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;review-your-own-code&#34;&gt;Review your own code&lt;/h2&gt;
&lt;p&gt;This should be done in a separate environment to the one you code in. For me, this could be GitHub (or any other online PR viewer), or in a local diff view.&lt;/p&gt;
&lt;h3 id=&#34;questions-to-ask-yourself-1&#34;&gt;Questions to ask yourself&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Does each commit &lt;em&gt;still&lt;/em&gt; make sense?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;High level overview&lt;/strong&gt;: Does it actually work? Are you wiring the correct functions to the correct place? We often miss the bigger picture when we&amp;rsquo;re down in the code.&lt;/li&gt;
&lt;li&gt;Does the architecture make sense? Are the functions you choose and the abstraction you made worth it?&lt;/li&gt;
&lt;li&gt;Does it work end-to-end?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Nits&lt;/strong&gt;. Do the names make sense, is the spacing correct. Less important, but still very important. If you can&amp;rsquo;t understand your own code, how can others?&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;optional-have-ai-review-your-code&#34;&gt;Optional: Have AI review your code&lt;/h2&gt;
&lt;p&gt;You can use a good agent, with a good prompt, and access to your code base (it must be aware of coding style and general abstractions), to review your code. The agent should have some understand of the code base. Otherwise it might have to go and find it each time.&lt;/p&gt;
&lt;p&gt;It will catch things you didn&amp;rsquo;t think of, and act as a barrier between you and the reviewer, so that the reviewer has less to catch.&lt;/p&gt;
&lt;h2 id=&#34;review-from-a-reviewer&#34;&gt;Review from a reviewer&lt;/h2&gt;
&lt;p&gt;Hand the PR to another engineer in your team, who has an understand of the areas you&amp;rsquo;ve changed. This process is last, and takes the longest, so you want to arrive at this step having made sure that lower level errors have been corrected, and let the reviewer worry about higher level reviewing (although the reviewer should still pick things apart and comments their &lt;em&gt;nit picks&lt;/em&gt;).&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Velvet Revival</title>
      <link>https://johncosta.tech/places/velvet-revival/</link>
      <pubDate>Mon, 30 Mar 2026 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/places/velvet-revival/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://www.velvet-revival.co.uk/&#34;&gt;Velvet Revival&lt;/a&gt; is a vintage shop which sells up-cycled goods. It&amp;rsquo;s in &lt;a href=&#34;https://en.wikipedia.org/wiki/Woking&#34;&gt;Woking&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I found the selection to be great. I bought a &lt;a href=&#34;https://www.carhartt.com/en-gb/&#34;&gt;Carhartt&lt;/a&gt; t-shirt, which is very nice, and I suspect a new trend in my wardrobe.&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;re ever in Surrey, or fancy a stroll outside London (the train is 25 minutes), this is a cute little shop to visit.&lt;/p&gt;
&lt;h3 id=&#34;flyer&#34;&gt;Flyer&lt;/h3&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:center&#34;&gt;Front&lt;/th&gt;
&lt;th style=&#34;text-align:center&#34;&gt;Back&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;&lt;img src=&#34;https://static.johncosta.tech/velvet-revival-flyer-front.jpg&#34; alt=&#34;Flyer Front&#34;&gt;&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;&lt;img src=&#34;https://static.johncosta.tech/velvet-revival-flyer-back.jpg&#34; alt=&#34;Flyer Back&#34;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
</description>
    </item>
    <item>
      <title>Save Victoria Way</title>
      <link>https://johncosta.tech/blog/save-victoria-way/</link>
      <pubDate>Sat, 21 Mar 2026 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/blog/save-victoria-way/</guid>
      <description>&lt;h2 id=&#34;prelude-late-2024&#34;&gt;Prelude (Late 2024)&lt;/h2&gt;
&lt;p&gt;I moved to Enterprise Place, Woking. This is an apartment block, with around 120 apartments. Next to our building (physically attached to), is a car park - called Victoria Way.  If you wanted a permit, you&amp;rsquo;d pay Working Borough Council £1,000 (!) a year, which entitled you to a 24/7/365 parking spot in your chosen car park.&lt;/p&gt;
&lt;p&gt;I was happy with this arrangement. I mostly don&amp;rsquo;t drive since I work in London or from home, but my significant other drives to work. She was happy with this arrangement also.&lt;/p&gt;
&lt;h2 id=&#34;trouble-december-2024&#34;&gt;Trouble (December 2024)&lt;/h2&gt;
&lt;p&gt;Woking Borough Council announced that the car park would be closed on the 14th of February 2025.&lt;/p&gt;
&lt;p&gt;No real reason given, other than &lt;em&gt;&amp;lsquo;a risk to public safety&amp;rsquo;&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;We were given the alternative to park in the main town car park, Victoria Place. It&amp;rsquo;s a nice car park with plenty of space. The only problem was that it was a 10 minute walk from my apartment. It is also situated in the middle of town - so to walk to your car - you must walk through the centre of town.&lt;/p&gt;
&lt;p&gt;This is where our problem began. My partner drives to work, and therefore had to make this trip twice a day, five days a week.&lt;/p&gt;
&lt;p&gt;This made the new parking arrangement, not ideal.&lt;/p&gt;
&lt;p&gt;We weren&amp;rsquo;t happy, but we accepted this, and waited patiently for the council to advice us in how to move forward, or for repairs to take place and re-open the Victoria Way car park, which us and many other residents relied on.&lt;/p&gt;
&lt;h2 id=&#34;radio-silent-august-2025&#34;&gt;Radio silent (August 2025)&lt;/h2&gt;
&lt;p&gt;No update was given from the Council, other than some Facebook comments from council leader Anne-Marie.&lt;/p&gt;
&lt;p&gt;This situation was frustrating.&lt;/p&gt;
&lt;p&gt;Walking 10 minutes to your car isn&amp;rsquo;t great, but it&amp;rsquo;s not the worst thing in the world. What most impacted us was the cheer lack of communication. We didn&amp;rsquo;t know how to manage our expectations, or plan for the future (when we moved in, parking was non-negotiable, so what should we do?).&lt;/p&gt;
&lt;p&gt;At this point, I decided to focus more effort into getting information, or action from the Council.&lt;/p&gt;
&lt;p&gt;I had already emailed Mr Will Forster (Woking MP). This was actually a good experience, he was fairly responsive and did what I thought he could do (mostly liaisons between myself and the council). I understand his concerns are broader than a parking issue.&lt;/p&gt;
&lt;p&gt;I emailed every Woking councillor. Only Anne-Marie decided to get back to me.&lt;/p&gt;
&lt;p&gt;I called Anne-Marie, and we had a half-hour phone call, which was the first time I actually spoke to somehow, who had some authority over these local decisions. It was a productive phone call, I floated some ideas to her, for alternatives for myself and every other Enterprise Place resident, whilst the car park as assessed and later repaired.&lt;/p&gt;
&lt;p&gt;One of the alternatives I suggested was Duke&amp;rsquo;s Court car park. Which was large enough to accommodate the small number of parking permits which Enterprise Place residents had (around 36 total).&lt;/p&gt;
&lt;p&gt;I kept in contact with Anne-Marie, and would like to thank her, for the help in this matter.&lt;/p&gt;
&lt;p&gt;But time went on, and the contact started to fade slowly.&lt;/p&gt;
&lt;h2 id=&#34;savevictoriawaycom-september-2025&#34;&gt;SaveVictoriaWay.com (September 2025)&lt;/h2&gt;
&lt;p&gt;I&amp;rsquo;m not much of an activist. I have no experience in public affairs, nor have I ever really been too involved in a local issue. But I wanted to try something. I&amp;rsquo;m a software engineer, so naturally I thought of a technological solution, a website!&lt;/p&gt;
&lt;p&gt;Hence came &lt;code&gt;savevictoriaway.com&lt;/code&gt;. The first iteration was made with Lovable (this was my first time trying it out), it did remarkably well, and better than I could at making a somewhat visually appealing website.&lt;/p&gt;
&lt;p&gt;I decided to go live with Lovable hosting my project. They give you a Supabase database, and vibe-code everything together for you. The code was &lt;em&gt;not at all&lt;/em&gt; good. But I wanted something done quickly, and in an afternoon, I had the website running, with a domain that I bought that day as well.&lt;/p&gt;
&lt;p&gt;The website had a simple petition functionality, which allowed people to submit petitions (with the option to submit anonymously).&lt;/p&gt;
&lt;p&gt;Now the real problem, and hardest park began. How do I make people aware of this project?&lt;/p&gt;
&lt;p&gt;I printed 200 of these.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://static.johncosta.tech/save-victoria-way.jpeg&#34; alt=&#34;Save Victoria Way Poster&#34;&gt;&lt;/p&gt;
&lt;p&gt;Me and Rio (my partner), put them through every letter box in our buildings, we put them in the lifts, in the notice boards, and someone (not me) put them very discreetly around Victoria Place car park.&lt;/p&gt;
&lt;p&gt;We then posted on local Facebook groups, messaged family members, asked them to spread the word to people they knew were also somewhat affected (basically anyone who goes to or has gone to Woking).&lt;/p&gt;
&lt;p&gt;The support was incredible. We hit &lt;strong&gt;100&lt;/strong&gt; signatures the day after I released this website. People who lived in my building, who had some very sad stories.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ll quote a few.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I decided to rent in enterprise place specifically because of the accessibility to parking. Paying higher rent for that privellege. Now I&amp;rsquo;m spending money for nothing&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;My husband needs a wheelchair and this car park was by far the easiest to get him in and out of. The ones in town are soo small for this. It needs to reopen. But it won’t because WBC are skint and need the money from selling it on.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;As a resident, it&amp;rsquo;s the only way to get a car. If not, I will have to move away as a car it&amp;rsquo;s essential for me, specially with kids&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;i’m a young woman and I live in enterprise place. walking to and from the unsuitable alternative parking we’ve been given has meant i have been whistled at, stared at, and even assaulted recently. i feel extremely unsafe being forced to walk through the town center every single day and late at night just to get home.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Vital car park for reaching the station safely in the evening and for servicing that area of town including Surrey County Council building now being next door and housing staff each day&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The most satisfying part about all this, was that I had created a small outlet to help people who were in a much worse situation than myself.&lt;/p&gt;
&lt;p&gt;Sure, it was annoying for Rio to do the walk twice a day, and naturally, it is scarier for a woman to walk through any town or city centre, at night, by themselves. Something to consider when looking at situations like this&amp;hellip;&lt;/p&gt;
&lt;p&gt;There were parents, elderly residents, and disabled people who relied very heavily on this car park. This was taken from them, and many were left feeling stranded in their own homes, since the 10 minute walk daily was a big challenge in their lives.&lt;/p&gt;
&lt;p&gt;It is easy for us, who luckily, don&amp;rsquo;t struggle to walk, or don&amp;rsquo;t need a car. It really gave me perspective, and put me outside of my little bubble of young professionals, in which I mostly live. This situation was &lt;em&gt;frustrating&lt;/em&gt; for me and Rio, and very inconvenient, but it wasn&amp;rsquo;t life changing. Some people had it much worse, and I&amp;rsquo;m most proud that I helped them, even if just in a small way.&lt;/p&gt;
&lt;p&gt;Another sad part of this story, is how little trust people seem to have in their local government. Maybe this is problem that has always happened, but I know that there are decent people who work at the concil (although I also know there are a lot of not very nice ones). Woking residents have earned the right to be skeptical. The previous council made Woking into - literally - the most in-debt council in the UK. And everyone is suffering for it. I hope Woking Borough Council (or soon to be West Surrey Council) can rebuild the trust the residents once had.&lt;/p&gt;
&lt;h2 id=&#34;surreylive-september-2025&#34;&gt;SurreyLive (September 2025)&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;https://www.getsurrey.co.uk/news/surrey-news/woking-residents-despair-car-park-32790786&#34;&gt;https://www.getsurrey.co.uk/news/surrey-news/woking-residents-despair-car-park-32790786&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I don&amp;rsquo;t necessarily agree with every word of this article. The title is overly dramatic, but it&amp;rsquo;s still a good article, and a nice over view of what happened. Take it with a pinch of salt though. You know what the media is like.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I reached out to a few news papers or online news sources to see if they&amp;rsquo;d be interested in the story. I spoke to a reporter from SurreyLive, had a long phone conversation with him, a few days later, we had one of the biggest news agencies in Surrey publish an article about Rio and myself (our SEO is now amazing as well).&lt;/p&gt;
&lt;h2 id=&#34;arons-introduction-october-2025&#34;&gt;Aron&amp;rsquo;s Introduction (October 2025)&lt;/h2&gt;
&lt;p&gt;I have a contact page where people can reach out to me (in &lt;code&gt;savevictoriaway.com&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;One lady did and put me in contact with Aron, the person in charge of Enterprise Place Residence Association, an entity unknown to me at the time. They were responsible for bringing down a cladding replacement bill (from 2022), from the original £15,000 per leaseholder, to £2,000. A change that came about at the end of a legal fight, with Aron spearheaded, this also resulted in the management company for Enterprise Place being replaced.&lt;/p&gt;
&lt;p&gt;Aron is and has been incredible for residents of the building. He was instrumental in making everyone&amp;rsquo;s lives a little bit easier. From what I know, he does this all on his time, with no benefit to self.&lt;/p&gt;
&lt;p&gt;I got into contact with him, and offered any help I could to improve the situation. He was already on the case even before I launched the website, talking to the council, and challenging the decision to close the car park.&lt;/p&gt;
&lt;p&gt;He was involved in very regular meeting with the council. And he told me as a result of one of the meeting, that the council had brought forward the idea of the residents potentially using Duke&amp;rsquo;s Court car park.&lt;/p&gt;
&lt;p&gt;I might never know if this was an independent through than mine and Rio&amp;rsquo;s conversation with Anne-Marie back in August, where I first suggested to her - and she was quite reseccise of - that we could use Duke&amp;rsquo;s Court car park.&lt;/p&gt;
&lt;p&gt;I like to think that my suggestion and persistence led to the council floating this idea.&lt;/p&gt;
&lt;h2 id=&#34;the-solution-november-2025&#34;&gt;The Solution (November 2025)&lt;/h2&gt;
&lt;p&gt;We finally heard that the council was working on giving the residents of Enterprise Place.&lt;/p&gt;
&lt;p&gt;Parking at Duke&amp;rsquo;s Court. Things were finally moving.&lt;/p&gt;
&lt;p&gt;Naturally, me and Rio were very happy that we would finally wrap up this rather annoying quest in our lives, and we would have somewhere more convenient to park again.&lt;/p&gt;
&lt;p&gt;It took another 2 months to have all the paper work drafted, signed and approved. But in January, we were finally able to park in Duke&amp;rsquo;s Court car park.&lt;/p&gt;
&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;This story has made me reflect on the every day life that everyone faces. I tend to get caught up in my work, in the incredible innovation that we see everyday, and often the terrible events of the world. Sometimes, if we take a step back and look around, there are plenty of every day problems waiting to be solved. We don&amp;rsquo;t all have to collectively live in the 24 hours news cycle.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m not the main protagonist of this story - that would be Aron. However, this was the first time I felt like I made a genuine difference to the community in which I live. It also made me think about problem which I thought I would have no influence in.&lt;/p&gt;
&lt;p&gt;For you, this might sound completely inconsequential. But there are real people, who&amp;rsquo;s everyday was affected, and has now been improved by the actions of a few people.&lt;/p&gt;
&lt;p&gt;I want to thank a few people who worked to solve this issue.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Aron. Easily the most pivotal person in this story. Without him, I think none of this would have happened.&lt;/li&gt;
&lt;li&gt;Anne-Marie. Being a councillor is a difficult job. She took her time to talk to me, and clearly there were attempts from inside Woking Borough Council to figure out a solution.&lt;/li&gt;
&lt;li&gt;Will Forster. My local MP. He was very quick at responding and did a good job at bringing this situation to the attention of the council.&lt;/li&gt;
&lt;li&gt;Everyone who signed the petition on my website. You helped more than you know.&lt;/li&gt;
&lt;li&gt;SurreyLive for publishing the article, and spreading the word even further.&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    <item>
      <title>Bugs</title>
      <link>https://johncosta.tech/gists/bugs/</link>
      <pubDate>Tue, 10 Mar 2026 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/gists/bugs/</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Until you know everything, you don&amp;rsquo;t know anything.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A co-worked told me this when we were talking about the possible cause for a specific bug I was chasing.&lt;/p&gt;
&lt;p&gt;I said things like:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I think x might be causing y which is an issue..&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;If the user does &lt;em&gt;a&lt;/em&gt; then &lt;em&gt;b&lt;/em&gt; could be affected.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Notice my language here. &lt;em&gt;I think&lt;/em&gt;, &lt;em&gt;If&lt;/em&gt;, &lt;em&gt;could&lt;/em&gt;. None of it is absolute. I&amp;rsquo;m &lt;em&gt;90% sure&lt;/em&gt;, or &lt;em&gt;I think&lt;/em&gt; there&amp;rsquo;s something in this particular part of the system.&lt;/p&gt;
&lt;p&gt;These are guesses. They will help you be sure. But if you don&amp;rsquo;t actually know what&amp;rsquo;s happening, then you don&amp;rsquo;t actually know what the bug is.&lt;/p&gt;
&lt;p&gt;The quote is a slightly over statement, you might know some things (which systems, how it happens, etc&amp;hellip;). But you cannot be sure, and until you actually figure out what is going wrong, you will not be able to solve the bug.&lt;/p&gt;
&lt;p&gt;And because this is quite difficult to do, engineers often patch symptoms and not causes.&lt;/p&gt;
&lt;p&gt;Image the following code.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-typescript&#34; data-lang=&#34;typescript&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;users&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;await&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;fetch&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;server.com&amp;#39;&lt;/span&gt;).&lt;span style=&#34;color:#a6e22e&#34;&gt;then&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;r&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;r&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;json&lt;/span&gt;());
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;users&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;map&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;user&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;user&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;name&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;What happens if &lt;code&gt;users&lt;/code&gt; is:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-typescript&#34; data-lang=&#34;typescript&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;[{ &lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;name&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;John&amp;#34;&lt;/span&gt; }, { &lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;name&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;John&amp;#34;&lt;/span&gt;}, { &lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;2&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;name&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Costa&amp;#34;&lt;/span&gt;}]
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Clearly, &lt;code&gt;John&lt;/code&gt; is duplicated. You see this bug, and you might end up writing a solution like so.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-typescript&#34; data-lang=&#34;typescript&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;users&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;await&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;fetch&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;server.com&amp;#39;&lt;/span&gt;).&lt;span style=&#34;color:#a6e22e&#34;&gt;then&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;r&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;r&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;json&lt;/span&gt;());
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;seenUsers&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;new&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Set&lt;/span&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;number&lt;/span&gt;&amp;gt;();
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;uniqueUsers&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; [];
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; (&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;user&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;of&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;users&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;seenUsers&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;has&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;user&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;		&lt;span style=&#34;color:#66d9ef&#34;&gt;continue&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	&lt;span style=&#34;color:#a6e22e&#34;&gt;seenUsers&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;add&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;user&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	&lt;span style=&#34;color:#a6e22e&#34;&gt;uniqueUsers&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;push&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;user&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;uniqueUsers&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;map&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;user&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;user&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;name&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You didn&amp;rsquo;t fix a bug. You fixed the &lt;em&gt;symptom of the bug&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;The issue is in the server. The server is returning duplicated users. So, go to the server code, and fix it there! There might be a bad SQL query, some incorrect mapping logic, whatever. There is a bigger issue at play here, and this bug will not go away, it will resurface.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I appreciate that sometimes you cannot change the server. This example assumes you can.&lt;/p&gt;
&lt;/blockquote&gt;
</description>
    </item>
    <item>
      <title>Mitmproxy - My new best friend</title>
      <link>https://johncosta.tech/gists/mitmproxy/</link>
      <pubDate>Tue, 20 Jan 2026 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/gists/mitmproxy/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://www.mitmproxy.org&#34;&gt;mitmproxy&lt;/a&gt; is - as the name suggests - a proxy.&lt;/p&gt;
&lt;p&gt;At &lt;a href=&#34;https://requesty.ai&#34;&gt;Requesty&lt;/a&gt;, I do a lot of request manipulation, from one format to another. We listen to a lot of streams. Basically we do a lot of networking.&lt;/p&gt;
&lt;p&gt;So, when I need to understand the shape of my outgoing requests, where logging or debugging might be enough, I reach for &lt;code&gt;mitmproxy&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You start it by:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;mitmproxy --mode reverse:https://google.com
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I use it in &lt;code&gt;reverse&lt;/code&gt; mode almost exclusively. This is because I mostly want to debug outbound requests.&lt;/p&gt;
&lt;p&gt;Then all you have to do is make a request!&lt;/p&gt;
&lt;p&gt;&lt;code&gt;mitmproxy&lt;/code&gt; will show you all your outbound requests, the response, the headers and a lot more options (you can even replay requests!).&lt;/p&gt;
&lt;p&gt;If you do any kind of requests and have ever had to debug them, I highly recommend you give this tool a try.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Pointer vs Value</title>
      <link>https://johncosta.tech/gists/pointer-vs-value/</link>
      <pubDate>Mon, 24 Nov 2025 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/gists/pointer-vs-value/</guid>
      <description>&lt;p&gt;When working with pointers, what do you think the difference is?&lt;/p&gt;
&lt;h2 id=&#34;1-assign-to-pointer&#34;&gt;1. Assign to pointer&lt;/h2&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-go&#34; data-lang=&#34;go&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;func&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;c&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;MyStruct&lt;/span&gt;) &lt;span style=&#34;color:#a6e22e&#34;&gt;SomeFunction&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;val&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;any&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	&lt;span style=&#34;color:#a6e22e&#34;&gt;parsedStruct&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;:=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;someProcessingFunc&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;val&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	&lt;span style=&#34;color:#a6e22e&#34;&gt;c&lt;/span&gt; = &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;parsedStruct&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;vs&lt;/p&gt;
&lt;h2 id=&#34;2-assign-to-value&#34;&gt;2. Assign to value&lt;/h2&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-go&#34; data-lang=&#34;go&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;func&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;c&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;MyStruct&lt;/span&gt;) &lt;span style=&#34;color:#a6e22e&#34;&gt;SomeFunction&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;val&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;any&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	&lt;span style=&#34;color:#a6e22e&#34;&gt;parsedStruct&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;:=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;someProcessingFunc&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;val&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	&lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;c&lt;/span&gt; = &lt;span style=&#34;color:#a6e22e&#34;&gt;parsedStruct&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I came across this at work today and it took me a second to figure out what was wrong.&lt;/p&gt;
&lt;h2 id=&#34;number-2-is-correct&#34;&gt;Number 2 is correct&lt;/h2&gt;
&lt;p&gt;The first example actually assigned the pointer of &lt;code&gt;parsedStruct&lt;/code&gt; to the local variable &lt;code&gt;c&lt;/code&gt; which itself is just a pointer.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-go&#34; data-lang=&#34;go&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;c&lt;/span&gt; = &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;parsedStruct&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;All we&amp;rsquo;ve done, is reassign a local variable.&lt;/p&gt;
&lt;p&gt;Whereas:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-go&#34; data-lang=&#34;go&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;c&lt;/span&gt; = &lt;span style=&#34;color:#a6e22e&#34;&gt;parsedStruct&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Actually changes the underlying value of the pointer &lt;code&gt;c&lt;/code&gt;, and changes it to the content of &lt;code&gt;parsedStruct&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s easy to overlook these things, specially now when LLMs write more and more code. But it will be more and more important to understand and spot these differences, they might cost you or your company a lot of business.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Taking Accountability</title>
      <link>https://johncosta.tech/blog/taking-accountability/</link>
      <pubDate>Mon, 17 Nov 2025 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/blog/taking-accountability/</guid>
      <description>&lt;p&gt;There is an interesting shift that happens when you transition from a &lt;em&gt;junior&lt;/em&gt; to a more senior level engineer (or any other career for that matter).&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Note: You&amp;rsquo;ve probably met 40 year old &lt;em&gt;juniors&lt;/em&gt; and 20 year old &lt;em&gt;seniors&lt;/em&gt;, age has some correlation, but less than you&amp;rsquo;d expect.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I&amp;rsquo;ve had a self-driven approach to work for many years. I started my own company when I was just in my first year of uni. I was self employed for quite a few years (tutoring), and I&amp;rsquo;ve worked on multiple software projects with other people.&lt;/p&gt;
&lt;p&gt;But work is different.&lt;/p&gt;
&lt;p&gt;Back at &lt;a href=&#34;https://github.com/decipad/decipad&#34;&gt;Decipad&lt;/a&gt; (my  first &lt;em&gt;real&lt;/em&gt; job), I was a junior. Sure, I knew how to code but did I know how to be an engineer? I didn&amp;rsquo;t.&lt;/p&gt;
&lt;p&gt;As months past I got very good at being self driven. From figuring out what the product needed, to discussing it with the team, to implementing it, to delivering it, to maintaining it. This is something I am very grateful for having the freedom to do when I was working here.&lt;/p&gt;
&lt;p&gt;Now that I am at &lt;a href=&#34;https://requesty.ai&#34;&gt;Requesty&lt;/a&gt;, I&amp;rsquo;ve had to relearn this.&lt;/p&gt;
&lt;h2 id=&#34;everyone-is-a-junior-when-they-first-join&#34;&gt;Everyone is a junior when they first join.&lt;/h2&gt;
&lt;p&gt;OK. Maybe that&amp;rsquo;s not true but stay with me.&lt;/p&gt;
&lt;p&gt;When you first join a software project, you don&amp;rsquo;t really know what&amp;rsquo;s going on. You don&amp;rsquo;t fully understand the customers, you don&amp;rsquo;t fully understand the product, and you certainly do not fully understand the code. So what can you do?&lt;/p&gt;
&lt;p&gt;You can do tasks. And ask (many) questions.&lt;/p&gt;
&lt;p&gt;You shouldn&amp;rsquo;t be responsible for the full delivery of a brand new feature the moment you step foot through the door. Your job should be to learn as much as possible. Contributing will come.&lt;/p&gt;
&lt;h2 id=&#34;take-accontability&#34;&gt;Take Accontability&lt;/h2&gt;
&lt;p&gt;When you&amp;rsquo;re more established, you understand this new place a little better, then you need to turn your engineering brain fully on. You need to understand that you are not here to be a ticket crunching machine. You are an engineer!&lt;/p&gt;
&lt;p&gt;What do I think an engineer (in a software company) is? Well, it&amp;rsquo;s someone who writes the code, tests it, makes sure it goes into production without breaking other parts, makes sure it actually works, makes sure it was worth building in the first place, goes back to improve existing code and infrastucture, someone who can talk about the business requirements and the more abstract concepts surrounding the code they write (or tell an LLM to write).&lt;/p&gt;
&lt;p&gt;The reason I&amp;rsquo;m writing this blog post is because this part is hard.&lt;/p&gt;
&lt;p&gt;Writing code is many (maybe all?) engineers confortable place. We like writing our tests, watching the screen go green as we make them pass. We like taking some code and refactoring it to look nice and pretty. (At least I do).&lt;/p&gt;
&lt;p&gt;But then what?&lt;/p&gt;
&lt;p&gt;You must go beyond this. You need to lead the way. You shouldn&amp;rsquo;t be just the tool your manager uses to spit out code. You should be the person your manager delegates to, to fully build something.&lt;/p&gt;
&lt;p&gt;How does this have to do with accountability?&lt;/p&gt;
&lt;p&gt;If no one is telling you what to do, or how to do it, what do you do?&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s not easy, and often we are not as self monivated as we would like to be (I know I sometimes lack in this regard). But you need to turn your engineering brain on, and figure things out. You need to know what to do next, and how it will impact the business and other people around you.&lt;/p&gt;
&lt;p&gt;It isn&amp;rsquo;t enough to sit back and write code. That code needs to be in the hand of customers, it needs to be tested, it needs to be deployed, maintained, it needs to be designed. It needs love and attention.&lt;/p&gt;
&lt;h2 id=&#34;my-conclusion&#34;&gt;My conclusion&lt;/h2&gt;
&lt;p&gt;Take accountabiliy for your projects at work. You need to be able to lead from start to finish. You cannot wait for someone to tell you what the next step is. You need to figure out that next step.&lt;/p&gt;
&lt;p&gt;Now, I talked a lot about you, but I must stress. If you cannot go to your team to share opinions and ask for help, then you need to leave whatever company you&amp;rsquo;re working for. We&amp;rsquo;re very much shaped and pushed by those around you. And part of this concept is that you need to help others too, in a funny way, you need to know when to help others!&lt;/p&gt;
&lt;p&gt;Writing code isn&amp;rsquo;t enough. Be an engineer!&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Keeping it safe and simple. My preferred way to verify API requests in the frontend</title>
      <link>https://johncosta.tech/blog/how-i-deal-with-rest-apis/</link>
      <pubDate>Mon, 18 Aug 2025 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/blog/how-i-deal-with-rest-apis/</guid>
      <description>&lt;p&gt;The challenge of keeping backend APIs and frontend applications in sync has been around for a while, and there are many different solutions from this problem.&lt;/p&gt;
&lt;p&gt;The simplest one is to ignore it completely. Look at what the API returns, and use those values in the frontend without any sort of parsing or validation. This works, for a time. Eventually, the API will change, and if you&amp;rsquo;re lucky it will change in a big way, making it obvious that you are no longer in sync. But if you are unlucky, it will change in a small, miniscule way, that will lead you down hour long debugging sessions for some weird, undefined behaviour. I don&amp;rsquo;t recommend this approach, unless you have complete control over both, and even then, this is one small human error away from being a nightmare.&lt;/p&gt;
&lt;p&gt;An extension to this approach would be have your backend API fit an OpenAPI schema, which makes it easy for tools to generate the types, and potentially validators (which we&amp;rsquo;ll get onto later), for your API. This approach is good, but it involves some level of maintenance for compliance with the OpenAPI schema, and also external tools to generate code for you. However, I would actually recommend this approach under certain scenarios.&lt;/p&gt;
&lt;p&gt;The other approaches I see are more complicated. They involve standardising the API in some way, this is where GraphQL would come in. The frontend asks for the data, and if the data is not returned in the expected way (types and all), then you will get an error. The experience of developing with this approach are good, for the frontend developer (to an extend). But it involves changing your API completely, potentially making it much harder to develop, harder to maintain, less performant, and overly complicated.&lt;/p&gt;
&lt;p&gt;Another similar approach is the use of tools such as tRPC. It&amp;rsquo;s somewhat similar to GraphQL, but it is TypeScript specific. This probably has the best developer experience if you&amp;rsquo;re working with TypeScript only. But again, you&amp;rsquo;re changing the backend again to fix the problems of the frontend, not to mention you are restricted to using TypeScript on the backend. There are other tools or standards, such as gRPC, which would allow you to use this for any language, but again, you will have to make the API compliant.&lt;/p&gt;
&lt;h2 id=&#34;parse-the-response&#34;&gt;Parse the response&lt;/h2&gt;
&lt;p&gt;In my experience, guessing the types, will only get you so far. To have a good, scalable(ish) solution, which will save you countless hours debugging, you need to parse the response you get from the API. This is what GraphQL does, what tRPC does and plenty of other API standards do. But I don&amp;rsquo;t want to use any of those, I want a simple REST API (and note, I&amp;rsquo;m using REST loosely here, I&amp;rsquo;m not referring to perfect REST standard APIs, just APIs that return some data when asked).&lt;/p&gt;
&lt;p&gt;Instead of making the burden of maintenance on the backend side (like OpenAPI schemas), I shift it to the frontend, by writing validators which can look at a response, and tell me if anything changed, or if the response is correct.&lt;/p&gt;
&lt;p&gt;The reason I like this approach is because it is simple. All I need is a basic validation library (such as Valibot, Zod, or any other), and write what I&amp;rsquo;m expecting the response to look like, and then parse it. Even better, now you have TypeScript types, that you know for sure are not lying to you. You also get integration testing, you can run all the requests from the backend and make sure the corresponding validators pass, and if not, then you know something changed in the API.&lt;/p&gt;
&lt;h2 id=&#34;implementation&#34;&gt;Implementation&lt;/h2&gt;
&lt;p&gt;We&amp;rsquo;ll start off by writing a helper function &lt;code&gt;createEndpoint&lt;/code&gt;, which allows me to define an API request, give it a schema, and have it handle the parsing for me.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ll show the code section by section, and explain as we go along.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-typescript&#34; data-lang=&#34;typescript&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;type&lt;/span&gt; { &lt;span style=&#34;color:#a6e22e&#34;&gt;StandardSchemaV1&lt;/span&gt; } &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;@standard-schema/spec&amp;#39;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This is an interesting part of the code. A recent project called &lt;code&gt;standard-schema&lt;/code&gt;, has made it very easy to swap out what validator you would like to use. This means that my function can take a validator from Zod, Valibot or any of the other libraries which implement this interface. You don&amp;rsquo;t even need this library to be in your dependencies, you could copy it straight from their website. Pretty neat.&lt;/p&gt;
&lt;hr&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-typescript&#34; data-lang=&#34;typescript&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;type&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;RequestFnWithSchema&lt;/span&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;T&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;extends&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;StandardSchemaV1&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;,&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;TFn&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;extends&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;...args&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;any&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;)&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;=&lt;/span&gt;&amp;gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;any&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#a6e22e&#34;&gt;fn&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; (...&lt;span style=&#34;color:#a6e22e&#34;&gt;input&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;Parameters&lt;/span&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;TFn&lt;/span&gt;&amp;gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Promise&lt;/span&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;StandardSchemaV1.InferOutput&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;T&lt;/span&gt;&amp;gt;&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    [&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;~schema&amp;#39;&lt;/span&gt;]&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;T&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;createEndpoint&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;T&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;extends&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;StandardSchemaV1&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;,&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;TFn&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;extends&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;...args&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;any&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;)&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;=&lt;/span&gt;&amp;gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;any&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&lt;/span&gt;(
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#a6e22e&#34;&gt;schema&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;T&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#a6e22e&#34;&gt;fn&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;TFn&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;RequestFnWithSchema&lt;/span&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;T&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;,&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;TFn&lt;/span&gt;&amp;gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#a6e22e&#34;&gt;fn&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;async&lt;/span&gt; (...&lt;span style=&#34;color:#a6e22e&#34;&gt;input&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;res&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;await&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;fn&lt;/span&gt;(...&lt;span style=&#34;color:#a6e22e&#34;&gt;input&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;x&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;schema&lt;/span&gt;[&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;~standard&amp;#39;&lt;/span&gt;].&lt;span style=&#34;color:#a6e22e&#34;&gt;validate&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;res&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;x&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;instanceof&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Promise&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                &lt;span style=&#34;color:#66d9ef&#34;&gt;throw&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;new&lt;/span&gt; Error(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;unreachable&amp;#34;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;x&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;issues&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;null&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                &lt;span style=&#34;color:#66d9ef&#34;&gt;throw&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;new&lt;/span&gt; Error(&lt;span style=&#34;color:#a6e22e&#34;&gt;JSON&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;stringify&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;x&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;issues&lt;/span&gt;));
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;x&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;value&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        },
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;~schema&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;schema&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This method takes two parameters. The first is a schema, this is what your data looks like, the part that you have to write by hand. The second is the request function. This can be anything, but usually it&amp;rsquo;s a simple function that returns a promise.&lt;/p&gt;
&lt;p&gt;We return an object that contains the function to call, and also the schema it uses. This is most so we return a type rather than a function, because I don&amp;rsquo;t want this to get mixed up with other simple functions that request data from the API, I want to make it distinct.&lt;/p&gt;
&lt;p&gt;The callback function is first called with the correct arguments, we then take the schema and validate the response from the callback function, Make sure there&amp;rsquo;s no issues and return the parsed value. This function will throw if there&amp;rsquo;s an error, this is mostly to keep this example simple, but you can choose to return an error value instead, create your own Error class and throw that, whatever you want.&lt;/p&gt;
&lt;p&gt;The return type for this function is &lt;code&gt;RequestFnWithSchema&lt;/code&gt;, which is just a helper type, that returns a correctly inferred value, so you get nice TypeScript types on the other end.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s an example of how you would use this:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-typescript&#34; data-lang=&#34;typescript&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; { &lt;span style=&#34;color:#a6e22e&#34;&gt;array&lt;/span&gt;, &lt;span style=&#34;color:#66d9ef&#34;&gt;object&lt;/span&gt;, &lt;span style=&#34;color:#66d9ef&#34;&gt;string&lt;/span&gt; } &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;valibot&amp;#34;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; { &lt;span style=&#34;color:#a6e22e&#34;&gt;createEndpoint&lt;/span&gt; } &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;./frontend&amp;#34;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;userSchema&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;array&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;object&lt;/span&gt;({
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;string&lt;/span&gt;(),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#a6e22e&#34;&gt;name&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;string&lt;/span&gt;(),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}));
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;userEndpoint&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;createEndpoint&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;userSchema&lt;/span&gt;, &lt;span style=&#34;color:#66d9ef&#34;&gt;async&lt;/span&gt; () &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;response&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;await&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;fetch&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;http://localhost:1234/users&amp;#34;&lt;/span&gt;).&lt;span style=&#34;color:#a6e22e&#34;&gt;then&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;r&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;r&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;json&lt;/span&gt;());
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;response&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;});
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can see now I am writing the schema using valibot. I then pass it over to the &lt;code&gt;createEndpoint&lt;/code&gt; function, and a callback which takes no arguments and returns the JSON response (note that I am assuming the API always returns JSON or the fetch throws an error).&lt;/p&gt;
&lt;p&gt;Like this, you now get a lovely typed request function, by doing &lt;code&gt;userEndpoint.fn&lt;/code&gt;, TypeScript knows it doesn&amp;rsquo;t need any arguments, and will use &lt;code&gt;userSchema&lt;/code&gt; to infer the return type. And all the complexity of parsing the request is hidden inside &lt;code&gt;createEndpoint&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You can pass in parameters as well, very simply.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-typescript&#34; data-lang=&#34;typescript&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;singleUser&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;object&lt;/span&gt;({
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;string&lt;/span&gt;(),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#a6e22e&#34;&gt;name&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;string&lt;/span&gt;(),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;});
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;createUserEndpoint&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;createEndpoint&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;singleUser&lt;/span&gt;, &lt;span style=&#34;color:#66d9ef&#34;&gt;async&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;params&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; { &lt;span style=&#34;color:#a6e22e&#34;&gt;name&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;string&lt;/span&gt; }) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;response&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;await&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;fetch&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;http://localhost:1234/users&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            &lt;span style=&#34;color:#a6e22e&#34;&gt;method&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;POST&amp;#39;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            &lt;span style=&#34;color:#a6e22e&#34;&gt;body&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;JSON.stringify&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;params&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        }).&lt;span style=&#34;color:#a6e22e&#34;&gt;then&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;r&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;r&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;json&lt;/span&gt;());
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;response&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;})
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;a-little-about-validators&#34;&gt;A little about validators&lt;/h2&gt;
&lt;p&gt;There is a small detail that is easy to overlook by looking at the code above. The &lt;code&gt;object&lt;/code&gt; part of the schema hides away the fact that it does not perfectly match the object. Take a look at the following:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-json&#34; data-lang=&#34;json&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;id&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;id&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;name&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;name&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This is exactly what you expect to pass validation - and it does - but now take a look at this object.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-json&#34; data-lang=&#34;json&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;id&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;id&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;name&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;name&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;surname&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;surname&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Valibot (experience may differ with other libraries), the standard &lt;code&gt;object&lt;/code&gt; validator removes extra fields. This is actually key for enabling migrations, which I&amp;rsquo;ll talk about further down. To recap, this object passes validation, but the extra field is stripped away. So TypeScript is still telling the truth.&lt;/p&gt;
&lt;p&gt;The validation fails when a field isn&amp;rsquo;t present, or has an incorrect type. Such as:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-json&#34; data-lang=&#34;json&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;id&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;some-field&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;not-name&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This fails. And Valibot is very useful at pointing out the errors, &lt;code&gt;id&lt;/code&gt; is not of type string, and &lt;code&gt;name&lt;/code&gt; is missing.&lt;/p&gt;
&lt;h2 id=&#34;what-happens-when-the-api-changes-development--production&#34;&gt;What happens when the API changes. Development &amp;amp; Production.&lt;/h2&gt;
&lt;p&gt;Let&amp;rsquo;s keep the user validator as an example. What happens when the API changes? And there are two scenarios where the schema you have on the frontend, does not match the response that your API does.&lt;/p&gt;
&lt;p&gt;Number one, you&amp;rsquo;re developing the backend API - or someone else has and hasn&amp;rsquo;t changed the frontend schemas - and you validator crashes. But wait you&amp;rsquo;re saying, the example above clearly shows that the extra fields are ignored, and therefore, potentially bugs can pass through. One more thing we can do to make development air tight, is to change the &lt;code&gt;object&lt;/code&gt; to a &lt;code&gt;strictObject&lt;/code&gt;. This way, there is no escaping that API change, the moment an extra field is added you will know about it, because your frontend will crash. This is very important to make sure that you get small and fast errors now, instead of bigger bugs which take you a while to figure out.&lt;/p&gt;
&lt;p&gt;One very important thing is: we &lt;em&gt;only&lt;/em&gt; want this &lt;code&gt;strictObject&lt;/code&gt; for development, because shipping it to production will mean that anyone with an out of date frontend (which happens a lot), their application will crash. The most common migration you make is adding fields, which is very easy with &lt;code&gt;object&lt;/code&gt;, just add a field. If it&amp;rsquo;s present but the validator doesn&amp;rsquo;t see it, it will ignore it.&lt;/p&gt;
&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;This is a practical way to create types that you know are true. You can also be extra strict during development and flexible to allow for users with outdated clients still use the app. It&amp;rsquo;s not perfect, but it is still my favourite way of validating on the frontend.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>The 7 Habits of Highly Effective People</title>
      <link>https://johncosta.tech/books-and-tv/the-7-habits-of-highly-effective-people/</link>
      <pubDate>Tue, 22 Jul 2025 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/books-and-tv/the-7-habits-of-highly-effective-people/</guid>
      <description></description>
    </item>
    <item>
      <title>Requesty.</title>
      <link>https://johncosta.tech/blog/requesty/</link>
      <pubDate>Mon, 07 Jul 2025 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/blog/requesty/</guid>
      <description>&lt;p&gt;I will be joining &lt;a href=&#34;https://requesty.ai&#34;&gt;Requesty&lt;/a&gt; in August. My time at Decipad is coming to an end. I want to describe what I&amp;rsquo;m feeling, what I&amp;rsquo;m hoping for in the future, my apprehensions, and what I&amp;rsquo;m looking forward to.&lt;/p&gt;
&lt;h1 id=&#34;3-years-what-im-feeling&#34;&gt;3 Years (What I&amp;rsquo;m feeling)&lt;/h1&gt;
&lt;p&gt;Decipad has been the start of my professional career. Even though I had worked at other places before - and even founded my own company - Decipad was the first time I worked, as part of a sizable engineering team, to build a product.&lt;/p&gt;
&lt;p&gt;I was hired by &lt;a href=&#34;https://www.linkedin.com/in/nunojob/&#34;&gt;Nuno&lt;/a&gt;, who I regard as one of the kindest, most inspiring and decisive people I&amp;rsquo;ve ever had the pleasure of meeting. I hope that our paths cross again, and if not I will forever regard him as a friend and role-model.&lt;/p&gt;
&lt;p&gt;I learnt how to work as a team, I learnt how to make product decisions, I learnt how to talk to clients. I came into Decipad as a hot-shot programmer, I could crunch tickets like a machine, but could I steer a very new product the correct direction? No, I could not.&lt;/p&gt;
&lt;p&gt;I leave Decipad feeling that I can make those decisions, I am able to steer a product the correct way. I am not just a coder, I&amp;rsquo;m a product engineer.&lt;/p&gt;
&lt;p&gt;I met lot&amp;rsquo;s of amazing people - too many to list - and for all of them I am thankful for your kindness and patience as we went on this crazy journey together.&lt;/p&gt;
&lt;h1 id=&#34;my-senior-arc-what-im-hoping-for-the-future&#34;&gt;My Senior Arc (What I&amp;rsquo;m hoping for the future)&lt;/h1&gt;
&lt;p&gt;I am joining as the 2nd hire, a Founding Engineer. This role caries a lot of weight, I am not just an employee of the company, I will be someone who will shape the product itself. work hand-in-hand with the founders to build the best developer experience, the most reliable and performant way to interact with LLMs from your codebase.&lt;/p&gt;
&lt;p&gt;Like always, I have a lot to learn. I am hoping to learn from &lt;a href=&#34;https://www.linkedin.com/in/daniel-trugman/&#34;&gt;Daniel&lt;/a&gt;, but I&amp;rsquo;m also hoping he can learn from me, and this I believe is the key difference from when I started Decipad. I am now a more complete engineer, and I am able to lead, much more than when I started at Decipad. I hope to bring my skills as an engineer and as a product person to the team.&lt;/p&gt;
&lt;p&gt;This will likely be the hardest job I&amp;rsquo;ve ever worked. The area is hard, the space is crowded by already incredible people and products, and the hours will be long. It took me a while to decide that this is what I wanted to embark on, I deliberated over it for many days (I had other offers, that would potentially be more relaxed, Series A start-up). I want to be the person to take these opportunities and difficulties and face them head on with a smile. And do that I shall.&lt;/p&gt;
&lt;h1 id=&#34;what-im-scared-of-apprehensions&#34;&gt;What I&amp;rsquo;m scared of (Apprehensions)&lt;/h1&gt;
&lt;p&gt;I feel nervous, but OK with the difficulty of the technical challenges ahead of me. I enjoy the space, I know a fair bit about it already, and I will learn more everyday. What I am not so confident in, is my physical ability to join an in-person team, with high uncertainty, and a growing customer base. These are very rational fears, and I am working on having control over them, but it will take a while. I am taking the time from now to my start date, to prepare myself for what&amp;rsquo;s about to come.&lt;/p&gt;
&lt;h1 id=&#34;what-im-looking-forward-to&#34;&gt;What I&amp;rsquo;m looking forward to&lt;/h1&gt;
&lt;p&gt;Honestly, Golang. I&amp;rsquo;ve used this language so many times in so many projects - and yes I know it is &lt;a href=&#34;https://fasterthanli.me/articles/i-want-off-mr-golangs-wild-ride&#34;&gt;flawed&lt;/a&gt; - I still get much joy from writing it. I am also looking forward to working on a service which is mostly non-user facing. Requesty does provide a very lovely dashboard, but the people actually using our core service (The router), are people who will never see into requesty.&lt;/p&gt;
&lt;p&gt;I am super excited to build these systems, focusing on: high availability, high scalability, and performance. I guess I&amp;rsquo;m saying I&amp;rsquo;m looking forward to being a backend engineer.&lt;/p&gt;
&lt;h1 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;I&amp;rsquo;m moving jobs. I am really excited, and hyped to write code. More than I have been in a long time. I will enjoy this month before I start, and make sure that I am up to the challenge.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Life, Recently.</title>
      <link>https://johncosta.tech/blog/life-recently/</link>
      <pubDate>Sat, 21 Jun 2025 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/blog/life-recently/</guid>
      <description>&lt;p&gt;I have been going through an unusual period of unbusyness. Normally I tend to be quite busy, working my full-time job, working on side projects after, going to the gym in the morning and talking to friends some evenings, and the weekends tend to be much of the same, only that I work on side projects the majority of the day.&lt;/p&gt;
&lt;h2 id=&#34;so-what-has-happened-recently&#34;&gt;So what has happened recently?&lt;/h2&gt;
&lt;p&gt;My work has slowed down quite a bit, I have also been on two holidays in one month, with 2 weeks in between, one to Scotland and one to Lisbon. Both were quite nice, and I managed to see a lot of both of these wonderful places. But this has meant that my last 4-6 weeks have been lacking a certain busyness I was used to.&lt;/p&gt;
&lt;p&gt;This sounds great, doesn&amp;rsquo;t it? Well&amp;hellip; Yes. I recently watched 9 hours of TV in a single day, I don&amp;rsquo;t remember ever doing that before. It felt &lt;em&gt;ok&lt;/em&gt;, I&amp;rsquo;m glad I&amp;rsquo;m in a position where having such unproductive days doesn&amp;rsquo;t hurt, but it does leave a sense of unnacomplishment (although this particular example I was somewhat proud of, in a weird way), this is something I have fought with for about a year now, and I&amp;rsquo;m starting to understand this feeling better.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve learnt to appreciate this feeling, it pushes me to do &lt;em&gt;something&lt;/em&gt;, it isn&amp;rsquo;t something to fight, it is something to be grateful for. It pushes me to continue learning, continue working and push myself. It goes away once I&amp;rsquo;ve completed a good days work, when I&amp;rsquo;ve been to the gym, and when I&amp;rsquo;ve made a good, healthy meal.&lt;/p&gt;
&lt;h2 id=&#34;what-about-remote-work&#34;&gt;What about (remote) work?&lt;/h2&gt;
&lt;p&gt;Firstly, I will try and get back to a good state of bussyness, first and for most.&lt;/p&gt;
&lt;p&gt;Secondly - although I am a big believer in remote work - I understand the need to leave the house. This is not some revolutionaty idea I have discovered, I&amp;rsquo;ve known that practically anyone who does remote work for a long time wants to leave the house. Maybe not for an office, but for a coffee shop, a co-working space, the park. Literally anywhere but their house (obviously from time to time).&lt;/p&gt;
&lt;p&gt;So an action I will undertake is to try and leave the house everyday, and during weekdays I will try and work - at least 3 days - outside of my home office. This will mostly come in the form of going to a London office, in general I want to spend more time in London, as I always have fun and meet incredible people when I take the time to go to events, spend time at the pub, or simply working from the office. My mental health improves and so does my work.&lt;/p&gt;
&lt;p&gt;However, the time I spend at home I also want to be better. The home office can be an incredibly productive space, and I want to keep it that way. I will come up with rules around using my phone near my desktop, about starting the day right when I am at home (waking up at the same time), and a few other baselines which I want to achieve. I might also write a blog post about these, more in detail.&lt;/p&gt;
&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;I&amp;rsquo;m somewhat unhappy with my current productivity. I feel like I am lagging behind, not keeping up with industry trends and much as I should -  and most importantly - I am not programming enough.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Self Hosting</title>
      <link>https://johncosta.tech/blog/self-hosting/</link>
      <pubDate>Sun, 08 Jun 2025 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/blog/self-hosting/</guid>
      <description>&lt;p&gt;Since I moved into my &lt;a href=&#34;https://en.wikipedia.org/wiki/Flat#Architecture&#34;&gt;flat&lt;/a&gt;, one of the first things I bought was a used computer which I could use as a server. This cost me £50, and it&amp;rsquo;s not a very powerful machine. But this tiny machine has been a great source of fun for me. I want to break down what I&amp;rsquo;m doing with my own machine, but also the philosophy of self-hosting, and taking back control over your data, and deployment processes.&lt;/p&gt;
&lt;h1 id=&#34;cloud-can-be-bad&#34;&gt;Cloud can be bad&lt;/h1&gt;
&lt;p&gt;For many use-cases, using the cloud to host your projects, can be more trouble than the ol&amp;rsquo; server under the desk. I run mustly outward facing services on this machine, with some users and the service is very similar to what I would get if I hosted it on a VPS or some managed service. I don&amp;rsquo;t get many &lt;a href=&#34;https://en.wikipedia.org/wiki/High_availability#%22Nines%22&#34;&gt;nines&lt;/a&gt;, I probably only get 1 (or 2 on a good streak!), but does it really matter?
- My most important service is the backend of Haystack. A project in a closed beta which allows users to upload pictures. If the service goes down, then my users lose the ability to view, and process their images, which is obviously a bad experience.
- I have had one outage (my fault, skill issue), which lasted a day. And I argue that this doesn&amp;rsquo;t matter, realistically Haystack is and will always be a small project with few (but interested) users. One where I believe 1 or 2 nines is enough.&lt;/p&gt;
&lt;p&gt;So I&amp;rsquo;ve mentioned the downside, availability. But what are the good things?
- Money. I paid very little for the server, but for a similarly speced VPS on most cloud providers I would be paying 72$ a month!! &lt;a href=&#34;https://www.linode.com/products/dedicated-cpu/&#34;&gt;Source&lt;/a&gt;. I do have other costs, namely electricity (I don&amp;rsquo;t have a good number for this, but with the CPU averaging 10% usage, I don&amp;rsquo;t think it&amp;rsquo;s massive), and internet (which I would pay for regardless). There is a good amount of money to be saved by having an old computer under your desk running your stuff.
- &amp;gt; I will counter myself though. I will end up upgrading this server, as self-hosting is very much a hobby (and an expensive one when you start playing with fancy hardware!)&lt;br&gt;
- Ownership. No one will take away this server from me. The data stored on it, is controlled by me, and not some giant corporation. This becomes important when it comes to personal data. Which I will talk about now.&lt;/p&gt;
&lt;h1 id=&#34;own-your-data&#34;&gt;Own your data&lt;/h1&gt;
&lt;p&gt;Self-hosting isn&amp;rsquo;t just for hosting projects, and outward facing services. Most of my time is spend on inward facing services. I&amp;rsquo;ve talked about services I host on the [Gitea post (https://johncosta.tech/blog/hello-gitea/), but to summarise, I have a lot of personal data from myself and my partner, which I would rather control rather than give it up to Google or Apple. A good example is my &lt;a href=&#34;https://immich.app&#34;&gt;Immich&lt;/a&gt; instance, which has all my photos, and these are terrabytes worth.&lt;/p&gt;
&lt;p&gt;In today&amp;rsquo;s age, it is important we all think about our personal data, who has control over it and who stands to profit from it. I don&amp;rsquo;t want to be training data for an LLM without my consent.&lt;/p&gt;
&lt;h1 id=&#34;learning-and-enjoyment&#34;&gt;Learning and Enjoyment&lt;/h1&gt;
&lt;p&gt;Most importantly, I just love tinkering with the server. I love staying up to date with new open source projects which you has host yourself, I love having little home automations that run on my own hardware (my office lights are controlled by a really single Go script and a WLED controller).&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve also learnt so much about server administration and DevOps. I&amp;rsquo;ve learnt a lot about observability, about hosting your own CI/CD, and how to know when things have gone wrong. I&amp;rsquo;ve also continued to learn about Linux, networking, and so many other things I would love have a chance to play with, unless I had my own server. You can argue that this is possible with a VPS, but really, where&amp;rsquo;s the fun in that?&lt;/p&gt;
&lt;h1 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;Self-hosting is really fun, you should try having an old computer under your desk running your stuff. You get a sense of accomplishment, for learning all you need to make it work, and to then manage it such that it continue to work. You will also be able to do things you never thought about doing, like hosting your own Netflix with &lt;a href=&#34;https://jellyfin.org&#34;&gt;Jellyfin&lt;/a&gt;, or having actual production services running  right next you, and managing your own database. I&amp;rsquo;ve really enjoyed it, and will continue to enjoy it for years to come.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Hello Gitea</title>
      <link>https://johncosta.tech/blog/hello-gitea/</link>
      <pubDate>Wed, 12 Mar 2025 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/blog/hello-gitea/</guid>
      <description>&lt;h1 id=&#34;tldr&#34;&gt;TLDR&lt;/h1&gt;
&lt;blockquote&gt;
&lt;p&gt;I use my own Gitea instance now! &lt;a href=&#34;https://git.johncosta.tech&#34;&gt;git.johncosta.tech&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Three days after I moved into my apartment, I bought a server. A small, fairly low power Fujitsu desktop, from facebook marketplace. Since then I&amp;rsquo;ve been really into self-hosting, so far I have.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://immich.app&#34;&gt;Immich&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://jellyfin.org&#34;&gt;Jellyfin&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://pi-hole.net&#34;&gt;Pi-hole&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://planka.app&#34;&gt;Planka&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://grafana.com&#34;&gt;Grafana&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And a couple of others.&lt;/p&gt;
&lt;p&gt;Point being, I&amp;rsquo;ve really enjoyed the journey of managing and using all these services. In the future I&amp;rsquo;ll write more in detail about my setup.&lt;/p&gt;
&lt;h1 id=&#34;gitea&#34;&gt;Gitea&lt;/h1&gt;
&lt;p&gt;I came across &lt;a href=&#34;https://about.gitea.com&#34;&gt;Gitea&lt;/a&gt;, and prompt closed it - surely GitHub is unbeatable, right? But it kept bugging me, but at the same time I thought.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It&amp;rsquo;s probably too hard to manage.&lt;/li&gt;
&lt;li&gt;SSH would be too weird.&lt;/li&gt;
&lt;li&gt;GitHub is just better.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I was wrong on all fronts.&lt;/p&gt;
&lt;p&gt;In fact, this might be the service I most enjoy using (although they are all pretty great). Having ownership over my code has felt good, and the WebUI is snappy and a pleasure to use, and because it&amp;rsquo;s self-hosted it&amp;rsquo;s super quick (I only have to go through LAN most of the time).&lt;/p&gt;
&lt;h2 id=&#34;but-github&#34;&gt;But GitHub?&lt;/h2&gt;
&lt;h3 id=&#34;open-source&#34;&gt;Open Source&lt;/h3&gt;
&lt;p&gt;I still believe GitHub is the best for open-source projects - it&amp;rsquo;s just more popular - and therefore much easier to people to contribute. But for private code? Or personal projects you don&amp;rsquo;t expect to have contributors to? Why not try another service?&lt;/p&gt;
&lt;h3 id=&#34;the-ai-problem&#34;&gt;The AI problem&lt;/h3&gt;
&lt;p&gt;GitHub was (and for the most part still is) an incredible service, but now it&amp;rsquo;s using it&amp;rsquo;s massive amounts of code to train AI, whether you want to or not. It&amp;rsquo;s perhaps not worth it to trade privacy for convinience anymore.&lt;/p&gt;
&lt;p&gt;I also do not trust a huge company (Microsoft), to not use my private repo&amp;rsquo;s to train AI.&lt;/p&gt;
&lt;h1 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;So far, I love Gitea. It&amp;rsquo;s super fast, incredibly easy to setup and manage, and it&amp;rsquo;s completely open source. And from now on, my personal projects and private projects will be self hosted. Check out &lt;a href=&#34;https://git.johncosta.tech&#34;&gt;git.johncosta.tech&lt;/a&gt; to view my public repo&amp;rsquo;s on there.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>The importance of loose coupling</title>
      <link>https://johncosta.tech/blog/the-importance-of-loose-coupling/</link>
      <pubDate>Wed, 05 Feb 2025 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/blog/the-importance-of-loose-coupling/</guid>
      <description>&lt;p&gt;Recently at work, I was faced with creating a system that needed to integrate between two very big modules of code. These two modules are practically our entire product at &lt;a href=&#34;https://decipad.com&#34;&gt;Decipad&lt;/a&gt;. And when you have to integrate such big parts of code, it might be tempting to do it, and test by running the server and click around in the browser (in this case, our product is a web app).&lt;/p&gt;
&lt;p&gt;However, I didn&amp;rsquo;t want to continue this pattern (we had some code that integrated these two systems, but in a heavily coupled way), and therefore I set about with a slightly different approach, and when I was done I had a much greater appreciation for interfaces (and higher order functions).&lt;/p&gt;
&lt;h2 id=&#34;the-problem&#34;&gt;The Problem&lt;/h2&gt;
&lt;p&gt;I need to pass information from one module (the &lt;code&gt;Editor&lt;/code&gt;), to another (the &lt;code&gt;Computer&lt;/code&gt;). I also need to keep some state, and do some comparisons.&lt;/p&gt;
&lt;p&gt;Let me illustrate what I wanted to achieve by writing some pseudocode, in a non-testable way.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;setup&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;computer&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;Computer&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;editor&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;Editor&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;void&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	&lt;span style=&#34;color:#a6e22e&#34;&gt;editor&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;on&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;some-event&amp;#39;&lt;/span&gt;, (&lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;		&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;proccessedEvent&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;processEvent&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;); &lt;span style=&#34;color:#75715e&#34;&gt;// Some function
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;		&lt;span style=&#34;color:#a6e22e&#34;&gt;computer&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;push&lt;/span&gt;({ ...&lt;span style=&#34;color:#a6e22e&#34;&gt;somethingComplicated&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;x&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;processedEvent&lt;/span&gt; });
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	});
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If I wanted to test this part of code, I would have to create an instance of both of these two modules. This isn&amp;rsquo;t the easiest approach, because the integration I needed would have to do some pretty heavy setup for tests, which would mean the test would mostly be boilerplate, not to mention unpredictable, as these two parts of code come with a huge amount of potentially buggy code.&lt;/p&gt;
&lt;p&gt;This is a simple enough function -  and at first -  it is tempting to just wire it together and move on, however, in my case I also needed to keep track of some state to avoid pushing to the computer too often.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;setup&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;computer&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;Computer&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;editor&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;Editor&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;void&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;state&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;new&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Map&lt;/span&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;string&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;,&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Event&lt;/span&gt;&amp;gt;();
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	&lt;span style=&#34;color:#a6e22e&#34;&gt;editor&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;on&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;some-event&amp;#39;&lt;/span&gt;, (&lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;		&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;proccessedEvent&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;processEvent&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;); &lt;span style=&#34;color:#75715e&#34;&gt;// Some function
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;		&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;existingEvent&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;state&lt;/span&gt;.&lt;span style=&#34;color:#66d9ef&#34;&gt;get&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;		&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;someComparison&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;existingEvent&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;			&lt;span style=&#34;color:#a6e22e&#34;&gt;computer&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;push&lt;/span&gt;({ ...&lt;span style=&#34;color:#a6e22e&#34;&gt;somethingComplicated&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;x&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;processedEvent&lt;/span&gt; });
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;			&lt;span style=&#34;color:#a6e22e&#34;&gt;state&lt;/span&gt;.&lt;span style=&#34;color:#66d9ef&#34;&gt;set&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;		}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	});
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This function still looks fairly innocent, but you can see the growing complexity. In order to test in isolation that my state mechanism works, I would need to setup an entire editor, an entire computer and then I would have to use this event system through the editor in order to test my function. This might be OK in an integration test where you want to test groups of systems, but as a unit test to test the individual logic of this function, it isn&amp;rsquo;t ideal.&lt;/p&gt;
&lt;h2 id=&#34;only-use-what-you-need&#34;&gt;Only use what you need&lt;/h2&gt;
&lt;p&gt;I don&amp;rsquo;t want to pass the whole computer and the whole editor to this function. Instead a better approach that would allow me to test this in a much better way, is to instead pass an event emitted (or some other interface), and instead of the computer, I could pass a higher order function. This way I no longer need an editor or a computer to test this code.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;setup&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;onEventChange&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;Event&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;void&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;eventEmitter&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;EventEmitter&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;state&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;new&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Map&lt;/span&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;string&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;,&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Event&lt;/span&gt;&amp;gt;();
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	&lt;span style=&#34;color:#a6e22e&#34;&gt;eventEmitter&lt;/span&gt;((&lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;		&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;proccessedEvent&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;processEvent&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;); &lt;span style=&#34;color:#75715e&#34;&gt;// Some function
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;		&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;existingEvent&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;state&lt;/span&gt;.&lt;span style=&#34;color:#66d9ef&#34;&gt;get&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;		&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;someComparison&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;existingEvent&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;			&lt;span style=&#34;color:#a6e22e&#34;&gt;onEventChange&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;			&lt;span style=&#34;color:#a6e22e&#34;&gt;state&lt;/span&gt;.&lt;span style=&#34;color:#66d9ef&#34;&gt;set&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;		}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	});
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can even go a step further and remove the events all together by returning another higher order function, this way your function doesn&amp;rsquo;t have to deal with &lt;code&gt;EventEmitter&lt;/code&gt;, but instead with only &lt;code&gt;Event&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;setup&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;onEventChange&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;Event&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;void&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;state&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;new&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Map&lt;/span&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;string&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;,&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Event&lt;/span&gt;&amp;gt;();
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;Event&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;		&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;proccessedEvent&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;processEvent&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;); &lt;span style=&#34;color:#75715e&#34;&gt;// Some function
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;		&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;existingEvent&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;state&lt;/span&gt;.&lt;span style=&#34;color:#66d9ef&#34;&gt;get&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;		&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;someComparison&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;existingEvent&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;			&lt;span style=&#34;color:#a6e22e&#34;&gt;onEventChange&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;			&lt;span style=&#34;color:#a6e22e&#34;&gt;state&lt;/span&gt;.&lt;span style=&#34;color:#66d9ef&#34;&gt;set&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;		}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;	};
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now this function has been boiled down to it&amp;rsquo;s main purpose, to perform some action when an event has changed based on some state. You can then test this code very easily like this&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;const emittedEvents = [];

const eventHandler = setup((event) =&amp;gt; emittedEvents.push(event));

eventHandler({ ...event1 });
eventHandler({ ...event2 });

expect(emittedEvents).toMatchObject([...whatever you want])
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This way, our tests can focus on the fundamentals, and for the future they can easily show another programmer what the test is focusing on, rather than have them looking at a tone of boiler place. This test will also run a lot faster than if you have to do a tone of setup, although I don&amp;rsquo;t think this is a huge priority.&lt;/p&gt;
&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;It may be difficult to not reach for the solution straight away, as I mentioned the first function I showed is fairly simple and easy to understand, but it isn&amp;rsquo;t testable, and it is heavily coupled.&lt;/p&gt;
&lt;p&gt;When you&amp;rsquo;re programming a solution, think about what you&amp;rsquo;re trying to achieve with a specific function, or a specific module, and try and work out the best interfaces and parameters to give this function. A good rule of thumb that I&amp;rsquo;ve started using is figuring out how I&amp;rsquo;d like to test the code, and what I&amp;rsquo;d like the tests to show, this can lead you to a solution fairly quickly.&lt;/p&gt;
&lt;p&gt;This isn&amp;rsquo;t new of course, all I&amp;rsquo;ve talked about has been established in software engineering for decades (I&amp;rsquo;ve sort of described dependency injection, and interfaces), but it is interest when we see these best practices in our code, and it&amp;rsquo;s exciting to see why they work, it makes programming much more fun for me, because I don&amp;rsquo;t have to keep a massive amount of information in my head (the editor and the computer), but can instead focus on what is right in front of me.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Advent of Code</title>
      <link>https://johncosta.tech/projects/advent-of-code/</link>
      <pubDate>Thu, 28 Nov 2024 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/projects/advent-of-code/</guid>
      <description>&lt;p&gt;Git Repo: &lt;a href=&#34;https://git.johncosta.tech/JohnCosta27/AdventOfCode/&#34;&gt;https://git.johncosta.tech/JohnCosta27/AdventOfCode/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m a massive fan of the Advent of Code, I have created a big mono repo of all the years solutions.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>The year of the Camel - Advent of Code 2024</title>
      <link>https://johncosta.tech/blog/the-year-of-the-camel-advent-of-code-2024/</link>
      <pubDate>Thu, 28 Nov 2024 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/blog/the-year-of-the-camel-advent-of-code-2024/</guid>
      <description>&lt;h2 id=&#34;tldr&#34;&gt;TLDR;&lt;/h2&gt;
&lt;p&gt;I will be doing the advent of code in Ocaml this year.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve been doing the advent of code since I found out about it in 2019. It&amp;rsquo;s been an exercise that has me reflecting on my growth and development as an engineer, and taken me through many stages in life.&lt;/p&gt;
&lt;h1 id=&#34;2019-the-first-year&#34;&gt;2019. The first year.&lt;/h1&gt;
&lt;p&gt;In 2019, when I first started the challenge, I only completed 4 days. At the time I was in my second year of &lt;a href=&#34;https://en.wikipedia.org/wiki/Sixth_form&#34;&gt;Sixth form&lt;/a&gt;, and had gathered some proficiency in Java, which was the language of choice for my school. However, I did these 4 days in JavaScript and Node.js, as during extra curricular programming clubs, we had been taught JavaScript for game development, where we used it to develop simple 2D games on an HTML canvas, and the more interesting part to me, creating servers using JavaScript, with the infamous Node.js.&lt;/p&gt;
&lt;p&gt;Little did I know at the time how much JavaScript and Node.js would shape my career, and although I have strong opinions about both of these tools, I cannot deny that they drove my passion for building things.&lt;/p&gt;
&lt;h1 id=&#34;2020-the-tryhard-year&#34;&gt;2020. The tryhard year.&lt;/h1&gt;
&lt;p&gt;In 2020, I was at home, like most university students were. At this point I was a first year at Royal Holloway studying Computer Science, where the language of choice for learning was also Java.&lt;/p&gt;
&lt;p&gt;I didn&amp;rsquo;t find the first year very challenging and being at home I felt even worst, so I look back to December of this year quite fondly, as during a time where I was mostly alone, and with little to do other than work (I had begun my private tutoring career), I spend most of my time doing the advent of code. I managed to stay in the race until day 20.&lt;/p&gt;
&lt;p&gt;This marked the start of something great. A love for programming I had previously kindled had now ignited. And from here on out I would spend most of my time behind a screen, typing away, at algorithm problems, and endless side projects.&lt;/p&gt;
&lt;p&gt;I have gone back to this year and nearly finished it (I currently sit at 47 stars). This was a very special one for me.&lt;/p&gt;
&lt;h1 id=&#34;2021-the-vim-year&#34;&gt;2021. The VIM year.&lt;/h1&gt;
&lt;p&gt;During my second year, I had less time to go deeper into the advent of code. However I still managed to go on until around day 12.&lt;/p&gt;
&lt;p&gt;The goal for this year was twofold. I had been loving Golang, having learnt it for a few side projects, and I would still pick this language most of the time. But the main goal wasn&amp;rsquo;t to complete a few days with Golang, it was to only code in VIM - and not some emulator - no, I had to use the terminal VIM, with very little thrills (although I did setup the LSP).&lt;/p&gt;
&lt;p&gt;I again look back on this time, because I knew little more than to go into insert mode and just use a keyboard normally. I started to pick up the more complicated keystrokes and some cool motions.&lt;/p&gt;
&lt;p&gt;I know use Neovim to develop, and for me, it is the best development setup. I am the most productive, and the most comfortable, when inside a terminal.&lt;/p&gt;
&lt;h1 id=&#34;2022--the-typescript-year&#34;&gt;2022.  The TypeScript year.&lt;/h1&gt;
&lt;p&gt;I had just started my internship at &lt;a href=&#34;https://decipad.com&#34;&gt;Decipad&lt;/a&gt;, where we use TypeScript for every part of the tech stack. And I had enjoyed it.&lt;/p&gt;
&lt;p&gt;I was quite a hold out on the TypeScript movement, I didn&amp;rsquo;t see why we needed it. I was more than happy to just use JavaScript and did so for a very long time (even during this period, I used JavaScript for my second year project&amp;rsquo;s frontend).&lt;/p&gt;
&lt;p&gt;It wasn&amp;rsquo;t a dislike for static typing, it was simply a matter of not enjoying bloat. To me, it felt weird that we would develop in a language, compile down to JavaScript, and then run said JavaScript. This I know see as a necessary evil, as JavaScript is so very difficult without types (at least on larger codebases).&lt;/p&gt;
&lt;p&gt;So I decided to use TypeScript, it was the tool I used for work, so I extended that to my leisure. And it went great. I managed to until day 16, where I stopped as work was ramping up, and I had been put into difficult positions at work, to solve difficult challenges.&lt;/p&gt;
&lt;h1 id=&#34;2023-the-zig-and-youtube-year&#34;&gt;2023. The Zig and YouTube year.&lt;/h1&gt;
&lt;p&gt;This year I took it to another level. I had learnt some Zig and completed a simple implementation of &lt;a href=&#34;https://johncosta.tech/projects/huffmanz/&#34;&gt;Huffman Encoding&lt;/a&gt;, but I wanted to learn more about this language. I also wanted to continue working on my &lt;a href=&#34;https://www.youtube.com/@johncosta27/featured&#34;&gt;YouTube Channel&lt;/a&gt;, something I enjoyed whilst working as a tutor.&lt;/p&gt;
&lt;p&gt;So, everyday I would sit behind the monitor and record myself walking through the problem in a language that is quite difficult. This took a lot of time and dedication. And I would slow down around day 12, but would periodically post a video. I believe I managed 34 stars during December, and throughout this year, I have gone back and finished off the ones I didn&amp;rsquo;t manage to do at a time. With most of them being on YouTube as well.&lt;/p&gt;
&lt;p&gt;After a year of on and off work on it, I finally finished an entire calendar of the advent of code. All 50 stars.&lt;/p&gt;
&lt;p&gt;This grew my following a fair chunk to 160 subscribers, and I managed over 1k views on the day 1 video, which is pretty fun.&lt;/p&gt;
&lt;h1 id=&#34;2024-the-year-of-the-camel&#34;&gt;2024. The year of the Camel.&lt;/h1&gt;
&lt;p&gt;Throughout my time as an engineer, I have always written in imperative-like languages (Java, JavaScript/Typescript, Golang, Zig), and I lack functional experience.&lt;/p&gt;
&lt;p&gt;During my last year of university, I had learnt Haskell. It wasn&amp;rsquo;t an extensive course but it was enough to be familiar with the concepts of a functional language. I got enough of a taste to understand why functional languages are an important skill, even if you don&amp;rsquo;t use them in your day to day life.&lt;/p&gt;
&lt;p&gt;I have also enjoyed listening to Jane Street&amp;rsquo;s Podcast - &lt;a href=&#34;https://signalsandthreads.com&#34;&gt;Signals and Threads&lt;/a&gt;, where a variety of extremely impressive and interesting engineers talk about Ocaml, from using it in their day to day work, but also from their Compiler&amp;rsquo;s team. These episodes still feel like action movies to me.&lt;/p&gt;
&lt;p&gt;My best grade at university was in my Compilers module, taught by &lt;a href=&#34;https://pure.royalholloway.ac.uk/en/persons/elizabeth-scott&#34;&gt;Elizabeth Scott&lt;/a&gt;, who&amp;rsquo;s teaching style and expertise has made me so fascinated by compilers. I achieved an 88% in her class, with my best exam result at university of around 93%.&lt;/p&gt;
&lt;p&gt;For this reason I want to explore different languages, understand their syntax choices and the different perspectives an engineer must deal with when faced with functional ML-style languages.&lt;/p&gt;
&lt;p&gt;Another professor of mine, Dave Cohen, often said &amp;ldquo;If you learn another language, you will become better in both&amp;rdquo;. He was refering to learning SVN alongside Git, but the quote still applied everywhere else, and I completely agree with him.&lt;/p&gt;
&lt;p&gt;For these reasons, I will do the advent of code in Ocaml this year.&lt;/p&gt;
&lt;p&gt;Ocaml is a functional language, similar to Haskell, but a little less hardcore (and actually used in the real world ;) ). It has an impressive community, incredible tooling and a syntax that is not so restrictive if you want to write simpler code. Making it a great stepping stone.&lt;/p&gt;
&lt;p&gt;I will also be recording my attempts to YouTube, where you will be able to watch me stumble over myself many times. I hope to see you there.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Moving Out</title>
      <link>https://johncosta.tech/blog/moving-out/</link>
      <pubDate>Mon, 18 Nov 2024 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/blog/moving-out/</guid>
      <description>&lt;p&gt;On the 29th of October 2024, after 7 months, I finally moved into the apartment that me and my girlfriend [[Rio]] bought. This is the first time that me or her have lived on our own.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;d like to talk about my experience, how it affected me, what went well, what went wrong, and how I&amp;rsquo;m doing after 3 weeks. And how Woking is treating me.&lt;/p&gt;
&lt;h1 id=&#34;the-process&#34;&gt;The Process&lt;/h1&gt;
&lt;p&gt;As anyone experienced with buying flats in the UK, then you know the process takes a very long time, and 7 months is somewhat normal. I won&amp;rsquo;t get into too many details, but there is a lot of paperwork needed, from a lot of different people.&lt;/p&gt;
&lt;p&gt;This challenged me a lot mentally. I found myself in limbo, unsure of when I would get out. I really enjoyed living with my mum, and I can&amp;rsquo;t complain about my time at home. I was treated with respect as an adult, which I thank my mum and her partner for massively. Nevertheless, the mental strain on not knowing when the buying process would finalise and when me and Rio would move in, was though. I started seeing a therapist to help with this and other aspects of my life, I did so for about 5 months, and I recommend anyone who is struggling mentally to seek help if help is available, luckily I didn&amp;rsquo;t have serious problems, but I was still able to work through them, and now feel better equipped to deal with various wonders of life.&lt;/p&gt;
&lt;p&gt;Limbo wasn&amp;rsquo;t the only feeling however. Pressure was a big one too.&lt;/p&gt;
&lt;p&gt;As readers know, buying property requires a mortgage and a deposit. This deposit in my case was 10% of the total value. I&amp;rsquo;ve been fortunate in life and I&amp;rsquo;ve work since I was 16. I worked throughout my entire time at university, through tutoring and software projects, and the internship at Decipad in my third year. [As I side note, I feel extremely grateful to all the opportunities presented to me, and I&amp;rsquo;m quite proud of myself for all that work, it wasn&amp;rsquo;t easy at times, but it paid off (this sounds really vain, I really don&amp;rsquo;t mean it that way).]&lt;/p&gt;
&lt;p&gt;I have also worked full-time at Decipad since I graduated in May 2023, which again, helped me save the required money for the down deposit, legal costs, and moving in costs (furniture, and stuff like that).&lt;/p&gt;
&lt;p&gt;This is by far the biggest financial decision I&amp;rsquo;ve made in my life, and it comes with pressure. It is something I&amp;rsquo;ve wanted to do, and have had in my head for quite sometime, which helps. But the pressure is still there (even today). I have a mortgage now.&lt;/p&gt;
&lt;h1 id=&#34;moving-in&#34;&gt;Moving In&lt;/h1&gt;
&lt;p&gt;We exchanged on a Thursday (24/10/2024) and completed on Tuesday (29/10/2024), leaving the weekend to pack. Me and Rio did so and on Tuesday, we hired a van. Which we used to pick up a sofa we had bought at the weekend, and grab the stuff from mine and her house.&lt;/p&gt;
&lt;p&gt;Around midday we went to the estate agent to actually pickup the keys, and go to the flat for the first time in 7 months. Going in is quite a surreal feeling, but a very happy one.&lt;/p&gt;
&lt;p&gt;Took us the whole afternoon, but we managed to move everything in. And we&amp;rsquo;ve been slowly unpacking ever since.&lt;/p&gt;
&lt;h1 id=&#34;living-alone-together&#34;&gt;Living alone (together)&lt;/h1&gt;
&lt;p&gt;Usually people say it&amp;rsquo;s a shock, I don&amp;rsquo;t feel it that way. I was quite used to cooking, cleaning and maintaining (at least part) of a home, so doing chores and keeping the place tidy, cooking meals has been one of the easier parts of the whole process. I find it pleasant (especially cooking), there&amp;rsquo;s something freeing about things not being done if you (or Rio) don&amp;rsquo;t do them.&lt;/p&gt;
&lt;h2 id=&#34;living-with-a-partner&#34;&gt;Living with a partner&lt;/h2&gt;
&lt;p&gt;This has been the best part. Me and Rio have been together since we were both 16, so around 7 years, and we click, and we continue to click once we moved in. There are certain aspects that took some communication, we&amp;rsquo;re different human beings after all, but I feel like we&amp;rsquo;re quite open about preferences and dislikes about the apartment.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s not perfect, but no two people living in the same place are. But I&amp;rsquo;m very happy with how we&amp;rsquo;re doing.&lt;/p&gt;
&lt;h1 id=&#34;working-in-woking&#34;&gt;Working (in Woking)&lt;/h1&gt;
&lt;p&gt;I work remotely the majority of my time (I sometimes go into our London office, which I&amp;rsquo;ll talk about below), and we specifically bought a 2 bedroom apartment so one of the bedrooms would become an office. We have two desks side by side, one for me and one for Rio.&lt;/p&gt;
&lt;p&gt;I get the most use out of this room since I&amp;rsquo;m the one who works from home, and it&amp;rsquo;s really n upgrade. I used to work in the same place I slept, which worked fine and carried me through university, but since I started working full-time, slowly I&amp;rsquo;ve been feeling worst and worst about my work situation. It was very hard to focus, and painful to disconnect. A dedicated room for work (or some leisure, video games mostly), is really great.&lt;/p&gt;
&lt;h1 id=&#34;woking&#34;&gt;Woking&lt;/h1&gt;
&lt;p&gt;I love this town. It feels busy without being overly busy. Almost everything I&amp;rsquo;d like is close by (looking at you Waterstones), and within walking distance. The parks, the people and the shops are all great, it&amp;rsquo;s a great place to live.&lt;/p&gt;
&lt;p&gt;Another reason I choose Woking is because it is a 25 minute train away from London. And I am 5 minutes away from the train station.&lt;/p&gt;
&lt;p&gt;There isn&amp;rsquo;t much else to say, I just really like this town.&lt;/p&gt;
&lt;h1 id=&#34;what-id-like-to-do-better&#34;&gt;What I&amp;rsquo;d like to do better&lt;/h1&gt;
&lt;p&gt;It is still early days, so I won&amp;rsquo;t beat myself up too much about these, but there are some points I&amp;rsquo;d like to improve upon.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Work after work, continue to build personal projects, do coding puzzles. Don&amp;rsquo;t fall into the trap of working, eating, sleeping repeat. Go to conferences, etc&amp;hellip;&lt;/li&gt;
&lt;li&gt;Exercise. I have started on this point, but it is one I really want to get better at, I want to continue with Judo, and become good and physically fit.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;That&amp;rsquo;s it so far. I&amp;rsquo;m sure I&amp;rsquo;ll come up with more but those are the two points I really want to focus on.&lt;/p&gt;
&lt;h1 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;I moved out to Woking, to an apartment me and Rio (my partner) bought together. And we&amp;rsquo;re both enjoying it a lot, the process has been difficult, expensive and stressful. But we are here, and the more interesting project starts, settling in, and developing ourselves as people, and as a couple.&lt;/p&gt;
&lt;p&gt;There are many things I want to do, and it very much feels like the end of an era, and the beginning of the next one.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;d like to thank a few people.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Rio, you have been nothing but amazing in everything. You&amp;rsquo;re the best partner I could ever ask for, and I&amp;rsquo;m truly grateful for you. I hope that we continue to bring out the best in each other, and live out the rest of our lives together.&lt;/li&gt;
&lt;li&gt;Mum, you&amp;rsquo;ve provided for me for 22 years. It is because of your solid foundations that I was able to push myself through school, college and then university. I couldn&amp;rsquo;t even begin to work hard if it wasn&amp;rsquo;t for your extreme effort to give me these opportunities.&lt;/li&gt;
&lt;li&gt;Stephen, Mum did most of the work but I&amp;rsquo;m not sure the last stretch would be possible without you. I lived at home all my time at university, and you helped provide a stable environment for me, where I got the grades and my first real job. Much of my professional and personal development is down to your help.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There are many more people that have helped me, so in no order here are the rest: Marcos, Henri, Marne, Mat, and the countless others. Thank you to all of you and every friend and family member I haven&amp;rsquo;t listen, you are all important.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Real Time Trading system</title>
      <link>https://johncosta.tech/projects/real-time-trading-system/</link>
      <pubDate>Sun, 17 Nov 2024 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/projects/real-time-trading-system/</guid>
      <description>&lt;ul&gt;
&lt;li&gt;Git Repo: &lt;a href=&#34;https://github.com/JohnCosta27/RealTimeTradingSystem&#34;&gt;https://github.com/JohnCosta27/RealTimeTradingSystem&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;YouTube video: &lt;a href=&#34;https://youtu.be/OlzLp7X_UnY&#34;&gt;https://youtu.be/OlzLp7X_UnY&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;During my final year at university, I developed a real time trading system as a way to explore distributed systems development.&lt;/p&gt;
&lt;p&gt;I built a modular architecture that enabled horizontal scaling, and implemented various strategies for speeding up the application.&lt;/p&gt;
&lt;p&gt;You can also check out my final report &lt;a href=&#34;https://github.com/JohnCosta27/RealTimeTradingSystem/blob/main/final_report.pdf&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Build a Second Brain - Tiago Forte</title>
      <link>https://johncosta.tech/books-and-tv/build-a-second-brain/</link>
      <pubDate>Thu, 06 Jun 2024 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/books-and-tv/build-a-second-brain/</guid>
      <description>&lt;p&gt;Now more than ever, people have to manage incredible amounts of information, and recall it at a moments notice.&lt;/p&gt;
&lt;p&gt;The cheer amount of data that most of us consume in our work and lives is the highest in human history.&lt;/p&gt;
&lt;p&gt;Tiago Forte&amp;rsquo;s book &lt;em&gt;Building a Second Brain&lt;/em&gt;, explains the need for a second brain, as well as guides into how you would implement your own system.&lt;/p&gt;
&lt;h1 id=&#34;what-is-it&#34;&gt;What is it?&lt;/h1&gt;
&lt;p&gt;A second brain is not a thing but a system. It is the collection of tools you use to store, organise and recall information from. It is also the information stored on those tools.&lt;/p&gt;
&lt;h1 id=&#34;why-do-you-need-it&#34;&gt;Why do you need it?&lt;/h1&gt;
&lt;p&gt;The famous quote from David Allen (Author of Getting Things Done) &lt;em&gt;&amp;lsquo;Your mind is for having ideas, not storing them&amp;rsquo;&lt;/em&gt;. You should not have to store all the information you deal with in your everyday life in your head, you simply won&amp;rsquo;t be able to.&lt;/p&gt;
&lt;p&gt;So we need to come up with a system to help us keep track of all the information, so that we can build on it and produce work from it.&lt;/p&gt;
&lt;h1 id=&#34;the-second-brain-methodology&#34;&gt;The Second Brain Methodology&lt;/h1&gt;
&lt;h2 id=&#34;code-capture-organise-distil-express&#34;&gt;CODE (Capture, Organise, Distil, Express)&lt;/h2&gt;
&lt;p&gt;Forte explains that the process you should take when using your Second Brain, is the following:&lt;/p&gt;
&lt;h2 id=&#34;capture&#34;&gt;Capture.&lt;/h2&gt;
&lt;p&gt;Write down things that you &lt;em&gt;vibe&lt;/em&gt; with, things that catch your interest or things that you think will be nice to look back on at a later time.&lt;/p&gt;
&lt;p&gt;Forte mentioned &lt;em&gt;The moment you first encounter an idea is the worst time to decide what it means&lt;/em&gt;. This stayed with me because it is very true, you often encounter things, make the decision that it is not important, and then move on with your life. Just to think about it in a week&amp;rsquo;s time and having no idea where you found it.&lt;/p&gt;
&lt;p&gt;You should capture things that make you stop and thing slightly. They will come back and be useful at some point.&lt;/p&gt;
&lt;p&gt;Forte mentions an idea from Richard Feynman, who said he keeps around 12 interesting problem floating around his head. Forte encourages you to sit down and think about what these problems are, and when you see something that loosely relates to one of them, you should capture it.&lt;/p&gt;
&lt;p&gt;Here are some of my interesting problems.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How can I work after my day job, without being tired or unmotivated?&lt;/li&gt;
&lt;li&gt;How can I be the best engineer I can possibly be?&lt;/li&gt;
&lt;li&gt;How to spend quality time with friends and family.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Perhaps mine are a bit too specific, but they are specific to my life, you might want to consider more broad problems instead.&lt;/p&gt;
&lt;h2 id=&#34;organise-the-para-system&#34;&gt;Organise. The PARA system.&lt;/h2&gt;
&lt;p&gt;PARA (Projects, Areas, Resources and Archive), is the &lt;em&gt;folder&lt;/em&gt; system Forte recommends.&lt;/p&gt;
&lt;h3 id=&#34;projects&#34;&gt;Projects&lt;/h3&gt;
&lt;p&gt;A folder containing all your active projects, from all areas of your life. This serves the main place in your second brain that you interact with day to day because it contains the most &lt;em&gt;actionable&lt;/em&gt; information, as well as actual pieces of work.&lt;/p&gt;
&lt;h3 id=&#34;areas&#34;&gt;Areas&lt;/h3&gt;
&lt;p&gt;More high-level than projects, these serve as things in your life that you actively thing about but aren&amp;rsquo;t projects. Some examples are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Finances.&lt;/li&gt;
&lt;li&gt;Hobbies / Sports (For me this is Judo).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Although these are not projects, they are things you probably think about quite frequently, and therefore deserve to have a folder to contains various bits of information.&lt;/p&gt;
&lt;p&gt;It is also often from here that projects spawn from, as you develop a more specific interest or goal from one of these areas.&lt;/p&gt;
&lt;h3 id=&#34;resources&#34;&gt;Resources&lt;/h3&gt;
&lt;p&gt;Reference material. Information that you don&amp;rsquo;t think about but information that needs a place to live. You can store pretty much anything here, as long as it is somewhat relevant to your projects or areas, or you think it will in the future.&lt;/p&gt;
&lt;p&gt;Here are some of my resources:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Books and Authors&lt;/li&gt;
&lt;li&gt;Restaurants&lt;/li&gt;
&lt;li&gt;Quotes&lt;/li&gt;
&lt;li&gt;Daily Notes&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is very general, and what I found myself doing is going through the folders inside &lt;em&gt;resources&lt;/em&gt; for inspiration, and thinking about how I can &lt;em&gt;distill&lt;/em&gt; this information into an interesting piece of work, or how I could use it in my current projects.&lt;/p&gt;
&lt;h3 id=&#34;archive&#34;&gt;Archive&lt;/h3&gt;
&lt;p&gt;Everything you don&amp;rsquo;t need to look at, probably ever again. However, you &lt;em&gt;might&lt;/em&gt;, so it is important to not delete it, just in case you need to look back at some stuff.&lt;/p&gt;
&lt;p&gt;It is also important because it gives you motivation to keep going. All your finished projects will end up in the Archive, and if you are ever feeling down or unproductive, you can look back in your archive to see how far you&amp;rsquo;ve come.&lt;/p&gt;
&lt;p&gt;The archive is also where I started my more structured second brain. I dumped every file I had in the Archive, and slowly took things out, and realised how many things I did not need to have lying around.&lt;/p&gt;
&lt;h2 id=&#34;distil&#34;&gt;Distil&lt;/h2&gt;
&lt;p&gt;The previous two sections were fairly familiar to me, even if I didn&amp;rsquo;t use the PARA system, I had &lt;em&gt;a&lt;/em&gt; system.&lt;/p&gt;
&lt;p&gt;But what my previous system was very bad at was enabling me to &lt;em&gt;Distil&lt;/em&gt;. The process of distilling something means looking at current information and breaking it down into smaller, more easily consumed chunks, so that your future self can look back and not have to do much work.&lt;/p&gt;
&lt;p&gt;Forte offers a technique called &lt;em&gt;Progressive Summarisation&lt;/em&gt;, where you highlight a bit of raw source material (let&amp;rsquo;s say a Wikipedia article), and you highlight the bits that are relevant, and then do it again. Until you have a very concise sentence of two which captures the entire article.&lt;/p&gt;
&lt;h2 id=&#34;express&#34;&gt;Express&lt;/h2&gt;
&lt;p&gt;Take your work, and create something presentable out of it. It is interesting to me that Forte choose to add this step as part of the process and not as a side-effect. But the more I thought about it, the more it made sense.&lt;/p&gt;
&lt;p&gt;Expressing your work is a crucial part of learning. One of the best ways to become better at something (at least for me), is to teach it to someone else. Not only that but other people might have incredibly valuable insights into your work and will help you make it better.&lt;/p&gt;
&lt;p&gt;There is only so much you can do when working alone, so it is important to share your work, and help others, and get help from others.&lt;/p&gt;
&lt;h1 id=&#34;my-own-system&#34;&gt;My Own System&lt;/h1&gt;
&lt;p&gt;I&amp;rsquo;ve talked about the book as a whole and the key lessons I have taken from it (although I have omitted some). I will now show you what my own system looks like.&lt;/p&gt;
&lt;h2 id=&#34;obsidianhttpsobsidianmd&#34;&gt;&lt;a href=&#34;https://obsidian.md&#34;&gt;Obsidian&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This is the champion of the entire system. I use other tools but this contains most information.
&lt;img src=&#34;https://johncosta.tech/obsidian_menu.png&#34; alt=&#34;Obsidian Menu&#34;&gt;&lt;/p&gt;
&lt;p&gt;There are two reasons why I choose Obsidian, not only as the best option, but in many ways &lt;em&gt;the only option&lt;/em&gt;.&lt;/p&gt;
&lt;h3 id=&#34;1-my-data&#34;&gt;1. My Data&lt;/h3&gt;
&lt;p&gt;Obsidian works on Markdown files (.md), which is a common, plain-text format. It has enough features to create rich text, and it is light enough so that it doesn&amp;rsquo;t annoy me.&lt;/p&gt;
&lt;p&gt;But the important thing is that these are my files, and they are no one elses, I have ownership over them, and can at any point transfer them to another app if I wanted to, of even edit the raw files themselves, I am not stuck to Obsidian, which in many ways is why I choose to use Obsidian.&lt;/p&gt;
&lt;p&gt;The other side of this is that I setup my own syncing solution using &lt;a href=&#34;https://syncthing.net&#34;&gt;Syncthing&lt;/a&gt; so that my laptop, tablet, desktop, phone and server all have the same files.&lt;/p&gt;
&lt;h3 id=&#34;2-community-plugins&#34;&gt;2. Community Plugins&lt;/h3&gt;
&lt;p&gt;The eco-system around Obsidian is increbible, and the plugins turn Obsidian into a complete solution for your second brain system.&lt;/p&gt;
&lt;p&gt;Here are some that I use.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://blacksmithgu.github.io/obsidian-dataview/&#34;&gt;Dataview&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/esm7/obsidian-map-view&#34;&gt;Mapview&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/delashum/obsidian-checklist-plugin&#34;&gt;Checklist&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A really powerful thing you can do with Dataview, is bringing tasks from across various files.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://johncosta.tech/tasks.png&#34; alt=&#34;Tasks&#34;&gt;&lt;/p&gt;
&lt;p&gt;This alone means that I no longer need a todo app or a project manager, because this is plenty for me.&lt;/p&gt;
&lt;p&gt;Mapview is also really useful so I can store all the places I have been to, and check what I thought about them. Here is an example from a recent trip to Barcelona.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://johncosta.tech/map.png&#34; alt=&#34;Map&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;raindrophttpsraindropio&#34;&gt;&lt;a href=&#34;https://raindrop.io&#34;&gt;Raindrop&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This is my bookmark manager. Whenever I go on a web page that I find interesting, I bookmark it to look back on later.&lt;/p&gt;
&lt;p&gt;Whilst Obsidian acts as my box of information for more abstract things, Raindrop is the system I use to store websites and links.&lt;/p&gt;
&lt;p&gt;It is very useful to then look back on them later, and mostly I organise and sort through my Raindrop when I&amp;rsquo;m out and only have my phone to keep me entertained. There I can read things I saved for later and sort links into certain folders.&lt;/p&gt;
&lt;h2 id=&#34;physical-notebook&#34;&gt;Physical Notebook&lt;/h2&gt;
&lt;p&gt;Along with all the digital tools, I also use an A5 notebook as my day book. Every day I write the date and day on the top of the right hand side page, and use that page and the one on the left, to keep notes about the day, more important tasks and anything I find cool.&lt;/p&gt;
&lt;p&gt;This is a life saver during workdays, because I often have to juggle a lot of information, so it&amp;rsquo;s good to keep a physical list I can look at.&lt;/p&gt;
&lt;p&gt;It is also very useful to look at the previous days, to check what you got through.&lt;/p&gt;
&lt;h2 id=&#34;other-tools&#34;&gt;Other Tools&lt;/h2&gt;
&lt;p&gt;There are many others I use to get work done, but they are less specific.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;GitHub - Keeps all my code.&lt;/li&gt;
&lt;li&gt;OBS - Software for screen recording and streaming.&lt;/li&gt;
&lt;li&gt;Arch Linux + KDE - My OS of choice, most of the defaults here are sensible and I find myself using KDE apps for a lot of things (PDFs, screenshots, etc&amp;hellip;).&lt;/li&gt;
&lt;li&gt;Syncthing - For keeping Obsidian in sync.&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;This book was extremely useful. It not only explains the need for a good system, but it is an incredible guide as to how someone can build this system.&lt;/p&gt;
&lt;p&gt;Forte is a very good writer, with many practical chapters focused directly at getting your work organised, with just the write amount of more abstract chapters to discuss the concept of a second brain.&lt;/p&gt;
&lt;p&gt;I highly recommend you read it yourself, even if you skip a bunch of chapter to just look at CODE, this is the best resource to learn about it.&lt;/p&gt;
&lt;p&gt;Rating: 8/10. e&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Sedated - By James Davies</title>
      <link>https://johncosta.tech/books-and-tv/sedated/</link>
      <pubDate>Sun, 02 Jun 2024 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/books-and-tv/sedated/</guid>
      <description>&lt;p&gt;Sedated is a book about mental health, and the increase is mental illness in recent years - and with that the increase in anti depressants and other psychoactive drugs.&lt;/p&gt;
&lt;p&gt;The books revolves around a question. &amp;lsquo;If we have increased anti-depressant usage, why are we seeing an increase in mental illness?&amp;rsquo;. Davies has two ways of answering the question.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Anti-depressants are not effective at treating depression.&lt;/li&gt;
&lt;li&gt;Our economic system increases the amount of people with mental illnesses.&lt;/li&gt;
&lt;/ol&gt;
&lt;h1 id=&#34;are-anti-depressants-a-lie&#34;&gt;Are anti-depressants a lie?&lt;/h1&gt;
&lt;p&gt;Davies presents some very convincing sources, coming up with the conclusion that long term use of anti depressants is almost always detrimental to the user, and even short term use is more often harmful than helpful. The withdrawal from these drugs is also a lot more brutal than the pharmaceutical companies states.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;So why do we use them so much?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&#34;the-expansion-of-mental-illnesses&#34;&gt;The expansion of mental illnesses.&lt;/h2&gt;
&lt;p&gt;There is a book called &lt;strong&gt;The Diagnostic and Statistical Manual of Mental Disorders&lt;/strong&gt;, it contains all the known mental disorders. Interestingly, the researchers who approve new entries onto this book are often funded by pharmaceutical companies - not only that but the bar required to constitute a mental disorder is really low.&lt;/p&gt;
&lt;p&gt;Almost every aspect of human personality can come down to a distorter, every single aspect of a persons emotions can be described by this book in some form of &lt;em&gt;disease&lt;/em&gt;. From this we can conclude a few things.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We have expanded the definition of mental disorder, to a point where it no longer means all that much.&lt;/li&gt;
&lt;li&gt;People with perfectly normal personality traits will now be described as mentally ill.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And who wins with all the over-diagnosing?&lt;/p&gt;
&lt;h2 id=&#34;big-pharma-and-privatised-suffering&#34;&gt;Big Pharma and privatised suffering.&lt;/h2&gt;
&lt;p&gt;We live in a Neo-liberal society, the Chicago School of thought. We allow markets to do what they want with minimal government restriction. Because of this freedom, companies were able to privatise suffering.&lt;/p&gt;
&lt;p&gt;We can now buy anti-depressants, to cure the suffering and therefore making money if people are worst off mentally.&lt;/p&gt;
&lt;p&gt;Not at all surprisingly, most research that promotes the use of anti-depressants, come out of the research sponsored or conducted by the very companies that manufacture the drugs. The research is often very shaky as well, if not just outright wrong.&lt;/p&gt;
&lt;p&gt;This is not to say that the use of anti-depressant is never justified, it is simply stating that many powerful companies benefit if we constantly consume the drugs, for a long time, therefore lowering the barrier to entry is an important goal for them (even if they&amp;rsquo;ll never say it is).&lt;/p&gt;
&lt;h2 id=&#34;it-is-your-fault&#34;&gt;It is your fault.&lt;/h2&gt;
&lt;p&gt;This book doesn&amp;rsquo;t just talk about mental illness, it talks about the economic situations which give a rise to not just mental illnesses, but the expansion of this umbrella.&lt;/p&gt;
&lt;p&gt;If a person is stressed at work, or suffering from workplace dissatisfaction, it must because because they are not good at managing their time, socialising with co-workers, or doesn&amp;rsquo;t champion the mission of the company. It seems that, today, it is simply not good enough to say that you are dissatisfied with your work, there must be something wrong with you.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You must be suffering from depression or anxiety.&lt;/li&gt;
&lt;li&gt;Your attitude is incorrect and must be medicated and changed.&lt;/li&gt;
&lt;li&gt;It is simply, your fault.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We don&amp;rsquo;t dare question the atmosphere around us, we don&amp;rsquo;t ask. Is it that the workplace is toxic? Is it that the work feels meaningless? Is the commute not too long? These questions go unanswered, and to &lt;em&gt;cure&lt;/em&gt; you, you are medicated, to restore some mythical balance.&lt;/p&gt;
&lt;p&gt;Anti-Depressants have become a quick fix to get workers back to work, to allow people to bare the work they do, and it can never be the jobs fault, it must be the individual&amp;rsquo;s fault.&lt;/p&gt;
&lt;p&gt;This is one of the reasons for the rise of a type of therapy called CBT (Cognitive Behavioural Therapy). Although I appreciate this type of therapy, and it is useful in helping reshape negative thought patterns, it however shifts the blame to the individual. It&amp;rsquo;s your thoughts that are wrong, it&amp;rsquo;s you who is at fault and who must change and be medicated.&lt;/p&gt;
&lt;p&gt;The author made this point extremely well, I started noticing this pattern in many places, from government mental health policy, to NHS therapy. It is really quite concerning that individuals are no longer considered in the mental health debate, but only their usefulness as an economic contributor.&lt;/p&gt;
&lt;h1 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;I am quite concerned about the statistics. The number of adults in the UK who have taken anti-depressants in the last year is 25%. And this is not likely to slow down any time soon.&lt;/p&gt;
&lt;p&gt;How long can we go before we have people permanently our of work because they&amp;rsquo;ve had enough? And their body simply cannot take anymore?&lt;/p&gt;
&lt;p&gt;The rise in the number of people who do not work due to physical and mental disabilities has risen a lot in the last few decades, and I not in any way think that people have become softer, I think these are genuine cases of people becoming disabled because of a very harsh situation that we all go through.&lt;/p&gt;
&lt;p&gt;I don&amp;rsquo;t think that Anti-Depressants are bad, or that we are prescribing them to give money to Big Pharma, no. It is a quick fix, a get healthy quick scheme, but one that is extremely short sighted, the long term risks of constant consumption of these drugs will be much worst than the short term positive that people can get back to work.&lt;/p&gt;
&lt;p&gt;The book has made me question how we think about mental health, and generally I think we are moving in a &lt;em&gt;better&lt;/em&gt; direction, and being more open about it, specially in the workplace. But we must do more. We must stop prescribing anti-depressants as if they are candy, and use them only &lt;em&gt;after&lt;/em&gt; therapy has been tried. Therapy has been shown to be extremely effective when done for a few months. But therapy is more expensive than a few pills. I truly don&amp;rsquo;t know what the answer is.&lt;/p&gt;
&lt;p&gt;Gloomy conclusion, but a needed one. The world can be harsh, but we are richer than we have ever been, now more than ever we can tackle these problems now that almost everyone&amp;rsquo;s basic needs have been met. We can move on to solving these &lt;em&gt;first&lt;/em&gt; world problems.&lt;/p&gt;
&lt;p&gt;Thank you for coming to my TedTalk.&lt;/p&gt;
&lt;h2 id=&#34;rating&#34;&gt;Rating&lt;/h2&gt;
&lt;p&gt;I would give this a good 7.5/10.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>A tale of a new Software Engineer</title>
      <link>https://johncosta.tech/blog/a-tale-of-a-new-software-engineer/</link>
      <pubDate>Fri, 05 Apr 2024 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/blog/a-tale-of-a-new-software-engineer/</guid>
      <description>&lt;p&gt;It has been close enough to a year now that I have written code for a living. I&amp;rsquo;ve done engineering jobs before this (I interned at Deci, for a year during my 3rd year of Uni), but I wanted to reflect on a full year of full time work.&lt;/p&gt;
&lt;h1 id=&#34;background&#34;&gt;Background&lt;/h1&gt;
&lt;p&gt;I work at &lt;a href=&#34;https://Decipad.com&#34;&gt;Decipad&lt;/a&gt;. We make an Excel alternative using notebooks (similar to Jupyter), with powerful number crunching capabilities, powered by our own language (really!) and the language&amp;rsquo;s runtime, all tucked away by beautiful UI components.&lt;/p&gt;
&lt;p&gt;Another important note is that Decipad is a startup, when I first joined in July 2022, we were still in closed beta, but since we have opened to the product and we&amp;rsquo;re not actively marketing the product and trying to get some market fit, while still continuing to build the best product we can.&lt;/p&gt;
&lt;h1 id=&#34;lessons-learnt&#34;&gt;Lessons learnt&lt;/h1&gt;
&lt;p&gt;Over the last 2 years I have learned a ton. I learnt what newer engineers don&amp;rsquo;t think they will need to learn.&lt;/p&gt;
&lt;p&gt;Even before going into my internship, I was a competent coder. I loved building projects, working with friends to build something cool, solving the advent of code (at least partially) ever since 2020. So I wasn&amp;rsquo;t as green as some would think.&lt;/p&gt;
&lt;h2 id=&#34;maintaining--development&#34;&gt;Maintaining &amp;gt; Development&lt;/h2&gt;
&lt;p&gt;However, my experience never involved maintaining &lt;em&gt;other people&amp;rsquo;s code&lt;/em&gt;. Sure, I&amp;rsquo;d worked with other people on projects, but the code others produced was quite visible, and so it always felt like it was my code, and I understood it too. This really isn&amp;rsquo;t the case in a big project.&lt;/p&gt;
&lt;p&gt;Deci&amp;rsquo;s codebase is still the biggest I&amp;rsquo;ve worked on. Big enough so that I cannot know everything about the project. I can be aware of many moving parts, but I don&amp;rsquo;t instantly know how every part of the project works, which is what I was used to in previous projects.&lt;/p&gt;
&lt;p&gt;This forced me to &lt;em&gt;read code&lt;/em&gt;. To actually sit down and read code as if it&amp;rsquo;s a story. I spend a big majority of my first few weeks working at Deci (during my internship), just reading code.&lt;/p&gt;
&lt;p&gt;And this isn&amp;rsquo;t even exclusive to code in Deci&amp;rsquo;s codebase. As every JavaScript project, we have a ton of dependencies. So if I truly wanted to understand how the project worked on the whole, not just surface level, I had to again, sit down and read some &lt;em&gt;library code&lt;/em&gt;. Git clone those bad boys, and open up Neovim and just go through it.&lt;/p&gt;
&lt;p&gt;Apart from having to explore the codebase and read other people&amp;rsquo;s code, I had to learn to write code that fits the puzzle. If someone in the past wrote an API a certain way, I can&amp;rsquo;t just decide to write another part of code that has a different API for the sake of being different.&lt;/p&gt;
&lt;p&gt;This has a few levels to it, if a certain part of the code prefers to use &lt;code&gt;const func = () =&amp;gt; {}&lt;/code&gt;, then I won&amp;rsquo;t just start naming my functions &lt;code&gt;function AnotherFunc()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This isn&amp;rsquo;t to say that I can&amp;rsquo;t rip out code - refactoring is perhaps my favourite part of the job - but a refactor isn&amp;rsquo;t warranted if the only reason for it is &lt;em&gt;&amp;lsquo;I just don&amp;rsquo;t like it&amp;rsquo;&lt;/em&gt;.&lt;/p&gt;
&lt;h2 id=&#34;refactoring&#34;&gt;Refactoring&lt;/h2&gt;
&lt;p&gt;My favourite.&lt;/p&gt;
&lt;p&gt;Working on a large code base with more than 1 or 2 developers, with a product team that loves to change requirements, means that you have to constantly refactor code. This is normal, but if it isn&amp;rsquo;t done, then your development speed will come to a halt.&lt;/p&gt;
&lt;p&gt;I hadn&amp;rsquo;t really refactored on a big scale before. Why would I refactor personal projects if they usually only last a few months and the requirements are fairly clear from the start? Sure, you can move functions around, dependency inject and many others, but I never need to do 50+, 100+ file changed refactors, like I have at Deci.&lt;/p&gt;
&lt;p&gt;Refactorings are the unsung process of software engineering, methodologies like &lt;a href=&#34;https://en.wikipedia.org/wiki/Extreme_programming&#34;&gt;Extreme Programming&lt;/a&gt;, bake it into the development process, which I really like. But I work in an environment where everything needs to be shipped yesterday. This forces you as an engineer to make a decision.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Do I not refactor and have a slightly botched job?&lt;/li&gt;
&lt;li&gt;Refactor the code before adding the feature.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I used to be a 50/50 split when I first started work. Sometimes you do just want to get the feature done. What&amp;rsquo;s one more prop to this React component? A Boolean parameter to this function?&lt;/p&gt;
&lt;p&gt;As I&amp;rsquo;ve grown as an engineer, I&amp;rsquo;ve realized I&amp;rsquo;m a solid 20/85 split. I will refactor beforehand, if a refactor is needed. This is because if you get into the habit of not refactoring, then you are just giving yourself a headache to refactor a massively more difficult piece of code later down the line, or giving one of your colleagues that headache.&lt;/p&gt;
&lt;p&gt;Another reason I really like to refactor is more related to being part of a small dev team. We develop on trust, we trust team mates to do the best possible work, and will trust them to refactor the code if needed. But in a small team, it&amp;rsquo;s easy to not do it, and if you don&amp;rsquo;t do it, other&amp;rsquo;s might also not do it. Be the change you want to see in your development process. I noticed at Deci that the more I would refactor code whilst adding features, and suggesting potential refactors to other parts of the code, other engineers started having the same conversations, and shifting code around to better fit the objective.&lt;/p&gt;
&lt;h2 id=&#34;notes&#34;&gt;Notes&lt;/h2&gt;
&lt;p&gt;There are many more lessons learnt, but I feel like these two were the most important, here&amp;rsquo;s a list of others.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Communication with team is extremely important.&lt;/li&gt;
&lt;li&gt;Writing the correct amount of code for a PR so other&amp;rsquo;s don&amp;rsquo;t have a hard time reviewing it.&lt;/li&gt;
&lt;li&gt;Test and test again, and maybe one more time.&lt;/li&gt;
&lt;li&gt;I dislike React.&lt;/li&gt;
&lt;li&gt;Delete code that doesn&amp;rsquo;t fit purpose (comes under Refactoring).&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id=&#34;working-full-time&#34;&gt;Working full time&lt;/h1&gt;
&lt;p&gt;I don&amp;rsquo;t hear this talked about enough, but it&amp;rsquo;s a big shift going from studying full time (from the age of 4 to 21), to working full time. That&amp;rsquo;s 15 years of studying, now being replaced for work. And work is very different.&lt;/p&gt;
&lt;h2 id=&#34;routine&#34;&gt;Routine&lt;/h2&gt;
&lt;p&gt;I almost can&amp;rsquo;t believe that it&amp;rsquo;s been nearly a year since I finished university. The time just flew by. And part of this is the routine that comes with full time work.&lt;/p&gt;
&lt;p&gt;You start to notice days just disappear, sit down at 9am and suddenly its 6pm and you&amp;rsquo;ve written hundreds of lines of code, tested multiple features, talked to many people, and the work day is done. It&amp;rsquo;s crazy.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s not that I don&amp;rsquo;t enjoy the routine, I do. But I don&amp;rsquo;t enjoy feeling like a passanger in my own life, so I try and break it up by doing more things outside of work, to try and break up the work routine.&lt;/p&gt;
&lt;p&gt;I don&amp;rsquo;t want my days to just be:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Get up -&amp;gt; Work -&amp;gt; Eat -&amp;gt; Work -&amp;gt; Sleep&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;They should be more like&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Get up -&amp;gt; Work -&amp;gt; Eat/Read -&amp;gt; Work -&amp;gt; Do something fun -&amp;gt; Sleep&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The do something fun part is extremely important, because this part of the day between 6pm and 9pm can just evaporate. So you must take an active role in doing something, scheduling something for that time so it doesn&amp;rsquo;t fade away.&lt;/p&gt;
&lt;p&gt;You won&amp;rsquo;t want to, because you&amp;rsquo;ll be tired and want to rest, but you must. Otherwise you won&amp;rsquo;t do much else with life except work.&lt;/p&gt;
&lt;h1 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;I have learnt many things in my first year of full-time work. Most of them not coding related, but software engineering related.&lt;/p&gt;
&lt;p&gt;I have learn to communicate effectively, with the correct people.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;To track progress more aggressively so everyone in my team is aligned.&lt;/li&gt;
&lt;li&gt;To write code that can be modified later.&lt;/li&gt;
&lt;li&gt;To refactor when refactoring is needed.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;But I have also learnt softer skills:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Be kind to co-workers, they are stressed enough.&lt;/li&gt;
&lt;li&gt;Don&amp;rsquo;t blame, you fail together.&lt;/li&gt;
&lt;li&gt;Don&amp;rsquo;t be afraid to ask for help, you&amp;rsquo;ll save yourself a ton of time.&lt;/li&gt;
&lt;li&gt;Learn when to switch the computer off.&lt;/li&gt;
&lt;li&gt;Know which features are worth building for the business.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I look forward to many more years in this industry (hopefully), and will continue to aggressively learn as much as possible.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Extreme Programming Explained - A Review</title>
      <link>https://johncosta.tech/books-and-tv/xp-explained/</link>
      <pubDate>Mon, 04 Mar 2024 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/books-and-tv/xp-explained/</guid>
      <description>&lt;h1 id=&#34;a-brief-summary&#34;&gt;A brief summary&lt;/h1&gt;
&lt;p&gt;Extreme Programming is a way of writing software as a team. It&amp;rsquo;s main goal is to reduce the risk of changes, by building the entire framework around allowing change.&lt;/p&gt;
&lt;p&gt;No one knows what a software project should actually do at the start of its development. A client could sit for weeks and still be wrong about requirements. This is natural. You can only see what you actually need once you start making it.&lt;/p&gt;
&lt;p&gt;Instead of imposing harsh rules on new requirements, XP embraces new requirements as part of the process.&lt;/p&gt;
&lt;h2 id=&#34;4-variables-a-team-can-adjust&#34;&gt;4 Variables a team can adjust&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Cost&lt;/li&gt;
&lt;li&gt;Time&lt;/li&gt;
&lt;li&gt;Quality&lt;/li&gt;
&lt;li&gt;Scope&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;cost&#34;&gt;Cost&lt;/h3&gt;
&lt;p&gt;A little more money can make things go faster, but too much can be a problem. 10 Engineers? Good. 100? You might be shooting yourself in the foot&lt;/p&gt;
&lt;h3 id=&#34;time&#34;&gt;Time&lt;/h3&gt;
&lt;p&gt;More time = More quality and increase scope.&lt;/p&gt;
&lt;h3 id=&#34;quality&#34;&gt;Quality&lt;/h3&gt;
&lt;p&gt;Other methodologies might sacrifice quality (take shortcuts, no tests), but you only save yourself time in the very short term, in the long run this will &lt;em&gt;always&lt;/em&gt; come back to hurt you. XP doesn&amp;rsquo;t negotiate on quality.&lt;/p&gt;
&lt;h3 id=&#34;scope&#34;&gt;Scope&lt;/h3&gt;
&lt;p&gt;Which features do you actually need?&lt;/p&gt;
&lt;p&gt;Scope comes directly from requirements, knowing which features to build and how flexible they must be.&lt;/p&gt;
&lt;h2 id=&#34;4-xp-values&#34;&gt;4 XP Values&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Communication - Talk constantly between developers and client, so work out scope of features.&lt;/li&gt;
&lt;li&gt;Simplicity - The code that exists served the current scope and no more. Complexity is the enemy.&lt;/li&gt;
&lt;li&gt;Feedback - Between developers, clients and managers.&lt;/li&gt;
&lt;li&gt;Courage - To change what needs to be changed and speak up about problems, even if they are unconfortable.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;development-in-xp&#34;&gt;Development in XP&lt;/h2&gt;
&lt;h3 id=&#34;pair-programming&#34;&gt;Pair Programming&lt;/h3&gt;
&lt;p&gt;Beck says that any production code should be done with two programmers at one machine. Beck claims this creates a very high level of software because the programmers will hold each other accountable to writing good tests, writing them before the code, and writing just enough code to make the tests pass.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m not sure I agree this is correct, I&amp;rsquo;ve been in many pairing sessions where we both look guiltily at each other before writing some &lt;em&gt;bad&lt;/em&gt; code we know we will have to fix later, just to meet a deadline.&lt;/p&gt;
&lt;p&gt;I don&amp;rsquo;t disagree with Beck, but I don&amp;rsquo;t agree &lt;em&gt;all&lt;/em&gt; production code should be done by pairs. Some? Sure. But individual contributions are still great. That being said, I would gladly spend 30% of my development time pairing.&lt;/p&gt;
&lt;h3 id=&#34;testing---full-tdd&#34;&gt;Testing - Full TDD&lt;/h3&gt;
&lt;p&gt;No code before tests. No more code than the code needed for the tests to pass.&lt;/p&gt;
&lt;p&gt;This creates robust software, that is just as simple as the scope requires it to be.&lt;/p&gt;
&lt;p&gt;I completely agree with this, often writing tests is about me as a programmer writing a specification, not so much testing a feature works. This also creates a self imposed restriction, I&amp;rsquo;m just going to write code to make tests green, I&amp;rsquo;m not going to write more. Whereas if you don&amp;rsquo;t have tests, then you might get carried away writing code.&lt;/p&gt;
&lt;h3 id=&#34;constantly-refactor&#34;&gt;Constantly Refactor&lt;/h3&gt;
&lt;p&gt;If the system ever becomes more complicated than needed. Change it. This is possible because of &lt;em&gt;testing&lt;/em&gt; being done thoroughly throughout the project. Without these tests to aid refactoring, it would not be possible.&lt;/p&gt;
&lt;p&gt;The presence of good tests means you can change the entire architecture of the system, and still be satisfied that it will work.&lt;/p&gt;
&lt;h3 id=&#34;constant-integration&#34;&gt;Constant Integration&lt;/h3&gt;
&lt;p&gt;Your code should never sit for more than a few hours without being checked against the rest of the code in the project.&lt;/p&gt;
&lt;p&gt;As a way of writing software, I love XP. I think it nails it, when it comes to writing quality software. I mentioned I didn&amp;rsquo;t fully agree with the &lt;em&gt;pair programming&lt;/em&gt; take, but I don&amp;rsquo;t completely disagree with it either, I can see why (specially pre-2000s), this was such a good idea.&lt;/p&gt;
&lt;p&gt;Overall I think Version Control, and messaging platforms (discord, slack&amp;hellip;) have gotten so good, that there isn&amp;rsquo;t a need to even be in the same physical location (Beck even mentioned this in a recent blog post).&lt;/p&gt;
&lt;p&gt;But I see the need for present, interaction with other programmers.&lt;/p&gt;
&lt;p&gt;There are other attributes that relate to development in XP, such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Collective ownership - Everyone can change everything in the project.&lt;/li&gt;
&lt;li&gt;40-Hour workweek - A tired programmer is a bad programmer.&lt;/li&gt;
&lt;li&gt;Accepted responsibility - Tasks aren&amp;rsquo;t given, they are accepted.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;planning-with-xp&#34;&gt;Planning with XP&lt;/h2&gt;
&lt;p&gt;Beck refers to this as &lt;em&gt;the planning game&lt;/em&gt;. Where business people and programmers play a back and sort on what needs to be done, and what can be done&lt;/p&gt;
&lt;h3 id=&#34;business&#34;&gt;Business&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Scope&lt;/li&gt;
&lt;li&gt;Priority&lt;/li&gt;
&lt;li&gt;Composition of releases&lt;/li&gt;
&lt;li&gt;Dates of releases&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;programmers&#34;&gt;Programmers&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Estimates&lt;/li&gt;
&lt;li&gt;Consequences&lt;/li&gt;
&lt;li&gt;Process&lt;/li&gt;
&lt;li&gt;Detailed Scheduling&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The programmers will push back on business, specially on scope, and make business aware of the consequences of having certain features or not. This way everyone can come away happy, if both parties give some way to the other, the best possible sofware will be built.&lt;/p&gt;
&lt;h3 id=&#34;small-releases&#34;&gt;Small Releases&lt;/h3&gt;
&lt;p&gt;XP wants systems to be in production ASAP. A system in production is vastly different from one that is not, you simply cannot gather as much information if you are not in production.&lt;/p&gt;
&lt;p&gt;Because XP has a very high code standard (testing, refactoring), you can happy to make very big changes even &lt;em&gt;after&lt;/em&gt; you have released to production.&lt;/p&gt;
&lt;h1 id=&#34;thoughts&#34;&gt;Thoughts&lt;/h1&gt;
&lt;p&gt;This was a very brief overview of this book. Beck goes into detail about many other aspects of this methodology, but I think this mostly covers it.&lt;/p&gt;
&lt;p&gt;It is interesting how much of this is mainstream now. Constant Integration for example, I don&amp;rsquo;t see a project &lt;em&gt;without&lt;/em&gt; it. What more projects need is the focus on testing and refactoring.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s a hard sell for most, because in the short term it does slow you down, but overtime it speeds you up magnitudes. And in high-stress environments (which are most software jobs), a programmer is going to cave, and just not test or refactor code. This is both a management problem and an individual problem.&lt;/p&gt;
&lt;p&gt;I think XP isn&amp;rsquo;t so much a methodology to follow strictly, but a base for your own systems. It provides guidelines as to how you should plan your sprints (it does insist on sprints of 1-3 weeks), but how you plan them can be up to you. What doesn&amp;rsquo;t change it the discussion between business and development, and the constantly communication between programmers and the customer, so that we can incorporate any changes the customer might (will) want to make, into our sprints, without any risk.&lt;/p&gt;
&lt;p&gt;Really that&amp;rsquo;s all XP is about, not preventing change, but being ready for change, so that the risk of making a change is the same no matter when it&amp;rsquo;s made in the development process (or at least a very slow increase over time).&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Dune 2 - Review</title>
      <link>https://johncosta.tech/books-and-tv/dune-2-review/</link>
      <pubDate>Sun, 03 Mar 2024 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/books-and-tv/dune-2-review/</guid>
      <description>&lt;p&gt;Dune 2 shows us Paul Attreides rise to power, fulfilling the prophecy that a voice from the outer world shall come to Arrakis, and lead the Fremen. We witness Paul&amp;rsquo;s development and triumph over the Emperium, in an epic, stunning and near perfect movie.&lt;/p&gt;
&lt;p&gt;This review is overwhelmingly positive, I thoroughly enjoyed it. However, I am a big fan of the Dune books and its universe, so naturally I had very high hopes for the movie, given that the first one had stuck to the source material pretty well.&lt;/p&gt;
&lt;h1 id=&#34;overview&#34;&gt;Overview&lt;/h1&gt;
&lt;h2 id=&#34;pauls-development&#34;&gt;Paul&amp;rsquo;s Development&lt;/h2&gt;
&lt;p&gt;Paul starts his journey to become a Fedaykin (a fighter) for Sketch Tabr, under Stilgar. We witness him crossing the desert by himself, interacting with other Fremen and learning their ways. This part of the movie ends with Paul riding a sandworm, in one of the coolest scenes in any movie I&amp;rsquo;ve ever seen.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m not sure how I felt about this early part of the movie, I liked it, but the pacing felt wrong, almost too slow at parts. I can&amp;rsquo;t quite describe why I didn&amp;rsquo;t &lt;em&gt;fully&lt;/em&gt; enjoy this part of the movie, but I wouldn&amp;rsquo;t help the feeling that something was off.&lt;/p&gt;
&lt;h2 id=&#34;feyd-rautha&#34;&gt;Feyd-Rautha&lt;/h2&gt;
&lt;p&gt;Holy shit, this was incredible. The depth of this character was just breathtaking, it took what I knew about him from the book and made it 10 times better. Incredible character.&lt;/p&gt;
&lt;p&gt;The home world of the Harkonnen &lt;em&gt;Giedi Prime&lt;/em&gt;, perfectly depicts the cruelty we know and expect from them. A completely flooded, uncreative, dystopian city, with big buildings towering over the population, not to mention the lack of any plants and colour, to drain the very soul of anyone present. Incredible work. Honestly, this kinda of stole the show, it was so good.&lt;/p&gt;
&lt;h2 id=&#34;the-speech&#34;&gt;The Speech&lt;/h2&gt;
&lt;p&gt;When Paul goes South, he truly becomes the &lt;em&gt;Lisan Al-Gaib&lt;/em&gt;, leading the Fremen into battle, not by choice but by duty, showing every aspect of House Attreides in him.&lt;/p&gt;
&lt;h2 id=&#34;the-battle&#34;&gt;The Battle&lt;/h2&gt;
&lt;p&gt;Just so sick. They nailed the story (apart from The Baron&amp;rsquo;s death! I mention it later&amp;hellip;), this is very close to the way the book ends.&lt;/p&gt;
&lt;p&gt;Just amazing, when I first read this fight in the book, I did not even dream of this level of epicness.&lt;/p&gt;
&lt;p&gt;So that&amp;rsquo;s a little overview of the whole movie, fairly short I know, I don&amp;rsquo;t want to bore you too much.&lt;/p&gt;
&lt;p&gt;Here are some other aspects of the movie I felt worth it to mention.&lt;/p&gt;
&lt;h1 id=&#34;visually&#34;&gt;Visually&lt;/h1&gt;
&lt;p&gt;Stunning movie, absolutely stunning. They made Arrakis (Dune) look so much better than I imagined it looking. The mix between medieval customs and what I believe is Islamic inspired architecture used by the Fremen, was simply stunning. I have no doubt this was what Herbert (The author), had in mind when he wrote the book.&lt;/p&gt;
&lt;p&gt;The worms were still incredible, they nailed their size and ferosity. The scene where Paul first solo rides a worm really immersed me in the experience, as if I was going through exactly what Paul was, that third person angle they used through a chunk of the scene was incredible.&lt;/p&gt;
&lt;p&gt;The explosions from the attacks on the harvesters were very good, the tenacity of the Fremen on full display here, as well as the industrial scale at which Arrakis is being harvested.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;Atomics&lt;/strong&gt;. That was so sick. The explosion near Arraken, was just so good. With the following battle with the sandworms. I don&amp;rsquo;t need to say anything, I&amp;rsquo;ve never seen something quite like it.&lt;/p&gt;
&lt;p&gt;The way they completely nailed the &lt;em&gt;scale&lt;/em&gt; of things in this scene is something we don&amp;rsquo;t fully appreciate, but the size of the emperors troops, and the destruction caused by the bombs, on point.&lt;/p&gt;
&lt;h1 id=&#34;sound&#34;&gt;Sound&lt;/h1&gt;
&lt;p&gt;This made the movie for me, sitting in a cinema and having the epic music shake the entire room, just made the experience so good. Hans Zimmer delivers once again.&lt;/p&gt;
&lt;h1 id=&#34;the-story&#34;&gt;The Story&lt;/h1&gt;
&lt;p&gt;Ok, I had some thing sto say about this. I&amp;rsquo;ll preface by saying that I&amp;rsquo;m a massive fan of the Dune books, and therefore am biased to having Frank Herberts story told closer to the source material. I think most people who aren&amp;rsquo;t as into the books, or haven&amp;rsquo;t read them at all will probably not agree with me.&lt;/p&gt;
&lt;h2 id=&#34;religion&#34;&gt;Religion&lt;/h2&gt;
&lt;p&gt;This part was nailed by the movie, in a way that even the book didn&amp;rsquo;t make me think this deeply about it. How deeply religious the Fremen are, and how they live their entire lives waiting for the prophecy (which we know is Bene Gesserit tosh), really makes you appreciate the grand scheme of the universe of Dune. Hundreds of years the Fremen were sold lies, such that they could be controlled, in a fate of dramatic irony, the Bene Gesserit are the ones who suffer from their own doing, as Paul, assumes his position perfectly and counters the Status Quo of the sisterhood.&lt;/p&gt;
&lt;p&gt;The divide between Northern and Southern Fremen was also displayed very well here, with the fundamental south being much more extreme, even wanting Paul to slay Stilgar just so he could speak, as was tradition.&lt;/p&gt;
&lt;h2 id=&#34;presciense&#34;&gt;Presciense&lt;/h2&gt;
&lt;p&gt;This word isn&amp;rsquo;t mentioned in the movie (AFAIK), but it is the ability to see possibilities of the future, as well as being able to see the past clearly through genetic memories. (To be fair, this isn&amp;rsquo;t massively explored in the first dune book, I feel like I mostly understood what this meant in the third book &amp;ldquo;Children of Dune&amp;rdquo;, so really, can I fault the movie?).&lt;/p&gt;
&lt;p&gt;Paul&amp;rsquo;s abilities are shown throughout the movie, but the &lt;em&gt;threads&lt;/em&gt; of future possibilities is mentioned once, after Paul takes the &lt;em&gt;Water of life&lt;/em&gt;, and is talking to Jessica about his mind being open. Could they not have made a bigger deal about this? I feel like even the southern sietch scene, where Paul perfectly describes the past of a few Fremen, is a tad confusing if you aren&amp;rsquo;t told more about this principle. We don&amp;rsquo;t really see the past, as Paul saw it, which I feel is my biggest disappointment from this movie (don&amp;rsquo;t get me wrong, this movie is incredible, just listing a thing that made me feel a bit cheated).&lt;/p&gt;
&lt;p&gt;I really wished this ability of Paul&amp;rsquo;s was further explored, and why it&amp;rsquo;s such a big deal to the Fremen, and to the Bene Gesserit. We hear the words &lt;em&gt;Kwisatz Haderach&lt;/em&gt; being thrown around, but&amp;hellip; show me the past as Paul can see it! Show us Paul splitting the future! Show him eliminating possibilities! Show us! (Am I out of touch here?)&lt;/p&gt;
&lt;h2 id=&#34;alia&#34;&gt;Alia&lt;/h2&gt;
&lt;p&gt;Ok, I&amp;rsquo;ll admit. If the movie had added Alia (who in the books is born before the war), most people would probably be very confused as to why a new born (who very quickly becomes a 4 year old), is there? How do you even translate that into visual medium? So, I&amp;rsquo;m not complaining about it really.&lt;/p&gt;
&lt;p&gt;I will say two things:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The fact that Alia is preborn is shown well in the movie, Jessica can clearly talk to the daughter. What isn&amp;rsquo;t shown very well, is how Jessica and Alia can talk to past reverend mothers, and have their memories. The scene where Jessica drinks the &lt;em&gt;Water of live&lt;/em&gt;, could have explored this more, as well as why it&amp;rsquo;s a mistake to do it if Jessica is pregnant (&lt;em&gt;Abomination&lt;/em&gt;).&lt;/li&gt;
&lt;li&gt;Alia kills the Baron, not Paul. Yes, a 4 year old with the mind of a 20 year old and many past lives living in her brain, uses the &lt;em&gt;Gom Jabbar&lt;/em&gt; (poison needle we see being used by the Reverend Mother on Paul in the first movie, and later with Feyd-Rautha), to kill the Baron Harkonnen. I would have loved to see it, I get why they didn&amp;rsquo;t do it (how would you even do it?).&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;the-ending&#34;&gt;The Ending&lt;/h2&gt;
&lt;p&gt;The book ends with Jessica telling Chani not to worry about Paul taking Irulan for wife, because Jessica herself was a concubine not a wife, the marriage is purely political. I think they did Chani dirty with this, the book ends with positive note on their relationship.&lt;/p&gt;
&lt;p&gt;The movie explained the defiance of the Landsraad extremely well, and shows the reason why Paul start a Jihad, that takes the universe by storm, to cement his position as Emperor.&lt;/p&gt;
&lt;p&gt;Maybe you could do a bit more on &lt;em&gt;why&lt;/em&gt; the Landsraad don&amp;rsquo;t invade Dune, Paul says they have nukes pointed at the spice fields (is this accurate?) but why is that a big deal, and why does the Spacing Guild refuse to let anyone come down to the planet. Because they are &lt;em&gt;blind&lt;/em&gt; without the spice! And Paul can see all of this! Paul can see them with his Prescience powers!&lt;/p&gt;
&lt;h1 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;Amazing movie, almost perfect, I just like the book a lot and would have preferred to see some of the more intricate details from the story, but I get it - it probably would have made for a worst movie, so I&amp;rsquo;m not upset about it. (Although I sound it).&lt;/p&gt;
&lt;h2 id=&#34;rating-8810&#34;&gt;Rating: 8.8/10&lt;/h2&gt;
</description>
    </item>
    <item>
      <title>The book of five rings</title>
      <link>https://johncosta.tech/books-and-tv/the-book-of-five-rings/</link>
      <pubDate>Mon, 19 Feb 2024 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/books-and-tv/the-book-of-five-rings/</guid>
      <description>&lt;p&gt;A book written by a famous samurai, what a selling point.&lt;/p&gt;
&lt;p&gt;The amount of thought that went into Musashi&amp;rsquo;s thinking is impressive, and speaks volumes of this older culture.&lt;/p&gt;
&lt;p&gt;Separated by 5 main chapters - Earth, Water, Fire, Wind and Void. Each with their own teachings, Musashi presents the important of mindless and balance, and most importantly, the mental discipline needed in every area of life in order to be successful.&lt;/p&gt;
&lt;h1 id=&#34;earth&#34;&gt;Earth&lt;/h1&gt;
&lt;p&gt;Much like the literal Earth, this scroll provides a solid foundation for the rest of the book.&lt;/p&gt;
&lt;p&gt;The more important takeaways for me in this scroll are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Know your tools well, and have no preference for any. This highlights the importance in which Musashi&amp;rsquo;s places balance.&lt;/li&gt;
&lt;li&gt;Know your own skills and limitations, as well as the people around you, and your enemies.&lt;/li&gt;
&lt;li&gt;Understand and practice your own field tirelessly.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is very sound advice. My favourite passage from this chapter is perhaps&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Don&amp;rsquo;t do anything useless.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id=&#34;water&#34;&gt;Water&lt;/h1&gt;
&lt;p&gt;My key takeaway from this part of the book, is the importance of adaptability and fluidity in all things. You can&amp;rsquo;t get too accustomed to one tool (or in his case - a weapon).&lt;/p&gt;
&lt;p&gt;He also goes on to mention that most confrontations happen in the mind, where you must be prepared to think, before you are prepared to fight.&lt;/p&gt;
&lt;h1 id=&#34;fire&#34;&gt;Fire&lt;/h1&gt;
&lt;p&gt;This scroll talks a lot about direct confrontation (hence the name), and namely how you must seize opportunities when they arise and you mustn&amp;rsquo;t let go of them until you have achieved what you want.&lt;/p&gt;
&lt;p&gt;Some fairly brutal messages such as.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;ldquo;stomp&amp;rdquo; with a sword in such a way, that the opponent cannot make a second move.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It does still mention the need for stillness and calmness of mind in all things, even when &lt;em&gt;attacking someone with a katana&lt;/em&gt;.&lt;/p&gt;
&lt;h1 id=&#34;wind&#34;&gt;Wind&lt;/h1&gt;
&lt;p&gt;Here, there is big emphasis on the analysis and practising of other schools of thought. You shouldn&amp;rsquo;t get stuck in your own way of thinking, even if you know it is better. You should actively venture out and learn from others.&lt;/p&gt;
&lt;p&gt;Having said this, he also mentions you should learn their weaknesses, and ultimately, why your way is superior. If you end up concluding your way is not superior, then maybe you have some more serious thinking to do.&lt;/p&gt;
&lt;p&gt;There is also the idea of &amp;ldquo;no mind&amp;rdquo; in this chapter. (And throughout the book really).&lt;/p&gt;
&lt;p&gt;&amp;ldquo;no mind&amp;rdquo; is a state of eliminating exterior distractions as well as inner thoughts in order to focus on the task at hand. He highlights that this is incredibly hard to do, and takes a lot of practice - he supports this with a lot of Buddhist references, a theme throughout the book.&lt;/p&gt;
&lt;h1 id=&#34;void&#34;&gt;Void&lt;/h1&gt;
&lt;p&gt;A very small epilogue about his Zen influences, and how important it is to train the mind.&lt;/p&gt;
&lt;h1 id=&#34;thoughts&#34;&gt;Thoughts&lt;/h1&gt;
&lt;p&gt;I really enjoyed this book, it highlights a slightly different way of thinking about problems and distractions. Most books I have read about similar topics comes from Stoic writers, all from Europe.&lt;/p&gt;
&lt;p&gt;This more Zen way of thinking is very similar, yet quite different, and it has a much bigger emphasis on the understanding of oneself from within, whereas Stoics tend to live through their actions. Both are good.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>My first &#39;big&#39; project - Real Tutor</title>
      <link>https://johncosta.tech/projects/real-tutor/</link>
      <pubDate>Mon, 20 Nov 2023 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/projects/real-tutor/</guid>
      <description>&lt;p&gt;I made a YouTube video walking through this old project, looking at the features I made, and what the code looked like.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://youtu.be/0gqzGBTOJvI&#34;&gt;Video&lt;/a&gt;&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Interfaces &gt; Classes - A refactor story.</title>
      <link>https://johncosta.tech/blog/interfaces/</link>
      <pubDate>Sat, 18 Nov 2023 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/blog/interfaces/</guid>
      <description>&lt;h1 id=&#34;introduction&#34;&gt;Introduction&lt;/h1&gt;
&lt;p&gt;Recently I was tasked with making a sizeable change to my companies product. There were many parts to the change, but I will summarise the more important one.&lt;/p&gt;
&lt;h1 id=&#34;the-problem&#34;&gt;The Problem&lt;/h1&gt;
&lt;h2 id=&#34;userevents&#34;&gt;UserEvents&lt;/h2&gt;
&lt;p&gt;We have a chunk of code, let&amp;rsquo;s say a class called &lt;strong&gt;UserEvents&lt;/strong&gt;, this class (not a class, but it makes more sense if I describe it as one) does many things, and a lot of business logic, but it is self contained, by this I mean that is it not aware of other parts of the code.&lt;/p&gt;
&lt;p&gt;Importantly, this class has a method called &lt;code&gt;apply&lt;/code&gt;, a function that takes in events. It is used by the class to use these user events and actually apply them to the UI.&lt;/p&gt;
&lt;h2 id=&#34;eventcapture&#34;&gt;EventCapture&lt;/h2&gt;
&lt;p&gt;The &lt;strong&gt;EventCapture&lt;/strong&gt; is tasked with synching events from &lt;strong&gt;UserEvents&lt;/strong&gt; and the outside. It has to do two things:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Take events from &lt;strong&gt;UserEvents&lt;/strong&gt; and save them remotely.&lt;/li&gt;
&lt;li&gt;Take remote events (from other clients for example), and sync them with the local &lt;strong&gt;UserEvents&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is important to note, that every method that the &lt;strong&gt;UserEvents&lt;/strong&gt; class has, were extended onto this class. I usually dislike inheritance, but in this case it actually made some sense. (However, it wasn&amp;rsquo;t without cost, I&amp;rsquo;ll discuss it the problems faced below).&lt;/p&gt;
&lt;h2 id=&#34;implementation&#34;&gt;Implementation&lt;/h2&gt;
&lt;p&gt;The &lt;strong&gt;UserEvents&lt;/strong&gt; class extended the &lt;strong&gt;UserEvents&lt;/strong&gt; object, and took that important &lt;code&gt;apply&lt;/code&gt; function, and wrapped it so it was able to capture all the events that would go into that function, like so:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; { &lt;span style=&#34;color:#a6e22e&#34;&gt;apply&lt;/span&gt; } &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;userEvents&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;userEvents&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;apply&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;event&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#a6e22e&#34;&gt;trackUserEvents&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;event&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#a6e22e&#34;&gt;apply&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;event&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;};
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I don&amp;rsquo;t love this implementation, as I think it obfuscates what the &lt;code&gt;apply&lt;/code&gt; function actually is, and you become less confident in calling it. But I cannot deny that it did work well, for a long time without anyone needing to touch it.&lt;/p&gt;
&lt;h1 id=&#34;the-new-requirements&#34;&gt;The New Requirements&lt;/h1&gt;
&lt;p&gt;The new requirements made it so I would now need various &lt;strong&gt;UserEvents&lt;/strong&gt; objects, and this number would be determined by the user. This breaks the relationship that the &lt;strong&gt;EventCapture&lt;/strong&gt; has with &lt;strong&gt;UserEvents&lt;/strong&gt; because it now needs to account for multiple of them.&lt;/p&gt;
&lt;p&gt;Not only does it need to track all the events from different &lt;strong&gt;UserEvents&lt;/strong&gt; it needs to be able to forward remote events to the correct one locally.&lt;/p&gt;
&lt;h2 id=&#34;the-refactor&#34;&gt;The Refactor&lt;/h2&gt;
&lt;p&gt;At this point I decided the best way forward was to create a new class called &lt;strong&gt;Controller&lt;/strong&gt; (terrible name), which would intercept all the &lt;strong&gt;UserEvents&lt;/strong&gt; classes locally, and forward them to &lt;strong&gt;EventCapture&lt;/strong&gt;, meaning that &lt;strong&gt;EventCapture&lt;/strong&gt; does not need to know about who sent the event, it just needs to track it, as all the events were massaged by my &lt;strong&gt;Controller&lt;/strong&gt; class.&lt;/p&gt;
&lt;p&gt;Remote events would be sent from &lt;strong&gt;EventCapture&lt;/strong&gt; down into the &lt;strong&gt;Controller&lt;/strong&gt; class which would then figure out which &lt;strong&gt;UserEvents&lt;/strong&gt; it needs to forward events to.&lt;/p&gt;
&lt;p&gt;And so I did, the new architecture looked like this:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;                                                 /-- UserEvent
                                                /
Remote &amp;lt;----&amp;gt; EventCapture &amp;lt;----&amp;gt; Controller &amp;lt;- ---- UserEvent
                                                \
                                                 \-- UserEvent
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This worked great architectural wise (there were some bugs, but that&amp;rsquo;s for another story).&lt;/p&gt;
&lt;h2 id=&#34;the-problem-1&#34;&gt;The Problem&lt;/h2&gt;
&lt;p&gt;If you notice, I changed the &lt;strong&gt;EventCapture&lt;/strong&gt; class to deal with &lt;strong&gt;Controller&lt;/strong&gt; instead of &lt;strong&gt;UserEvent&lt;/strong&gt;. This is not great because &lt;strong&gt;Controller&lt;/strong&gt; does nothing by itself, it is a bridge between two other classes, so now I have tightly coupled &lt;strong&gt;EventCapture&lt;/strong&gt; and any sub modules to deal with &lt;strong&gt;Controller&lt;/strong&gt; classes, which are very different from &lt;strong&gt;UserEvent&lt;/strong&gt; classes.&lt;/p&gt;
&lt;p&gt;I had to change every test for &lt;strong&gt;EventCapture&lt;/strong&gt; and many dependent modules, as well as a lot of other code which assumed a certain structure.&lt;/p&gt;
&lt;h2 id=&#34;the-obvious-solution&#34;&gt;The Obvious Solution&lt;/h2&gt;
&lt;p&gt;Use. An. Interface.&lt;/p&gt;
&lt;p&gt;For some reason this completely skipped my brain when implementing this. All I had to do was create an interface that mimics &lt;strong&gt;UserEvent&lt;/strong&gt;, in this case the interface would have been as easy as:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;interface&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;EventEmitter&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#a6e22e&#34;&gt;apply&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;event&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;Event&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;void&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If the &lt;strong&gt;Controller&lt;/strong&gt; class implements this interface, I can change the &lt;strong&gt;EventCapture&lt;/strong&gt; to deal with &lt;strong&gt;EventEmitter&lt;/strong&gt; interfaces instead of concrete classes, meaning I can test it in a more isolated way, and remove this tight coupling which I created.&lt;/p&gt;
&lt;h1 id=&#34;the-conclusion&#34;&gt;The Conclusion&lt;/h1&gt;
&lt;p&gt;Interfaces rule. To keep your code nice and decoupled try and use common interfaces between modules/classes so you don&amp;rsquo;t end up having to refactor entire modules. This also improves the test ability of code massively.&lt;/p&gt;
&lt;p&gt;Isolated modules, that do one thing very well. Next time I know to think very hard, before adding another coupling between modules again.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Huffmanz - Huffman Encoding Implementation in Zig</title>
      <link>https://johncosta.tech/projects/huffmanz/</link>
      <pubDate>Thu, 21 Sep 2023 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/projects/huffmanz/</guid>
      <description>&lt;hr&gt;
&lt;ul&gt;
&lt;li&gt;Link to Repo: &lt;a href=&#34;https://github.com/JohnCosta27/Huffmanz&#34;&gt;https://github.com/JohnCosta27/Huffmanz&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Link to Video: &lt;a href=&#34;https://www.youtube.com/watch?v=D5l5GUuNXB8&amp;amp;ab_channel=JohnCosta&#34;&gt;https://www.youtube.com/watch?v=D5l5GUuNXB8&amp;amp;ab_channel=JohnCosta&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href=&#34;https://en.wikipedia.org/wiki/Huffman_coding&#34;&gt;Huffman Encoding&lt;/a&gt; is an algorithm for compressing text, using a binary tree to shorted the number of bits needed to represent each character. It&amp;rsquo;s one of the first algorithms I learned in Computer Science. I was 14 year old and in Year 9. But until recently it hadn&amp;rsquo;t crossed my mind again.&lt;/p&gt;
&lt;p&gt;Then I found out about &lt;a href=&#34;https://ziglang.org/&#34;&gt;Zig&lt;/a&gt;. A new(ish) language where you manage your own memory, and have access to an incredible compiler that support &lt;code&gt;comptime&lt;/code&gt;, it&amp;rsquo;s an amazing (and extremely fast) language.&lt;/p&gt;
&lt;p&gt;So I decided to learn both fully, and implemented a huffman encoding algorithm using the zig programming language. Up until this point I haven&amp;rsquo;t worked on a project in a language like zig, which requires memory management and everything that goes along with it. I have also never thought much about huffman encoding, but it&amp;rsquo;s a fairly simple algorithm so it was the perfect project to learn about this language.&lt;/p&gt;
&lt;p&gt;I won&amp;rsquo;t go into much detail about Huffman Encoding, you can find many tutorials that do it better than I ever could. But I will talk about what I think about Zig.&lt;/p&gt;
&lt;h2 id=&#34;zig---its-great&#34;&gt;Zig - It&amp;rsquo;s great&lt;/h2&gt;
&lt;p&gt;I&amp;rsquo;m not a big language connoisseur, I like things that work, that are simple and have a friendly syntax, so I happen to love (Golang)[https://go.dev/], it&amp;rsquo;s simple, robust and very fast. It&amp;rsquo;s also garbage collected which is a plus.&lt;/p&gt;
&lt;p&gt;I didn&amp;rsquo;t think I was going to be a big fan of Zig, my experience with C has been fine, but I haven&amp;rsquo;t loved it much, and I&amp;rsquo;ve never touched C++, but I really enjoyed it.&lt;/p&gt;
&lt;h3 id=&#34;some-things-i-liked&#34;&gt;Some things I liked&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;The compiler is fast, and extremely informative, I found that I didn&amp;rsquo;t need to go to the official documentation, the compiler knew what I was trying to do and often led me in the right direction.&lt;/li&gt;
&lt;li&gt;Using allocator objects to initialise various data structure is a very nice pattern, one that makes managing memory really not complicated.&lt;/li&gt;
&lt;li&gt;Comptime. Absolutely genious!&lt;/li&gt;
&lt;li&gt;No secret allocations (looking at you Rust!). You are in control of the allocations completely.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;some-things-i-didnt-like&#34;&gt;Some things I didn&amp;rsquo;t like&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;This isn&amp;rsquo;t a fairly criticism, because it&amp;rsquo;s a fairly new and evolving language, but the LSP isn&amp;rsquo;t the best, it&amp;rsquo;s very fast and when it works it works really well, but it seems to have been lacking some features. The one I missed the most was &lt;em&gt;hover&lt;/em&gt;, where you can ask the LSP what type something is, it sometimes worked but most of the time it got confused.&lt;/li&gt;
&lt;li&gt;Using comptime types and returning a struct from a function seems odd, but also the best way to achieve generic data structures, don&amp;rsquo;t love this pattern and there might be a better way. See the &lt;code&gt;heap.zig&lt;/code&gt; file in my repo to see what I&amp;rsquo;m talking about.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I would say I definitely would love to work more with Zig. It seems like the logical step forward for program that require the blazingly fast speed of no garbage collection. You can already see this happening in &lt;a href=&#34;https://bun.sh/&#34;&gt;Bun.js&lt;/a&gt;, which seems to have great speed advantages (sometimes) compared to Node.js or Deno (even though both are written in a low level language).&lt;/p&gt;
&lt;p&gt;Thank you for reading, if you would like to chat with me. You can email me at &lt;code&gt;johncosta027@gmail.com&lt;/code&gt;. Or visit my GitHub profile.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Xml Parser</title>
      <link>https://johncosta.tech/projects/xmlparser/</link>
      <pubDate>Thu, 27 Jul 2023 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/projects/xmlparser/</guid>
      <description>&lt;hr&gt;
&lt;ul&gt;
&lt;li&gt;Git Repo: &lt;a href=&#34;https://github.com/JohnCosta27/GoXmlParser&#34;&gt;Here&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;During my time at university I took a compilers module, it turned out to be my favourite module out of all my 3 years at university, and I had the privilege of being taught by &lt;a href=&#34;https://pure.royalholloway.ac.uk/en/persons/elizabeth-scott&#34;&gt;Elizabeth Scott&lt;/a&gt;, one of the creators of &lt;a href=&#34;https://www.cs.rhul.ac.uk/research/languages/csle/GLLparsers.html&#34;&gt;GLL Parsers&lt;/a&gt;, a parsing algorithm that can parse any context free grammar, it&amp;rsquo;s very cool.&lt;/p&gt;
&lt;p&gt;I did very well in this module, and I really enjoyed it, but it was heavily theoretical, with little to no practical work. This is fine, it taught me a lot of parsing algorithms, and everything I know about grammars and languages.&lt;/p&gt;
&lt;p&gt;So I decided to give it a go and actually write one!&lt;/p&gt;
&lt;h1 id=&#34;xml-like&#34;&gt;XML (like)&lt;/h1&gt;
&lt;p&gt;I decided to parse a XML like language. You are probably mostly familiar with XML from its use in HTML.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-html&#34; data-lang=&#34;html&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;hello&lt;/span&gt;&amp;gt;World&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;hello&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You have an opening tag, some content in the middle, and a closing tag. However it can get more complicated than that.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-html&#34; data-lang=&#34;html&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;hello&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;hello&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;world&amp;#34;&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  Some text here
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;a&lt;/span&gt;&amp;gt;&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;a&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  dsamkdsamdkas
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;b&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;attribute&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;dksoadisma&amp;#34;&lt;/span&gt; /&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;hello&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As you can see, we can have nested structures, attributes on tags, and self closing tags.&lt;/p&gt;
&lt;h1 id=&#34;building-the-parser&#34;&gt;Building the Parser&lt;/h1&gt;
&lt;p&gt;I used Golang to build the parser, it&amp;rsquo;s a language that is familiar to me, extremely permanent and a delight to use.&lt;/p&gt;
&lt;p&gt;I decided to use recursive descent to build the parser, as XML is fairly easy to parse this way, and it becomes less complicated to start my compiler journey using this technique. From my compilers module I knew how to generate recursive descent parsing functions even if I was blind folded for any grammar, so this shouldn&amp;rsquo;t be hard&amp;hellip; Right?&lt;/p&gt;
&lt;h2 id=&#34;what-i-learnt&#34;&gt;What I learnt&lt;/h2&gt;
&lt;h3 id=&#34;theory--practice&#34;&gt;Theory != Practice&lt;/h3&gt;
&lt;p&gt;Even though I knew how to generate RDP (Recursive descent parsers), I was always given a grammar to start from. But this was a different problem, I have to create a grammar that cannot be left recursive (RDP limitation), and would parse without ambiguity.&lt;/p&gt;
&lt;p&gt;This turned our harder than I thought, because it&amp;rsquo;s a task that can be done in millions of different ways. In the end I settled for the following grammar.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Element ::= OpenTag ElementSuffix
OpenTag ::= &amp;#39;&amp;lt;&amp;#39; NAME Attributes
Attributes ::= NAME &amp;#39;=&amp;#39; STRING Attributes | EPSILLON
ElementSuffix ::= &amp;#39;/&amp;gt;&amp;#39; | Content CloseTag
Content ::= DATA Content | Element Content | EPSILLON
CloseTag ::= &amp;#39;&amp;lt;/&amp;#39; NAME &amp;#39;&amp;gt;&amp;#39;

// Literals
DATA = All the content between &amp;#39;&amp;gt;&amp;#39; and &amp;#39;&amp;lt;&amp;#39;
NAME = A continuous string of alphabetical characters
STRING = Content inside (and including) &amp;#34;&amp;#34;
EPSILLON = null
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This seems like a good grammar. It allows for all the XML structures we are used to seeing, and it also seemed to have the right mix of parser and lexer complexity. I&amp;rsquo;ll explain what I mean by this.&lt;/p&gt;
&lt;h3 id=&#34;lexer-vs-parser&#34;&gt;Lexer vs Parser&lt;/h3&gt;
&lt;p&gt;Lexer (Lexical Analysis), or Tokenizer takes the raw string input and turns it into meaningful tokens, we saw the tokens I used above:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&amp;lt;&lt;/li&gt;
&lt;li&gt;&amp;gt;&lt;/li&gt;
&lt;li&gt;/&amp;gt;&lt;/li&gt;
&lt;li&gt;&amp;lt;/&lt;/li&gt;
&lt;li&gt;STRING&lt;/li&gt;
&lt;li&gt;DATA&lt;/li&gt;
&lt;li&gt;NAME&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Some of these are trivial, such as the top 4 on the list, but the rest isn&amp;rsquo;t so easy. String would be an example of a slightly more complex token.&lt;/p&gt;
&lt;p&gt;But when I was first starting, in my head all the hard work would have to be done by the parser and the lexer would basically just pick up single strings of characters. This led me to a rabbit hole of parsing basically single characters as tokens (including spaces!), and writing progressively more complicated grammar rules (and therefore more complicated parser), in order to not have the lexer be complicated.&lt;/p&gt;
&lt;p&gt;But I quickly realised that regular expressions are a tool, and I should use them well. And so that&amp;rsquo;s how I ended up with more complex tokens, and was able to drastically simplify my grammar rules.&lt;/p&gt;
&lt;h1 id=&#34;semantics&#34;&gt;Semantics&lt;/h1&gt;
&lt;p&gt;The last thing I want to talk about was my semantic analysis, which was by far the easiest part of the project, simply because all I have to do is make sure that the opening tags have the correct closing tags associated with them.&lt;/p&gt;
&lt;p&gt;This is implemented using a stack, you push as you see opening tags, pop as you see closing ones, and compare. If you see a closing tag that does not correspond to the top item of the stack then there is something wrong.&lt;/p&gt;
&lt;h1 id=&#34;future-work&#34;&gt;Future Work&lt;/h1&gt;
&lt;p&gt;I am mostly finished with this project. The only thing I would like to add is translation from XML to other languages. This step would be fairly easy because of the AST already being build, and now I simply have to walk it.&lt;/p&gt;
&lt;p&gt;But for other project, I would like to go into the world of programming languages instead of markup languages. To start with I could write a program that compilers down to Golang, and use the already amazing Golang tools to compile the underlying program. But this is for another time.&lt;/p&gt;
&lt;p&gt;If you made it this far, hey thank you for reading, you can always email me at &lt;a href=&#34;mailto:johncosta027@gmail.com&#34;&gt;johncosta027@gmail.com&lt;/a&gt; for any inquiries, or check out the GitHub repo linked at the top of the article if you have any further coments.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>HackNotts 84</title>
      <link>https://johncosta.tech/blog/hack-notts-84/</link>
      <pubDate>Tue, 11 Jul 2023 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/blog/hack-notts-84/</guid>
      <description>&lt;p&gt;This year, I attended &lt;a href=&#34;https://www.hacknotts.com/&#34;&gt;HackNotts 84&lt;/a&gt; 84, a 24-hour hackathon hosted by the University of Nottingham. It was a great event with around 150 hackers, great sponsors and great prizes. I cannot fault the event and the organisers, they did a fantastic job.&lt;/p&gt;
&lt;h1 id=&#34;my-project&#34;&gt;My Project&lt;/h1&gt;
&lt;p&gt;I worked with my friend &lt;a href=&#34;https://www.linkedin.com/in/james-arnott-341705143/&#34;&gt;James&lt;/a&gt;, who attended the same course at Royal Holloway with me, and graduated in the same year.&lt;/p&gt;
&lt;p&gt;For a while I&amp;rsquo;ve wanted to build a distributed database project, as I wanted to tackle the synchronisation issues that come with this type of data storage, and so we did. We built &lt;strong&gt;AidNet&lt;/strong&gt;, a distributed database that worked not through the internet or mobile networks, but through &lt;a href=&#34;https://en.wikipedia.org/wiki/LoRa&#34;&gt;LoraWan&lt;/a&gt;, a low-power wide area network. You can use &lt;a href=&#34;https://en.wikipedia.org/wiki/LoRa&#34;&gt;LoraWan&lt;/a&gt; with ESP32s across a serial port (USB). This allows two or more machines to synchronise a database over wireless signals without the need to be connected to any other network.&lt;/p&gt;
&lt;p&gt;The reason this is important is because it allows our project to be used in places where internet is not available, primarily (and the reason why it&amp;rsquo;s called AidNet), war-torn regions, such as Eastern Ukraine and more recently Gaza. Our project consisted of a simple database of nodes, medical supplies and supply requests, which each node could add to, or view other nodes requests. We also provided a small UI to allows users to more easily interact with the database.&lt;/p&gt;
&lt;h2 id=&#34;technologies-used&#34;&gt;Technologies used&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;The ESP32s are programmed using C++, but this was a rather simple program that simply broadcast (and check summed), any message across the serial port.&lt;/li&gt;
&lt;li&gt;The database we used was a SQLite database for its extreme portability (it is just a file).&lt;/li&gt;
&lt;li&gt;The synchronisation was done in Golang, which also handled input/output from the serial port to the ESP32s&lt;/li&gt;
&lt;li&gt;The UI was made using React (more about that in a minute).&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id=&#34;successful&#34;&gt;Successful&lt;/h1&gt;
&lt;p&gt;It worked! Our machines were able to consistently maintain a synchronised database using the LoraWan ESP32 for communication, it was able to do this with minimal loss and maintain message integrity using checksums, and even re-sync if the node was every taken offline.&lt;/p&gt;
&lt;h1 id=&#34;lessons-to-be-learnt&#34;&gt;Lessons to be learnt&lt;/h1&gt;
&lt;p&gt;Whenever I attend hackathons, I learn a lot - it&amp;rsquo;s the main reason I go - and the learning is often about things to do &lt;em&gt;better&lt;/em&gt;, not so much things that went well.&lt;/p&gt;
&lt;p&gt;I learnt a tone about distributed databases and the challenges that surround them, as well as learning about serial ports and how to interact with them (this is actually the first time I&amp;rsquo;ve manually interacted with a serial port, it was easier than I expected).&lt;/p&gt;
&lt;p&gt;However, I learnt a lot about things I want to do better next time&lt;/p&gt;
&lt;h2 id=&#34;dont-complicate-your-ui&#34;&gt;Don&amp;rsquo;t complicate your UI&lt;/h2&gt;
&lt;p&gt;We used React for our UI. And there should already be a red flag there. You might say &amp;ldquo;Well, it&amp;rsquo;s the most popular UI framework&amp;rdquo; (and it is a framework, not a library). Sure, it&amp;rsquo;s great when your UI need to be very particular and interactive, but we were just displaying a couple of tables and taking in some user input, it seems completely obvious to me that we should have rendered the HTML using some HTML templates from our Golang system.&lt;/p&gt;
&lt;p&gt;It already had access to the database, why are we making our lives worst by having to maintain state in the UI?&lt;/p&gt;
&lt;p&gt;Not only that but we also used MUI to display the data in a more fancy format, which was a terrible idea. Complexity doesn&amp;rsquo;t scale well, and it for sure does not pair well with 2 over caffeinated, 12 straight coding hours engineers (me and James).&lt;/p&gt;
&lt;p&gt;The entire UI fell apart very quickly, the complexity grew so much, so quickly that me and James were at a loss to salvage it.&lt;/p&gt;
&lt;p&gt;In a project where you have to synchronise various database nodes &lt;em&gt;offline&lt;/em&gt;, the hardest part was building the UI.&lt;/p&gt;
&lt;p&gt;Client side rendering is great, but it isn&amp;rsquo;t always the answer. I don&amp;rsquo;t think I&amp;rsquo;ll quickly forget this lesson.&lt;/p&gt;
&lt;h2 id=&#34;focus-on-the-user&#34;&gt;Focus on the user&lt;/h2&gt;
&lt;p&gt;Our database synchronisation worked! That&amp;rsquo;s great!&lt;/p&gt;
&lt;p&gt;What are you going to do with it?&lt;/p&gt;
&lt;p&gt;We build a very simple schema for our database, with only 4 tables, which themselves didn&amp;rsquo;t make a whole lot of sense. This is because we were much more interested in building something that worked on from a technological stand point, instead of building something that a user would find some real use from.&lt;/p&gt;
&lt;p&gt;Always keep the user in mind.&lt;/p&gt;
&lt;h1 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;I really enjoyed my weekend. A big thank you to &lt;a href=&#34;https://www.linkedin.com/in/james-arnott-341705143/&#34;&gt;James&lt;/a&gt; for being a great teammate, I really enjoyed our project.&lt;/p&gt;
&lt;p&gt;Thank you HackNotts, for the very fun event, and thanks to all the sponsers for making it possible.&lt;/p&gt;
&lt;p&gt;And thank you Nottingham Brewery, for serving us some very delicious local beers, at a much needed time.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>The Psychology of Money by Morgan Housel - A review</title>
      <link>https://johncosta.tech/books-and-tv/the-psychology-of-money/</link>
      <pubDate>Tue, 15 Nov 2022 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/books-and-tv/the-psychology-of-money/</guid>
      <description>&lt;p&gt;This book contains 19 chapters, all with a small bit of wisdom about money, all quite useful. Much of what the book covers sounds like common sense if you are already somewhat money savvy, however getting the refresher or the introduction to these topics, is something this book did very well for me.&lt;/p&gt;
&lt;p&gt;A big theme I found in this book was simply: Patience.&lt;/p&gt;
&lt;h2 id=&#34;patience-compounding&#34;&gt;Patience: Compounding&lt;/h2&gt;
&lt;p&gt;Chapter 4 talks about compounding interest, and how wealth is not build over night, but instead takes years and even decades to accumulate, through the power of compounding, this - I believe, is the most important lesson that the book has to teach. It doesn&amp;rsquo;t matter if you invest £1000 today if you won&amp;rsquo;t do anymore for the rest of the year, it is all about continual investments month after month after month, and leaving it. Just leave it, it will grow.&lt;/p&gt;
&lt;p&gt;Housel further proves this point with the beautiful statistic: If you invest over a 20-year period in the US Stock marked, based on historical data you are 100% guaranteed to make money. Even if you bought in the worst possible moment, and also sold in the worst moment, because of the amount of time your money had to grow, it is (historically) impossible to lose money, unless of course you withdraw it early.&lt;/p&gt;
&lt;h2 id=&#34;patience-staying-wealthy&#34;&gt;Patience: Staying wealthy&lt;/h2&gt;
&lt;p&gt;In the chapter 5, Housel goes on to discuss the different between getting wealthy, staying wealthy. And similarly to compounding it is about patience.&lt;/p&gt;
&lt;p&gt;It is about being happy with your circumstance and not blowing all your wealth in unnecessary things, and instead, enjoying your wealth reasonably (maybe don&amp;rsquo;t buy a Ferrari, but maybe you can afford an AMG), and continually investing - to make sure you STAY wealthy.&lt;/p&gt;
&lt;h2 id=&#34;patience-lifestyle&#34;&gt;Patience: Lifestyle&lt;/h2&gt;
&lt;p&gt;Throughout the book, Housel hints at the fact that often people change their life-style depending on how much they make, so even if you make millions, if you are spending millions you are not really wealthy, because you&amp;rsquo;re not accumulating and making money work for you. This relates to the overall theme of patience, as a person must be calm and reasonable about their lifestyle, and very careful about raising it. Because it is easy to go forward, but very difficult to bring down the expensive bills.&lt;/p&gt;
&lt;p&gt;I find it quite interesting how the entire book, doesn&amp;rsquo;t so much talk about making money, or what to do with money, but more so about how people behave with money.&lt;/p&gt;
&lt;h2 id=&#34;other-themes&#34;&gt;Other themes&lt;/h2&gt;
&lt;p&gt;The book explores other themes, such as how people think about different assets depending on factors completely unrelated to those assets, for example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;People living in 1970, saw the S&amp;amp;P500 Boom, and therefore will for the rest of their lives, believe that is it a good way to invest money.&lt;/li&gt;
&lt;li&gt;Someone living during the 2000s .COM crash, might not think the same.&lt;/li&gt;
&lt;li&gt;Or if you work in Tech, you are likely to be Bullish on Tech&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There are various factors, but the book showed me that I must think about my own biases, and listen to advice in a reasonable way, instead an emotion, or self-conforming way, because these are dangerous traps, and the short-term suffering of finding out you are biased and forcing yourself to make better decisions, is definitely better than investing in something because you personally think it will work.&lt;/p&gt;
&lt;p&gt;People will also listen to facts, that fit the opinions that they have before, but this is another massive topic which Housel describes quite well (you are more likely to listen to financial advisers that confirm your beliefs). This topic I should write something about.&lt;/p&gt;
&lt;p&gt;All in all, this review was quite rambly, and I didn&amp;rsquo;t cover all the aspects the book talked about, but mostly the ones which I found to be more eye opening in a way. Housel talks about a series of other topics such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Different goals from other people&lt;/li&gt;
&lt;li&gt;Always leaving room for error&lt;/li&gt;
&lt;li&gt;Never think something is impossible&lt;/li&gt;
&lt;li&gt;Don&amp;rsquo;t be taken by current event, let the markets do their thing&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All of which were really important for me to read as a young person who now actually has some money to start investing into my future. Very good read, and would definitely read more books from Housel - He put complicated topics in a very easily digestible format which I enjoyed.&lt;/p&gt;
&lt;p&gt;8/10&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Digital Minimalism - Cal Newport</title>
      <link>https://johncosta.tech/books-and-tv/digital-minimalism-review/</link>
      <pubDate>Mon, 05 Sep 2022 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/books-and-tv/digital-minimalism-review/</guid>
      <description>&lt;p&gt;The author of the very popular &amp;ldquo;Deep work&amp;rdquo;, is a book describing a problem, which is our digital addictions and malpractices, and also how we can adopt the philosophy of &amp;ldquo;Digital Minimalism&amp;rdquo;, in order to make us use technology in a healthy, and productive way.&lt;/p&gt;
&lt;p&gt;The book opens up by talking about how many of us feel trapped by technology, we have developed unhealthy habits of constant connection and constant scrolling. There have been many articles written about this, and many people have this feeling that technology isn&amp;rsquo;t working for them, but it seems that we are the slaves to it. This is good business on the side of giant technology companies such as Facebook (Meta), which make money from our attention, it is only natural they want us to be constantly attached to our phones.&lt;/p&gt;
&lt;p&gt;Before reading this book, I had thought about this - specially when it comes to short form content such as TikTok, Instagram Reels, you name it&amp;hellip; I was extremely concerned about my own well being, because I had never felt such a pull from a piece of social media, I always used it fairly sparingly - but when Instagram Reels came out, I was hooked, pulling around 1 - 2 hours a day just on these short videos, and it showed. I couldn&amp;rsquo;t concentrate on my online lectures, I couldn&amp;rsquo;t learn as quickly as I had done before, nor could I concentrate for as long, so I stopped it. The first step came a while ago, but I used to text my partner on Instagram DMs, and I asked if she would mind switching to Telegram, and the simple act of not opening the app slashed my screen time in half. I am rambling let&amp;rsquo;s get back on track.&lt;/p&gt;
&lt;h2 id=&#34;digital-minimalism-and-digital-declutter&#34;&gt;Digital Minimalism and Digital Declutter&lt;/h2&gt;
&lt;p&gt;Digital Minimalism as Newport describes it is:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Digital Minimalism is a philosophy towards technology which prioritises digital use to a small number of deeply thought out and efficient activities.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;He backs this up with the following points (I won&amp;rsquo;t go into too much detail here).&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Clutter is costly&lt;/li&gt;
&lt;li&gt;Optimisation is important: Each tool should be finely tool to help you get your work done / have proper leisure.&lt;/li&gt;
&lt;li&gt;Intentional is satisfying: Doing things because you want to them is by itself satisfying.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Newport suggests that we undergo a 30 day digital de-clutter where we remove all non-essential digital technologies from our life. This includes Netflix, most apps (excluding work), TV, and most importantly: Social Media. Newport then suggests that after the 30 days we start to reintroduce some technologies, but we do so with every intention of using them properly, therefore we apply the principles of Digital Minimalism. Newport claims this is important because it shows us what we need and what we don&amp;rsquo;t in our lives.&lt;/p&gt;
&lt;p&gt;I think this might be slightly extreme, I think you can see problems in your current tools and act accordingly, however I haven&amp;rsquo;t had a huge problem with technology - perhaps someone with a greater addiction would benefit from the complete de-clutter.&lt;/p&gt;
&lt;h2 id=&#34;practices-of-digital-minimalism&#34;&gt;Practices of Digital Minimalism&lt;/h2&gt;
&lt;h3 id=&#34;spend-time-alone&#34;&gt;Spend time alone&lt;/h3&gt;
&lt;p&gt;With the rise of modern technology, we have almost completely removed solitude. Think about it, when was the last time you were truly alone? No music, no TV, no work, just you? This was a scary realisation for me because the answer was none. I am either always surrounded by friends or see them on social media, or I am listening to music or watching netflix when I&amp;rsquo;m alone, this means I have spent very little time alone.&lt;/p&gt;
&lt;p&gt;There are great examples that Newport gives in the book about why Solitude is important, but my favourite is that we have very complicated social circuits in our brain, and they are not meant to be on all the time, but they are now a days, constant notifications, alerts, pings, etc&amp;hellip;&lt;/p&gt;
&lt;p&gt;Spending time alone can benefit your mental health and it gives you time to realise the person you want to be and actually have a chat with yourself, something I believe (and so does Newport) to be of the utmost importance.&lt;/p&gt;
&lt;h3 id=&#34;dont-click-like&#34;&gt;Don&amp;rsquo;t click like&lt;/h3&gt;
&lt;p&gt;Clicking the like button on social media makes you more committed to social media, interacting with in any way makes you more invested in it, and in recent times we have all heard the odd family member say &amp;ldquo;Why didn&amp;rsquo;t you like my post?&amp;rdquo;, as clicking twice on a piece of glass shows that I really care for them.&lt;/p&gt;
&lt;p&gt;Social media companies know this, that we now have a certain contract between each other to like and comment on each others posts, and this makes us waste more time online, scrolling to endless posts and double tapping, for most of us it is probably muscle memory, which is just horrifying.&lt;/p&gt;
&lt;p&gt;The reason I read this book WAS because of how social media affected my mental health and how often I was spending on it, after reading the book I uninstalled all social media from my phone and I message my closes friends on WhatsApp or Telegram (or god forbid SMS). And most people will say that they &amp;ldquo;cannot do it&amp;rdquo;, YES YOU CAN, just try&amp;hellip; you&amp;rsquo;ll realise that you don&amp;rsquo;t even care about 90% of the people on social media and all you&amp;rsquo;ve been doing is distancing yourself from the relationships you actually want to maintain. Focus on the 10% of people you actually care about, go see them, call them, sending a &amp;ldquo;heart&amp;rdquo; on Instagram every once in a while is no way to maintain a relationship.&lt;/p&gt;
&lt;h3 id=&#34;reclaim-leisure&#34;&gt;Reclaim leisure&lt;/h3&gt;
&lt;p&gt;The one I struggle with the most.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Prioritise demanding activity over passive consumption&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Our leisure habits, most often consist of scrolling through Twitter or watching Netflix. This stuff is fine but it has to be kept in check, if this is all we do then it is not okay, you need to have a proper leisure activity, a club or anything really to keep you busy when you are not working, something you really enjoy doing. These also have the benefit of being extremely satisfying compared to just watching Netflix.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Seek activities, that require real-world, social interaction&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I, just like many others, love working remotely and love playing some video games with friends (or even by myself) however this cannot replace the leisure you have from playing chess over the board, or going to a badminton club where you have to socialise with your doubles partner. Social interaction in leisure is extremely important.&lt;/p&gt;
&lt;h3 id=&#34;join-the-attention-resistance&#34;&gt;Join the attention resistance&lt;/h3&gt;
&lt;p&gt;Many giant social media companies are fighting for your attention, that is their business model, they need your eyes, on your phone, to sell you ads. Don&amp;rsquo;t give it to them.&lt;/p&gt;
&lt;p&gt;Easier said then done but Newport does suggest a couple of things to get you started:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Delete social media from your phone (check it on your computer instead).&lt;/li&gt;
&lt;li&gt;Use social media like a profession (use it to check on your friends, message someone, don&amp;rsquo;t waste time scrolling).&lt;/li&gt;
&lt;li&gt;Embrace slow media (long articles, something that really requires your full attention).&lt;/li&gt;
&lt;li&gt;Dumb down your phone (I will go into this last one).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Your phone, is the closest object to you, maybe the closest object humans have ever had. We are rarely 1 meter from our phone. Phones are amazing inventions, everything you could ever know is just at your finger tips on a device many times more powerful than the moon lander.&lt;/p&gt;
&lt;p&gt;However, it can also be extremely addictive to just stare at the screen for hours, so I (and Newport) suggest you dumb down your phone. For me, I installed Niagra launcher (I have a OnePlus 8 running Android 11), this is a super simple launcher that lists your favourite apps, and the rest are hidden, that&amp;rsquo;s it. This means when you open the phone you go straight to the app you want, you don&amp;rsquo;t scroll for no reason. Something else this has helped me with is removing the apps I was somewhat addicted to (Instagram and YouTube), and put them out of sight, making me less likely to open them.&lt;/p&gt;
&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Digital Minimalism is a great book that I think most people should read, it really exposes our addiction to technology and social media, and how it just isn&amp;rsquo;t okay we spend so much time on it. It helped me form better, healthier habits with technology and in turn I am much happier, more productive, and spend more time doing more meaningful things - But I won&amp;rsquo;t like, I still binge netflix from time to time, I still watch YouTube a TON, but this book has made me much more cautious about this, I can make sure that at least I don&amp;rsquo;t use social media, or that I am aware of how much time I am spending on my phone.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Deepwork - Cal Newport</title>
      <link>https://johncosta.tech/books-and-tv/deepwork-review/</link>
      <pubDate>Tue, 16 Aug 2022 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/books-and-tv/deepwork-review/</guid>
      <description>&lt;p&gt;This review is a little different because I wrote it down on paper, here are the pages:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://johncosta.tech/static/DeepworkPart1.jpg&#34; alt=&#34;DeepworkPart1&#34;&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://johncosta.tech/static/DeepworkPart2.jpg&#34; alt=&#34;DeepworkPart2.jpg&#34;&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://johncosta.tech/static/DeepworkPart3.jpg&#34; alt=&#34;DeepworkPart3.jpg&#34;&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://johncosta.tech/static/DeepworkPart4.jpg&#34; alt=&#34;DeepworkPart4.jpg&#34;&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://johncosta.tech/static/DeepworkPart5.jpg&#34; alt=&#34;DeepworkPart5.jpg&#34;&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://johncosta.tech/static/DeepworkPart6.jpg&#34; alt=&#34;DeepworkPart6.jpg&#34;&gt;&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Threaded JavaScript!</title>
      <link>https://johncosta.tech/blog/threaded-js/</link>
      <pubDate>Sun, 10 Apr 2022 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/blog/threaded-js/</guid>
      <description>&lt;p&gt;For a long time, my language of choice has been JavaScript (and recently TypeScript), this is for both frontend development as well as backend development.&lt;/p&gt;
&lt;p&gt;I enjoy the simplicity of using the same language for both sides of a project and I especially like working with Node.js, a Javascript run time environment with a very sophisticated asynchronous event loop, which makes it perfect for applications such as RESTful APIs which access databases etc&amp;hellip;&lt;/p&gt;
&lt;p&gt;However, I have also done backend work using Golang, a strongly typed, compiled, very fast language with a vibrant community and a &amp;ldquo;do it yourself&amp;rdquo; attitude, quite the change from Javascript. And something I have touched and enjoyed playing with are go routines, which are a way to create very light weight threads. This works by calling a function as a &amp;ldquo;go routine&amp;rdquo;, which I think is very elegant. This is managed by the go run-time environment, but it can spawn threads if it needs to - a nice abstraction which means I don&amp;rsquo;t have to handle threads directly - but do have to handle go routines as if they ARE threads.&lt;/p&gt;
&lt;p&gt;But anyways, it left me wondering if I could have threads in JavaScript, which sounds crazy but Node.js has support for this is &amp;ldquo;Worker Threads&amp;rdquo;. These are threads managed by Node.js which can run a .js file and communicate with its parent - it is quite similar to go routines.&lt;/p&gt;
&lt;p&gt;So I made a small program to calculate the same MD5 hash 1 million times:&lt;/p&gt;
&lt;p&gt;(Note that these files are .mjs files (module JavaScript), Node.js will only run them if you have .mjs as the file extension - All they do is allow the &amp;ldquo;import&amp;rdquo; syntax and a few other things).&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-js&#34; data-lang=&#34;js&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;crypto&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;crypto&amp;#34;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;console&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;time&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Single-Thread&amp;#34;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;n&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;10000000&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;string&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Hello World&amp;#34;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; (&lt;span style=&#34;color:#66d9ef&#34;&gt;let&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;i&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;; &lt;span style=&#34;color:#a6e22e&#34;&gt;i&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;n&lt;/span&gt;; &lt;span style=&#34;color:#a6e22e&#34;&gt;i&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;++&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;hash&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;crypto&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;createHash&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;md5&amp;#34;&lt;/span&gt;).&lt;span style=&#34;color:#a6e22e&#34;&gt;update&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;string&lt;/span&gt;).&lt;span style=&#34;color:#a6e22e&#34;&gt;digest&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;hex&amp;#34;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;console&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;timeEnd&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Single-Thread&amp;#34;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Running this program gave me this result:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Single-Thread: 1.139s
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I then modified my code to use worker threads. This splits the work load into 8 worker threads, it gives each thread a start and an end range for the hash - which in total makes 1 million hashes.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-js&#34; data-lang=&#34;js&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; { &lt;span style=&#34;color:#a6e22e&#34;&gt;fileURLToPath&lt;/span&gt; } &lt;span style=&#34;color:#a6e22e&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;url&amp;#34;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; { &lt;span style=&#34;color:#a6e22e&#34;&gt;Worker&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;isMainThread&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;parentPort&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;workerData&lt;/span&gt; } &lt;span style=&#34;color:#a6e22e&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;worker_threads&amp;#34;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;crypto&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;crypto&amp;#34;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;__filename&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;fileURLToPath&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;meta&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;url&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;n&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;1000000&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;THREAD_NUM&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;8&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;string&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Hello World&amp;#34;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;isMainThread&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;threads&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;new&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Set&lt;/span&gt;();
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; (&lt;span style=&#34;color:#66d9ef&#34;&gt;let&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;i&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;; &lt;span style=&#34;color:#a6e22e&#34;&gt;i&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;THREAD_NUM&lt;/span&gt;; &lt;span style=&#34;color:#a6e22e&#34;&gt;i&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;++&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#a6e22e&#34;&gt;threads&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;add&lt;/span&gt;(
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#66d9ef&#34;&gt;new&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Worker&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;__filename&lt;/span&gt;, {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#a6e22e&#34;&gt;workerData&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#a6e22e&#34;&gt;start&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;i&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;n&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;THREAD_NUM&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#a6e22e&#34;&gt;end&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;i&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;n&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;THREAD_NUM&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;n&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;THREAD_NUM&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        },
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    );
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#a6e22e&#34;&gt;console&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;time&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Thread&amp;#34;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; (&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;worker&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;of&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;threads&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#a6e22e&#34;&gt;worker&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;on&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;message&amp;#34;&lt;/span&gt;, (&lt;span style=&#34;color:#a6e22e&#34;&gt;msg&lt;/span&gt;) =&amp;gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;console&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;log&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;msg&lt;/span&gt;));
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#a6e22e&#34;&gt;worker&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;on&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;exit&amp;#34;&lt;/span&gt;, () =&amp;gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#a6e22e&#34;&gt;threads&lt;/span&gt;.&lt;span style=&#34;color:#66d9ef&#34;&gt;delete&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;worker&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;threads&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;size&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;===&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#a6e22e&#34;&gt;console&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;timeEnd&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Thread&amp;#34;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    });
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;else&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; (&lt;span style=&#34;color:#66d9ef&#34;&gt;let&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;i&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;workerData&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;start&lt;/span&gt;; &lt;span style=&#34;color:#a6e22e&#34;&gt;i&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;workerData&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;end&lt;/span&gt;; &lt;span style=&#34;color:#a6e22e&#34;&gt;i&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;++&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;hash&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;crypto&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;createHash&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;md5&amp;#34;&lt;/span&gt;).&lt;span style=&#34;color:#a6e22e&#34;&gt;update&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;string&lt;/span&gt;).&lt;span style=&#34;color:#a6e22e&#34;&gt;digest&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;hex&amp;#34;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#a6e22e&#34;&gt;parentPort&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;postMessage&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Done!&amp;#34;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This results in the following output:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-js&#34; data-lang=&#34;js&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;Done&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;Done&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;Done&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;Done&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;Done&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;Done&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;Done&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;Done&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;Thread&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;335.294&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;ms&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;A 4x increase in speed. There is a delay because worker threads actually spawn threads and therefore there is a bit of overhead with the syscall to create these threads.&lt;/p&gt;
&lt;p&gt;This is very clear if we changed the number of hashes to 10 000.&lt;/p&gt;
&lt;h3 id=&#34;single-thread&#34;&gt;Single Thread&lt;/h3&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Single-Thread: 23.476ms
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;8-worker-threads&#34;&gt;8 Worker Threads&lt;/h3&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Done!
Done!
Done!
Done!
Done!
Done!
Done!
Done!
Thread: 70.337ms
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;As you can see the single thread beat the 8 threads by almost 4x. This is because it is costly to create a thread outright which is what Node.js seems to be doing.&lt;/p&gt;
&lt;h2 id=&#34;disclaimer&#34;&gt;Disclaimer&lt;/h2&gt;
&lt;p&gt;The Node.js crypto module is basically a wrapper for the native OpenSSL hashing functions, so I suspect that Node.js is just making a very fast C program do the hard work - but never the less it works very well.&lt;/p&gt;
&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Node.js is a very solid backend technology to perform parallalism, it is not just limited to making RESTful APIs. It can competes with strongly typed and compiled languages such as golang.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>The Republic by Plate - A recap / review</title>
      <link>https://johncosta.tech/books-and-tv/therepublic-review/</link>
      <pubDate>Sun, 05 Jan 2020 00:00:00 +0000</pubDate>
      <guid>https://johncosta.tech/books-and-tv/therepublic-review/</guid>
      <description>&lt;h1 id=&#34;a-summary-and-review&#34;&gt;A summary and review&lt;/h1&gt;
&lt;p&gt;&lt;strong&gt;Disclaimer: This book has some fairly rough topics, I&amp;rsquo;m simply writing a summary and a review&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&#34;context&#34;&gt;Context&lt;/h2&gt;
&lt;p&gt;The Republic was written by Plato in 375 BC, many years ago. In was written in Greece, when the country was made up of various states who were at constant wars with not only each other but with the Persians at the time. This does explain some of the ideas in the book, which would be seen as extreme in any sense of the word.&lt;/p&gt;
&lt;p&gt;This book was written by Plato in the form of a dialogue between Socrates and various other people, however this might be a made up dialogue, it is obviously very hard to confirm whether this is Socrates&amp;rsquo; thoughts or Plato&amp;rsquo;s, but most likely it is Plato&amp;rsquo;s.&lt;/p&gt;
&lt;p&gt;Plato came from a long line of powerful Athenians who were very involved in politics and were obviously very wealthy, however this was not the path that Plato choose for himself, he would rather become a philosopher and open his famous Academia, which has produced some of the ideas that structure our world today, by producing pupils such as Aristotle, and even Alexander the Great, who went on to shape the world as we know it.&lt;/p&gt;
&lt;p&gt;This should all be kept in context when reading this book as to, understand why Plato thought such extreme ideas were not only true but the best for both the individual and the state, this is extremely important to keep in mind.&lt;/p&gt;
&lt;h2 id=&#34;what-is-justice&#34;&gt;What is Justice?&lt;/h2&gt;
&lt;p&gt;The book basically starts with this question, of what justice is and whether the just man is really the best, happiest and most well of than the unjust man, views challenged by his opponents in the dialogue.&lt;/p&gt;
&lt;p&gt;To solve this question Socrates goes on to describe a city which contains many rules and extreme ideas, this state would be considered a near fascist regism in today&amp;rsquo;s world, but with the failing democracies in Athens, and many starving people in Greece due to poor leadership, we can see why Socrates/Plato think this is the best way to form a city.&lt;/p&gt;
&lt;p&gt;The reason a state is describes is because Socrates tried to compare the individual to the state, and therefore if the state is just, the individual is also just, furthermore if the state is a good one then we can also assume that its people are good. This ideas doesn&amp;rsquo;t quite hold completely in today&amp;rsquo;s world, but there are some parallels to be drawn. For example countries with better education will produce citizens which pollute less, are less likely to be racist amongst other things, although even these assumptions are not always correct.&lt;/p&gt;
&lt;p&gt;So what are these rules? Well we must trace Socrates train of thought as it is the easiest way to understand this topic. Firstly, when forming our state each person will do what they are best at; the example given is that of a show maker, who Socrates claim will produce better shoes if he only focuses on shoe making. This means that our very basic state will consist of farmers, miners, builders and other basic professions.&lt;/p&gt;
&lt;p&gt;However this state is hardly permanent, because it is natural for a state to want to expand, another characteristic of the state drive by individuals. Because of this the state must be ready for war to take over land, this means that we must add to our state, not only do we have regular professions we must also have warriors.&lt;/p&gt;
&lt;p&gt;And this is a big deal, because warriors are obviously more powerful than the regular citizen and therefore Socrates claims that there warriors or as he calls them &amp;ldquo;Auxiliaries&amp;rdquo;, are restrained in two ways.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Education, they are brought up with extensive education and only the best will be able to become part of this Auxiliary class.&lt;/li&gt;
&lt;li&gt;Rulers, this is a sub class of the Auxiliary class within the state, the best of the Auxiliaries group will be able to become the rulers of the state, which will command the Auxiliary.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There is a lot to unpack but starting with education, Plato claims that much of what they are exposed to must be censored; This means that only certain art can be shown or certain poetry can be read. This is an element which is obviously present in our current education systems, we do not expose children of certain things for their own sake, whether this is a good thing or a bad thing is the base for much heated debate and it would be quite difficult to discuss this completely. All I can say is that this book was written many many years ago and therefore is not in line with what we view as a good way of life. This is the reason that Plato saw this censorship as a good thing.&lt;/p&gt;
&lt;p&gt;It was essential for this class system to only work on the basis of whether the individual fits into a certain group or not, therefore Plato comes out with another idea which is very out there. No child should meet their parents and vice versa, they are children of the state which would mean they grow up, loving the state. Again, an idea which could hardly ever be realised and Plato is very aware of this, many passages in the book state that this state is purely one of the mind and will never (really) exist.&lt;/p&gt;
&lt;p&gt;There are a few more rules to bring up, starting with the fact that in this state, private housing is simply banned. People should live together with groups of people who do similar things they do and are of the same class, this brings an idea of collectivism, or as many critics of this book call it: Communism.&lt;/p&gt;
&lt;p&gt;And similarly to private housing, wealth is also not allowed. This is for a number of reasons but most is to prevent people from taking action for personal gain, which is definitely a big problem in modern politics today. This was actually challenged in the book by one of the other characters, because it states that this state could not form any allies because it did not have any gold. Socrates is quick to shut it down by saying that the state has the best soldiers, and does not want wealth, therefore if other states allied with this one, they would keep all of the looting and gold from the enemies.&lt;/p&gt;
&lt;h2 id=&#34;the-family&#34;&gt;The family&lt;/h2&gt;
&lt;p&gt;Plato describes in this book that women are different from men, we can all agree on this. However he did not see any difference in their capacities to be rules, an idea thought to be completely wrong at the time of writing. This is obviously something we all relish, the ability for anyone, regardless of gender or colour to take any job with the only restriction being their own ability to carry out that job (or at least it should).I obviously completely agree with this part of the book, it is perhaps the only part I completely, 100% agree with.&lt;/p&gt;
&lt;p&gt;However, moving on to family, because children do not meet their parents, children are made in &amp;ldquo;Mating rituals&amp;rdquo; where the state picks pairs of people, basically to breed the best possible citizens, and eventually the best possible rules. However, very important to note that the citizens are not aware that the pairing are done, to their knowledge they simply won a &amp;ldquo;lottery&amp;rdquo;, another part of censorship in our state.&lt;/p&gt;
&lt;h2 id=&#34;the-ruler&#34;&gt;The ruler&lt;/h2&gt;
&lt;p&gt;Plato states that &amp;ldquo;philosophers should be kings&amp;rdquo;, he also states that this does not happen in the world because those who are most suited for ruling, are the ones less likely to get into politics. Which is argued against but we can see where he is coming from. Philosophers who&amp;rsquo;s only goal in life is to seek the truth, are not interested in politics of the state because it contains too much unmoral activity, campaigning, tactics and other things. This means they are likely never to rule.&lt;/p&gt;
&lt;p&gt;Our state fixes this by having the best performing children, those who are seen to seek good and truth, to be our rulers.&lt;/p&gt;
&lt;p&gt;This is pretty much impossible to achieve in the modern world, or in any world for that matter because it is obviously very hard to describe who is the best and it also begs the question, is the education system proper and a million other questions.&lt;/p&gt;
&lt;h2 id=&#34;failed-states&#34;&gt;Failed states&lt;/h2&gt;
&lt;p&gt;Plato talked a lot of failed states, and I feel these were very directed at particular states in ancient Greece. He also states in the Republic that these states would originate from the society he described n the following order&lt;/p&gt;
&lt;p&gt;Timarchy &amp;ndash;&amp;gt; Oligarchy &amp;ndash;&amp;gt; Democracy &amp;ndash;. Tyranny&lt;/p&gt;
&lt;p&gt;Going from least bad to most bad, and each deriving from one another. Plato gives very intresting examples of the kind of person that would live in each one and how they came to be, as their parents represented the prior type of state. This does depend on assumptions made earlier that the state is made of people and therefore the two are very much linked.&lt;/p&gt;
&lt;p&gt;It is worth describing what each of these societies are and a real world example of each.&lt;/p&gt;
&lt;p&gt;Starting with Timarchy, this is the most similar to our state but a few elements started to slip, for example private property is allowed, but most importantly, glory and honour are the leading principles of the state, instead of intelligence and the love for the truth. He gave Sparta as an example, a state which Plato seems to admire, because it is not far from the one he describes in this book. I won&amp;rsquo;t give any real world examples because frankly this was not discussed in great length in the book and I do not know enough about the subject to categorise a single country in the modern world into a Timarchy (However, I believe that WWII Japan might have come close).&lt;/p&gt;
&lt;p&gt;Oligarchy happens when a very small amount of people have control over the state because of huge amounts of wealth, it reminds me of most countries today to some extent, specially the US due to their extensive neo-liberal views, and the huge influences of billionaire donators to political parties, many more countries could be partially categorised as an oligarchy though. Plato said this derived from a Timarchy because of the ever expanding wealth of the political powers in a timarchy.&lt;/p&gt;
&lt;p&gt;Democracy, rated very poorly by Plato, most likely because of Athens, which was a democracy. However Athens was still quite corrupt, and their execution of Socrates probably meant that Plato despised the city, we must also remember this is where he grew up, and witnessed first hand the corruption happening within the state. Democracy then derives from an oligarchy when the poor, which compose the majority of the state finally take over in a sort of revolution. A democracy values personal freedom above everything else and therefore people have a say as to who is in power. This can be a bad thing because populism exists and is described in the Republic (not by that name but as a simple description of it). It is also said that many laws won&amp;rsquo;t be respected because of the personal freedom everyone has in this state.&lt;/p&gt;
&lt;p&gt;This then leaves a Tyranny, and this one is the most interesting one. A Tyranny comes from a democracy because one populist leader is elected who then becomes a tyrant. This is rather interesting because in the dialogue, Plato comes to the conclusion that the tyrant is the least happy man, and also the most unjust. He argues this because he is always looking over his shoulder and fears that injustice happen to them, the reasoning is slightly unclear to me but he arrives at this conclusion.&lt;/p&gt;
&lt;p&gt;Okay so this has gone on to long I would just like to finish my thoughts up.&lt;/p&gt;
&lt;p&gt;The republic is an excellent book to read, it is interesting and logical, it is a window back into ancient Greece and into a way of thinking which is a little different to us today. It is a book which carries some weight and describes some complex topics in a conversation which is very interesting to me, obviously the book suggests a pretty extreme state which does demonstrate its age, but I still think it is very important to look at ways of thinking from the past. I like how many ideas in the book actually have a lot of relevance in today&amp;rsquo;s world, for example Tyranny and the rise of populism which Plato said would happen from a democracy, this has happened all over the world with populist leaders such as Saddam Hussein.&lt;/p&gt;
&lt;p&gt;I also find it interesting how, Plato who lived more than 2000 years ago describes women as being no different then men men when it came to ruling, and it took us so long (up until very recently), to finally see this and allow women in power.&lt;/p&gt;
&lt;p&gt;Overall this book was a brilliant read and very informative in some ways, obviously I disagree with a lot of it, but that does not mean it was a bad book at all, I actually credit most of these disagreements to the age of the book and how different things were 2 millennia ago.&lt;/p&gt;
</description>
    </item>
  </channel>
</rss>
