<?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: Henrique Leite</title>
    <description>The latest articles on DEV Community by Henrique Leite (@henriqueleite42).</description>
    <link>https://dev.to/henriqueleite42</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%2F1441709%2F3ae804d7-b101-48da-9619-33bf891b7b2d.png</url>
      <title>DEV Community: Henrique Leite</title>
      <link>https://dev.to/henriqueleite42</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/henriqueleite42"/>
    <language>en</language>
    <item>
      <title>TypeScript (and JSDoc) vs JavaScript</title>
      <dc:creator>Henrique Leite</dc:creator>
      <pubDate>Thu, 24 Oct 2024 19:59:28 +0000</pubDate>
      <link>https://dev.to/henriqueleite42/typescript-and-jsdoc-vs-javascript-4d96</link>
      <guid>https://dev.to/henriqueleite42/typescript-and-jsdoc-vs-javascript-4d96</guid>
      <description>&lt;p&gt;Introduction&lt;/p&gt;

&lt;p&gt;Even in 2024, 12 years after the release of TypeScript and 17 years after the release of JSDoc, many people still dont know why to use a static typing tool in their JavaScript project, even after it became a standard in the JavaScript/NodeJs community.&lt;/p&gt;

&lt;p&gt;In this article, Ill explain what TypeScript and JSDoc are, and why you should use one of them in your projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  What they are
&lt;/h2&gt;

&lt;p&gt;TypeScript and JSDoc are tools to allow JavaScript to have static typing. See below for an example of both of them.&lt;/p&gt;

&lt;p&gt;As you can see, TypeScript usually is less verbose than JSDoc, but on the other hand, JSDoc doesnt require a build step, it works directly with comments in JavaScript code.&lt;/p&gt;

&lt;h3&gt;
  
  
  TypeScript
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;convert-string-to-int.ts (TYPESCRIPT file!)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc65tmo9s6k8ugw67x48j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc65tmo9s6k8ugw67x48j.png" width="643" height="88"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  JSDoc
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;convert-string-to-int.js (JAVASCRIPT file!)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiww0n5tkygnfzmrer6lx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiww0n5tkygnfzmrer6lx.png" width="800" height="206"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Pros
&lt;/h2&gt;

&lt;p&gt;Before speaking about the pros, I must say that no matter how many articles you read or how good these articles are, theres no way to describe how much better the developer experience is when you work with static typing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No one&lt;/strong&gt; can explain with words or arguments how good it is to work with a codebase that has static typing over an untyped one, not even the best of poets.&lt;/p&gt;

&lt;p&gt;I, like many others, will try to translate this feeling into facts and data, but I ensure that it will not be enough to describe the exact feeling.&lt;/p&gt;

&lt;h3&gt;
  
  
  Avoid errors in production
&lt;/h3&gt;

&lt;p&gt;This, without a doubt, is the biggest advantage of static typing. There are not enough words to describe how helpful it is, both in terms of avoiding reworks and saving money.&lt;/p&gt;

&lt;p&gt;To ship things fast, mainly hotfixes, we end up not having the time to write unit tests or test all the possible flows of a solution. If you work with pure JavaScript, theres no way to ensure that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;All the variables that you are using exist&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;All the variables that you are using are declared&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You are using allowed methods for that type (ex: you can use &lt;code&gt;map&lt;/code&gt; in a &lt;code&gt;number&lt;/code&gt; variable)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you are comparing equivalent variables (you shouldnt compare an &lt;code&gt;number&lt;/code&gt; with an &lt;code&gt;array&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you do not test your code extremely well, you will have to work on it again to fix a bug, spending precious time on something that you could have coughed before. Bugs caused by these things may sound stupid, but they are the ones that happen the most.&lt;/p&gt;

&lt;p&gt;Using static typing, you ensure safer and faster development, decrease absurdly the amount of bugs in production, and allow the developer to focus only on the thing that really delivers value: The business logic.&lt;/p&gt;

&lt;h3&gt;
  
  
  No unnecessary testing
&lt;/h3&gt;

&lt;p&gt;Most legacy projects and cloud-intensive projects (projects that you many resources exclusive to the cloud) have a difficult process of running the code locally, or even worse, you have to deploy it to be able to execute without mocks.&lt;/p&gt;

&lt;p&gt;The process of running things locally can be very time-consuming and exhausting to the developers, and being able to avoid it saves a lot of resources (time, money, patience, cloud resources, etc).&lt;/p&gt;

&lt;p&gt;With static typing, the code is very predictable, and you can develop everything knowing what is happening in each part of the code, and track the execution very easily, this makes it so that the only time you need to run the code is after finishing development, to truly test if everything works as expected.&lt;/p&gt;

&lt;h3&gt;
  
  
  No outdated docs
&lt;/h3&gt;

&lt;p&gt;Most of the time (if not all of them) when we try to write documentation about a function and try to add examples of input/output it becomes outdated in the blink of an eye. Developers never remember to update the docs, and Scrum Masters never want to allocate enough time to do it.&lt;/p&gt;

&lt;p&gt;With static typing, the code is a live doc. Itll never become outdated, because when developers update the code, they will be updating the docs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Avoid problems with CommonJs / ES modules
&lt;/h3&gt;

&lt;p&gt;After the &lt;a href="https://blog.logrocket.com/commonjs-vs-es-modules-node-js/" rel="noopener noreferrer"&gt;implementation of ES modules in NodeJs&lt;/a&gt;, many libraries started to migrate to this new way of writing code, so their new versions (more secure, reliable, performative, and with more features) arent compatible with older versions of JavaScript, which leaves you stuck with unsafe outdated versions.&lt;/p&gt;

&lt;p&gt;Guess what is compatible with both CommonJs and ES modules without having to change anything in your code (only a few lines in the configuration)? Exactly, TypeScript (unfortunately, I think that JSDoc doesnt have this advantage).&lt;/p&gt;

&lt;h3&gt;
  
  
  Autocomplete &amp;amp; avoid miswriting
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnjj1l4k7i97p76xw9343.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnjj1l4k7i97p76xw9343.png" width="800" height="242"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Instead of having to remember every property and method that something has, let static typing and your favorite IDE do it for you!&lt;/p&gt;

&lt;p&gt;This decreases development time because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You do not have to go back and forward to consult the properties of something&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can type only the first letters of the property/method and press enter (or select the right suggestion, then press enter), and it will be autocompleted&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It also &lt;strong&gt;avoids the miswriting of words&lt;/strong&gt; , a thing that causes more bugs in production than it should.&lt;/p&gt;

&lt;h3&gt;
  
  
  Less loss of knowledge &amp;amp; no time wasted
&lt;/h3&gt;

&lt;p&gt;Its common that in a project, different developers write specific parts of the code, and what may seem very obvious to the person writing it, may not be intuitive to everyone.&lt;/p&gt;

&lt;p&gt;If other developers work on a new thing written by another person, they will have to spend some time understanding it before being able to make any changes. Using static typing allows developers to cut A LOT of time understanding the values of the variables and the flow of execution.&lt;/p&gt;

&lt;p&gt;If the developer who wrote that code leaves the company/team, it will not have an impact as big as it would have, because all this documentation is directly on the code. Easy to find and easy to understand.&lt;/p&gt;

&lt;p&gt;Developers also need to rely less on pair programming to be able to work on a project, if its well-typed and simple enough, they may be able to make improvements/changes without even talking to someone in the project, increasing absurdly their efficiency.&lt;/p&gt;

&lt;h3&gt;
  
  
  Modern and attractive to developers
&lt;/h3&gt;

&lt;p&gt;TypeScript is one of the most loved languages based on the Stack Overflow Developer Survey, heres the results of 4 consecutive years:&lt;/p&gt;

&lt;p&gt;2020:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl1jhyjoe8vd95qzi2r5w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl1jhyjoe8vd95qzi2r5w.png" alt="Stack Overflow 2020 Developer Survey" width="700" height="527"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2021:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fudiof0ponfsb04hwwg12.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fudiof0ponfsb04hwwg12.png" width="800" height="243"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2022:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkful6v69dvbc97opog51.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkful6v69dvbc97opog51.png" width="800" height="243"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2023:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvdkimmk7vptm3pdpmwa2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvdkimmk7vptm3pdpmwa2.png" width="800" height="163"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;JSDoc is not present in the survey, so I do not have any kind of data to say that its a good option. The only thing that I can say is that &lt;a href="https://htmx.org" rel="noopener noreferrer"&gt;HTMX&lt;/a&gt; is using it, but its a very simple library.&lt;/p&gt;

&lt;p&gt;On the other hand, we can say that from this survey, developers have preferred TypeScript over JavaScript for most of the recent years.&lt;/p&gt;

&lt;h3&gt;
  
  
  Flexible
&lt;/h3&gt;

&lt;p&gt;You do not need to type everything. TypeScript and JSDoc can guess the type of most of the things, which makes it a lot easier and less verbose than other languages like Java or C.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl2esjcs50ft0tl4uu8fd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl2esjcs50ft0tl4uu8fd.png" width="471" height="88"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For TypeScript, in the worst-case scenario, just use &lt;code&gt;any&lt;/code&gt;. &lt;code&gt;any&lt;/code&gt; is the joker type, it represents &lt;em&gt;anything&lt;/em&gt;, and because of this you &lt;strong&gt;should avoid it at all costs&lt;/strong&gt; , but if you are short on time or dont want to be blocked by the lack of a type, you have this option.&lt;/p&gt;

&lt;p&gt;For JSDoc, simply do not comment on anything, its pure JavaScript!&lt;/p&gt;

&lt;h3&gt;
  
  
  No more unnecessary refactor
&lt;/h3&gt;

&lt;p&gt;Ill explain more about the why of it in the It has a high learning curve section, but Ill give some spoilers here.&lt;/p&gt;

&lt;p&gt;Codebases with ununderstandable code need to be refactored, and codebases that dont have proper documentation (that we agree is impossible to maintain if its separate from the code) have a higher amount of sections &lt;strong&gt;impossible&lt;/strong&gt; to understand without a lot of digging and time to analyze.&lt;/p&gt;

&lt;p&gt;Refactors should not happen because your code is impossible to understand, but because of performance issues or changes in the business logic. having to do the same thing twice is bad for everyone: the developers, the users, and the investors.&lt;/p&gt;

&lt;h3&gt;
  
  
  More independence for developers
&lt;/h3&gt;

&lt;p&gt;Its common for long-lived projects to have multiple people working on them, and it always takes some time (both for the newcomer and the more experienced developers) to make newcomers proficient with that codebase.&lt;/p&gt;

&lt;p&gt;With static types, we can decrease the necessary time A LOT, because developers can understand at least the basics of the code alone, and need the help of other developers only to understand more complex business logic (if they arent documented in the code, but this is a topic for another article).&lt;/p&gt;

&lt;p&gt;It makes it easier to have newcomers in the projects, decreases their learning curve a lot, and allows them to work on the project with less risk of breaking something, increasing the efficiency of your team as a whole.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cons
&lt;/h2&gt;

&lt;h3&gt;
  
  
  More complex build step
&lt;/h3&gt;

&lt;p&gt;The only con that TypeScirpt has is that its build step is more complex (because lets be real, nowadays ALL JavaScript projects have a build step already, so it only makes it a little more complex).&lt;/p&gt;

&lt;p&gt;You may need proper plugins or adapters to integrate your build process with TypeScript, but nowadays we have a bunch of mature and ready-for-production libraries, plugins, tools, and whatever you need to make it work.&lt;/p&gt;

&lt;p&gt;Im not gonna lie, it may cause you some trouble the first time, like most other tools in the JavaScript ecosystem, but not enough to overtake the pros.&lt;/p&gt;

&lt;p&gt;If you choose to use &lt;a href="https://jsdoc.app" rel="noopener noreferrer"&gt;JSDoc&lt;/a&gt; instead of TypeScript, this only con that TypeScript has is gone, but a new one appears: JSDoc doesnt work very well with more complex types if you dont use classes to represent them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Debunking arguments
&lt;/h2&gt;

&lt;h3&gt;
  
  
  It has a high learning curve
&lt;/h3&gt;

&lt;p&gt;Static typing requires you to &lt;em&gt;write a few more things&lt;/em&gt;, but the learning curve is not related to the extra &lt;code&gt;: string&lt;/code&gt; that you have to write, but to &lt;strong&gt;how difficult it is to work with that codebase&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Without static typing, you need A LOT more context to understand what is happening in the code, what values a variable has, and what business logic is being applied.&lt;/p&gt;

&lt;p&gt;Lets see an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;processOrders&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="c1"&gt;// Logic here&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With only this information, can you determine what values does &lt;code&gt;orders&lt;/code&gt; has? You may say &lt;em&gt;Its an array!&lt;/em&gt;, but guess what? You are wrong. &lt;code&gt;orders&lt;/code&gt; is an &lt;em&gt;object&lt;/em&gt;. Which properties does it have? Good luck spending at least a minute looking at the code to figure it out.&lt;/p&gt;

&lt;p&gt;Are the properties optional? Do they always exist? They are objects, arrays, or strings? Does another member of your team have this knowledge or the person who wrote this code is long gone?&lt;/p&gt;

&lt;p&gt;Static typing by itself &lt;strong&gt;reduces&lt;/strong&gt; the learning curve &lt;strong&gt;by a colossal amount&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;With pure JavaScript, each person who would work at something related to &lt;code&gt;processorders&lt;/code&gt; would have to go through the same process:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Asking themselves what &lt;code&gt;orders&lt;/code&gt; is&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Spending a lot of time inside the &lt;code&gt;processOrders&lt;/code&gt; logic trying to figure it out&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If it requires a specific behavior of &lt;code&gt;processOrders&lt;/code&gt;, probably asking other team members for more details and spending their time also&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Lets put it in numbers, to make it more fun:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A team of 5 people, each one making $ 100k/year&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lets say they must work with &lt;code&gt;processOrders&lt;/code&gt; one time every 6 months, time enough to forget about specific details&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;They spend 5 minutes to figure out EVERYTHING they need (Yes, Im being very, very optimistic here)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A project usually has thousands or at least hundreds of functions, all of them similar to &lt;code&gt;processOrders&lt;/code&gt;, but lets consider only a small project here, with only 10 functions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;5 developers * 10 minutes / year * 10 functions = 500 minutes per year&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If each developer makes 88 cents per minute, &lt;strong&gt;It would cost $440&lt;/strong&gt; only to figure out what &lt;strong&gt;10 functions&lt;/strong&gt; receive and return. This is unproductive time, that doesnt generate any value, in the BEST case of a fictional scenario where your magical project only has 10 functions, and not the real-world where a project has &lt;strong&gt;thousands&lt;/strong&gt; of these.&lt;/p&gt;

&lt;p&gt;Now, with TypeScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Orders&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="nl"&gt;ids&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
 &lt;span class="nx"&gt;skipTypes&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="c1"&gt;// Skip orders if they have specific types&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;ProcessedOrders&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="nl"&gt;total&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;
 &lt;span class="nx"&gt;success&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="c1"&gt;// Amount of orders that were succesfully&lt;/span&gt;
 &lt;span class="nx"&gt;processed&lt;/span&gt; &lt;span class="nx"&gt;skipped&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="c1"&gt;// Amount of skipped orders based on input filters&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;processOrders&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Orders&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ProcessedOrders&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Logic here&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I know that this is a terrible unintuitive function, but this happens in the code. &lt;strong&gt;It shouldnt&lt;/strong&gt; , but it does, so its better to at least have it documented.&lt;/p&gt;

&lt;p&gt;Contrary to the pure JavaScript version, here you have all the context that you need to understand &lt;strong&gt;everything&lt;/strong&gt; that the function receives and returns, whether its optional or not, and the basic principle of what the function does.&lt;/p&gt;

&lt;p&gt;After all this, you can still argue many things, like &lt;em&gt;Its a Clean Code problem, not JavaScripts problem!&lt;/em&gt; or &lt;em&gt;Its a Lack of Documentation&lt;/em&gt; &lt;em&gt;problem, not JavaScripts problem!,&lt;/em&gt; but I ensure you, all of these things are &lt;strong&gt;DIFFERENT&lt;/strong&gt; problems that yes, happen in the code, that I may address in other articles, but arent the focus of this one.&lt;/p&gt;

&lt;h3&gt;
  
  
  Some libraries dont support TypeScript
&lt;/h3&gt;

&lt;p&gt;This is the magic of TypeScript: You do not need your libraries to support TypeScript.&lt;/p&gt;

&lt;p&gt;You can use the library without any typing, and it will work the same, but since it will be harder to work with a pure JavaScript library (because it doesnt have any of the advantages mentioned in this article) you probably should consider using a different one.&lt;/p&gt;

&lt;h3&gt;
  
  
  Ill have to learn something new
&lt;/h3&gt;

&lt;p&gt;Yes. We as developers &lt;strong&gt;have to&lt;/strong&gt; learn something new &lt;strong&gt;every day&lt;/strong&gt;. its part of our jobs. We are here to create technical solutions for problems, to be a reference, and to figure out how to solve the problems that we face.&lt;/p&gt;

&lt;p&gt;Learning something new that has so many benefits is an effort that makes the time worthwhile.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;After knowing how much static typing tools help development, without any considerable cons against it, theres no way to deny how beneficial it is for everyone: The developer, the users, and the finances of the company.&lt;/p&gt;

&lt;p&gt;I hope that this article helps you to understand it and convince your pairs to improve your development experiences.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>node</category>
    </item>
    <item>
      <title>Should I do it in the client or the server?</title>
      <dc:creator>Henrique Leite</dc:creator>
      <pubDate>Sun, 18 Aug 2024 21:53:07 +0000</pubDate>
      <link>https://dev.to/henriqueleite42/should-i-do-it-in-the-client-or-the-server-11db</link>
      <guid>https://dev.to/henriqueleite42/should-i-do-it-in-the-client-or-the-server-11db</guid>
      <description>&lt;p&gt;When working on interactive websites, we constantly face the challenge of defining if something should be executed on the server or in the client, but how do we decide it? This article will help you know how.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This article does not applies to SPAs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Different types of web apps
&lt;/h2&gt;

&lt;p&gt;We have two types of web apps: Offline-first and Online-first.&lt;/p&gt;

&lt;p&gt;Offline-first apps are the ones where you need an insanely fast response for the user. They are extremely interactive. Good examples are Notion (or any WYSIWYG editors), Google Calendar, Trello, and Google Sheets.&lt;/p&gt;

&lt;p&gt;Online-first apps are the most common cases, all apps that don't need to be offline-first should be online-first. They rely on the server's responses to execute things and show the results to the users only after it.&lt;/p&gt;

&lt;p&gt;For offline-first apps, you must execute everything on the client BEFORE executing it on the server, this way you don't have to deal with the server's latency, so it's a solved case.&lt;/p&gt;

&lt;p&gt;Now, online-first apps, are the real deal. They prompt us with the challenge of deciding where to execute something.&lt;/p&gt;

&lt;h2&gt;
  
  
  The criteria
&lt;/h2&gt;

&lt;p&gt;To determine if you should execute something in the client or on the server, you need to ask yourself the following questions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Does the user will lose something if the power goes out?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If they lose something, will it be extremely important?&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, let's see how to apply these questions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Our example
&lt;/h2&gt;

&lt;p&gt;Let's have a web app with a sidebar that displays the username of the currently logged user and a page that has a button "edit username button":&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1724012343580%2Fe4111be1-5149-4485-98a8-d4d691deda57.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1724012343580%2Fe4111be1-5149-4485-98a8-d4d691deda57.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When clicking on the "edit username button", a modal shows up:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1724012793006%2F48ddfa91-bfb3-488f-9a1f-b66441397105.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1724012793006%2F48ddfa91-bfb3-488f-9a1f-b66441397105.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And after the username is successfully updated, the username on the sidebar changes, and a success toast appears on the top right corner of the page:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1724012839801%2F2944fdbd-f55e-42ff-8ddc-7cc71d4ddcc2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1724012839801%2F2944fdbd-f55e-42ff-8ddc-7cc71d4ddcc2.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This is not a real web app, I created these images using &lt;a href="https://www.photopea.com" rel="noopener noreferrer"&gt;Photopea&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  State
&lt;/h2&gt;

&lt;p&gt;Notice that we have multiple states here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The user's username is a state&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The open/closed modal is a state&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The toast open/closed and the message are states&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code&gt;client&lt;/code&gt; should only manage short-lived, unimportant states, that control mostly visual things.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;server&lt;/code&gt; should have no state, but should be able to operate with states:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;query string&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;sessions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;cookies&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In summary, avoid states as best as you can, but be aware that we rarely can avoid them, so we must learn how to deal with them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Opposite poles
&lt;/h2&gt;

&lt;p&gt;We have multiple ways of doing it, and I'll tell you the 2 cases: One that does all the changes through the client and the other that does all the changes through the server.&lt;/p&gt;

&lt;h3&gt;
  
  
  All client
&lt;/h3&gt;

&lt;p&gt;Initial load:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The page loads with all the elements, but the username is empty&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Does a request to the server's API to get the username&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Changes the HTML using JS with the data returned by the server's API&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The user clicks on the "edit username button" button:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It triggers a JS function that opens the modal (removing a &lt;code&gt;hidden&lt;/code&gt; class, creating it, and appending it to the HTML, it doesn't matter)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The user inserts his new username and clicks on the "submit" button:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The client makes a request on the server's API and waits for it to succeed&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then update the HTML text of the username with the new username&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Closes the modal&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Makes the toast appear with the message "username successfully updated!" and disappears after some seconds.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  All server
&lt;/h3&gt;

&lt;p&gt;Initial load:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Get username from session / JWT / database / doesn't matter&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Returns the page already completed with the username&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The user clicks on the "edit username button" button:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Redirects the user to another page, that has the modal open and the input&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Because the username still appears on the sidebar, it will have to get the username again&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The user inserts his new username and clicks on the "submit" button:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Submits a form that makes a POST request to a route in the server, that changes the username and redirects to another page&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The new page has the modal closed, the new username, and a toast rendered&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why do both cases suck
&lt;/h2&gt;

&lt;p&gt;Let's see why none of the cases work very well to create a good user experience:&lt;/p&gt;

&lt;h3&gt;
  
  
  All client
&lt;/h3&gt;

&lt;p&gt;For the ones that only ever worked with React/SPAs, this seems like the only way to do things, and nothing seems wrong, but let's see the drawbacks that this solution has for the user experience:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The user will see a glitch on their username in the bottom left corner since it has to be loaded after the page loads&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It's hard to isolate the things and reproduce the steps to get to the "new username" state (in this case, make the success toast show up)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  All server
&lt;/h3&gt;

&lt;p&gt;In this case, I think that it's easier for everyone to see why this approach is bad:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You will need to copy the page with the "update username button", with the addition of a modal on top of it. Increases nonsense code duplication.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;As we can't use any client-side interactions, the toast will stay there for as long as the user stays on the page&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Uh, but what about the latency??&lt;/em&gt; If you need to worry about latency in 2024, you probably are doing something wrong. Please, reconsider where are you hosting your servers, how you are delivering your content, and what are your routes doing. Read &lt;a href="https://developer.yahoo.com/performance/rules.html" rel="noopener noreferrer"&gt;this article&lt;/a&gt; from the Yahoo guys, they rule.&lt;/p&gt;

&lt;h2&gt;
  
  
  Balance
&lt;/h2&gt;

&lt;p&gt;The best approach is neither all server-side nor all client-side, but a mix of both. And we need to balance this properly.&lt;/p&gt;

&lt;h3&gt;
  
  
  The correct flow
&lt;/h3&gt;

&lt;p&gt;Initial load:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;[server]&lt;/strong&gt; Get username from session / JWT / database / doesn't matter&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;[server]&lt;/strong&gt; Returns the page already completed with the username&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The user clicks on the "edit username button" button:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;[client]&lt;/strong&gt; It triggers a JS function that opens the modal (removing a &lt;code&gt;hidden&lt;/code&gt; class, creating it, and appending it to the HTML, it doesn't matter)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The user inserts his new username and clicks on the "submit" button:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;[server]&lt;/strong&gt; Submits a form that makes a POST request to a route in the server, that changes the username and redirects to the same page, but this time using a query param &lt;code&gt;toastJSON&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;[server]&lt;/strong&gt; The route will then check if &lt;code&gt;toastJSON&lt;/code&gt; is present in the query params, and in addition to the page, will also return a toast without JS.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;[client]&lt;/strong&gt; The client will have an &lt;code&gt;window.onload&lt;/code&gt; event, that searches for toast elements and applies the necessary JS to them.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now the user never will lose an important toast nor have glitches in the UI.&lt;/p&gt;

&lt;p&gt;It's a lot easier to test if the UI is working: all of our state is shortlived and has no impact if it's lost.&lt;/p&gt;

&lt;h2&gt;
  
  
  States
&lt;/h2&gt;

&lt;p&gt;Let's review our states and see which part of our system is controlling them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;[server]&lt;/strong&gt; The user's username is a state&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;[client]&lt;/strong&gt; The open/closed modal is a state&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;[server + client]&lt;/strong&gt; The toast open/closed and the message are states&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Mixing client and server actions helps us to develop more stable and testable applications, without having to manage complex unreproducible states.&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

</description>
      <category>clientsiderendering</category>
      <category>serversiderendering</category>
      <category>webdev</category>
    </item>
    <item>
      <title>The current state of GitHub</title>
      <dc:creator>Henrique Leite</dc:creator>
      <pubDate>Thu, 15 Aug 2024 18:38:12 +0000</pubDate>
      <link>https://dev.to/henriqueleite42/the-current-state-of-github-3dfp</link>
      <guid>https://dev.to/henriqueleite42/the-current-state-of-github-3dfp</guid>
      <description>&lt;p&gt;It's not a secret that I dislike all the things that Microsoft owns, and yet, I'm haunted by them every single day. No day passed by without I'm forced to use Microsoft Teams, Azure with their terrible excuse of scrum boards, or GitHub, with their lack of features only being compensated for the free things they offer.&lt;/p&gt;

&lt;p&gt;The only exception is VSCode, but they are really trying their best to make it as bloated as possible, so I have high hopes for &lt;a href="https://zed.dev" rel="noopener noreferrer"&gt;Zed&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The last straw
&lt;/h2&gt;

&lt;p&gt;Today, I noticed something &lt;em&gt;very special&lt;/em&gt;: GitHub is working on lists to organize your stars.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1723744411007%2F23f2ceba-0e5e-46e9-86e3-37c4f74fcda3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1723744411007%2F23f2ceba-0e5e-46e9-86e3-37c4f74fcda3.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the feature that the community is claiming for! We NEED it, and I didn't even know that a few seconds ago. I'm so happy that they know their customers so well.&lt;/p&gt;

&lt;p&gt;Who thinks like that? Who has a list of missing features on GitHub where the first item is "list of starred repositories"? This to me is the last straw. They don't know what they are doing with the platform.&lt;/p&gt;

&lt;p&gt;GitHub is good enough, but is far from perfect. Let's see a small list of things that it's lacking:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Repository folders, so you can group your repositories&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Default reviewers for group of repositories&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;GUI to change and configure the default reviews&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Repository topics on the home page of an organization, like in the repositories page&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Organization/account wide configuration for repositories&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Organization access tokens, so you don't have to use user personal account key in pipelines&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;RSS feed for releases&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A better home page&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;GUI for filters (on issues, discussions, etc)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;And many, many more&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  "We are a social platform"
&lt;/h2&gt;

&lt;p&gt;Who uses GitHub to hang out?&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Hey, I saw on my GitHub homepage, because I follow your profile btw, that you create a new repository, very nice champ!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If I want to follow you, I'll follow you on Twitter or Daily.Dev, not on GitHub.&lt;/p&gt;

&lt;p&gt;GitHub is the platform for open-source (kinda hilarious how the open-source platform isn't open-source, isn't it?), we go there to create public things and interact through issues and discussions, and yet, Microsoft tries its best to force it to be Facebook.&lt;/p&gt;

&lt;p&gt;It should be focused on collaboration, on making things easier. Easier to find repositories (folders), easier to organize permissions (access key for organizations), and a lot of things that GitHub has been ignoring for years.&lt;/p&gt;

&lt;h2&gt;
  
  
  The alternatives
&lt;/h2&gt;

&lt;p&gt;Do we really have alternatives?&lt;/p&gt;

&lt;p&gt;I tried to use Bitbucket, but it has SOOOO MANY things that it's hard to configure anything. The interface is extremely polluted, you can't find anything there. The learning curve is immense.&lt;/p&gt;

&lt;p&gt;I heard that GitLab has the same problem Bitbucket has, so what more do we have? Amazon CodeCommit? No, thanks.&lt;/p&gt;

&lt;p&gt;GitHub was amazing before it was purchased by Microsoft, and on the first few years, the purchase was a great thing: free private repositories and free pipelines, but now they are doing the same thing that they do with every Microsoft product: destroying it.&lt;/p&gt;

&lt;p&gt;The good thing is: The same way that the fall of Skype brought the rise of Discord, I see a new git platform for open-source coming in the next few years. One that solves the problems that GitHub have, even if it has a price.&lt;/p&gt;

&lt;p&gt;If you know any GitHub alternatives, please leave it in the comments to share with the community, may we can at least give GitHub some fair competition to make them fell the pressure to improve.&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

</description>
      <category>github</category>
      <category>git</category>
      <category>startup</category>
      <category>ideas</category>
    </item>
    <item>
      <title>Anvil: An attempt of saving time</title>
      <dc:creator>Henrique Leite</dc:creator>
      <pubDate>Wed, 14 Aug 2024 20:00:12 +0000</pubDate>
      <link>https://dev.to/henriqueleite42/anvil-an-attempt-of-saving-time-4if7</link>
      <guid>https://dev.to/henriqueleite42/anvil-an-attempt-of-saving-time-4if7</guid>
      <description>&lt;p&gt;When I'm creating a new project, I always have the same problem: In order to follow best practices and make the code maintainable, the codebase becomes extremely verbose.&lt;/p&gt;

&lt;p&gt;It always takes my motivation from me to have to write a bunch of stuff only to make some CRUDs. It's boring, repetitive and takes all my joy off coding.&lt;/p&gt;

&lt;p&gt;Why I don't use Template Repositories?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It's a terrible experience to have to keep updating dependencies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I always forgot to change example values, like the README&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The changes that I do on the template aren't applied to the previous projects, so if I want to add a new thing like graceful shutdown, I have to do it one by one, and I have it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This one doesn't affect it so much, but I don't like to have commits from the template repository on a new repository, and it's an extra thing to have to delete the &lt;code&gt;.git&lt;/code&gt; folder&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This leads me to think about the things that I hate, and I discovered that I hate many things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Lack of documentation in a project&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lack o standards between multiple projects&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lack of a way to track where a piece of data is used&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lack o standards between multiple projects&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lack of a way to track the flow of events and communication between services&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lack o standards between multiple projects&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Did I mention that I hate Lack o standards between multiple projects? Because I hate it. A lot.&lt;/p&gt;

&lt;p&gt;And all these frustrations gave me an idea: &lt;em&gt;What If I tried to create a specification to creating APIs?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Most APIs follow the same pattern, have the same things, and we all agree in a couple of standards and best practices for web development.&lt;/p&gt;

&lt;p&gt;And from this, &lt;a href="https://github.com/henriqueleite42/anvil" rel="noopener noreferrer"&gt;Anvil&lt;/a&gt; was born.&lt;/p&gt;

&lt;p&gt;Anvil is my attempt to create something that's a mix of three things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;OpenAPI/Swagger specs&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;No-Code solutions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Frameworks&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, from a schema file (similar to OpenAPI specs), a code generator that can be fully customized by anyone, will generate a repository with all the standards and best practices that you want, without making you dependent on it like a Framework would.&lt;/p&gt;

&lt;p&gt;The best part is that it can update your project for you, so it's not used only on the project creation. The schema file will always be the starting point for any feature.&lt;/p&gt;

&lt;p&gt;I'm already working on the schema definition, it's hard to make it work with all the features that HTTP has, it ends up being too much flexible (WE NEED MORE STANDARDS!!!!), but nothing that a couple of days to define if a property should be called &lt;code&gt;ResHeaders&lt;/code&gt; or &lt;code&gt;ResponseHeader&lt;/code&gt;, am I right?&lt;/p&gt;

&lt;p&gt;Please, give a look at &lt;a href="https://github.com/henriqueleite42/anvil" rel="noopener noreferrer"&gt;the repository&lt;/a&gt;, the &lt;a href="https://github.com/henriqueleite42/anvil/blob/master/schemas/v1.0.0.json" rel="noopener noreferrer"&gt;json schema definition&lt;/a&gt; and &lt;a href="https://github.com/henriqueleite42/anvil/tree/master/examples" rel="noopener noreferrer"&gt;the examples&lt;/a&gt; to see what you think about it. I'm open to any suggestions, the more edge cases that we can predict, the less breaking changes we have.&lt;/p&gt;

&lt;p&gt;If you have any options that you wanna share, please, leave it in the comments or create an issue in the repository and let's talk about it. Thanks for reading.&lt;/p&gt;

</description>
      <category>codegeneration</category>
      <category>nocode</category>
      <category>standards</category>
    </item>
    <item>
      <title>Why the upvote system is a pyramid scheme</title>
      <dc:creator>Henrique Leite</dc:creator>
      <pubDate>Mon, 12 Aug 2024 16:21:24 +0000</pubDate>
      <link>https://dev.to/henriqueleite42/why-the-upvote-system-is-a-pyramid-scheme-1795</link>
      <guid>https://dev.to/henriqueleite42/why-the-upvote-system-is-a-pyramid-scheme-1795</guid>
      <description>&lt;p&gt;I'm sure I'll get a lot of downvotes on this one, but I have to say it.&lt;/p&gt;

&lt;p&gt;In programming, most of the communities like Reddit, Stackoverflow and DailyDev have an upvote/downvote system, and in this article, I'll say why this is a nonsensical pyramid scheme that has the only purpose of inflating ego.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the votes work
&lt;/h2&gt;

&lt;p&gt;It's very simple:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Someone upvotes your post/comment/answer and your reputation increases&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Someone downvotes your post/comment/answer and your reputation decreases&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But here's the trick part: It's only valid when it's coming from someone with &lt;strong&gt;high reputation&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;By allowing only the people with high reputation to give reputation to others, you segregate your users and build a monopoly of reputation. Only the ones approved, chosen by the gods, are worth to have their voices listen.&lt;/p&gt;

&lt;p&gt;This leads to very toxic communities, the best example is StackOverflow, where most of the mods are there only to inflate their egos and not to help. This is a disfavor for all the dev community.&lt;/p&gt;

&lt;h2&gt;
  
  
  The solution
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Rate limiting
&lt;/h3&gt;

&lt;p&gt;These platforms already have a rate limiting system, where you can post / interact just a couple of times a day. By enforcing hate limiting, like "you can only give reputation to someone 1 time a day", this would cut most of the bots.&lt;/p&gt;

&lt;h3&gt;
  
  
  Behavior analysis
&lt;/h3&gt;

&lt;p&gt;To increase even more the security, what I think that it's always necessary, you could do checks to see if someone is creating fake accounts with very suspicious behavior:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Only giving reputation to a specific set of people&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;if their account's only purpose is to upvote&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Things would be more susceptible to bots? Yes, for sure, but I think that it's better to give voice to the people and moderators to ban the bots than creating a niched club of selected people.&lt;/p&gt;

&lt;p&gt;I personally hate how this incentivizes division, superiority of a few and dominance instead of community, collaboration and knowledge share.&lt;/p&gt;

&lt;p&gt;These "communities" are more like stages to a few people to have their egos massaged than a place to share knowledge and help each other.&lt;/p&gt;

</description>
      <category>stackoverflow</category>
      <category>community</category>
      <category>reddit</category>
      <category>dailydev</category>
    </item>
    <item>
      <title>Why companies and teams should be dictatorships</title>
      <dc:creator>Henrique Leite</dc:creator>
      <pubDate>Mon, 12 Aug 2024 15:33:14 +0000</pubDate>
      <link>https://dev.to/henriqueleite42/why-companies-and-teams-should-be-dictatorships-50nn</link>
      <guid>https://dev.to/henriqueleite42/why-companies-and-teams-should-be-dictatorships-50nn</guid>
      <description>&lt;p&gt;Everyone sees the world through a unique lens, shaped by their own experiences and ideas. Recognizing this and being willing to listen to and understand different perspectives is essential for discovery, personal growth, and building better things together. However, sometimes this openness can also lead us down a darker path.&lt;/p&gt;

&lt;p&gt;As a leader, you need to be someone your team can rely on, someone they trust and feel comfortable speaking to, whether they have an idea, a problem, or even a solution to your nightmares.&lt;/p&gt;

&lt;p&gt;It's always valuable to listen to your team, but that doesn't mean you should always follow their suggestions. Good leadership involves hearing every voice, then making thoughtful decisions based on what's best for the team and the goals at hand.&lt;/p&gt;

&lt;p&gt;In this article, we’ll explore the risks of trying to consider everyone’s ideas equally, and share strategies to avoid these challenges while still encouraging collaboration and open dialogue.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;Just as a ship has only one captain, a company or team needs a single leader: someone responsible for making decisions and guiding both the product and the people toward what’s best for the group as a whole.&lt;/p&gt;

&lt;p&gt;If you rely too heavily on group opinions or put every decision up for a vote, you risk avoiding your responsibility as a leader. It's your job to understand the bigger picture and how each decision affects it. If things go wrong, it’s your fault, not theirs. That’s why it’s essential to be discerning about how you listen to others.&lt;/p&gt;

&lt;p&gt;Let’s be clear: people have their own motivations, their own challenges, and their own areas of focus. Your team isn’t responsible for the big picture — their job is to handle the small details. And it’s precisely those details that keep a company growing and delivering results.&lt;/p&gt;

&lt;p&gt;A developer won’t have insight into marketing, just as a salesperson won’t be familiar with the company’s quarterly financials. That’s not their role.&lt;/p&gt;

&lt;p&gt;A leader, however, must understand the broader picture: the basics of how each area of the company operates to align everyone toward a common goal. Team members are the engines of the company, and leaders are the gears that connect them to the wheels, making the whole vehicle move forward.&lt;/p&gt;

&lt;h2&gt;
  
  
  The solution
&lt;/h2&gt;

&lt;p&gt;Listening to others is essential. No one has all the answers, and the wisest thing you can do is stay open, truly open, to other people’s perspectives. That’s how we grow, challenge our assumptions, and become better.&lt;/p&gt;

&lt;p&gt;Sometimes, a janitor might share an insight that changes your life. Never judge someone by their role, race, sexual orientation, or any other bias. When you do, you’re not just being unfair, you’re closing the door to valuable experiences and perspectives.&lt;/p&gt;

&lt;p&gt;Listening to what others have to say, understanding their context, and having the empathy to put yourself in their shoes, that’s what allows you to truly analyze their perspective. Doing this for each person on your team, one by one, is what will lead you to greatness.&lt;/p&gt;

&lt;p&gt;It’s not easy, is it? But no one ever said that being a good leader would be easy.&lt;/p&gt;

&lt;h2&gt;
  
  
  The example
&lt;/h2&gt;

&lt;p&gt;Let’s look at an example:&lt;/p&gt;

&lt;p&gt;Your company has decided to refactor an important microservice. The current codebase is outdated, written in PHP 5.4, and no longer meets modern development standards. Your team is now responsible for rewriting the service, giving it the opportunity to choose a new programming language.&lt;/p&gt;

&lt;p&gt;Your team consists of four members: John, Dave, Mike, and Lucas.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;John&lt;/strong&gt;, a junior developer who joined the company a few months ago, suggests using Node.js.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Dave&lt;/strong&gt;, another junior developer recently hired, agrees with John.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Mike&lt;/strong&gt;, a mid-level developer with a couple of years at the company, has no strong preference but is open to trying Node.js.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Lucas&lt;/strong&gt;, a senior developer with many years of experience in the company, suggests sticking with PHP and simply upgrading to the latest stable version.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you run your team like a democracy, the decision would be to use Node.js: two votes in favor, one neutral (effectively in agreement), and one against.&lt;/p&gt;

&lt;p&gt;That sounds good, right? Power to the people. Everyone feels heard, there's no conflict, the team stays happy, and you avoid potential dissatisfaction, heated discussions, or even team turnover. Problem solved, right?&lt;/p&gt;

&lt;p&gt;Now let’s analyze the &lt;strong&gt;context&lt;/strong&gt;, because understanding context is your job as a leader:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The company has several teams, and &lt;em&gt;all of them&lt;/em&gt; work with PHP.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The entire infrastructure (pipelines, deployment processes, monitoring) is built around PHP.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The most experienced developer on your team has &lt;em&gt;years&lt;/em&gt; of professional experience with PHP. The second-most experienced does as well.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;em&gt;only&lt;/em&gt; experience with Node.js comes from two junior developers, both in their first jobs.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, do you still think choosing Node.js is a great idea?&lt;/p&gt;

&lt;p&gt;I don’t. In fact, I believe that any leader who allows a refactor like this to happen in a different language (under these circumstances) shouldn’t be in a leadership position.&lt;/p&gt;

&lt;p&gt;Is that because PHP is the best language in the world, suited for every project, everywhere? Absolutely not.&lt;br&gt;&lt;br&gt;
It’s because &lt;strong&gt;PHP is the best choice for this specific context&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You could swap PHP or Node.js with any other language: Python, Ruby, Go. The logic still stands: &lt;strong&gt;good decisions are made with context&lt;/strong&gt;, not popularity.&lt;/p&gt;

&lt;p&gt;To be even more didactic, let’s weigh the pros and cons of rewriting the project in &lt;strong&gt;Node.js&lt;/strong&gt; in this context.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Pros&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Your team members, especially the juniors, are excited and happy.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You &lt;em&gt;might&lt;/em&gt; see performance improvements or gain access to certain modern tools or frameworks.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Cons&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Your team would be the &lt;em&gt;only&lt;/em&gt; one in the company using Node.js, creating an inconsistent pattern across teams.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There would be &lt;strong&gt;no one else to turn to for help&lt;/strong&gt;. You’d be on your own when facing issues. It’s a very important service. Are you sure that you should accept the risk?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If the company uses internal libraries or shared utilities, &lt;strong&gt;new versions&lt;/strong&gt; would need to be written just for your project.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This duplicates logic.&lt;/li&gt;
&lt;li&gt;Duplicates effort.&lt;/li&gt;
&lt;li&gt;Duplicates cost (By spending more of a developer’s time).&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;New deployment pipelines and processes would need to be built and maintained separately.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;The most “experienced” developers in Node.js would be two juniors, still in their first jobs, with limited real-world understanding of the language and its ecosystem.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;And if they leave the company or, as the classic phrase goes, &lt;em&gt;get hit by a bus,&lt;/em&gt; what then?&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;When you look at the full picture, it’s hard to argue that the pros outweigh the cons. For me, it's clear: &lt;strong&gt;the cons far outweigh the benefits&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You could argue that "changing versions also could lead to all these problems", and you are right, but what can cause more conflicts, changing versions of the same language, or changing entire ecosystems? Making decisions is not about choosing the option that has no risks, but choosing the one that has the risks that you are willing to take.&lt;/p&gt;

&lt;p&gt;The same principle could be applied to anything: Libraries, frameworks, protocols (like GraphQL), and databases.&lt;/p&gt;

&lt;p&gt;Note that in this example I used Junior developers to be the ones that bring these changes, but this is not a matter of seniority. Even senior developers can fall into this trap. When you’ve worked with the same technology for a long time, it’s natural to feel bored and eager to try something new. And that’s a good thing—innovation comes from curiosity.&lt;/p&gt;

&lt;p&gt;But innovation needs direction.&lt;/p&gt;

&lt;p&gt;So instead of experimenting with the company’s core systems (the ones that run the business and keep everyone’s jobs), why not apply that drive for innovation to smaller services or less critical parts of the ecosystem? That way, you encourage growth and experimentation without putting the stability of the entire company at risk.&lt;/p&gt;

&lt;p&gt;Sometimes, the pros overcome the cons, and the technical gains that you have with that change would make up for all the trouble that comes with it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;As a leader, it’s your responsibility to evaluate the things your team members may not have the context to see. You must protect your project's integrity within the company so that the product remains functional, valuable, and sustainable. Your job is to make sure the work continues, and that &lt;em&gt;everyone still has a job&lt;/em&gt; next month, next year, and so on.&lt;/p&gt;

&lt;p&gt;Here’s my final advice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Don’t let quantity intimidate you.&lt;/strong&gt; Just because many people are saying something doesn’t mean it’s the right thing. Leadership is about discernment, not popularity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Think long-term.&lt;/strong&gt; You or your team members might not be in the company a year from now. That doesn’t mean you should cut corners. Build something that’s maintainable for the people who come after you. That’s how you show real leadership and respect.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;You can’t make everyone happy.&lt;/strong&gt; Sometimes people leave, and that’s okay. It’s the cycle of life and work. Ideally, the hiring process filters out those who aren’t aligned with how the company operates, but when that fails, &lt;em&gt;we&lt;/em&gt; have to manage the gap with empathy and maturity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Always listen.&lt;/strong&gt; Truly listen. Great ideas can come from anywhere—yes, even junior developers. Your role is to encourage those voices, evaluate them with context, and decide what’s best for the bigger picture.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>startup</category>
      <category>leadership</category>
    </item>
    <item>
      <title>How to install and configure Golang</title>
      <dc:creator>Henrique Leite</dc:creator>
      <pubDate>Thu, 11 Jul 2024 13:44:25 +0000</pubDate>
      <link>https://dev.to/henriqueleite42/how-to-install-and-configure-golang-4619</link>
      <guid>https://dev.to/henriqueleite42/how-to-install-and-configure-golang-4619</guid>
      <description>&lt;p&gt;In this article, you will see how to install Golang and configure it to use the private GitHub repositories of your company.&lt;/p&gt;

&lt;h2&gt;
  
  
  Right to the point
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;BE SURE TO REPLACE &lt;code&gt;{VERSION}&lt;/code&gt; WITH THE DESIRED VERSION THAT YOU WANT!!!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Download Go
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-OL&lt;/span&gt; https://golang.org/dl/go&lt;span class="o"&gt;{&lt;/span&gt;VERSION&lt;span class="o"&gt;}&lt;/span&gt;.linux-amd64.tar.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Install Go
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo tar&lt;/span&gt; &lt;span class="nt"&gt;-C&lt;/span&gt; /usr/local &lt;span class="nt"&gt;-xvf&lt;/span&gt; go&lt;span class="o"&gt;{&lt;/span&gt;VERSION&lt;span class="o"&gt;}&lt;/span&gt;.linux-amd64.tar.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Configure Go
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;nano ~/.profile
&lt;span class="c"&gt;# Or with zsh:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nano ~/.zprofile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Paste this at the end of the file, replacing &lt;code&gt;{YOUR COMPANY ALIAS}&lt;/code&gt; with your company alias:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Golang&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;GOROOT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/local/go
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;GOPATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;/go
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;GOBIN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$GOPATH&lt;/span&gt;/bin
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;GOPRIVATE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;github.com/&lt;span class="o"&gt;{&lt;/span&gt;YOUR COMPANY ALIAS&lt;span class="o"&gt;}&lt;/span&gt;/&lt;span class="k"&gt;*&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;:&lt;span class="nv"&gt;$GOROOT&lt;/span&gt;:&lt;span class="nv"&gt;$GOPATH&lt;/span&gt;:&lt;span class="nv"&gt;$GOBIN&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;&lt;span class="s2"&gt;:&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;go &lt;span class="nb"&gt;env &lt;/span&gt;GOPATH&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;/bin"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run this to update your terminal and apply the changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;source&lt;/span&gt; ~/.profile
&lt;span class="c"&gt;# Or with zsh:&lt;/span&gt;
&lt;span class="nb"&gt;source&lt;/span&gt; ~/.zprofile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Configure SSH key on GitHub
&lt;/h3&gt;

&lt;p&gt;Run this, and remember to replace &lt;code&gt;{YOUR EMAIL}\&lt;/code&gt; with your email:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Run this and only press enter until the command stop&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The ssh key &lt;strong&gt;MUST NOT&lt;/strong&gt; have a password&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-keygen &lt;span class="nt"&gt;-t&lt;/span&gt; ed25519 &lt;span class="nt"&gt;-C&lt;/span&gt; &lt;span class="s2"&gt;"{YOUR EMAIL}"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;ssh-agent &lt;span class="nt"&gt;-s&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-add ~/.ssh/id_ed25519
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; ~/.ssh/id_ed25519.pub
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy the content displayed on your terminal, including your email. &lt;strong&gt;COPY EVERYTHING&lt;/strong&gt; that the previous command returned.&lt;/p&gt;

&lt;p&gt;Go to GitHub and follow &lt;a href="https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account#adding-a-new-ssh-key-to-your-account" rel="noopener noreferrer"&gt;this tutorial&lt;/a&gt; to add the SSH key.&lt;/p&gt;

&lt;h3&gt;
  
  
  Configure Git
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;nano ~/.gitconfig
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Paste this at the end of the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;url &lt;span class="s2"&gt;"ssh://git@github.com/"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
    insteadOf &lt;span class="o"&gt;=&lt;/span&gt; https://github.com/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Done!
&lt;/h2&gt;

&lt;p&gt;Now you can work with Golang and private repositories on GitHub with no problems!&lt;/p&gt;

</description>
      <category>go</category>
      <category>beginners</category>
      <category>devops</category>
    </item>
    <item>
      <title>Why HTMX is far superior to React and NextJs</title>
      <dc:creator>Henrique Leite</dc:creator>
      <pubDate>Tue, 09 Jul 2024 01:48:21 +0000</pubDate>
      <link>https://dev.to/henriqueleite42/why-htmx-is-far-superior-to-react-and-nextjs-1o28</link>
      <guid>https://dev.to/henriqueleite42/why-htmx-is-far-superior-to-react-and-nextjs-1o28</guid>
      <description>&lt;p&gt;On Anuntech we have the challenge to create an ERP, and for the ones that already worked with it, know that ERP can be one of the more complex types of software to create (and use, god have mercy of SAP users).&lt;/p&gt;

&lt;p&gt;To avoid the complexity to use, we wanted something similar to PlayStore: You have an infinity of modules to enable, you can choose the ones that you need or choose a "business template" to fit your needs, and with our goal in mid, came or first problem: Choosing the frontend tool.&lt;/p&gt;

&lt;h2&gt;
  
  
  React
&lt;/h2&gt;

&lt;p&gt;So, to create any website, we need a framework, everyone knows this unquestionable truth. And as any other person, the first framework that came in mid was React, the most used, most loved, most incredible, of the billion JavaScript frameworks out there.&lt;/p&gt;

&lt;p&gt;React is nice, it gave us:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The ability to create components and reuse them, keeping a standard and avoiding duplication&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The ability to create high-interactive frontends (now our forms can have inline validation to know if your email has an &lt;code&gt;@&lt;/code&gt;!)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A way to decrease our server costs (very important for every startup), by running everything on the client&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But react itself has lots of problems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It bundles EVERYTHING together, and for a product like Anuntech, that will have hundreds of different things, the bundle would have the same size as an AAA game.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It's heavy &lt;em&gt;af&lt;/em&gt;, uses virtual DOM to create and manipulate things, what is terrible for weak pcs, and guess what? All our clients have weak pcs.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So we had to think a little more: If we can't use React, what is our next choice?&lt;/p&gt;

&lt;h2&gt;
  
  
  Next
&lt;/h2&gt;

&lt;p&gt;Of course, the natural evolution of React, Next!, React is already perfect, but with Next it's on another level of &lt;em&gt;perfectness&lt;/em&gt;! There's no way that it will not work:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Next bundles each page separately, and each page only has the required dependencies, this will keep the bundle at an acceptable size&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It still keeps all the &lt;em&gt;good stuff&lt;/em&gt; that React has: high-interactive frontends&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Has many built-in optimizations for images, videos, etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But Next has even more problems than React:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;We lose the pro of not spending with servers, now we need a server to run our frontend&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It still is heavy &lt;em&gt;af&lt;/em&gt;, it uses react to build things, and worst, it builds on the server too&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Know that we have client and server, we must keep the user logged on both, and it must be able to do authenticated requests to our APIs both on server and client, which increases the complexity A LOT.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So we began to realize that the problem wasn't the framework, but the whole JavaScript ecosystem.&lt;/p&gt;

&lt;h2&gt;
  
  
  War against JavaScript
&lt;/h2&gt;

&lt;p&gt;The JavaScript ecosystem has innumerable flaws:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;It's extremely complex for someone with 0 experience to work with JavaScript tools. They all require 10 other tools to work, and you MUST learn them all to do even the basics.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If we keep using Next, to hire a frontend developer, they would be required (or we would be required to invest time and money training they) to know: HTML, CSS, JavaScript, TypeScript, Tailwind, React, NextJs, Hookform (or whatever library they will be using 5 minutes from now), State management with React, Server components, the brand-new awesome way to write react that will change next month, the brand-new way to right next that will change next month, and so on. The list never ends, and all of it to do the basics.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;It requires LOTS of dependencies, and each dependency has even more dependencies. The JavaScript ecosystem has a serious problem with wanting to delegate even the smallest problem to someone other than themselves. It brings security risks in a scale never seems before, and they seem to not learn a thing with events like &lt;a href="https://snyk.io/blog/polyfill-supply-chain-attack-js-cdn-assets/" rel="noopener noreferrer"&gt;PolyfillJs&lt;/a&gt; and &lt;a href="https://www.bleepingcomputer.com/news/security/popular-coa-npm-library-hijacked-to-steal-user-passwords/" rel="noopener noreferrer"&gt;Coa&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Builds 1 bundle with your custom code and all the libraries that you use, what makes it impossible to cache the libraries on the client to avoid having to download them again if you change your custom code.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;JavaScript is terrible anything else than manipulating the DOM, using it on the server is something that we want to avoid at all costs. Has terrible performance, terrible memory management and terrible long-term life.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;The ecosystem is more unstable than the humor of someone with borderline disorder, JavaScript developers can't stand having one &lt;code&gt;;&lt;/code&gt; that they don't like, or they will create their own thing from scratch, and guess what? It will become the new standard, god knows why. Every couple months the way to write React changes, or the way to write Next changes, or the way to manage states changes, or manage forms, or do styling, ALWAYS something is changing and nothing never has the minimum amount of stability nor standard. It forces the developers to always learn the same thing in a different way, and your codebase will be outdated on the moment that you finish writing it.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;And for our specific case, we also had more problems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In our case, as we have microservices for the APIs, with Next/React we have to maintain gRPC (for server-server communication) and REST (for client-server communication), which makes the backend team maintain 2 delivery systems, 2 API documentations (.proto and openapi specs), and make the services available on the internet for the client to hit them directly, what also make us to have to validate the user authentication and authorization on every service.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And because of all the problems that we had on our place, we decided to take the things drastically. Instead of looking in one single solution and try to make it work, changing it a bit to see if we manage to fit a square into a triangle, we choose to turn 180° and look for extreme alternatives, avoiding the root of all these problems: JavaScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  HTMX
&lt;/h2&gt;

&lt;p&gt;As probably many of the people that knows HTMX, I heard of it firstly from &lt;a href="https://www.youtube.com/@ThePrimeTimeagen" rel="noopener noreferrer"&gt;Primeagen&lt;/a&gt;. At first, I hated it. My first though was "Nice, coming full circle back to PHP", but after some review on the solution and after learning more about the idea, I saw that HTMX is exactly what we are looking for.&lt;/p&gt;

&lt;p&gt;HTMX solves all our problems and gives us even more power:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It is SSR, which solves the bundle-size problem.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It provides interactive for the most important parts (partial page reloading), and allow us to create our own custom basic script for things that it cannot do (like validating form fields).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Allow us to choose the language that we want to run it, we are no longer stuck at JavaScript.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Has 0 dependencies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It's only 1 file of JavaScript, very easy to understand and well documented. If the maintainers decide to not maintain it anymore, we can maintain it ourselves, as opposite of React / Next, where we are stuck with them and their decision to where to go.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The final solution
&lt;/h2&gt;

&lt;p&gt;So, as we were already writing our backend services in Golang, we choose to write our frontend in Golang + HTMX + Templ, with Tailwind and DaisyUI for styling. Here are the main reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;As the backend team is already having to communicate between services, they are already maintaining a library for each service that exposes the "API routes", what makes it a lot easier for the frontend to integrate with the services: Just use the libraries instead of building an integration from the scratch.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The selling point of "JavaScript on the server" also can be used here: Having one language for frontend and backend allows your developers to be full-stack and have less trouble working on both parts of the system (what is a big lie with TypeScript, btw)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The benefits of having one language also affects the DevOps team: With 1 language there's only 1 dev environment to configure (and 1 doc to write about how to configure everything you need), 1 pipeline to maintain, 1 type of machine to configure to run the servers, and so on.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;With only SSR, almost zero JavaScript and no state management on the client, the automated tests become a lot easier to write and reliable: Just call the route and check if the text (HTML) returned is right.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Golang is EXTREMELY faster and lightweight than NextJs servers. It allows the devs to have weaker pcs and not lose performance and having to wait 5 minutes to start the server and render a single page, what makes the company able to buy cheaper pcs and save a lot of money.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HTMX allows us to run things in lambdas, something that we don't do at the moment, but hey, it's very nice to have this door open when it was sealed with concrete and 3 inches of steel when working with NextJs.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The challenges that we can see coming:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The good old ID duplication: Too many components can generate components with the same ID, what makes it easily change things that shouldn't be changed. We plan to avoid it, defining a good naming pattern for the IDs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The conclusion
&lt;/h2&gt;

&lt;p&gt;We are here exploring a new thing: There are not many production apps using HTMX, and probably none of them are as big as we want to become. I'm not sure if we are taking the right decision here, but I'm sure that it's better than using NextJs or dealing with the JavaScript ecosystem.&lt;/p&gt;

</description>
      <category>htmx</category>
      <category>javascript</category>
      <category>website</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Which programming language should you choose</title>
      <dc:creator>Henrique Leite</dc:creator>
      <pubDate>Sat, 15 Jun 2024 13:15:35 +0000</pubDate>
      <link>https://dev.to/henriqueleite42/what-programming-language-should-you-choose-4ed2</link>
      <guid>https://dev.to/henriqueleite42/what-programming-language-should-you-choose-4ed2</guid>
      <description>&lt;p&gt;Each programming language has its own purpose, they all are a tool to solve a specific problem, and you should choose the one that really fits your needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  The languages
&lt;/h2&gt;

&lt;h3&gt;
  
  
  JavaScript
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello World!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;JavaScript is a terrible and confusing language (see more &lt;a href="https://javascriptquiz.com" rel="noopener noreferrer"&gt;here&lt;/a&gt;), but unfortunately it's the only option that we have for working with Frontend Web development. You should choose (or is forced to) use it when your goal is to create interactive Frontend Websites.&lt;/p&gt;

&lt;p&gt;In any other case, JavaScript MUST be avoided, it's unsafe, underperforming, makes no sense, requires lots of configurations and libraries to do the basics, and it's infested with terrible practices.&lt;/p&gt;

&lt;p&gt;"Choose" it if you want to become a Frontend Web developer.&lt;/p&gt;

&lt;h3&gt;
  
  
  PHP
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt; &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'Hello, World!'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PHP still the most used language for the Web, mostly because most of the websites are legacy or build with WordPress, an easy-to-use tool where you can start almost with no knowledge about programming.&lt;/p&gt;

&lt;p&gt;You will find a lot of jobs to work with PHP, but it's "for the old people", and the new generation is avoiding it because of the &lt;a href="https://www.google.com/search?sca_esv=c25313c4b5559b8f&amp;amp;sxsrf=ADLYWIKE23m8_uZWq4oYjGXpLRKJ_VydBA:1718454482517&amp;amp;q=php+memes&amp;amp;udm=2&amp;amp;fbs=AEQNm0DYVld7NGDZ8Pi819Yg8r6em07j6rW9d2jUMtr8MB7htoxbI0iAKNRPykigVf3e9aputkbr8jzmN5LYbANOqrq5HYnx4MjtyMxZ94LvgeHWmGBcuWUoydKfNaoB5JMdZlMtXmg2De2y5O7nn-eTbNdYHsRiT1RQ-pB6qp3ejXJ5VpdCk5NA1Jug5hVR16L7F-A1C1p-4xpfp7qj2HsGNaipPZQOiw&amp;amp;sa=X&amp;amp;ved=2ahUKEwjIz_jnzd2GAxXoqZUCHWIUCvQQtKgLegQIERAB&amp;amp;biw=1882&amp;amp;bih=977&amp;amp;dpr=1" rel="noopener noreferrer"&gt;memes&lt;/a&gt;, and yeah, they are kinda right, but PHP was very important for the early Backend development.&lt;/p&gt;

&lt;p&gt;Choose it if you want to (or have to) work on legacy systems, or systems that are for companies which the focus isn't on their tech, like Stores or Supermarkets.&lt;/p&gt;

&lt;h3&gt;
  
  
  Python
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello World&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python is a very simple language, ideal for beginners that want to start in the programming world or for non-programmers that need to automate a task.&lt;/p&gt;

&lt;p&gt;It's heavily used for Machine Learning, Neural Networks and similar, usually build by mathematicians.&lt;/p&gt;

&lt;p&gt;Pythons has terrible performance, so it should be used in environments where you don't need things to be fast, like training your AI, running things locally to automatically format your CSVs, move your mouse so your companies spyware thinks you are working and similar.&lt;/p&gt;

&lt;p&gt;Python should not be used in production, but the result of what is produced by python can.&lt;/p&gt;

&lt;p&gt;Choose it if you want to start in programming but find it too hard in any other way, or if you aren't a programmer and don't want to be one, but needs to automate something or create AIs to take someone's job.&lt;/p&gt;

&lt;h3&gt;
  
  
  Java
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;HelloWorld&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello World!"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; 
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Java is the good-old trustable language, used for most backend systems that must be reliable, like banking. It's kinda verbose and heavy, but a good language overall, has lots of job positions, good practices, great developers. It's the one that you can't go wrong.&lt;/p&gt;

&lt;p&gt;Choose it if you want something guaranteed, even if you don't work directly with Java, the things that you learned for sure will be useful in your career.&lt;/p&gt;

&lt;h3&gt;
  
  
  Golang
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, World!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Go is a safe, fast and easy programming language, it's growing, but not a lot of companies out there have job positions to work with this.&lt;/p&gt;

&lt;h3&gt;
  
  
  C++
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"Hello World!"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;C++ is the language for who wants to develop games. You will probably use Unreal Engine or (very, very rarely) develop your own. Most (maybe all) big games are developed using this language.&lt;/p&gt;

&lt;h3&gt;
  
  
  Lua
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello World"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lua is also for gaming, its focus is not to be performative, but to be very easy to learn and modify. If you want to create a game that supports a lot of mods and has a great community, use Lua. Your community will love to make mods and expand your game, it will also help with its growth.&lt;/p&gt;

&lt;h3&gt;
  
  
  C, Rust and Zig
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello World&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello World!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const std = @import("std");

pub fn main() !void {
    std.debug.print("Hello, World!\n", .{});
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Low level languages, perfect for things that really needs performance, like Databases (creating databases, not using them!) and Operational Systems.&lt;/p&gt;

&lt;p&gt;You will probably not get a job with these languages, but may need to develop something using them if you were hired by a medium/big tech company.&lt;/p&gt;

&lt;h3&gt;
  
  
  All other languages
&lt;/h3&gt;

&lt;p&gt;Don't use it, it's not worth it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Let's summarize
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;JavaScript: Frontend Web&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;PHP: Legacy backend&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Python: For non-programmers&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Java: Safe in all means, good option overall&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Golang: Good but not very used&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;C++: Very performative gaming, for competitive or immersive games&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lua: For community driven games&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;C, Rust and Zig: For OSs and Databases.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  For the fanboys
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgifs.eco.br%2Fwp-content%2Fuploads%2F2022%2F10%2Fgifs-de-chora-mais-9.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgifs.eco.br%2Fwp-content%2Fuploads%2F2022%2F10%2Fgifs-de-chora-mais-9.gif" alt="Chola mais"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a meme that represents "You can cry as much as you want, but it will not change a thing".&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Hope that it helps mainly the beginners to understand the purpose of each language and avoid people that only want their money, selling courses about "LEARN THIS LANGUAGE AND YOU WILL MAKE 500K A YEAR!!!", please, don't fall for these schemes.&lt;/p&gt;

&lt;p&gt;If you have different options (and don't want to cry about how your language is the best language in the world and should be used everywhere, except for C, C is the best), please leave it in the comments and let's talk about it!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>career</category>
      <category>development</category>
    </item>
    <item>
      <title>Git: How to fix PR conflicts</title>
      <dc:creator>Henrique Leite</dc:creator>
      <pubDate>Thu, 13 Jun 2024 11:14:21 +0000</pubDate>
      <link>https://dev.to/henriqueleite42/how-to-fix-pr-conflicts-4kfb</link>
      <guid>https://dev.to/henriqueleite42/how-to-fix-pr-conflicts-4kfb</guid>
      <description>&lt;p&gt;When working with PRs, we may encounter conflicts trying to merge them. In this article, we will learn what conflicts are and how to fix them.&lt;/p&gt;

&lt;h2&gt;
  
  
  What causes conflicts
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JXBfT1zg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1718273383500/bc9db80d-172b-44b0-bf56-8cbb300d40d0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JXBfT1zg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1718273383500/bc9db80d-172b-44b0-bf56-8cbb300d40d0.png" alt="git conflict" width="461" height="281"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the image above, you can see that we have a main branch called &lt;code&gt;master&lt;/code&gt;, and from this branch we created 2 new branches at the same &lt;em&gt;point in time&lt;/em&gt;: &lt;code&gt;feat/1&lt;/code&gt; and &lt;code&gt;feat/2&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Obs:&lt;/strong&gt; &lt;em&gt;point in time&lt;/em&gt; is not the same as &lt;em&gt;time&lt;/em&gt;. &lt;em&gt;Point in time&lt;/em&gt; means that no changes happened in the branch since the last time you checked. On the example above, the &lt;code&gt;master&lt;/code&gt; branch keeps on the same &lt;code&gt;point in time&lt;/code&gt; until the &lt;code&gt;PR #1&lt;/code&gt; is merged and the state of the branch changes.&lt;/p&gt;

&lt;p&gt;After we created both branches (one can be created by you, and another one by your coworker), we start to make changes on them to develop a new feature, fix a bug, or improve the documentation, anything that we want to change.&lt;/p&gt;

&lt;p&gt;As things on each branch are different, one of them will probably be faster to develop and will have the PR merged first, and once in a while may happen that 2 branches must change the same file.&lt;/p&gt;

&lt;p&gt;As both branches were created at the same &lt;em&gt;point in time&lt;/em&gt;, git will not be able to know which one of the changes it must keep, the one of &lt;code&gt;PR #1&lt;/code&gt; or the one of &lt;code&gt;PR #2&lt;/code&gt; (your PR), and it will cause the conflict.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to fix the conflict
&lt;/h2&gt;

&lt;p&gt;If the git commands below don't work, it may be because you need to &lt;a href="https://henriqueleite42.hashnode.dev/git-how-to-boost-your-performance" rel="noopener noreferrer"&gt;configure your git&lt;/a&gt; before executing them.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Go back to the &lt;code&gt;master&lt;/code&gt; branch (or the source branch for your current branch)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git checkout master&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Get the updated state&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git pull&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Go back to your branch&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git checkout feat/2&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;a href="https://git-scm.com/book/en/v2/Git-Branching-Rebasing" rel="noopener noreferrer"&gt;Rebase&lt;/a&gt; with master&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git rebase master&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;See the files that are causing conflicts&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git status&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Go to the files and make the necessary change to the file to include both your changes and the previous changes.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Add the files to be tracked by git&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git add .&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Continue the rebase&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git rebase --continue&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;[May not occur] If a strange text appears, run the commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you are using &lt;code&gt;vim&lt;/code&gt;, press &lt;code&gt;Esc&lt;/code&gt;, &lt;code&gt;:wq&lt;/code&gt; and &lt;code&gt;Enter&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;If you are using Ubuntu's default editor, press &lt;code&gt;Ctrl + O&lt;/code&gt;, &lt;code&gt;Enter&lt;/code&gt; and &lt;code&gt;Ctrl + X&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Push the changes&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git push&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;And that's it! Solving conflicts is not the end of the world, we can fix them very quickly. Hope that this article helped you in some way, and if you have anything to say or an experience to share, please say it in the comments! 😄&lt;/p&gt;

</description>
      <category>git</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to handle migrations in Golang</title>
      <dc:creator>Henrique Leite</dc:creator>
      <pubDate>Tue, 11 Jun 2024 14:21:04 +0000</pubDate>
      <link>https://dev.to/henriqueleite42/how-to-handle-migrations-in-golang-4p67</link>
      <guid>https://dev.to/henriqueleite42/how-to-handle-migrations-in-golang-4p67</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;We always can create and run our migrations manually, but if we want to make it faster, safer, and easier to read and maintain, it's recommended to use a specialized tool for it.&lt;/p&gt;

&lt;p&gt;To choose this tool, we need first to analyze what are the requirements for "handling migrations". They are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Generate &lt;code&gt;UP&lt;/code&gt; and &lt;code&gt;DOWN&lt;/code&gt; migrations to apply and revert the changes&lt;/li&gt;
&lt;li&gt;Keep track of which migrations already were executed and be able to apply only the new migrations&lt;/li&gt;
&lt;li&gt;Have a clear, simple and fast way to know the current structure of your database&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On the next sections, let's dig up a bit about each one of these features, and at the end let's see some tools that we can use for it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generate &lt;code&gt;UP&lt;/code&gt; and &lt;code&gt;DOWN&lt;/code&gt; migrations
&lt;/h2&gt;

&lt;p&gt;Generate migrations is not a requirement, but is a great bonus. It saves a lot of time and rarely needs any adjust. To do it, the tool needs to get the current state of the database, the new state that you want to apply and create the necessary SQL queries to synchronize both, in the best way possible and without any bugs.&lt;/p&gt;

&lt;p&gt;The current new state that you want to apply can be defined as code or a specific schema file, but I'll talk more about it on the Know the current structure of your database chapter.&lt;/p&gt;

&lt;p&gt;Up and Down migrations can be written in 2 ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using raw SQL files&lt;/li&gt;
&lt;li&gt;Using &lt;code&gt;.&amp;lt;your-language&amp;gt;&lt;/code&gt; files (in this case, &lt;code&gt;.go&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I personally prefer to have raw SQL files, because this way I fell safer that none of the behaviors of the language will affect my migration, and any of the updates in the language will make me update previous migrations.&lt;/p&gt;

&lt;p&gt;If the tool doesn't generate the migrations for you, you will have to write them manually.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep track of migrations
&lt;/h2&gt;

&lt;p&gt;This is without a doubt the most important part of every migration tool. It's very important to know which migrations already were executed, so the tool can avoid running the same migration twice and causing an error.&lt;/p&gt;

&lt;p&gt;For our luck, all the most famous tools for handling migrations do it very well.&lt;/p&gt;

&lt;h2&gt;
  
  
  Know the current structure of your database
&lt;/h2&gt;

&lt;p&gt;This is the part that improves dev experience and the velocity that you can modify your database to fit your new needs. Have a simple and fast way to know the current state of your database is essential for many things: Have the big picture of your database, be sure how a change would affect it, if it has the best performance that it can have (with all the right indexes and relations), if it has a column that you need and how can you add it if necessary.&lt;/p&gt;

&lt;p&gt;Most tools don't have a way to do it, and once you start using this kind of documentation, your life changes, and you never want to work with an undocumented database again.&lt;/p&gt;

&lt;p&gt;There are ORMs like &lt;a href="https://gorm.io" rel="noopener noreferrer"&gt;gorm&lt;/a&gt; that supports some kind of documentation with files, but they mainly focus on converting the database to "things" in the code to be used by the ORM, and not as documentation only/documentation-first.&lt;/p&gt;

&lt;p&gt;To solve this problem, &lt;a href="https://dbml.dbdiagram.io/home" rel="noopener noreferrer"&gt;DBML&lt;/a&gt; was created, but it lacks a lot of features required for migration tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  Available tools
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/golang-migrate/migrate" rel="noopener noreferrer"&gt;golang-migrate&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;A basic Golang specific tool to run migrations.&lt;/p&gt;

&lt;p&gt;Pros:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is the most famous and loved one&lt;/li&gt;
&lt;li&gt;Has more than 14k stars in GitHub&lt;/li&gt;
&lt;li&gt;Is in development since 2014&lt;/li&gt;
&lt;li&gt;Very reliable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It can't generate migrations, can only run manually written migrations and ensure to not run already executed migrations.&lt;/li&gt;
&lt;li&gt;Has no way to know the current state of your database, depends on external tools like (DBeaver).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/pressly/goose" rel="noopener noreferrer"&gt;goose&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Another Golang specific tool to run migrations, with a bit more functionalities.&lt;/p&gt;

&lt;p&gt;Pros:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The second most famous and loved one&lt;/li&gt;
&lt;li&gt;Has more than 6k stars in GitHub&lt;/li&gt;
&lt;li&gt;Has better documentation than golang-migrate&lt;/li&gt;
&lt;li&gt;Can handle both SQL and Golang migrations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It can't generate migrations, can only run manually written migrations and ensure to not run already executed migrations.&lt;/li&gt;
&lt;li&gt;Has no way to know the current state of your database, depends on external tools like (DBeaver).&lt;/li&gt;
&lt;li&gt;Is more complex than golang-migrate&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://atlasgo.io" rel="noopener noreferrer"&gt;Atlas&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;A language agnostic tool to run migrations.&lt;/p&gt;

&lt;p&gt;Pros:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is language agnostic&lt;/li&gt;
&lt;li&gt;Is maintained by a (small) company&lt;/li&gt;
&lt;li&gt;Has more than 5k stars on GitHub&lt;/li&gt;
&lt;li&gt;Has an extensive and very good documentation&lt;/li&gt;
&lt;li&gt;Has a way to know the current state of your database&lt;/li&gt;
&lt;li&gt;Can generate migrations&lt;/li&gt;
&lt;li&gt;Has a Discord server for close contact with the maintainers&lt;/li&gt;
&lt;li&gt;Can convert your schema to other formats, like JSON, DBML, ERD and others&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is maintained by a &lt;strong&gt;SMALL&lt;/strong&gt; company, and not really adopted, so if the company goes bankrupt, it may be the end of support&lt;/li&gt;
&lt;li&gt;Uses a &lt;a href="https://atlasgo.io/atlas-schema/hcl" rel="noopener noreferrer"&gt;version of HCL&lt;/a&gt; as its schema language&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://goprisma.org" rel="noopener noreferrer"&gt;Go Prisma&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;A wrapper to a JavaScript library that is both an ORM and a migration management tool.&lt;/p&gt;

&lt;p&gt;Pros:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is language agnostic&lt;/li&gt;
&lt;li&gt;Has more than 2k stars on GitHub&lt;/li&gt;
&lt;li&gt;Has an extensive and very good documentation (on the original library, not the wrapper)&lt;/li&gt;
&lt;li&gt;Has a way to know the current state of your database&lt;/li&gt;
&lt;li&gt;Can generate migrations&lt;/li&gt;
&lt;li&gt;Both the original library and the wrapper have Discord servers for close contact with the maintainers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is maintained by a small group of people&lt;/li&gt;
&lt;li&gt;It's a JavaScript library&lt;/li&gt;
&lt;li&gt;Is a wrapper for another library, what can cause conflicts&lt;/li&gt;
&lt;li&gt;It's a JavaScript library&lt;/li&gt;
&lt;li&gt;Not only a migration tool, but an ORM, what means a bunch of unnecessary things come with the library&lt;/li&gt;
&lt;li&gt;It's a JavaScript library&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What tools do I recommend?
&lt;/h2&gt;

&lt;p&gt;Both golang-migrate and goose can't generate migrations and don't have a way to document your database, so I can exclude them already.&lt;/p&gt;

&lt;p&gt;Atlas has a lot of potential, has the core that we need: From a schema file it can generate things. Generate migrations, &lt;code&gt;.dbml&lt;/code&gt; files or "things" specific for your code to be used by an ORM if you want to.&lt;/p&gt;

&lt;p&gt;The only problem with Atlas is that I personally hate HCL for databases, I think that it's overcomplicating the problem, too many keywords words for something simple. I know that it decreases development complexity for the guys maintaining it, but it's a terrible experience for anyone using it.&lt;/p&gt;

&lt;p&gt;If you like HCL, I recommend you to go with Atlas. It may be risk because it's maintained by a small company, but I think that it's the best option that we have in the market.&lt;/p&gt;

&lt;p&gt;And last: Go prisma. I use it, not because I think it's a great tool, has the best performance or has extra unseen magical features. I use it because &lt;code&gt;prisma.schema&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The Prisma syntax for writing database specifications is good, not the best, may be a little overdecorated, but works, it's simple, it's understandable and has its own formatter (HCL also has one btw). Go Prisma is a workaround to use Prisma without having to install it using node, and to be honest, at this moment, I'm not even sure if you can run it without having node installed.&lt;/p&gt;

&lt;p&gt;I prefer to take the risk and have some other things installed to be able to use the &lt;code&gt;prisma.schema&lt;/code&gt; file, since at the moment (and for the next years) it will not affect significantly my project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Hope that you liked the article, and please feel free to share your options on the comments!&lt;/p&gt;

</description>
      <category>go</category>
      <category>database</category>
      <category>devops</category>
      <category>documentation</category>
    </item>
    <item>
      <title>Why JavaScript is a terrible language</title>
      <dc:creator>Henrique Leite</dc:creator>
      <pubDate>Tue, 11 Jun 2024 00:46:10 +0000</pubDate>
      <link>https://dev.to/henriqueleite42/why-javascript-is-a-terrible-language-364e</link>
      <guid>https://dev.to/henriqueleite42/why-javascript-is-a-terrible-language-364e</guid>
      <description>&lt;p&gt;I could spend a day talking about how JavaScript lacks performance, has terrible memory management, and relies on a thousand libraries to do the basics, but in this article I'll focus on the core: The Original Philosophy. If you want to learn more about how JavaScript works under the hood, I recommend &lt;a href="https://dev.to/lydiahallie/series/3341"&gt;this series of articles&lt;/a&gt;, &lt;a href="https://youtu.be/8aGhZQkoFbQ" rel="noopener noreferrer"&gt;this talk&lt;/a&gt; and &lt;a href="https://youtu.be/ip51Y5v3WLk" rel="noopener noreferrer"&gt;this video&lt;/a&gt;, all of them amazing of explaining the internal behavior of JavaScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  The creation
&lt;/h2&gt;

&lt;p&gt;The old history that everyone that works with JavaScript already knows: JavaScript was created in the 90s by Brendan Eich with the objective of bringing some interactivity to the web that at the time were composed only by static HTML and CSS.&lt;/p&gt;

&lt;p&gt;The best part is not that it was created by 1 person (nothing against Brendan, he truly did something amazing with the resources that he had), or that he had &lt;strong&gt;10 DAYS&lt;/strong&gt; to develop it, no, the best part is that they needed the language to be adopted, so they put any features into the language that was asked to them, like &lt;a href="https://youtu.be/S0ZWtsYyX8E" rel="noopener noreferrer"&gt;implicit type conversion&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;What can learn with this is: The bases of JavaScript is a language created following the best method of development: &lt;a href="https://medium.com/@dekaah/22-axioms-of-the-extreme-go-horse-methodology-xgh-9fa739ab55b4" rel="noopener noreferrer"&gt;GoHorse&lt;/a&gt;. No big picture, no defined goal, no planning, no worries about it being good, just about it being on the market.&lt;/p&gt;

&lt;p&gt;We developers know more than anyone how good products can be when you follow no process and just code as fast as we can without thinking, right? The best products are made this way, I'm sure that it's the best of the best. No, It isn't.&lt;/p&gt;

&lt;h2&gt;
  
  
  "It improved over time"
&lt;/h2&gt;

&lt;p&gt;Ok, the creation of it was terrible, but hey, JavaScript has more than 30 years, it had a lot of time to improve and become a better language, right?&lt;/p&gt;

&lt;p&gt;No, things move veeery slow on the developer's community, we almost kill each other when trying to get to a consensus, it takes years to decide the best option to do something, or you can simply do what JavaScript does: Go implementing stuff.&lt;/p&gt;

&lt;p&gt;JavaScript has more than 30 years and the people that use it still tries to make it fit every scenario, when it almost not fit the original case that it was created to fit. JavaScript keep trying to turn 180° and make it usable on the server, on CLIs, on pipelines, everywhere!&lt;/p&gt;

&lt;p&gt;The language was created to execute short-lived simple scripts to manipulate the DOM, not to stay running and execute complex tasks, live web servers, CLIs or pipelines. No matter how much you try to make a workaround to make it fit the scenario that you want, you still will be trying to fit a square into a circle.&lt;/p&gt;

&lt;h2&gt;
  
  
  The alternatives
&lt;/h2&gt;

&lt;p&gt;Honestly, you have many alternatives that aren't scripting languages that for more to the BackEnd, pipelines or CLIs. Unfortunately, for the Web we are stuck with JavaScript, but it's OK, it doesn't affect us that much (I hope).&lt;/p&gt;

&lt;p&gt;For REST APIs, you can use Java, Ruby, Elixir, Golang, even PHP (yes, it's a better option than using JavaScript on the BackEnd). Try to choose something that was created to fit your case, and not adapted to fit your case.&lt;/p&gt;

&lt;p&gt;A tool specifically made to solve a problem will always be better than a generic tool that has something kinda can solve that problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;JavaScript was an amazing innovation back in the day, Brendan Eich did something magical with the resources that he had, and thanks to it, we have the web the way that we have today.&lt;/p&gt;

&lt;p&gt;It's also a good start for new developers: It's simple, has a package manager so you can rely on others to do hard things for you (like checking if a number is even or odd) and you can run it directly on the browser to test things.&lt;/p&gt;

&lt;p&gt;But overall, any serious company or project should not use JavaScript to power its system. It's a workaround, something glued with gum and spit, if you want your system to have a good amount of reliability you should not use JavaScript.&lt;/p&gt;

&lt;p&gt;I know that you may have many arguments, like &lt;em&gt;"Netflix/Google/Facebook/AnyBigCompany.com uses Node on the BackEnd!"&lt;/em&gt;, and I know it, I just don't understand why, and I would love to have the opinions of the amazing developers that work there about the topic.&lt;/p&gt;

&lt;p&gt;Thanks for reading! If you have any comments about the topic, please, share below and let's discuss more about it.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>backend</category>
      <category>node</category>
    </item>
  </channel>
</rss>
