<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Daniel PL</title>
    <description>The latest articles on DEV Community by Daniel PL (@danielprlo).</description>
    <link>https://dev.to/danielprlo</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F613086%2F24292b32-16cb-40ff-b45f-4411b8939a46.png</url>
      <title>DEV Community: Daniel PL</title>
      <link>https://dev.to/danielprlo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/danielprlo"/>
    <language>en</language>
    <item>
      <title>Clean code by Robert Cecil Martin: My takeaways</title>
      <dc:creator>Daniel PL</dc:creator>
      <pubDate>Tue, 20 Sep 2022 06:52:21 +0000</pubDate>
      <link>https://dev.to/danielprlo/clean-code-by-robert-cecil-martin-my-takeaways-18gg</link>
      <guid>https://dev.to/danielprlo/clean-code-by-robert-cecil-martin-my-takeaways-18gg</guid>
      <description>&lt;p&gt;Another great book I've had the time to go through. The insights and advice given by &lt;a href="https://en.wikipedia.org/wiki/Robert_C._Martin"&gt;Robert Cecil Martin&lt;/a&gt; are the result of years of experience in the field.&lt;/p&gt;

&lt;p&gt;So as usual, I'll summarize my &lt;strong&gt;takeaways&lt;/strong&gt;, those that as a developer I want to keep in mind.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is clean code?
&lt;/h2&gt;

&lt;p&gt;So far, the best definition of clean code I've read in the book comes from Michael Feathers.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Clean code always looks like it was written by someone who cares&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And I couldn't agree more. When code is written by someone who &lt;strong&gt;cares&lt;/strong&gt; it's easy to read, pleasant and will tell you &lt;strong&gt;precisely&lt;/strong&gt; what you need to know about it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The boy scout rule
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Leave the campground cleaner than you found it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It happens to all of us. You have to develop a new feature in an existing code base, or fixing a bug. If you are going to touch a part of the code base, why not leave it &lt;strong&gt;better&lt;/strong&gt; than it was before?&lt;/p&gt;

&lt;p&gt;But wait, I might hear you saying "But what If I break something?". That's what unit &lt;strong&gt;tests&lt;/strong&gt; are for ;)&lt;/p&gt;

&lt;h2&gt;
  
  
  Naming
&lt;/h2&gt;

&lt;p&gt;The book also focuses a lot on &lt;strong&gt;naming&lt;/strong&gt; things properly. Functions, variables, classes. They all should have intention-revealing names.&lt;/p&gt;

&lt;p&gt;Classes should have nouns or noun phrases.&lt;br&gt;
Methods should have verbs or verb phrases.&lt;/p&gt;

&lt;p&gt;And the length of a name should be related to the size of its &lt;strong&gt;scope&lt;/strong&gt;. The broader the scope is, the larger the name should be.&lt;/p&gt;

&lt;h2&gt;
  
  
  The paperback model
&lt;/h2&gt;

&lt;p&gt;The author is responsible for making himself &lt;strong&gt;clear&lt;/strong&gt;, and not the academic model where the scholar has to dig the meaning.&lt;/p&gt;

&lt;p&gt;The code should be &lt;strong&gt;self-explanatory&lt;/strong&gt;, and clear to the reader. The developer who is going through the codebase shouldn't have to have a hard time trying to understand what the previous developer meant. &lt;/p&gt;

&lt;p&gt;The responsibility and the effort are on the developer who is writing the code to make it easy to understand. And not with comments, with &lt;strong&gt;code&lt;/strong&gt;! &lt;/p&gt;

&lt;h2&gt;
  
  
  Overloaded constructors
&lt;/h2&gt;

&lt;p&gt;When constructors are overloaded, use state factory methods that describe the arguments instead.&lt;/p&gt;

&lt;p&gt;An example given in the books is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Complex fulcrumPoint = Complex.FromRealNumber(23.0):&lt;br&gt;
is generally better than&lt;br&gt;
Complex fulcrumPoint = new Complex(23.0);&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The rules of functions
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;The first rule of functions is that they should be small. The second rule of functions is that they should be smaller than that.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Code in conditionals and whiles
&lt;/h2&gt;

&lt;p&gt;The blocks within if statements, else statements and while statements should be one line long. &lt;br&gt;
If it can't fit in that, use a &lt;strong&gt;function&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Flag arguments
&lt;/h2&gt;

&lt;p&gt;If you have to pass a boolean flag to a function to determine its behavior, that function is doing more than one thing and &lt;strong&gt;violating&lt;/strong&gt; the SRP principle. &lt;/p&gt;

&lt;p&gt;That function should be &lt;strong&gt;split&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Function with too many arguments
&lt;/h2&gt;

&lt;p&gt;When a function needs more than two or three arguments, some of those arguments can likely be wrapped into a separate &lt;strong&gt;class&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Functions responsibility
&lt;/h2&gt;

&lt;p&gt;A function should either do something or answer something. &lt;strong&gt;Not&lt;/strong&gt; both.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comments
&lt;/h2&gt;

&lt;p&gt;Comments are, best case scenario, a &lt;strong&gt;necessary evil&lt;/strong&gt;. Comments are there to compensate for our failure to express ourselves in code. &lt;/p&gt;

&lt;p&gt;So if you have to comment something out, you haven't done a good job expressing in code what you intended to do.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dependent functions
&lt;/h2&gt;

&lt;p&gt;Whenever a function calls another function, it should be vertically close in the code, and the caller always be above.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Nulls
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Returning null from methods is bad, but passing null into methods is worse.&lt;br&gt;
Except for API that might force you to do that.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So &lt;strong&gt;don't&lt;/strong&gt; return nulls.&lt;/p&gt;

&lt;h2&gt;
  
  
  TDD Laws
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;First Law:&lt;/strong&gt; You may not write production code until you have a written failing unit test.&lt;br&gt;
&lt;strong&gt;Second Law:&lt;/strong&gt; You may not write more of a unit test than is sufficient to fail, and not compiling is failing.&lt;br&gt;
&lt;strong&gt;Third Law:&lt;/strong&gt; You may not write more production code than is sufficient to pass the currently failing test.&lt;/p&gt;

&lt;p&gt;If you want to see also Robert in action explaining TDD you can check one of his talks &lt;a href="https://youtu.be/58jGpV2Cg50?t=1305"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  F.I.R.S.T
&lt;/h2&gt;

&lt;p&gt;Clean test should follow five rules:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fast:&lt;/strong&gt; They should be fast and run quickly.&lt;br&gt;
&lt;strong&gt;Independent:&lt;/strong&gt; They should not depend on each other.&lt;br&gt;
&lt;strong&gt;Repeatable:&lt;/strong&gt; They should be able to run in any environment.&lt;br&gt;
&lt;strong&gt;Self-validating:&lt;/strong&gt; They should have a boolean output.&lt;br&gt;
&lt;strong&gt;Timely:&lt;/strong&gt; They should be written in a timely fashion. So, the test is written before the production code, not after.&lt;/p&gt;

&lt;h2&gt;
  
  
  Classes
&lt;/h2&gt;

&lt;p&gt;Classes should have a small number of instance variables. Keep the &lt;strong&gt;cohesion&lt;/strong&gt; low.&lt;/p&gt;

&lt;p&gt;If a few functions share the same variables, split them into a separate class.&lt;/p&gt;

&lt;h2&gt;
  
  
  SOLID principles
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The single-responsibility principle:&lt;/strong&gt; There should never be more than one reason for a class to change. &lt;br&gt;
&lt;strong&gt;The open-closed principle:&lt;/strong&gt; Software entities should be open for extension, but closed for modification.&lt;br&gt;
&lt;strong&gt;The Liskov substitution principle:&lt;/strong&gt; Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it. &lt;br&gt;
&lt;strong&gt;The interface segregation principle:&lt;/strong&gt; Clients should not be forced to depend upon interfaces that they do not use.&lt;br&gt;
&lt;strong&gt;The dependency inversion principle:&lt;/strong&gt; Depend upon abstractions, not concretions.&lt;/p&gt;

&lt;p&gt;You can find more information &lt;a href="https://www.baeldung.com/solid-principles"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The principle of least surprise
&lt;/h2&gt;

&lt;p&gt;If you do something in a certain way, do all similar things in the same way. Keep the consistency.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The pragmatic programmer: my takeaways</title>
      <dc:creator>Daniel PL</dc:creator>
      <pubDate>Mon, 29 Aug 2022 07:04:31 +0000</pubDate>
      <link>https://dev.to/danielprlo/the-pragmatic-programmer-my-takeaways-4ani</link>
      <guid>https://dev.to/danielprlo/the-pragmatic-programmer-my-takeaways-4ani</guid>
      <description>&lt;p&gt;I have recently finished the book '&lt;em&gt;The Pragmatic Programmer:&lt;br&gt;
Your journey to mastery&lt;/em&gt;'. &lt;/p&gt;

&lt;p&gt;A very interesting reading, packed with &lt;strong&gt;tips&lt;/strong&gt; and &lt;strong&gt;ideas&lt;/strong&gt; to improve as a developer.&lt;/p&gt;

&lt;p&gt;So I've decided to write down here my personal takeaways. They might not be the best ones, but they are at least, the most &lt;strong&gt;relevant&lt;/strong&gt; for &lt;strong&gt;me&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I hope you like them.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Does your work environment suck or you find your job boring? Do something about it.
&lt;/h2&gt;




&lt;blockquote&gt;
&lt;p&gt;“Does your work environment suck? Is your job boring? Try to fix it. But don’t try forever. As Martin Fowler says, “you can change your organization or change your organization.”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;Try to &lt;strong&gt;fix&lt;/strong&gt; whatever is wrong with your work environment, if you can't, &lt;strong&gt;change&lt;/strong&gt; jobs. So far, our industry and the market is giving us that opportunity. Embrace it.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Don't make lame excuses
&lt;/h2&gt;

&lt;p&gt;Before telling anyone that something can't be done or whatever excuse you're going to say. Stop and think about it. Is it a lame excuse? How will it sound when you say it?&lt;br&gt;
Instead, come up with &lt;strong&gt;options&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Don't leave broken windows
&lt;/h2&gt;

&lt;p&gt;In the book, they explain the concept of 'broken windows'.&lt;/p&gt;

&lt;p&gt;The concept is simple. If you leave something &lt;strong&gt;broken&lt;/strong&gt; or in a bad state, that &lt;strong&gt;reinforces&lt;/strong&gt; the idea that either nothing can be fixed or that no one cares. &lt;/p&gt;

&lt;p&gt;The same happens with software, do not leave broken windows, if you find one, fix it or find the time to do it (and actually do it). Needless to say, do not break windows by yourself.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Keep an eye on the big picture
&lt;/h2&gt;

&lt;p&gt;If you don't see the big picture, you'll miss everything happening around you and you won't be able to react properly.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Invest in yourself
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Invest&lt;/strong&gt; in your knowledge portfolio regularly

&lt;ul&gt;
&lt;li&gt;Even if it's only a bit every day&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Diversify&lt;/strong&gt; your knowledge

&lt;ul&gt;
&lt;li&gt;Do not focus only on one technology/language/framework&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Manage risk&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Evaluate which technologies/languages/frameworks are better to invest in than others&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Emerging&lt;/strong&gt; technologies

&lt;ul&gt;
&lt;li&gt;Keep an eye on what is coming or new, being an early adopter, if it takes off in the market, can put you in a very valuable position.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Keep always yourself &lt;strong&gt;up to date&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Same as we do with our OS and libraries, keep yourself up to date&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  6. Be part of the community
&lt;/h2&gt;

&lt;p&gt;Find out what people are working on these days, especially outside of your company and actively participate in discussion groups.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Make your code easy to change
&lt;/h2&gt;

&lt;p&gt;If your code is easy to change, it will most likely be well designed and decoupled.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. DRY
&lt;/h2&gt;

&lt;p&gt;The DRY (Don't Repeat Yourself) principle does not apply to code &lt;strong&gt;duplication&lt;/strong&gt;, it applies to which intrinsic &lt;strong&gt;knowledge&lt;/strong&gt; the code contains.&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;“DRY is about the duplication of knowledge, of intent. It’s about expressing the same thing in two different places, possibly in two totally different ways.”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;You might have two pieces of code that are exactly the same, but they are intrinsically expressing different knowledge. That is not a violation of DRY.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Keep your code decoupled
&lt;/h2&gt;

&lt;p&gt;Try the &lt;strong&gt;Law of Demeter&lt;/strong&gt; in your code, to make sure you write modules that don't rely on other modules.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. TDD and unit tests
&lt;/h2&gt;

&lt;p&gt;Use &lt;strong&gt;TDD&lt;/strong&gt; and write &lt;strong&gt;unit tests&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  11. Prototyping is a learning experience
&lt;/h2&gt;

&lt;p&gt;The value of prototyping is the &lt;strong&gt;learning&lt;/strong&gt;, not the code itself. So don't be afraid of missing error handlings, using dummy data or not having the most complete functionality.&lt;/p&gt;

&lt;p&gt;The prototype is not the final product.&lt;/p&gt;

&lt;h2&gt;
  
  
  12. Find better ways for repetitive tasks
&lt;/h2&gt;

&lt;p&gt;If you find yourself doing the same thing &lt;strong&gt;multiple&lt;/strong&gt; times, ask yourself if there is a &lt;strong&gt;better way&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  13. Engineering daybook
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Write down&lt;/strong&gt; all the learnings, keep it in some doc, notes, whatever. So you can go and check it out in the future if needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  14. Write shy code
&lt;/h2&gt;

&lt;p&gt;Be clear and &lt;strong&gt;strict&lt;/strong&gt; on what the code is expecting as an &lt;strong&gt;input&lt;/strong&gt; and promise as &lt;strong&gt;little&lt;/strong&gt; as possible in &lt;strong&gt;return&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  15. Don't chain method calls
&lt;/h2&gt;

&lt;p&gt;Try to avoid more than one "." when accessing something.&lt;/p&gt;

&lt;p&gt;Example from the book:&lt;br&gt;
&lt;code&gt;amount = customer.orders.last().totals().amount&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  16. Refactor is not a full-on rewrite
&lt;/h2&gt;

&lt;p&gt;Don't fool yourself, a refactor should not take week/s of work. Refactor is something &lt;strong&gt;small&lt;/strong&gt;.&lt;br&gt;
And keep in mind a refactor or full-on rewrite it's not meant to add new features. That comes later.&lt;/p&gt;

&lt;h2&gt;
  
  
  17. Naming things
&lt;/h2&gt;

&lt;p&gt;Naming variables, systems, functions and so on is a big part of our work. And let's be honest, we are usually &lt;strong&gt;not&lt;/strong&gt; good at it. Name things according to the &lt;strong&gt;role&lt;/strong&gt; they play.&lt;/p&gt;

&lt;h2&gt;
  
  
  And that was it
&lt;/h2&gt;

&lt;p&gt;There are way more tips, and very well explained in this book. These are, in my personal case, the ones that I want to keep in mind the most and put into practice more often. &lt;/p&gt;

&lt;p&gt;Have you read the book? If so, which ones do you think are the most important for you?&lt;/p&gt;

&lt;p&gt;If not, what are you waiting for? Get the book, some tea and enjoy :D &lt;/p&gt;

</description>
      <category>programming</category>
      <category>books</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>Is Bun so much faster than Node.js?</title>
      <dc:creator>Daniel PL</dc:creator>
      <pubDate>Tue, 26 Jul 2022 06:29:27 +0000</pubDate>
      <link>https://dev.to/danielprlo/is-bun-so-much-faster-than-nodejs-17df</link>
      <guid>https://dev.to/danielprlo/is-bun-so-much-faster-than-nodejs-17df</guid>
      <description>&lt;p&gt;It seems like Bun is the new cool kid in the javascript runtime scenario. Looks very promising and all of that, but, is it that fast?&lt;/p&gt;

&lt;p&gt;I will do a set of simple tests, to see if even on a small scale the performance difference is already noticeable. &lt;/p&gt;

&lt;p&gt;Today I will focus only on requests performance and operations per second. &lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up Bun
&lt;/h2&gt;

&lt;p&gt;But first, I'll start installing bun in the bun directory&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl https://bun.sh/install | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And creating a basic response&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// http.js
export default {
  port: 3000,
  fetch(request) {
    return new Response("Welcome to Bun!");
  },
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Setting up node
&lt;/h2&gt;

&lt;p&gt;Now I can move on to node. Because I already have Node.js installed I just have to create a basic response as well.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) =&amp;gt; {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World');
});

server.listen(port, hostname, () =&amp;gt; {
  console.log(`Server running at http://${hostname}:${port}/`);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now I'm ready to have fun.&lt;/p&gt;

&lt;h2&gt;
  
  
  Http request performance
&lt;/h2&gt;

&lt;p&gt;For the HTTP request performance, I'll test both implementations using Artillery.&lt;/p&gt;

&lt;p&gt;Artillery can be installed through npm&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i artillery
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And comes with a nice CLI to execute a quick load test.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; artillery quick --count 500 --num 100 http://localhost:3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will run 500 virtual users with 100 requests each.&lt;/p&gt;

&lt;p&gt;The results are the following:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;http&lt;/th&gt;
&lt;th&gt;node&lt;/th&gt;
&lt;th&gt;bun&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;http.codes.200&lt;/td&gt;
&lt;td&gt;50000&lt;/td&gt;
&lt;td&gt;50000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;http.request_rate&lt;/td&gt;
&lt;td&gt;1585/sec&lt;/td&gt;
&lt;td&gt;1617/sec&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;http.requests&lt;/td&gt;
&lt;td&gt;50000&lt;/td&gt;
&lt;td&gt;50000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;http.responses&lt;/td&gt;
&lt;td&gt;50000&lt;/td&gt;
&lt;td&gt;50000&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;http.response_time&lt;/th&gt;
&lt;th&gt;Node&lt;/th&gt;
&lt;th&gt;Bun&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;min&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;max&lt;/td&gt;
&lt;td&gt;143&lt;/td&gt;
&lt;td&gt;73&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;median&lt;/td&gt;
&lt;td&gt;32.8&lt;/td&gt;
&lt;td&gt;22.9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p95&lt;/td&gt;
&lt;td&gt;63.4&lt;/td&gt;
&lt;td&gt;36.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p96&lt;/td&gt;
&lt;td&gt;100.5&lt;/td&gt;
&lt;td&gt;50.9&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;vusers.session_length&lt;/th&gt;
&lt;th&gt;Node&lt;/th&gt;
&lt;th&gt;Bun&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;min&lt;/td&gt;
&lt;td&gt;1835.3&lt;/td&gt;
&lt;td&gt;1103.1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;max&lt;/td&gt;
&lt;td&gt;4989.2&lt;/td&gt;
&lt;td&gt;2805.9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;median&lt;/td&gt;
&lt;td&gt;3678.4&lt;/td&gt;
&lt;td&gt;2566.3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p95&lt;/td&gt;
&lt;td&gt;4770.6&lt;/td&gt;
&lt;td&gt;2780&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p99&lt;/td&gt;
&lt;td&gt;4867&lt;/td&gt;
&lt;td&gt;2780&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;(in milliseconds)&lt;/p&gt;

&lt;p&gt;The results are far from the claims in performance from Bun, but still, very solid. In all aspects, Bun stands out as the winner.&lt;/p&gt;

&lt;h2&gt;
  
  
  Operations per second
&lt;/h2&gt;

&lt;p&gt;Here I'll do a test of just calculating prime numbers, to see how long it takes for each one.&lt;/p&gt;

&lt;p&gt;To test the calculation of prime numbers I will execute a very simple code and make use of &lt;code&gt;performance.now()&lt;/code&gt; to measure the execution time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(function (maxNumbers = 30000) {
  let start = performance.now();
  let primeNumbers = []
  let numberToCheck = 1;
  while (primeNumbers.length &amp;lt; maxNumbers) {
    if (isPrimeNumber(numberToCheck)) {
      primeNumbers.push(numberToCheck);
    }
    numberToCheck++;
  }

  console.log(performance.now() - start);
})();

function isPrimeNumber(number) {
  for (let i = 2; i &amp;lt; number; i++) {
    if (number % i === 0) return false;
  }
  return true;
}

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

&lt;/div&gt;



&lt;p&gt;The results for calculating prime numbers are the following (in milliseconds):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;prime numbers&lt;/th&gt;
&lt;th&gt;node&lt;/th&gt;
&lt;th&gt;bun&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;100&lt;/td&gt;
&lt;td&gt;1.035&lt;/td&gt;
&lt;td&gt;0.618&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;500&lt;/td&gt;
&lt;td&gt;4.5071&lt;/td&gt;
&lt;td&gt;3.223&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1000&lt;/td&gt;
&lt;td&gt;9.3060&lt;/td&gt;
&lt;td&gt;8.680&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5000&lt;/td&gt;
&lt;td&gt;209.8485&lt;/td&gt;
&lt;td&gt;198.4309&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10000&lt;/td&gt;
&lt;td&gt;909.618&lt;/td&gt;
&lt;td&gt;849.832&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;30000&lt;/td&gt;
&lt;td&gt;9113.5302&lt;/td&gt;
&lt;td&gt;8559.282&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This time the results are not that different, but Bun wins again.&lt;/p&gt;

&lt;p&gt;Bun is still in beta version, and we should keep that in mind. If at this stage the results already look promising, interesting times will come if the improvement continues along the same lines and, who knows, maybe in some years Bun will find its place on the market.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>bunjs</category>
      <category>performance</category>
    </item>
  </channel>
</rss>
