<?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: Alex Howez</title>
    <description>The latest articles on DEV Community by Alex Howez (@aech12).</description>
    <link>https://dev.to/aech12</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%2F184558%2F90d4b5f3-b982-4e34-ba1b-88ab07a6791d.jpeg</url>
      <title>DEV Community: Alex Howez</title>
      <link>https://dev.to/aech12</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aech12"/>
    <language>en</language>
    <item>
      <title>Don't set a Pomodoro while coding (unless you're learning)</title>
      <dc:creator>Alex Howez</dc:creator>
      <pubDate>Mon, 25 Mar 2024 21:32:34 +0000</pubDate>
      <link>https://dev.to/aech12/dont-set-a-pomodoro-while-coding-unless-youre-learning-32gm</link>
      <guid>https://dev.to/aech12/dont-set-a-pomodoro-while-coding-unless-youre-learning-32gm</guid>
      <description>&lt;p&gt;&lt;strong&gt;TLDR: You'll stop yourself from going into "flow state".&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F93d2pleuixtsgsybaf94.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F93d2pleuixtsgsybaf94.jpg" alt="Photo by Dmitry Ratushny on Unsplash&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
  " width="800" height="509"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Pomodoro Technique and Coding&lt;br&gt;
The Pomodoro Technique involves breaking work into intervals, traditionally 25 minutes in length, separated by short breaks. However, when it comes to coding, this technique might not always be the best fit.&lt;/p&gt;

&lt;p&gt;Coding often requires deep concentration and immersion in the task at hand, a state commonly referred to as 'flow'. &lt;strong&gt;This is THE technique/mechanic that will enable you to produce high-quality work&lt;/strong&gt; and solve complex problems more efficiently 🚀&lt;/p&gt;

&lt;p&gt;I can say that, as a junior dev, &lt;strong&gt;I tried to force this technique on my work, because it's exactly what I used to do at university.&lt;/strong&gt; I was simply doing what already worked for me. Here's the issue though, research shows that entering the state of flow will take around 20–50 minutes of working on a given task. The Pomodoro Technique, with its frequent breaks, can disrupt this flow. &lt;/p&gt;

&lt;p&gt;Use this technique to learn how to code, not to actually code at work!&lt;/p&gt;

</description>
      <category>coding</category>
      <category>webdev</category>
      <category>gamedev</category>
    </item>
    <item>
      <title>Breaking Down React Hooks (part 1)</title>
      <dc:creator>Alex Howez</dc:creator>
      <pubDate>Thu, 07 Mar 2024 02:41:40 +0000</pubDate>
      <link>https://dev.to/aech12/breaking-down-react-hooks-part-1-4m7g</link>
      <guid>https://dev.to/aech12/breaking-down-react-hooks-part-1-4m7g</guid>
      <description>&lt;p&gt;I wanted to learn more about how React Hooks work under the hook, so I dove in the source code. In this blog we'll demistify all hooks and learn a bit about typed Javascript and React. Let's go!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F904012m9iunimyvq6cky.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F904012m9iunimyvq6cky.jpg" alt="Image description" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  useState
&lt;/h2&gt;

&lt;p&gt;Let's start with React's most used hook&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [count, setCount] = useState(0);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first thing we notice is the "[var, setVar]" syntax. This is actually Javascript syntax that allows you to spread an array returned from a function. Check example below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function fn() {
  let var1 = 'Hello', var2 = 'World', var3 = '!';
  return [var1, var2, var3];
}

const [var1, var2, var3] = fn();
console.log(var1); // Outputs: Hello
console.log(var2); // Outputs: World
console.log(var3); // Outputs: !
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Anyway, let's look at the useState source code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export function useState&amp;lt;S&amp;gt;(
  initialState: (() =&amp;gt; S) | S,
): [S, Dispatch&amp;lt;BasicStateAction&amp;lt;S&amp;gt;&amp;gt;] {
  const dispatcher = resolveDispatcher();
  return dispatcher.useState(initialState);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's the whole code for the useState function! It looks like Typescript, but actually Flow is used for types, originally developed at Facebook.&lt;/p&gt;

&lt;p&gt;Looking again at how state is initialized&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [count, setCount] = useState(0);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We see that we pass a generic value "0" which could be a number, string or even a function that returns a value. How do I know this? It's in the source!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function useState&amp;lt;S&amp;gt;(
  initialState: (() =&amp;gt; S) | S,
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we get that a generic value is passed (research Generics if you don't know this concept) and it can be the generic value itself or a function.&lt;/p&gt;

&lt;p&gt;Let's look further.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[S, Dispatch&amp;lt;BasicStateAction&amp;lt;S&amp;gt;&amp;gt;] 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We also get that the return type is an array with 2 values, S (generic vlaue) and a Dispatch function that helps use update that state. This is what we broke down initially, remember?&lt;/p&gt;

&lt;p&gt;We won't go into what a dispatcher is, yet. It's a very important concept but I'm already making this too long.&lt;br&gt;
Basically it "dispatches" a change of state through a "reducer".&lt;/p&gt;
&lt;h2&gt;
  
  
  useEffect
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export function useEffect(
  create: () =&amp;gt; (() =&amp;gt; void) | void,
  deps: Array&amp;lt;mixed&amp;gt; | void | null,
): void {
  const dispatcher = resolveDispatcher();
  return dispatcher.useEffect(create, deps);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;That is the whole code for useEffect. Yes, I know! It's short.&lt;/p&gt;

&lt;p&gt;We can see almost the same format as in useState. But this time we take a function and an array as arguments. The function itself returns either another function or void.&lt;/p&gt;

&lt;p&gt;If you look at an example of useEffect:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  useEffect(() =&amp;gt; {
    // Update the document title using the browser API
    document.title = `You clicked ${count} times`;
  }, []);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We precisely see that useEffect() takes first a function as argument, and then an optional array.&lt;/p&gt;

&lt;p&gt;In typescript you'd see the use of "?:" for optional types but here we see this which works for Flow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; deps: Array&amp;lt;mixed&amp;gt; | void | null,
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We also see the use of dispatchers again and a dispatcher being called with "dispatcher.useEffect". Let me know if you want me to go more in depth on the dispatchers in a later blog.&lt;/p&gt;

&lt;h2&gt;
  
  
  More hooks
&lt;/h2&gt;

&lt;p&gt;Let's see more hook examples&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export function useContext&amp;lt;T&amp;gt;(Context: ReactContext&amp;lt;T&amp;gt;): T {
  const dispatcher = resolveDispatcher();
  return dispatcher.useContext(Context);
}
&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;export function useReducer&amp;lt;S, I, A&amp;gt;(
  reducer: (S, A) =&amp;gt; S,
  initialArg: I,
  init?: I =&amp;gt; S,
): [S, Dispatch&amp;lt;A&amp;gt;] {
  const dispatcher = resolveDispatcher();
  return dispatcher.useReducer(reducer, initialArg, init);
}
&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;export function useCallback&amp;lt;T&amp;gt;(
  callback: T,
  deps: Array&amp;lt;mixed&amp;gt; | void | null,
): T {
  const dispatcher = resolveDispatcher();
  return dispatcher.useCallback(callback, deps);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we notice that we can no longer avoid this anymore, we must know what a dispatcher is!&lt;/p&gt;

&lt;p&gt;If you're interested, we'll continue in part 2.&lt;/p&gt;

</description>
      <category>react</category>
    </item>
    <item>
      <title>Why Are Programming Languages Looking More Like JavaScript?</title>
      <dc:creator>Alex Howez</dc:creator>
      <pubDate>Mon, 25 Dec 2023 15:11:47 +0000</pubDate>
      <link>https://dev.to/aech12/why-are-programming-languages-looking-more-like-javascript-3fig</link>
      <guid>https://dev.to/aech12/why-are-programming-languages-looking-more-like-javascript-3fig</guid>
      <description>&lt;p&gt;In 2023 I started testing a lot of new languages and saw newer languages copying JS syntax, and for good reason! JavaScript is one of the most popular and widely used programming languages.&lt;/p&gt;

&lt;p&gt;While initially I thought I was biased to the JavaScript syntax, apparently more and more languages are copying it's style.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Did JavaScript prove it's readability and visual scalability?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--L-72aS6Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ty0e5q2qg7ozgq0f5bn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--L-72aS6Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ty0e5q2qg7ozgq0f5bn.png" alt="JavasScript logo" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  The New Languages
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;Take a look at Carbon, Google's new programming language that aims to be a modern and expressive successor to C++, designed to be compatible with existing C++ code and libraries.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KjV0nWCc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uhi06mpvi6mm0qlxs0m4.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KjV0nWCc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uhi06mpvi6mm0qlxs0m4.jpeg" alt="Carbon Code Example" width="800" height="783"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The use of arrow functions, the way to declare variables and for loops, you can always confuse this with Typescript!&lt;/p&gt;

&lt;p&gt;As a reminder on JavaScript's plasticity, bracket "{}" symbols are optional, same for arrow functions and the same goes for spacing (4 space vs 2 space vs tab spacing).&lt;/p&gt;

&lt;p&gt;Below is the same function, written in different ways.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--v7d-tVV5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u6jyz16z3jmbeg8uzr5g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--v7d-tVV5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u6jyz16z3jmbeg8uzr5g.png" alt="JS code example" width="783" height="232"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  It's also Kotlin
&lt;/h2&gt;

&lt;p&gt;**&lt;br&gt;
Another example is Kotlin, a programming language that targets the Java Virtual Machine (JVM) and can interoperate with Java code while being more concise and expressive.&lt;/p&gt;

&lt;p&gt;It's a language that I'm interested in, and looking at it's documentation I couldn't help but notice the JavaScript similarities again. Curly braces for blocks, semicolons for statements, and var/val for variables.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Hq2n4KTW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r5d6l41mdnj806ych24d.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Hq2n4KTW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r5d6l41mdnj806ych24d.jpeg" alt="Kotlin on left, Java on right" width="800" height="515"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Looking at the Kotlin/Java comparison, you can see how Kotlin drops the variable declaration in the "public final int id" in favour of "val id: Int".&lt;/p&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  And also Rust?
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;I'll leave the same example in Rust for fun, another one of the newer languages with this same syntax look.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Igh6MXXW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p9gjqp7e4xd0tcbessps.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Igh6MXXW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p9gjqp7e4xd0tcbessps.png" alt="Rust ChatGPT generated example" width="800" height="675"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final Thoughts&lt;/strong&gt;&lt;br&gt;
In my opinion, Python's ease of writing shortcuts make it harder to read on larger codebases, while Java's intricacies make it harder to read line by line.&lt;br&gt;
On the other hand JS/TS or strike a great balance in the middle.&lt;/p&gt;

&lt;p&gt;What do think?&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>java</category>
      <category>rust</category>
      <category>python</category>
    </item>
  </channel>
</rss>
