<?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: Bruno</title>
    <description>The latest articles on DEV Community by Bruno (@bcostaaa01).</description>
    <link>https://dev.to/bcostaaa01</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%2F562058%2F817ec840-aa21-4af9-951f-03f4dbd6a89e.jpg</url>
      <title>DEV Community: Bruno</title>
      <link>https://dev.to/bcostaaa01</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bcostaaa01"/>
    <language>en</language>
    <item>
      <title>How to work with nested locale folder structures in Vue</title>
      <dc:creator>Bruno</dc:creator>
      <pubDate>Sat, 01 Nov 2025 20:38:03 +0000</pubDate>
      <link>https://dev.to/bcostaaa01/how-to-work-with-nested-locale-folder-structures-in-vue-2bn4</link>
      <guid>https://dev.to/bcostaaa01/how-to-work-with-nested-locale-folder-structures-in-vue-2bn4</guid>
      <description>&lt;p&gt;Recently, I was working on a Vue-based application where I decided to explore a bit how I could adapt the frontend architecture (or more specifically - the folder structure and the config, in this case) to work with multiple locale/translation files, including nested in other directories.&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%2Fenzxni8xyyw4uazn4n9v.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%2Fenzxni8xyyw4uazn4n9v.png" alt="app folder structure for locales" width="472" height="219"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Getting a single locale JSON file for each language is easy, especially if you work with Vite in your project, but what about multiple files for the same locale/language? Well, it is not that much of a big deal. I played around a bit with different solutions and our beloved ChatGPT has suggested the following approach.&lt;/p&gt;

&lt;h5&gt;
  
  
  The code
&lt;/h5&gt;

&lt;p&gt;First step is to assign the translation files to a &lt;code&gt;messages&lt;/code&gt; variable, and the catch here is, that if you want to assign a name to a specific set of translations (like "notifications", in this case), then you can just give it a key and assign the file to it:&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;de&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./locale/de.json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;en&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./locale/en.json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;notificationsDe&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./locale/notifications/notifications_de.json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;notificationsEn&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./locale/notifications/notifications_en.json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// the rest of the code for the config bla bla...&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;messages&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;de&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;de&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;notifications&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;notificationsDe&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;en&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;en&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;notifications&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;notificationsEn&lt;/span&gt;&lt;span class="p"&gt;,&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;And then in your Vue files, you just use either the normal keys in the "main" translation files in the root of the locales directory, or access the notifications translations specifically:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;{{ $t('app.notifications-banner') }}&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;{{ $t('notifications.newMessage') }}&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then it will pick each translation accordingly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do I like this approach?
&lt;/h3&gt;

&lt;p&gt;Yeah, sure. Why not? I mean, it works. Do I find it to be the cleanest, most efficient one? I am not sure. If I would write this from scratch for some other project right now, I would probably move the &lt;code&gt;messages&lt;/code&gt; variable to a separate "utility" file instead, at least, just to keep the config file a bit cleaner and the locale stuff a bit more centralised. But as for an alternative solution, that is what I leave that up for discussion. I am curious if anyone has tried any other solutions than this, and if there is something better I have not thought of. 😉&lt;/p&gt;

</description>
      <category>vue</category>
      <category>javascript</category>
      <category>frontend</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Software Engineering: How to work and think like an engineer</title>
      <dc:creator>Bruno</dc:creator>
      <pubDate>Wed, 18 Sep 2024 22:10:29 +0000</pubDate>
      <link>https://dev.to/bcostaaa01/software-engineering-how-to-work-and-think-like-an-engineer-4p4o</link>
      <guid>https://dev.to/bcostaaa01/software-engineering-how-to-work-and-think-like-an-engineer-4p4o</guid>
      <description>&lt;p&gt;So far, building things with code has been one of the coolest, and most sought out fields of profession. Yep, no doubt there. However, sometimes I get the feeling that a lot of people confuse software development with the misconception that our job is to code. Solely, code. Nope, that is wrong. Well, in part it is correct, I know. However, being a software developer is much more than that. Because sometimes things can only be learned from working with fellow engineers with more experience than us, or perhaps different experiences, I thought sharing my thoughts in this would be useful for you somehow, fellow engineer.&lt;/p&gt;

&lt;h3&gt;
  
  
  Development is not only coding
&lt;/h3&gt;

&lt;p&gt;I started this post with the misconception that our job is to code, code, and code. And even though that is true to a certain extent, our tasks go way deeper than the code we write. &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%2Fmbp8zkdjpiuzs96md9z7.gif" 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%2Fmbp8zkdjpiuzs96md9z7.gif" alt="cat coding" width="200" height="210"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;During my day as a software engineer, I find myself doing more than simply deploying features into prod. I would say coding is a reduced fraction of what it looks like to the people around us. It involves tasks like planning, estimating, writing tests, fixing tests, fixing tests (again), designing user interfaces, writing documentation, fixing bugs, doing quality assurance, helping, being helped, asking questions, being asked questions. Anyway, the list goes on and on. This should be enough to give an idea that our job is much more than building, there is a whole other realm of tasks that we have to do to make sure our work brings any value to the end user. Brent Rambo supports quality work.&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%2F9e6ijf08ykihbiy2jjgi.gif" 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%2F9e6ijf08ykihbiy2jjgi.gif" alt="quality work" width="316" height="222"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Take the following example. Imagine you were a developer, and a client asks you to build an application which allows them to manage their whole inventory/stock, track sales, and get access to all the data in a dashboard with charts, and such. Now, you as a software developer need to have a good understanding of what the client wants, right? Yes. Correct. Next, you need to plan, estimate, and deliver. You will also most likely face bugs, just like any other application. And your client will ask you for more features, so you have to reestimate, replan, and adapt. These are just a few of the things you will have to do, and be aware of before, and during the process of building the project for them. This will help you ensure quality work, and a satisfied customer, because the faster, and better you can build, the happier they will be, right?&lt;/p&gt;

&lt;h3&gt;
  
  
  What does "software engineering" even mean?
&lt;/h3&gt;

&lt;p&gt;Well, this is another big misunderstanding that people seem to have, and it is completely normal, by the way. First, what question should we ask before we even ask ourselves what "sofware engineering" means? We should ask ourselves what &lt;em&gt;engineering&lt;/em&gt; means in the first place. That is where software engineering comes from. Without it, there would be no &lt;em&gt;software engineering&lt;/em&gt; anyway.&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%2Fs328kp9jea2dachvtvkf.gif" 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%2Fs328kp9jea2dachvtvkf.gif" alt="engineer" width="220" height="124"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The term &lt;em&gt;Engineering&lt;/em&gt; by itself means &lt;em&gt;"the application of an empirical, scientific approach to finding efficient, econmic solutions to practical problems"&lt;/em&gt; ("Modern Software Engineering", David Farley). It is basically the foundation of the thinking we should adapt in our profession as software engineers. If we rely on the notion that coding is the main "tool" to achieve the result, then we are fooling ourselves to believe that it code is by itself the means, and the end. &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%2Fne4d1nf8naif5du9whsx.gif" 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%2Fne4d1nf8naif5du9whsx.gif" alt="means to an end" width="400" height="222"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Code is a tool, a language like any other spoken language, just interpreted by our computers to perform tasks. That is what coding in its rawest meaning is. However, in order to produce high-quality code, and build solutions to business problems, we need to apply a rather scientific reasoning (combined with our code, of course). By doing so, we are ensuring that we are in the pursue of a more authentic meaning to what our role actually is all about, and pursuing solutions that are more efficient, cleaner, and fun to build, too. &lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;While coding is definitely the languages we "speak", and use as a means to building something, our jobs involve much more than just that. It involves the scientific, engineering-based reasoning that helps us go beyond the code we write, and come up with more clever solutions as we gradually maintain a project. By understanding what the term &lt;em&gt;engineering&lt;/em&gt; means, you are hopefully able to apply a more scientific reasoning to your work as a software engineer, and therefore build more clever solutions to solve real-world problems.&lt;/p&gt;

&lt;h3&gt;
  
  
  About the Author
&lt;/h3&gt;

&lt;p&gt;I'm a software developer, and technical writer based in Portugal. I'm passionate about software engineering 👨‍💻 and I love to explore new tools in my day-to-day, and find interesting, and creative solutions to common business, and techincal problems. You can find me on &lt;a href="//github.com/bcostaaa01"&gt;GitHub&lt;/a&gt;. If you have any questions or feedback, feel free to reach out! 🚀&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>development</category>
      <category>productivity</category>
      <category>showdev</category>
    </item>
    <item>
      <title>How to pass props from child to parent component in React</title>
      <dc:creator>Bruno</dc:creator>
      <pubDate>Tue, 10 Sep 2024 21:18:13 +0000</pubDate>
      <link>https://dev.to/bcostaaa01/how-to-pass-props-from-child-to-parent-component-in-react-1ci4</link>
      <guid>https://dev.to/bcostaaa01/how-to-pass-props-from-child-to-parent-component-in-react-1ci4</guid>
      <description>&lt;p&gt;You have probably been passing &lt;code&gt;props&lt;/code&gt; from parent to child components, and you have questioned yourself: "Hmm... but what if I want to pass props from child to a parent component? I mean... the other way round?", right? 🤔 I have also questioned myself that, but there are solutions actually. &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%2Fckv9lkmq7r3lguc3fplk.gif" 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%2Fckv9lkmq7r3lguc3fplk.gif" alt="harold and old woman from creepshow 2019" width="400" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will go through them.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the typical flow of props?
&lt;/h3&gt;

&lt;p&gt;The typical flow of props is from parent to child. Basically, let's say you have a &lt;code&gt;Parent&lt;/code&gt; component which looks like this:&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%2F9zhn4lgk209pwr8c89va.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%2F9zhn4lgk209pwr8c89va.png" alt="parent component code snippet" width="800" height="718"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The child component we have below uses a &lt;code&gt;Button&lt;/code&gt; component from the very much beloved &lt;a href="https://ui.shadcn.com/" rel="noopener noreferrer"&gt;shadcn/ui&lt;/a&gt; component library. The &lt;code&gt;Button&lt;/code&gt; component has a &lt;code&gt;children&lt;/code&gt; prop, which is passed from the &lt;code&gt;Parent&lt;/code&gt; component.&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%2Fro0zoia5r1cxgpqtvx82.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%2Fro0zoia5r1cxgpqtvx82.png" alt="child component code snippet" width="800" height="608"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Above, we are passing a &lt;code&gt;children&lt;/code&gt; prop from the &lt;code&gt;Parent&lt;/code&gt; component to the &lt;code&gt;Child&lt;/code&gt; component. All good so far, right?&lt;/p&gt;

&lt;h4&gt;
  
  
  What if we want to pass props from child to parent?
&lt;/h4&gt;

&lt;p&gt;Now, this is where things get a bit tricky, espcially if it is your first time implementing such logic. The tricky part about it is probably not how to go about doing it, but more how to visualize it. Either way, I have been there, and my experience will hopefully help you out 😌&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%2Fh7ct6w5zl89iemic3cd9.gif" 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%2Fh7ct6w5zl89iemic3cd9.gif" alt="crafting things" width="220" height="124"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Because learning is best done by doing, let's bring the example from earlier, and modify it a bit to see how we can pass props from child to parent. The goal of this example is to show how we can modify the state of the &lt;code&gt;Parent&lt;/code&gt; component by passing data from the &lt;code&gt;Child&lt;/code&gt; component.&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%2Fn9wytjcozodlol8mer8e.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%2Fn9wytjcozodlol8mer8e.png" alt="parent component code snippet" width="800" height="544"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And here is what we do from the &lt;code&gt;Child&lt;/code&gt; component:&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%2Ffk8c0uyueed15m77sunr.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%2Ffk8c0uyueed15m77sunr.png" alt="child component code snippet" width="800" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Making it simpler to understand in written form, what we are trying to accomplish with the two components is that we initialise the state in the &lt;code&gt;Parent&lt;/code&gt; component, and then pass the variables down to the &lt;code&gt;Child&lt;/code&gt; component, and the respective function to update the value of the state in the &lt;code&gt;Parent&lt;/code&gt; component. In this case, suppose the value of the state is first set to &lt;code&gt;false&lt;/code&gt;. When we click on the button from the &lt;code&gt;Child&lt;/code&gt; component, it will take that value, and change it to the opposite of &lt;code&gt;false&lt;/code&gt; (&lt;code&gt;!&lt;/code&gt; in the value negates it) when the function gets called on the click event.&lt;/p&gt;

&lt;h4&gt;
  
  
  A common pitfall while passing data from child to parent
&lt;/h4&gt;

&lt;p&gt;Passing data from the child component to the parent does have its quirks. One of the most common pitfalls is forgetting to pass the callback function as a prop to the child component, but that also means that you are passing more logic that you you need to pass. This can lead to more annoying, and harder to debug bugs. &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%2Fo4s5c5gvnwqv61c3lubt.gif" 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%2Fo4s5c5gvnwqv61c3lubt.gif" alt="on fire meme" width="220" height="149"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One way to prevent this is to use the &lt;code&gt;useCallback&lt;/code&gt; hook, which makes sure that the function you pass as a callback to the child component remains stable across renders, preventing unnecessary re-renders and improving performance. What happens with &lt;code&gt;useCallback&lt;/code&gt; is that you pass a function as a prop to the child component, and the child component will have access to the function, and can call it when needed. Let's see how we can do this.&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%2Fc7s6jgljtnpmv8dvu8wz.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%2Fc7s6jgljtnpmv8dvu8wz.png" alt="useCallback example code snippet" width="800" height="620"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let's show how it looks like in the &lt;code&gt;Child&lt;/code&gt; component:&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%2F51d13m0u63k0ce166jnz.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%2F51d13m0u63k0ce166jnz.png" alt="child component using useCallback function code snippet" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Isn't this cleaner than passing the function, and then updating it from the child, and then passing again to the parent? Cleaner, and easier to implement, too, right? 🤩&lt;/p&gt;

&lt;h3&gt;
  
  
  Thank you for reading!
&lt;/h3&gt;

&lt;p&gt;Even though there are surely more, and potentially even cleaner, better-looking ways of passing data from child to parent in React, I hope that after reading my article, you will find it easier to understand the flow of how data passes from child to parent, and how to go about implementing that with two different ways. Who knows, maybe you will find a more creative way of doing it yourself? 😉 If so, it would be greatly appreciated to explain your ideas in the comments! &lt;/p&gt;

&lt;h3&gt;
  
  
  About the Author
&lt;/h3&gt;

&lt;p&gt;I'm a software developer, and technical writer based in Portugal. I'm passionate about software engineering 👨‍💻 and I love to explore new tools in my day-to-day, and find interesting, and creative solutions to common business, and techincal problems. You can find me on &lt;a href="//github.com/bcostaaa01"&gt;GitHub&lt;/a&gt;. If you have any questions or feedback, feel free to reach out! 🚀&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>programming</category>
    </item>
    <item>
      <title>Vue Composables: what are they, and how to create &amp; use one</title>
      <dc:creator>Bruno</dc:creator>
      <pubDate>Fri, 29 Mar 2024 18:16:45 +0000</pubDate>
      <link>https://dev.to/bcostaaa01/vue-composables-what-are-they-and-how-to-create-use-one-4b06</link>
      <guid>https://dev.to/bcostaaa01/vue-composables-what-are-they-and-how-to-create-use-one-4b06</guid>
      <description>&lt;p&gt;Hey there, fellow Vue enthusiasts! 🎉 Ever found yourself lost in the jungle of a Vue component, overwhelmed by its tangled mess of tasks? 🤯 We've all been there! Picture this: you start with a simple component, but as your project blossoms, so does the complexity. Before you know it, your once tidy component has morphed into a wild beast, hard to read, test, or reuse. 😱&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%2F0slc0cldstw2jz9d51sm.gif" 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%2F0slc0cldstw2jz9d51sm.gif" alt="confused" width="560" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Isn't it a pain when you're constantly scrolling up and down, trying to decipher what's happening? Or worse, when you find yourself copy-pasting the same logic across multiple components? Or testing a cascading waterfall of side effects? It's like a bad dream, isn't it? Fear not, my fellow brave coder! Vue.js to the rescue with its secret weapon: composables. 🦸‍♂️&lt;/p&gt;

&lt;h3&gt;
  
  
  What Exactly Are Composables?
&lt;/h3&gt;

&lt;p&gt;Think of composables as your code's trusty sidekick, always ready to swoop in and save the day! 🦸‍♀️ They're like little nuggets of wisdom, encapsulating reusable logic that you can sprinkle throughout your app. 🌟 In simpler terms, they're functions that return an object of goodies you can use in your Vue components. Neat, huh?&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="c1"&gt;// useVuei18n.js&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useI18n&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vue-i18n&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;useVuei18n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useI18n&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;t&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;Now, you can sprinkle that &lt;code&gt;t&lt;/code&gt; function magic in any component that imports the &lt;code&gt;useVuei18n&lt;/code&gt; composable. Voila! ✨&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{{&lt;/span&gt; &lt;span class="nf"&gt;t&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="si"&gt;}}&lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt; &lt;span class="na"&gt;setup&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useVuei18n&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./useVuei18n&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useVuei18n&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Let's Dive into an Example
&lt;/h3&gt;

&lt;p&gt;Ready for some hands-on learning? Let's dive into an example together! Imagine we have a component fetching users from an API and filtering them by name. Sounds simple, right? Here's how it could look:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;v-model=&lt;/span&gt;&lt;span class="s"&gt;"search"&lt;/span&gt; &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="na"&gt;input=&lt;/span&gt;&lt;span class="s"&gt;"searchUsers"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;v-for=&lt;/span&gt;&lt;span class="s"&gt;"user in users"&lt;/span&gt; &lt;span class="na"&gt;:key=&lt;/span&gt;&lt;span class="s"&gt;"user.id"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{{&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="si"&gt;}}&lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt; &lt;span class="na"&gt;setup&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;onMounted&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;([])&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;search&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;searchUsers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&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;// fetch users&lt;/span&gt;
  &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://jsonplaceholder.typicode.com/users&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;search&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;onMounted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;searchUsers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The component starts simple, but as it grows, it becomes a tangled mess. Fear not! We'll rescue it with a &lt;code&gt;useFetch&lt;/code&gt; composable, splitting responsibilities and making our code cleaner and more focused. 👌&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="c1"&gt;// useFetch.js&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;useFetch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;search&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;searchUsers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;search&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;search&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;searchUsers&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;Now, let's sprinkle some &lt;code&gt;useFetch&lt;/code&gt; magic in our component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;v-model=&lt;/span&gt;&lt;span class="s"&gt;"search"&lt;/span&gt; &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="na"&gt;input=&lt;/span&gt;&lt;span class="s"&gt;"searchUsers"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;v-for=&lt;/span&gt;&lt;span class="s"&gt;"user in users"&lt;/span&gt; &lt;span class="na"&gt;:key=&lt;/span&gt;&lt;span class="s"&gt;"user.id"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{{&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="si"&gt;}}&lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt; &lt;span class="na"&gt;setup&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;onMounted&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useFetch&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./useFetch&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;([])&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;search&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;searchUsers&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useFetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://jsonplaceholder.typicode.com/users&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;onMounted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;searchUsers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We went from a component that juggles two tasks to a clean and focused setup: one task for the component and one for the composable. It's like a breath of fresh air, isn't it? 🌬️ And that's the beauty of composables! They keep your codebase tidy and your components happy. 🎈 Even your cat will thank you later. 🐈‍⬛&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%2F0wsbjhpb7kbppjzaj68f.gif" 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%2F0wsbjhpb7kbppjzaj68f.gif" alt="tom cat relieved" width="280" height="158"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Composables: Behind the Scenes
&lt;/h3&gt;

&lt;p&gt;Curious about how composables work under the hood? Buckle up, because we're diving into the nitty-gritty details! 🕵️‍♂️ When you import a composable, it springs into action like a trusty sidekick 🦸‍♂️, executing once and caching its properties. This ensures efficiency and prevents messy side effects. Plus, composables are reactive! 🔄 They respond to changes, ensuring your components stay in sync with the data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{{&lt;/span&gt; &lt;span class="nf"&gt;$t&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="si"&gt;}}&lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt; &lt;span class="na"&gt;setup&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useI18n&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vue-i

18n&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;t&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;$t&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useI18n&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&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="s1"&gt;composable executed&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Click that button, and watch the magic happen! The composable springs back to life, reacting to changes like a champ. 🎉 Because let's face it, what's Vue.js without that sweet, sweet reactivity?&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%2Fl40hb6p6lhd6ku1z1r9x.gif" 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%2Fl40hb6p6lhd6ku1z1r9x.gif" alt="all over again, deja vu" width="400" height="170"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, performance speaking, composables also help you avoid unnecessary re-renders. By splitting your logic into composables, you can ensure that only the relevant parts of your component re-render when the data changes. 🚀 It would be pretty annoying if your entire component re-rendered every time you typed a single letter, wouldn't it?&lt;/p&gt;

&lt;h3&gt;
  
  
  When not to use Composables
&lt;/h3&gt;

&lt;p&gt;While composables are a powerful tool in your Vue.js arsenal, there are times when you should think twice before using them. 🤔 For instance, if you're working on a small project or a one-off component, composables might be overkill. 🛠️ Instead, keep it simple and stick to the basics. Also, if you're dealing with a component that's tightly coupled with its logic, you might not need a composable. 🤝 Sometimes, it's okay to keep things together if they work well as a team. Take an example of a simple button component that toggles a modal. It's small, simple, and doesn't need to be split into a composable. 🛑&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="na"&gt;click=&lt;/span&gt;&lt;span class="s"&gt;"toggleModal"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Open Modal&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;Modal&lt;/span&gt; &lt;span class="na"&gt;v-if=&lt;/span&gt;&lt;span class="s"&gt;"showModal"&lt;/span&gt; &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="na"&gt;close=&lt;/span&gt;&lt;span class="s"&gt;"toggleModal"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt; &lt;span class="na"&gt;setup&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;showModal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;toggleModal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;showModal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;showModal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you put the &lt;code&gt;toggleModal&lt;/code&gt; function in a composable, it would make the component more complex than it needs to be. 🤯 So, remember, composables are great, but use them wisely! 🧠&lt;/p&gt;

&lt;h3&gt;
  
  
  Wrapping Up
&lt;/h3&gt;

&lt;p&gt;And there you have it, folks! Composables: the unsung heroes of Vue.js development. 🦸‍♀️ Give it a try, and you will thank yourself later! Happy coding!😁&lt;/p&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://v3.vuejs.org/guide/composition-api-introduction.html" rel="noopener noreferrer"&gt;Vue 3 Composition API&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://v3.vuejs.org/api/sfc-script-setup.html" rel="noopener noreferrer"&gt;Vue 3 Script Setup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://v3.vuejs.org/guide/composition-api-introduction.html#composables" rel="noopener noreferrer"&gt;Vue 3 Composables&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://v3.vuejs.org/guide/typescript-support.html#using-composition-api" rel="noopener noreferrer"&gt;Vue 3 Composables with TypeScript&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://v3.vuejs.org/guide/typescript-support.html#using-vite" rel="noopener noreferrer"&gt;Vue 3 Composables with Vite&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  About the Author
&lt;/h3&gt;

&lt;p&gt;I'm a frontend developer and technical writer based in Portugal. I'm passionate about software engineering 👨‍💻, and I love to explore new tools in my day-to-day. You can find me on &lt;a href="//github.com/bcostaaa01"&gt;GitHub&lt;/a&gt;. If you have any questions or feedback, feel free to reach out! 🚀&lt;/p&gt;

</description>
      <category>vue</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>🚀 Getting started with Vite</title>
      <dc:creator>Bruno</dc:creator>
      <pubDate>Fri, 01 Mar 2024 21:46:15 +0000</pubDate>
      <link>https://dev.to/bcostaaa01/getting-started-with-vite-4fah</link>
      <guid>https://dev.to/bcostaaa01/getting-started-with-vite-4fah</guid>
      <description>&lt;p&gt;Vite. Vite? Yes! But... what is Vite? Well, Vite is the next generation frontend tooling. It's a build tool that aims to provide a faster and leaner development experience for modern web projects. Come with me and let's explore Vite together. Who knows? Maybe you'll find it interesting and useful for your next project 😉&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Vite?
&lt;/h3&gt;

&lt;p&gt;First, let's learn a bit of history, because you know what they say: "Those who don't know history are doomed to repeat it" 📖 Vite is a French word that means "fast". It's pronounced like "veet". The name is a reference to the tool's main selling point: speed. Vite was created by Evan You, the creator of Vue.js, and it's designed to be a build tool that is the next generation in frontend development. If you try Vite, forget about slow builds and waiting for your project to compile. Vite is fast, really fast. It's so fast that it feels like you're working with a framework that has a built-in server. It's like, hmm well... magic! 🎩✨&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Vite?
&lt;/h3&gt;

&lt;p&gt;For starters, Vite was designed to solve a problem that many frontend developers face: slow builds. When you're working on a project, you want to see the changes you make in real-time. You don't want to wait for your project to compile every time you make a change. &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%2Fbqafew82namyqoxvfwlf.gif" 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%2Fbqafew82namyqoxvfwlf.gif" alt="tom cat painting a dog house" width="220" height="164"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Even Tom Cat knows that waiting is not fun. Vite addresses slow build times by providing a highly efficient development server that significantly speeds up the feedback loop for developers. It achieves this by using native ES modules in the browser, which allows for on-demand file serving and transformation, and by pre-bundling dependencies with esbuild, which is much faster than traditional JavaScript-based bundlers. This approach not only accelerates the development process, but also reduces the time developers spend waiting for changes to be reflected in the browser, making it feel very responsive.&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%2Fhacks.mozilla.org%2Ffiles%2F2018%2F03%2F02_module_scope_04.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%2Fhacks.mozilla.org%2Ffiles%2F2018%2F03%2F02_module_scope_04.png" alt="combined chunks, kind of like Lego blocks, illustrated to create all different kinds of applications from the same set of modules" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Like the above illustration from Mozilla(see &lt;a href="https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/" rel="noopener noreferrer"&gt;https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/&lt;/a&gt;) shows, breaking up the code into smaller chunks is possible with the ability to export and import variables between modules. This allows Vite to serve your code as-is, without having to bundle it into a single file. Comparing to tools like Webpack, which has to bundle your code into a single file before serving it, this is a huge performance improvement, and it's one of the main reasons why Vite is so fast.&lt;/p&gt;

&lt;h3&gt;
  
  
  Vite vs Webpack vs Snowpack
&lt;/h3&gt;

&lt;p&gt;To get a better picture into the whole JavaScript bundler landscape, let's compare Vite with Webpack and Snowpack. Webpack is a popular JavaScript bundler that has been around for a while. It's powerful and flexible, but it can be slow, especially for large projects, the more they grow and the more packages you are using. Snowpack is a newer JavaScript bundler that is designed to be fast and lightweight. It's similar to Vite in that it uses native ES modules in the browser, but it's not as feature-rich as Vite. Vite, on the other hand, is designed to be fast, feature-rich, and highly optimized for Vue.js projects. It's also designed to be extensible, so you can use it with other frameworks and libraries as well. &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%2Fjx5h4mhwur141xfbfwz4.gif" 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%2Fjx5h4mhwur141xfbfwz4.gif" alt="vuejs prettier vite code snippet gif" width="1920" height="1080"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In short, Vite is probably the best choice for Vue.js projects, but it's also a great choice for other modern web projects. Still not convinced? Let's take a look at some of the features that make Vite stand out.&lt;/p&gt;

&lt;h3&gt;
  
  
  Features
&lt;/h3&gt;

&lt;p&gt;Let's break down some of the features that make Vite stand out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Fast Builds&lt;/strong&gt;: Vite is designed to be fast. It uses native ES modules in the browser, which allows for on-demand file serving and transformation, and it pre-bundles dependencies with &lt;code&gt;esbuild&lt;/code&gt;, which is much faster than traditional JavaScript-based bundlers. This makes Vite feel very responsive and accelerates the development process.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Hot Module Replacement (HMR)&lt;/strong&gt;: Vite supports HMR out of the box, which means that you can see the changes you make in real-time without having to refresh the page. This makes the development process much more efficient and enjoyable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Highly Optimized for Vue.js&lt;/strong&gt;: Vite is designed to be highly optimized for Vue.js projects. It leverages Vue's reactivity system to provide a fast and efficient development experience for Vue developers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Extensible&lt;/strong&gt;: Vite is designed to be extensible, so you can use it with other frameworks and libraries as well. This makes it a great choice for modern web projects, not just Vue.js projects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Built-in Features&lt;/strong&gt;: Vite comes with built-in features like TypeScript support, CSS preprocessing, and more. This makes it easy to get started with Vite and reduces the need for additional configuration.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
   Getting Started
&lt;/h3&gt;

&lt;p&gt;If this article has opened your appetite for Vite, you can get started by installing it with &lt;code&gt;npm&lt;/code&gt; or &lt;code&gt;yarn&lt;/code&gt;. To install Vite with npm, run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm init vite@latest my-vite-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To install Vite with &lt;code&gt;yarn&lt;/code&gt;, run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn create vite my-vite-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you've installed Vite, you can start your project by running the following commands:&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;cd &lt;/span&gt;my-vite-project
npm &lt;span class="nb"&gt;install
&lt;/span&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will start the Vite development server and open your project in the browser. You can start making changes to your project and see the changes in real-time. It's that easy!&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%2Fql3owfuu6nhtecdw5rbs.gif" 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%2Fql3owfuu6nhtecdw5rbs.gif" alt="mindblown" width="200" height="150"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;I hope this article has given you a good overview of Vite and why it's worth considering for your next project. As a quick recap, Vite is a fast, feature-rich, and highly optimized build tool that provides a faster and leaner development experience for modern web projects. It's designed to be highly efficient and responsive, and it comes with built-in features like TypeScript support, CSS preprocessing, and more. If you're looking for a modern build tool that is fast, feature-rich, and highly optimized for Vue.js projects, Vite is definitely worth considering. Give it a try and see for yourself!🚀&lt;/p&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://vitejs.dev/" rel="noopener noreferrer"&gt;Vite&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/vitejs/vite" rel="noopener noreferrer"&gt;Vite on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/vite_js" rel="noopener noreferrer"&gt;Vite on Twitter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.reddit.com/r/vitejs/" rel="noopener noreferrer"&gt;Vite on Reddit&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://chat.vitejs.dev/" rel="noopener noreferrer"&gt;Vite on Discord&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🙋‍♂️ About the Author
&lt;/h3&gt;

&lt;p&gt;I'm a frontend developer and technical writer based in Portugal. I'm passionate about software engineering 👨‍💻, and I love to explore new tools in my day-to-day. You can find me on &lt;a href="//github.com/bcostaaa01"&gt;GitHub&lt;/a&gt;. If you have any questions or feedback, feel free to reach out! 🚀&lt;/p&gt;

</description>
      <category>vite</category>
      <category>javascript</category>
      <category>vue</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>What is Amazon AWS EC2 and where can you use them?</title>
      <dc:creator>Bruno</dc:creator>
      <pubDate>Thu, 06 Jul 2023 16:30:57 +0000</pubDate>
      <link>https://dev.to/bcostaaa01/what-is-amazon-aws-ec2-and-where-can-you-use-them-2beh</link>
      <guid>https://dev.to/bcostaaa01/what-is-amazon-aws-ec2-and-where-can-you-use-them-2beh</guid>
      <description>&lt;p&gt;As you embark on your AWS journey, you've likely encountered references to EC2 (Elastic Compute Cloud) along the way. In this article, I aim to demystify EC2 by guiding you through its core concepts, origins, operational mechanics, and diverse application areas. So, let's delve into the captivating realm of EC2 together, unraveling its immense potential and discovering the myriad opportunities it presents!🏰&lt;/p&gt;

&lt;h2&gt;
  
  
  🤔 What exactly is "EC2"?
&lt;/h2&gt;

&lt;p&gt;What is it? Who invented it? Well, you surely know it was developed by Amazon, I know... But... what is it? Well, EC2 stands for "Elastic Compute Cloud". &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%2Fbxaasvtdybl32v203us7.gif" 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%2Fbxaasvtdybl32v203us7.gif" alt="spongebob character patrick elastic" width="200" height="150"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, what is exactly "Elastic Compute Cloud" and what does it mean for the cloud to be "elastic compute"? It means that the computing resources provided can be easily scaled up and down based on demand. Why is this useful? EC2 allows you to "rent" virtual machines in the cloud. With this, you are able to run applications which require a lot of computing power, and saving money in hardware and physical data centres. &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%2Ft3084qt8gqe4qy40su5h.gif" 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%2Ft3084qt8gqe4qy40su5h.gif" alt="large sets of data the simpsons cartoon scientist" width="200" height="153"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Suppose you are working with heavy sets of data, you can use an EC2 instance to work with it without having the need to buy ultra expensive hardware, for example.&lt;/p&gt;

&lt;p&gt;Besides, EC2 instances are highly reliable, which means they make a great choice when deploying and storing apps and data in the cloud.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧰 What kind of tools does EC2 provide?
&lt;/h2&gt;

&lt;p&gt;With EC2, you get access to a handful of tools and types of instances, each to suit your needs. EC2 instances differ in terms of CPU, memory, storage, and networking capacity. Some examples of EC2 instances include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;General Purpose&lt;/li&gt;
&lt;li&gt;Compute Optimised&lt;/li&gt;
&lt;li&gt;Memory Optimised&lt;/li&gt;
&lt;li&gt;Storage Optimised&lt;/li&gt;
&lt;li&gt;GPU Instances&lt;/li&gt;
&lt;li&gt;Bare Metal Instances&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For instance, if you need a general-purpose instance, you can choose the General Purpose type. If you need an instance that is optimised for compute-intensive workloads, you can choose the Compute Optimised type. If you need an instance with high memory capacity, you can choose the Memory Optimised type. If you need an instance that is optimised for storage-intensive workloads, you can choose the Storage Optimised type. If you need an instance that is optimised for graphics-intensive workloads, you can choose the GPU Instances type. And if you need direct access to the underlying hardware, you can choose the Bare Metal Instances type.&lt;/p&gt;

&lt;h2&gt;
  
  
  🏎️ On-Demand EC2
&lt;/h2&gt;

&lt;p&gt;AWS EC2 on-demand instances are charged by hour, immediately available and are ideal for short-term workloads or when you need to scale up quickly. They are used for a variety of workloads, including development and testing, web apps and small to medium-size databases. One other advantage with On-Demand instances is that you don't need to make any upfront commitments or reservations, and you can easily scale up or down your compute capacity as your needs change.&lt;/p&gt;

&lt;h2&gt;
  
  
  🙆‍♀️ Amazon EC2 Auto-Scaling
&lt;/h2&gt;

&lt;p&gt;Auto Scaling is a key feature of Amazon Elastic Compute Cloud (EC2) that allows you to automatically adjust your computing resources based on the needs of your applications. &lt;/p&gt;

&lt;p&gt;With Auto Scaling, you can increase or decrease the number of EC2 instances in your group based on several factors such as CPU utilisation, network traffic, or custom metrics.&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%2Fm08ckaw4jfm04afpbafj.gif" 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%2Fm08ckaw4jfm04afpbafj.gif" alt="giraffe growing out of a flower pot" width="500" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Auto Scaling helps you maintain the availability of your applications and services by automatically replacing failed instances and distributing incoming traffic across healthy instances. It also helps you optimize the cost of your infrastructure by automatically scaling down your resources when they are not needed.&lt;/p&gt;

&lt;p&gt;You can configure Auto Scaling to launch new instances based on predefined rules or in response to events such as traffic spikes or application failures. You can also integrate Auto Scaling with other AWS services such as Elastic Load Balancing (ELB) and Amazon CloudWatch to create a highly available and scalable architecture. &lt;/p&gt;

&lt;p&gt;With all of the above aspects of EC2 instance auto-scaling, you play on the safe side when it comes to saving costs and keeping your users happy 😃&lt;/p&gt;

&lt;h2&gt;
  
  
  🧾 PAYG - Pay-as-you-go
&lt;/h2&gt;

&lt;p&gt;What does it mean to be a "pay-as-you-go" service? Well, elastic compute clouds typically operate on a pay-as-you-go pricing model. &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%2Fzsvdqnv0jsvuubis2aht.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%2Fzsvdqnv0jsvuubis2aht.png" alt="aws ec2 pay-as-you-go model" width="475" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With EC2, you only pay for the compute resources you consume and the duration for which you use them. This flexibility eliminates the need for upfront hardware investments and allows you to align costs with actual usage. By scaling resources up or down as needed, you can optimise spending and maintain cost-effectiveness. This is one of the great benefits of this payment model.&lt;/p&gt;

&lt;h3&gt;
  
  
  Thank you for reading!👋
&lt;/h3&gt;

&lt;p&gt;After having gone through all of these bits and bytes of AWS EC2 instances, you should now be able to get started in learning more about it by setting up one and exploring the services and tools it provides. Congratulations 🙌 and I hope it was helpful for you!🙂&lt;/p&gt;

&lt;p&gt;I'd like to thank you for reading my article and invite you to follow me on Dev.to, as well as my other platforms:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GitHub: https://github.com/bcostaaa01
Twitter: https://twitter.com/bruno2001costa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;I look forward to seeing you on my next one!&lt;/p&gt;

&lt;p&gt;Until then,&lt;br&gt;
Happy Coding!👩‍💻&lt;/p&gt;

</description>
      <category>amazon</category>
      <category>aws</category>
      <category>cloud</category>
      <category>productivity</category>
    </item>
    <item>
      <title>AWS Cloud services: a friendly introduction</title>
      <dc:creator>Bruno</dc:creator>
      <pubDate>Mon, 26 Jun 2023 10:58:28 +0000</pubDate>
      <link>https://dev.to/bcostaaa01/aws-cloud-services-a-friendly-introduction-41i6</link>
      <guid>https://dev.to/bcostaaa01/aws-cloud-services-a-friendly-introduction-41i6</guid>
      <description>&lt;p&gt;In today's digital landscape, cloud computing plays a big role in handling codebases, databases and digital assets for businesses and individuals. One of the leading players in the cloud computing game is Amazon Web Services (AWS for short). By making use of the many services AWS offers, businesses get access to a wide range of tools to scale and maintain their digital environments in the cloud ☁️&lt;/p&gt;

&lt;h2&gt;
  
  
  🤔 What is Amazon Web Services (AWS)?
&lt;/h2&gt;

&lt;p&gt;But, what is AWS exactly, you might ask. Well, AWS is a cloud computing product developed and maintained by Amazon with the aim to provide a wide range of secure and useful services to businesses so they can keep their web environments up and running, and easily maintainable and scalable. AWS offers all kinds of infrastructure services such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;computing power&lt;/li&gt;
&lt;li&gt;storage&lt;/li&gt;
&lt;li&gt;databases&lt;/li&gt;
&lt;li&gt;Machine Learning&lt;/li&gt;
&lt;li&gt;Artificial Intelligence&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The list of services you get access to in AWS is actually pretty long, so you bet you have a lot to choose from to be creative.&lt;/p&gt;

&lt;h2&gt;
  
  
  🔑 What are the key features of AWS?
&lt;/h2&gt;

&lt;p&gt;You might now ask what are the key features of AWS. Here are some of the most relevant ones:&lt;/p&gt;

&lt;p&gt;1: Scalability - it is no lie that AWS provides a good ability to scale resources (up or down based on demand). Two of the most interesting features to mention are the &lt;strong&gt;EC2 (Elastic Compute Cloud) instances&lt;/strong&gt; and the &lt;strong&gt;auto-scaling (based on traffic or other metrics)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;2: Reliability - but, what does it mean to be, "reliable"? Well, I am sure no user likes when the website or content they want to access is not available or when the servers go down, right? AWS has got you covered here too. It provides multiple &lt;strong&gt;availability zones&lt;/strong&gt; and data centers in several locations across the globe. This ensures that the content is accessible with the lowest latency, is less vulnerable to downtimes and failures, and therefore, more &lt;em&gt;reliable&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;3: Security - no user and business want an insecure web environment or unauthorised access to data, right? Imagine you were running a hospital database. Would you want the patient data to be accessed by some bad intentioned individual to spread on the internet? I suppose not. AWS has as one of their highest priorities the security of the instances and their whole cloud environment. It provides services and tools to configure security and encryption such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Server-Side Encryption (SSE)&lt;/li&gt;
&lt;li&gt;Client-Side Encryption&lt;/li&gt;
&lt;li&gt;AWS Certificate Manager&lt;/li&gt;
&lt;li&gt;AWS CloudHSM&lt;/li&gt;
&lt;li&gt;Identity and Access Management (IAM)&lt;/li&gt;
&lt;li&gt;security groups&lt;/li&gt;
&lt;li&gt;Network ACLs (Access Lists)
...&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;4: Flexibility - one other interesting and motivating aspect of AWS is the ability to scale and innovate with the various services it provides and the scalability we mentioned earlier. However, there is much more juice in the glass 🧃:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;supports various programming languages and provides different SDKs for your specific code needs&lt;/li&gt;
&lt;li&gt;provides virtual servers, instances, storage solutions, big data analytics, ...&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🏂 Key benefits of AWS
&lt;/h2&gt;

&lt;p&gt;As you could see with the above mentioned, AWS provides a really nice and easy to scale policy. Hereby mentioned are some of its main benefits:&lt;/p&gt;

&lt;p&gt;1: Cost-effectiveness - AWS provides several pricing tiers and models, but it also gives you the ability to save costs by defining how your instance will behave when demand grows or decreases, and you also don't have the need to pay rents for a physical data center and hardware as all you need is in the &lt;strong&gt;cloud&lt;/strong&gt; ☁️ and at the tip of your fingers.&lt;/p&gt;

&lt;p&gt;2: Global reach - one of the key benefits of deploying on AWS is the ability to provide content and services in a more reliable manner, with the least latency possible, regardless of their location. This is achieved with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;availability zones&lt;/li&gt;
&lt;li&gt;edge locations&lt;/li&gt;
&lt;li&gt;Amazon S3&lt;/li&gt;
&lt;li&gt;Amazon DynamoDB&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3: Innovation and Agility - innovating and scaling in AWS is one of the "tastiest" bits about this "juice" 🧃 You get the flexibility of working with various programming languages, frameworks, development environments, AI and ML tools, and so on. You can even process huge chunks of data and AWS will still not complain - as long as you use the right resources, of course 🤪&lt;/p&gt;

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

&lt;p&gt;These are some of the most important aspects for an introduction to AWS that I could think of, but bear with me as this is the beginning of this series about the AWS cloud services, because trust me, it is a very big topic and no single article can cover even the basics of the basics 😉&lt;/p&gt;

&lt;p&gt;In general, I think the AWS gives us access to do more with our creativity and needs as developers and business owners. There are a lot of services to choose from, which means you are not limited to a short range of tools. It is easily scalable and you can be creative with the different tools and options to configure them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Thank you for reading!👋
&lt;/h3&gt;

&lt;p&gt;After having gone through all of these bits and bytes of cloud computing in AWS, you should now be able to get started in learning more about it by setting up an account and exploring their platform. Congratulations 🙌 and I hope it was helpful for you!🙂&lt;/p&gt;

&lt;p&gt;I'd like to thank you for reading my article and invite you to follow me on Dev.to, as well as my other platforms:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GitHub: https://github.com/bcostaaa01
Twitter: https://twitter.com/bruno2001costa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;I look forward to seeing you on my next one!&lt;/p&gt;

&lt;p&gt;Until then,&lt;br&gt;
Happy Coding!👩‍💻&lt;/p&gt;

</description>
      <category>cloud</category>
      <category>aws</category>
      <category>cloudcomputing</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Asynchronous programming in Python</title>
      <dc:creator>Bruno</dc:creator>
      <pubDate>Wed, 22 Mar 2023 10:35:25 +0000</pubDate>
      <link>https://dev.to/bcostaaa01/asynchronous-programming-in-python-ko7</link>
      <guid>https://dev.to/bcostaaa01/asynchronous-programming-in-python-ko7</guid>
      <description>&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%2Fvaht07t5pe0w9nq6jx8x.gif" 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%2Fvaht07t5pe0w9nq6jx8x.gif" alt="pyramid turning" width="474" height="471"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have you ever wanted to learn how to write asynchronous code, but found it difficult to understand how it all works and how to apply it in Python? Well, let me tell you it is not as difficult as it seems. Just bear with me as we go through the different sides of the pyramid.&lt;/p&gt;

&lt;h3&gt;
  
  
  🤔 What is asynchronous programming? And how does it differ from synchronous programming?
&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%2Fyfsjxkb7oibyp0iwql8h.gif" 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%2Fyfsjxkb7oibyp0iwql8h.gif" alt="will ferrel asking " width="480" height="204"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When we write code, it is typically executed one line at a time, in the sequence in which it was written. This is referred to as &lt;em&gt;synchronous programming&lt;/em&gt;. However, there are occasions when we must execute lengthy activities, such as reading data from a file, fetching information from a remote server or API endpoint, or waiting for user input.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Asynchronous programming&lt;/em&gt;, on the other hand, allows us to perform these long-running tasks without blocking the rest of our code from executing. Instead of waiting for a task to complete before moving on, we can start the task and then move on to the next line of code. When the task is finished, we can come back to it and continue where we left off.&lt;/p&gt;

&lt;h3&gt;
  
  
  🐍 Asynchronour programing in Python
&lt;/h3&gt;

&lt;p&gt;In Python, we can write asynchronous programming using external libraries such as &lt;code&gt;asyncio&lt;/code&gt;, which I will be using throughout this article. &lt;/p&gt;

&lt;p&gt;In order to use &lt;code&gt;asyncio&lt;/code&gt;, you need to install (if you are using a version pre-3.7) and import it to your Python project:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Installing &lt;code&gt;asyncio&lt;/code&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;asyncio
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Importing &lt;code&gt;asyncio&lt;/code&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you should be able to use &lt;code&gt;asyncio&lt;/code&gt; and all its available functions/methods in your project 🎉&lt;/p&gt;

&lt;h3&gt;
  
  
  ⚙️ Coroutines
&lt;/h3&gt;

&lt;p&gt;A &lt;code&gt;coroutine&lt;/code&gt; is a function that can be paused and resumed during execution. &lt;/p&gt;

&lt;p&gt;You define a &lt;code&gt;coroutine&lt;/code&gt; using the &lt;code&gt;async&lt;/code&gt; keyword.&lt;/p&gt;

&lt;p&gt;Take the following example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;my_coroutine&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Coroutine started&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Coroutine resumed&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above, the coroutine function runs in the following order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;runs &lt;code&gt;print("Coroutine started")&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;waits (with &lt;code&gt;await&lt;/code&gt;) for 1 second until it can resume&lt;/li&gt;
&lt;li&gt;runs &lt;code&gt;print("Coroutine resumed)&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  🔂 Creating an event loop
&lt;/h3&gt;

&lt;p&gt;In order to run coroutines &lt;em&gt;concurrently&lt;/em&gt;, you need to use an &lt;strong&gt;event loop&lt;/strong&gt;. It can manage multiple coroutines at the same time and you can use the &lt;code&gt;asyncio.get_event_loop()&lt;/code&gt; method from the &lt;code&gt;asyncio&lt;/code&gt; library for that purpose:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;coroutine_one&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Coroutine started&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Coroutine resumed&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;coroutine_two&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Coroutine two started&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Coroutine two resumed&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;loop&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_event_loop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run_until_complete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;coroutine_one&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="nf"&gt;coroutine_two&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code above runs in the following order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;coroutine_one&lt;/code&gt; is executed&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;print("Coroutine started")&lt;/code&gt; prints a message stating the &lt;code&gt;coroutine&lt;/code&gt; has started&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;await asyncio.sleep(1)&lt;/code&gt; waits for 1 second until it resumes the execution of &lt;code&gt;coroutine_one&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;print("Coroutine resumed")&lt;/code&gt; prints a message stating the &lt;code&gt;coroutine&lt;/code&gt; has resumed&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;coroutine_two&lt;/code&gt; is executed&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;print("Coroutine started")&lt;/code&gt; prints a message stating the &lt;code&gt;coroutine&lt;/code&gt; has started&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;await asyncio.sleep(2)&lt;/code&gt; waits for 2 seconds until it resumes the execution of &lt;code&gt;coroutine_two&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;print("Coroutine resumed")&lt;/code&gt; prints a message stating the &lt;code&gt;coroutine&lt;/code&gt; has resumed&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;main()&lt;/code&gt; function is define and is used to run both coroutines &lt;em&gt;concurrently&lt;/em&gt; - simultaneously&lt;/li&gt;
&lt;li&gt;an &lt;code&gt;event loop&lt;/code&gt; is created using &lt;code&gt;loop = asyncio.get_event_loop()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;loop&lt;/code&gt; is executed on &lt;code&gt;loop.run_until_complete(coroutine_one(), coroutine_two())&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;coroutine_one()&lt;/code&gt; is executed and runs &lt;code&gt;print("Coroutine started")&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;coroutine_two()&lt;/code&gt; is executed and runs &lt;code&gt;print("Coroutine started")&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;coroutine_one()&lt;/code&gt; waits for 1 second until it can resume&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;coroutine_two()&lt;/code&gt; waits for 2 seconds until it can resume&lt;/li&gt;
&lt;li&gt;after both coroutines wait for 1 and 2 seconds to resume, &lt;code&gt;loop&lt;/code&gt; finishes executing and returns the results of the loop&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  🛰 Using async/await with external libraries
&lt;/h3&gt;

&lt;p&gt;Imagine you want to work with HTTP requests asynchronously, you can make use of the &lt;code&gt;async&lt;/code&gt; and &lt;code&gt;await&lt;/code&gt; keywords to make those requests in an asynchronous programming manner. Take the example of the &lt;code&gt;aiohttp&lt;/code&gt; library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;aiohttp&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_data&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
   &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;aiohttp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ClientSession&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
         &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
         &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
   &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;get_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;catsjsonapi.com/cat1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;loop&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_event_loop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run_until_complete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we are importing the &lt;code&gt;asyncio&lt;/code&gt; and &lt;code&gt;aiohttp&lt;/code&gt; libraries to make HTTP requests asynchronously. As an overview if the code above, the &lt;code&gt;main()&lt;/code&gt; coroutine is executed using &lt;code&gt;loop&lt;/code&gt; (the event loop), which executes the &lt;code&gt;get_data()&lt;/code&gt; coroutine and then prints the data from the &lt;code&gt;"catsjsonapi.com/cat1"&lt;/code&gt; API endpoint as JSON.&lt;/p&gt;

&lt;h3&gt;
  
  
  💭 Final thoughts
&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%2Fedxroj474lu0i06t0vzy.gif" 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%2Fedxroj474lu0i06t0vzy.gif" alt="boy asking " width="200" height="113"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Working with asynchronous programming in Python can be very useful in various environments/projects, and doing so is quite easy, as we saw throughout this article. All you need to do is import &lt;code&gt;asyncio&lt;/code&gt; and make use of its functions, combine with external libraries, and so on. &lt;/p&gt;

&lt;p&gt;However, there are other libraries which allow you to write asynchronous code in Python, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Trio: &lt;a href="https://trio.readthedocs.io/en/stable/" rel="noopener noreferrer"&gt;https://trio.readthedocs.io/en/stable/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Trio-asyncio: &lt;a href="https://trio-asyncio.readthedocs.io/en/latest/" rel="noopener noreferrer"&gt;https://trio-asyncio.readthedocs.io/en/latest/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Thank you for reading!👋
&lt;/h3&gt;

&lt;p&gt;After having gone through all of these bits and bytes of async programming in Python, you should now be able to apply it in your code. Congratulations 🙌 and I hope it was helpful for you!🙂&lt;/p&gt;

&lt;p&gt;I'd like to thank you for reading my article and invite you to follow me on Dev.to, as well as my other platforms:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GitHub: https://github.com/bcostaaa01
Twitter: https://twitter.com/bruno2001costa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;I look forward to seeing you on my next one!&lt;/p&gt;

&lt;p&gt;Until then,&lt;br&gt;
Happy Coding!👩‍💻&lt;/p&gt;

</description>
      <category>python</category>
      <category>tutorial</category>
      <category>api</category>
      <category>programming</category>
    </item>
    <item>
      <title>🌙 Lua: an introduction</title>
      <dc:creator>Bruno</dc:creator>
      <pubDate>Thu, 09 Feb 2023 11:15:01 +0000</pubDate>
      <link>https://dev.to/bcostaaa01/lua-an-introduction-4h23</link>
      <guid>https://dev.to/bcostaaa01/lua-an-introduction-4h23</guid>
      <description>&lt;p&gt;You have probably programmed with other languages like JavaScript or Java, or C++, but found yourself with the question &lt;em&gt;what is "Lua"?&lt;/em&gt;, or you would simply like to learn about it or learn a new language, am I right?&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%2Fcaa30760dldukpyheleo.gif" 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%2Fcaa30760dldukpyheleo.gif" alt="2d game" width="371" height="348"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From video games to web applications, Lua has proven to be the perfect potion for creating dynamic and interactive content. So, grab your virtual wand and join me as we explore the wonders of Lua and discover why it's one of the most interesting languages in the programming realm!✨&lt;/p&gt;

&lt;h2&gt;
  
  
  🤔 What exactly is &lt;em&gt;Lua&lt;/em&gt;?
&lt;/h2&gt;

&lt;p&gt;Before we begin with the more technical explanation, there is a funny particularity about the name, because "lua" in Portuguese means "moon". 😄 &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%2Fs7j8foiowei7xd1cmpqy.gif" 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%2Fs7j8foiowei7xd1cmpqy.gif" alt="moon and clouds" width="500" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, the technical side: Lua is a lightweight, high-level, multi-paradigm programming language designed primarily for embedded systems and clients. It is dynamically typed, interpreted, and garbage-collected, making it easy to learn and use. It supports procedural, object-oriented, and functional programming styles, and provides a simple syntax that can be used to build complex systems. It also has a small footprint, making it well suited for use in embedded systems, where memory and CPU resources are limited. Additionally, Lua has a strong ecosystem of libraries and tools, making it a popular choice for game development, scripting, and other applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  💾 How do you install Lua?
&lt;/h2&gt;

&lt;p&gt;Installing Lua depends on your machine, first of all, but I have divided the installation guide into Windows, MacOS and Linux so you only have to scroll to yours and start.&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Download the latest version of the Lua binary distribution from the official website (&lt;a href="http://www.lua.org" rel="noopener noreferrer"&gt;www.lua.org&lt;/a&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Extract the contents of the downloaded archive to a directory of your choice.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add the path to the Lua bin directory to your system's PATH environment variable.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;set &lt;/span&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;%PATH%&lt;span class="p"&gt;;&lt;/span&gt;&amp;lt;directory where Lua was extracted&amp;gt;&lt;span class="se"&gt;\b&lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Open a command prompt or terminal and run the command "lua" to verify the installation.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  MacOS:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Download the latest version of the Lua binary distribution from the official website (&lt;a href="http://www.lua.org" rel="noopener noreferrer"&gt;www.lua.org&lt;/a&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Extract the contents of the downloaded archive to a directory of your choice.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open Terminal and run the following commands:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; &amp;lt;directory where Lua was extracted&amp;gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;make &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Verify the installation by running the command "lua" in the terminal.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Linux:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Download the latest version of the Lua source code from the official website (&lt;a href="http://www.lua.org" rel="noopener noreferrer"&gt;www.lua.org&lt;/a&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Extract the contents of the downloaded archive to a directory of your choice.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open Terminal and run the following commands:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; &amp;lt;directory where Lua was extracted&amp;gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;make linux
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;make &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Verify the installation by running the command "lua" in the terminal.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;There is another possible alternative here, by installing Lua using the package manager for your specific distribution (e.g. apt-get on Ubuntu). For example:&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="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install &lt;/span&gt;lua5.4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In all cases, I recommend you check out the official documentation before jumping straight to installing: &lt;a href="https://www.lua.org/manual/5.4/readme.html" rel="noopener noreferrer"&gt;https://www.lua.org/manual/5.4/readme.html&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  👷‍♀️ Creating your first Lua script
&lt;/h1&gt;

&lt;p&gt;Let's take the most basic of examples: writing a function. In Lua, you can define a function using the "function" keyword followed by the function name, its parameters (enclosed in parentheses), and its body (enclosed in curly braces). Sounds familiar, doesn't it? 😉&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight lua"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;greeting&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;greeting&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;", "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Hey"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Bruno"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;pring&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;-- Hey, Bruno&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But, there's something new here: functions in Lua are &lt;em&gt;first-class citizens&lt;/em&gt;, meaning they can be assigned to variables (as you can see with &lt;code&gt;message = greet("Hey", "Bruno")&lt;/code&gt;), passed as arguments to other functions, and even returned as values from other functions. Here is an example use case: suppose you want to sort an array of numbers in ascending order. You can write a comparison &lt;code&gt;function&lt;/code&gt; that returns &lt;code&gt;true&lt;/code&gt; if the first argument is less than the second argument, and &lt;code&gt;false&lt;/code&gt; otherwise. This comparison function can then be passed as an argument to the &lt;code&gt;table.sort&lt;/code&gt; function, which sorts the array based on the results of the comparison function. Take a look at the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight lua"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Define the comparison function&lt;/span&gt;
&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;compare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="c1"&gt;-- Define an array of numbers&lt;/span&gt;
&lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;-- Sort the array using the compare function&lt;/span&gt;
&lt;span class="nb"&gt;table.sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;compare&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;-- Print the sorted array&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;ipairs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="c1"&gt;-- Output:&lt;/span&gt;
&lt;span class="c1"&gt;-- 1&lt;/span&gt;
&lt;span class="c1"&gt;-- 1&lt;/span&gt;
&lt;span class="c1"&gt;-- 2&lt;/span&gt;
&lt;span class="c1"&gt;-- 3&lt;/span&gt;
&lt;span class="c1"&gt;-- 3&lt;/span&gt;
&lt;span class="c1"&gt;-- 4&lt;/span&gt;
&lt;span class="c1"&gt;-- 5&lt;/span&gt;
&lt;span class="c1"&gt;-- 5&lt;/span&gt;
&lt;span class="c1"&gt;-- 5&lt;/span&gt;
&lt;span class="c1"&gt;-- 6&lt;/span&gt;
&lt;span class="c1"&gt;-- 9&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, the comparison function &lt;code&gt;compare()&lt;/code&gt; is a &lt;em&gt;first-class citizen&lt;/em&gt;, meaning it can be assigned to a &lt;code&gt;variable&lt;/code&gt;, passed as an &lt;code&gt;argument&lt;/code&gt; to another function &lt;code&gt;(table.sort)&lt;/code&gt;, and even returned as a value from another function. This allows for a high degree of flexibility and reusability in the code, and makes it easy to write generic functions that can work with any comparison function. Cool, right? 😉&lt;/p&gt;

&lt;h2&gt;
  
  
  ✨ Thank you for reading!
&lt;/h2&gt;

&lt;p&gt;Lua is a very powerful language and more articles will follow this one, so bear with me as we explore the realm of this language ✨🌙&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%2Flooksrare.mo.cloudinary.net%2F0x02c4394307de62241aa8d5a0915494a96B288261%2F0x3058645742ef9614ed89ff5320b2cc0a3ba08b4d84001803f731a693eefa31f6%3Fresource_type%3Dimage%26f%3Dauto%26c%3Dlimit%26w%3Diw%26q%3Dauto" 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%2Flooksrare.mo.cloudinary.net%2F0x02c4394307de62241aa8d5a0915494a96B288261%2F0x3058645742ef9614ed89ff5320b2cc0a3ba08b4d84001803f731a693eefa31f6%3Fresource_type%3Dimage%26f%3Dauto%26c%3Dlimit%26w%3Diw%26q%3Dauto" alt="moon gif" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'd like to thank you for reading my article and invite you to follow me on Dev.to, as well as my other platforms:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GitHub: https://github.com/bcostaaa01
Twitter: https://twitter.com/bruno2001costa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I look forward to seeing you on my next one!&lt;/p&gt;

&lt;p&gt;Until then,&lt;br&gt;
Happy Coding!👩‍💻&lt;/p&gt;

</description>
      <category>announcement</category>
      <category>devto</category>
      <category>crypto</category>
      <category>blockchain</category>
    </item>
    <item>
      <title>Garden.io: what is it and why should you be using it? 🪴</title>
      <dc:creator>Bruno</dc:creator>
      <pubDate>Tue, 31 Jan 2023 21:47:15 +0000</pubDate>
      <link>https://dev.to/bcostaaa01/gardenio-what-is-it-and-why-should-you-be-using-it-4m7g</link>
      <guid>https://dev.to/bcostaaa01/gardenio-what-is-it-and-why-should-you-be-using-it-4m7g</guid>
      <description>&lt;p&gt;Ready to streamline your development and operations processes? In this comprehensive guide, we'll dive deep into all that Garden.io has to offer, from its powerful features to its  user-friendliness. You won't want to pass up the efficiency and productivity boost that Garden.io can bring to your applications, regardless of their scopes of complexity. &lt;/p&gt;

&lt;h3&gt;
  
  
  🪴 What is Garden.io?
&lt;/h3&gt;

&lt;p&gt;Garden.io is a cloud native application development, testing, and deployment platform. It defines the build and deployment procedure for your application in a configuration file named 'garden.yml'. It is compatible with a variety of programming languages, including JavaScript, and may be used in projects developed using React, VueJS, NodeJS, and other frontend and backend technologies.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1585631425734144000-144" src="https://platform.twitter.com/embed/Tweet.html?id=1585631425734144000"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1585631425734144000-144');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1585631425734144000&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;Garden.io was developed in response to the demand for a standardized and adaptable method of managing and deploying applications, particularly in large and complex environments. It was created to support a broad variety of languages and frameworks, be simple to use, connect with well-known tools like Docker and Kubernetes, and be flexible.&lt;/p&gt;

&lt;p&gt;The platform has grown in popularity among developers since its inception.&lt;br&gt;
With constant additions of new features and integrations to fulfill the demands of companies and developers, it continues to expand and get better. &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%2F7vhsxku2s097uyz6d8t2.gif" 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%2F7vhsxku2s097uyz6d8t2.gif" alt="brent rambo thumbs up meme" width="400" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sounds cool, right? 😉&lt;/p&gt;
&lt;h3&gt;
  
  
  🤔 Why should you be using it?
&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%2Fuploads-ssl.webflow.com%2F62b28d5404e4318fe1ed6cca%2F632147d9a9338e6bbd4ed10b_img-diagram-3-p-1080.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%2Fuploads-ssl.webflow.com%2F62b28d5404e4318fe1ed6cca%2F632147d9a9338e6bbd4ed10b_img-diagram-3-p-1080.png" width="800" height="583"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I will give you some reasons why you should be using Garden.io in your projects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Garden.io makes complex app management easier by allowing you to describe all of your app's dependencies, build processes, and deployment configurations in a single configuration file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;CI/CD processes are streamlined by providing you with a configuration file that defines your pipeline's build, test, and deploy methods, automating the whole process of building, testing, and deploying your code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Garden.io lets you design a consistent workflow for your projects, including the tools and processes for developing, testing, and delivering code. This ensures that all of your projects adhere to the same set of standards and procedures.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It supports a wide range of languages and frameworks, including Node.js, Python, and Java, making it a versatile and adaptable solution for managing and deploying your applications.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's look at some of the principles that will help you better comprehend the workflow. &lt;/p&gt;
&lt;h3&gt;
  
  
  🤽‍♀️ DevOps
&lt;/h3&gt;

&lt;p&gt;DevOps is a software engineering methodology that emphasizes cooperation and communication between software developers and information technology (IT) experts while automating software delivery and infrastructure changes.&lt;br&gt;
It seeks to shorten the development lifecycle and enable continuous delivery of high-quality software. &lt;/p&gt;
&lt;h3&gt;
  
  
  🔮 CI/CD
&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%2Fcommunity.atlassian.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F137126i42CF00FCADA7DB47%2Fimage-dimensions%2F265x199%3Fv%3Dv2" 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%2Fcommunity.atlassian.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F137126i42CF00FCADA7DB47%2Fimage-dimensions%2F265x199%3Fv%3Dv2" alt="ci/cd hot dog" width="265" height="199"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Continuous Integration/Continuous Deployment is abbreviated as CI/CD. It is a software development approach that tries to increase software delivery speed, quality, and dependability.&lt;/p&gt;

&lt;p&gt;Continuous Integration (CI) is the technique of merging code changes into a central repository on a frequent basis, generally many times per day. This helps developers to recognize and resolve issues early in the development process, rather than waiting until later stages when they may be more difficult to resolve.&lt;/p&gt;

&lt;p&gt;Continuous Deployment (CD) extends CI by automating the process of delivering code changes to production. This implies that if a change is made and successfully integrated into the central repository, it is immediately deployed to the production environment without any manual involvement.&lt;/p&gt;
&lt;h3&gt;
  
  
  ⚙️ Installing Kubernetes, Docker and Garden.io
&lt;/h3&gt;

&lt;p&gt;To utilize Garden.io, you must first install Kubernetes and Docker on your machine. You will need these as Garden.io relies on Docker and Kubernetes to manage and deploy containerized applications.&lt;/p&gt;
&lt;h4&gt;
  
  
  📦 Kubernetes
&lt;/h4&gt;

&lt;p&gt;Install Kubernetes using NPM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g kubernetes-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install Kubernetes using Yarn:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn global add kubernetes-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install Kubernetes using Homebrew:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install kubernetes-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  🐳 Docker
&lt;/h4&gt;

&lt;p&gt;Install Docker using NPM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install Docker using Yarn:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn global add docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install Docker using Homebrew:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  🪴 Garden.io
&lt;/h4&gt;

&lt;p&gt;After the latter tools have finished installing, it's time to install Garden.io.&lt;/p&gt;

&lt;h5&gt;
  
  
  Homebrew
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew tap garden-io/garden
brew install garden-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Installation script
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -sfL https://git.io/get-garden | sh -s -- -b /usr/local/bin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The instructions above were designed for MacOS, but you can read more in the documentation if you are using Windows or Linux: &lt;a href="https://docs.garden.io/getting-started/1-installation" rel="noopener noreferrer"&gt;https://docs.garden.io/getting-started/1-installation&lt;/a&gt;.&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%2F0nwo90g7u76p38xyzqr6.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%2F0nwo90g7u76p38xyzqr6.png" alt="gardenio installation complete terminal" width="800" height="474"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After Garden.io finishes installing, you should see a beautiful terminal look like the above!🤩&lt;/p&gt;

&lt;h3&gt;
  
  
  👨‍💻 Setting up Garden.io
&lt;/h3&gt;

&lt;p&gt;In order to setup Garden.io in your project, run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;garden init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, configure the project by adding the following as example to the &lt;code&gt;garden.yml&lt;/code&gt; file, which is the file that specifies services, tasks, tests, and so on:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;web&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;.&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3000&lt;/span&gt;
        &lt;span class="na"&gt;published&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3000&lt;/span&gt;
        &lt;span class="na"&gt;protocol&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;tcp&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The configuration for Garden.io is now complete (based on the specific needs of your project, of course). &lt;/p&gt;

&lt;h3&gt;
  
  
  🚧 Building the application
&lt;/h3&gt;

&lt;p&gt;After having setup the configurations for Garden.io in your project, you can now run it by navigating to the project directory and running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;garden start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that you have setup, configured Garden.io in your project and is now running, Garden will start the project and create a container for each service that you defined in the &lt;code&gt;garden.yml&lt;/code&gt; file. If you access &lt;code&gt;http://localhost:3000&lt;/code&gt; in your browser, you should be able to access your project!🎉&lt;/p&gt;

&lt;h3&gt;
  
  
  🧪 Testing the application
&lt;/h3&gt;

&lt;p&gt;In order to setup testing in your Garden.io (because testing is also important, right?😉), you can do so by first setting up a section in your &lt;code&gt;garden.yml&lt;/code&gt; file called &lt;code&gt;tests&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;tests&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;my-tests&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;service&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;web&lt;/span&gt;
    &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npm run test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, you can define the specific testing that you need for your project. Then, when you run the following command, you should be able to see the test suites running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;garden test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This test, for example, will run &lt;code&gt;npm run test&lt;/code&gt; in the &lt;code&gt;web&lt;/code&gt; service. See? Testing in Garden.io is as easy as eating a slice of pizza!🍕&lt;/p&gt;

&lt;h3&gt;
  
  
  🚚 Deploying
&lt;/h3&gt;

&lt;p&gt;The question now is: "How do I deploy a project using Garden.io?" 🤔 Well, it's also easy!😀&lt;/p&gt;

&lt;p&gt;You can deploy it to various cloud providers and Kubernetes clusters, by creating a target environment section to your &lt;code&gt;garden.yml&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-kubernetes-cluster&lt;/span&gt;
  &lt;span class="na"&gt;provider&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;kubernetes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we specify that the target environment is a Kubernetes cluster called &lt;code&gt;my-kubernetes-cluster&lt;/code&gt;. Note that you would need to have &lt;code&gt;kubectl&lt;/code&gt; installed on your machine and have access to it in order to deploy to a Kubernetes cluster.&lt;/p&gt;

&lt;p&gt;Then, you run the following command to deploy it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;garden deploy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After completing these steps, Garden.io will start the deployment process and create the necessary resources in your cloud provider or Kubernetes cluster. You can accompany the state of deployment in your lovely terminal 🥰 &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%2F3k4amtchnc1su2oqlzxo.gif" 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%2F3k4amtchnc1su2oqlzxo.gif" alt="deploying terminal laptop" width="480" height="266"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, in order to access your deployed project, open the URL or IP address of the deployed environment, depending on the specific cloud provider or Kubernetes setup you are using. After following these steps, you can see how Garden.io is so easy to work with when setting up, testing and deploying your project 😁&lt;/p&gt;

&lt;h3&gt;
  
  
  🌻 The official documentation
&lt;/h3&gt;

&lt;p&gt;🪴 Garden.io's official documentation may be found here: &lt;a href="https://docs.garden.io/" rel="noopener noreferrer"&gt;https://docs.garden.io/&lt;/a&gt; -&lt;br&gt;
It covers all of the information you'll need in greater detail. &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%2F66.media.tumblr.com%2F035913a2deced9382e7eeb5199f21066%2Ftumblr_otf7v2Wfgv1uvsi7jo1_500.gifv" 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%2F66.media.tumblr.com%2F035913a2deced9382e7eeb5199f21066%2Ftumblr_otf7v2Wfgv1uvsi7jo1_500.gifv" alt="roses aesthetic" width="500" height="281"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And what a beatiful documentation they have written!👏&lt;/p&gt;

&lt;h3&gt;
  
  
  Thank you for reading!👋
&lt;/h3&gt;

&lt;p&gt;I'd like to thank you for reading my article! I hope it helped you getting to know a great tool and that it can be useful in your future projects 😁 I would also like to invite you to follow me on Dev.to, as well as my other platforms:&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/bcostaaa01" rel="noopener noreferrer"&gt;https://github.com/bcostaaa01&lt;/a&gt;&lt;br&gt;
Twitter: &lt;a href="https://twitter.com/bruno2001costa" rel="noopener noreferrer"&gt;https://twitter.com/bruno2001costa&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I look forward to seeing you on my next one!&lt;/p&gt;

&lt;p&gt;Until then,&lt;br&gt;
Happy Coding!👩‍💻&lt;/p&gt;

</description>
      <category>productivity</category>
    </item>
    <item>
      <title>Getting started with Pinia for VueJS and NuxtJS🍍</title>
      <dc:creator>Bruno</dc:creator>
      <pubDate>Mon, 23 Jan 2023 15:32:12 +0000</pubDate>
      <link>https://dev.to/bcostaaa01/getting-started-with-pinia-for-vuejs-and-nuxtjs-1m2p</link>
      <guid>https://dev.to/bcostaaa01/getting-started-with-pinia-for-vuejs-and-nuxtjs-1m2p</guid>
      <description>&lt;p&gt;Say goodbye to cluttered and confusing state management in your VueJS and NuxtJS projects with Pinia! This tropical paradise of a plugin is not just your average state management tool, it's a full-featured framework that'll have you sipping on pina coladas while you build dynamic and responsive user interfaces. &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%2Fthumbs.gfycat.com%2FLegalImaginaryIaerismetalmark-size_restricted.gif" 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%2Fthumbs.gfycat.com%2FLegalImaginaryIaerismetalmark-size_restricted.gif" alt="pixel pineapples" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With its powerful store manager, customizable layout system, and a plethora of tasty directives and components, Pinia is the ultimate way to add some island vibes to your development process. So put on your Hawaiian shirt and let's get ready to party with Pinia!&lt;/p&gt;

&lt;h3&gt;
  
  
  🍍 What exactly is Pinia?
&lt;/h3&gt;

&lt;p&gt;Pinia is a versatile and lightweight plugin for VueJS and NuxtJS that makes building dynamic and responsive user interfaces a breeze. It's packed with all the features you need to create amazing projects and it is designed to make state management easy and organized. &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%2Femffwbu78qb6941ahq3f.gif" 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%2Femffwbu78qb6941ahq3f.gif" alt="organised book shelf" width="1280" height="1280"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With Pinia, you can manage your application's state in a centralized way, customize the layout of your application, and use a variety of directives and components to make your development process more efficient. &lt;/p&gt;

&lt;h3&gt;
  
  
  🤔 How does it differ from Vuex?
&lt;/h3&gt;

&lt;p&gt;You may now ask yourserlf: "But how does it differ from Vuex?". Good question indeed! &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%2Fxc056m1sm4rzntuh6f84.gif" 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%2Fxc056m1sm4rzntuh6f84.gif" alt="what's the difference?" width="550" height="228"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pinia and Vuex are both state management libraries for VueJS, but they have some key differences.&lt;/p&gt;

&lt;h4&gt;
  
  
  Vuex
&lt;/h4&gt;

&lt;p&gt;Vuex is a centralized state management library that follows the Flux architecture pattern. It uses a strict unidirectional data flow and provides a centralized store for the whole application. This makes it simple to understand, but it can become complex when the application grows.&lt;/p&gt;

&lt;h4&gt;
  
  
  Pinia
&lt;/h4&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%2Fxy1r8m178yot6iucjoke.gif" 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%2Fxy1r8m178yot6iucjoke.gif" alt="cat pineapple" width="512" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the other hand, Pinia is a state management library that is built on top of Vuex. It aims to provide a more flexible approach to state management by allowing developers to split the store into smaller, more manageable modules. This can make it easier to understand and maintain, especially for larger applications. Additionally, Pinia also provides a layout system and a set of directives and components that can help you to build their application in an easy and efficient way. It's a sort of "Jack of all trades", like the cat above who is not only a cat, but also a pineapple 🙃&lt;/p&gt;

&lt;h3&gt;
  
  
  ✅ Why can it be a better choice?
&lt;/h3&gt;

&lt;p&gt;Now that you have an idea of the differences, you may ask why use one over the other, right? Well, I will share some reasons why Pinia might make a good choice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pinia allows you to split the store into smaller, more manageable modules, which can make it easier to understand and maintain, especially for larger applications.&lt;/li&gt;
&lt;li&gt;Pinia provides a simpler and more intuitive API that makes it easy to get started with state management in your VueJS and NuxtJS projects.&lt;/li&gt;
&lt;li&gt;Pinia also provides a layout system and a set of directives and components that can help developers to build their application in an easy and efficient way.&lt;/li&gt;
&lt;li&gt;Pinia allows to organize the state in a more natural way, making it easier to understand and to debug the application.&lt;/li&gt;
&lt;li&gt;Pinia provides a dynamic layout system that can be used to switch layouts on the fly and also to customize the layout of the application&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At the end of the day though, the choice over one or the other comes down to your specific needs for the project you are working on in particular. One could argue for hours what the best choice would be and like a colleague once told me: "it depends" 😉&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%2Fthumbs.gfycat.com%2FGlaringImpartialGrosbeak-max-1mb.gif" 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%2Fthumbs.gfycat.com%2FGlaringImpartialGrosbeak-max-1mb.gif" alt="friends pineapple talk" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  💾 How to install Pinia
&lt;/h3&gt;

&lt;p&gt;Too much talking, right? 😅 Let's now dive into what really matters - installing and using it. 😎&lt;/p&gt;

&lt;h4&gt;
  
  
  NPM
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @pina/core
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Yarn
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add @pina/core
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that you have installed it, let's import it to your project.&lt;/p&gt;

&lt;h4&gt;
  
  
  VueJS
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Pinia&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@pina/core&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="nx"&gt;Vue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Pinia&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  NuxtJS
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Pinia&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@pina/core&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="na"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@pina/core/nuxt&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="na"&gt;pinia&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="c1"&gt;// modules goes here&lt;/span&gt;
    &lt;span class="p"&gt;]&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;Installing and importing is done 👏 Let's now use it in an example project!&lt;/p&gt;

&lt;h3&gt;
  
  
  🚧 Use case
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Setup a &lt;code&gt;store&lt;/code&gt; to manage the state in your app:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// store.js&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createStore&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@pina/core&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;store&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createStore&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello, World!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;mutations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;updateMessage &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;payload&lt;/span&gt;
    &lt;span class="p"&gt;}&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;ol&gt;
&lt;li&gt;Create a component and paste the following &lt;code&gt;template&lt;/code&gt; and &lt;code&gt;script&lt;/code&gt; tags:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;// PiniaExample.vue

&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{{&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="si"&gt;}}&lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="na"&gt;click=&lt;/span&gt;&lt;span class="s"&gt;"updateMessage('Hello, Pinia!')"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Update Message&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;mapState&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;mapMutations&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@pina/core&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;computed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nf"&gt;mapState&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;message&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;methods&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nf"&gt;mapMutations&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;updateMessage&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I will now break the project down to simple steps so you have an idea of what's happening under the hood:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;In the &lt;code&gt;store&lt;/code&gt;, &lt;code&gt;state&lt;/code&gt; has a &lt;code&gt;message&lt;/code&gt; property which is set to &lt;code&gt;"Hello, World!"&lt;/code&gt;. The &lt;code&gt;mutations&lt;/code&gt; are methods that allow us to modify the &lt;code&gt;state&lt;/code&gt;. In this example, there is a &lt;code&gt;mutation&lt;/code&gt; called &lt;code&gt;updateMessage&lt;/code&gt; that takes a &lt;code&gt;payload&lt;/code&gt; and updates the &lt;code&gt;message&lt;/code&gt; property in the &lt;code&gt;state&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;template&lt;/code&gt; in &lt;code&gt;PiniaExample.vue&lt;/code&gt; displays the &lt;code&gt;message&lt;/code&gt; from the &lt;code&gt;store&lt;/code&gt; and has a button that when clicked, triggers the &lt;code&gt;updateMessage&lt;/code&gt; &lt;code&gt;mutation&lt;/code&gt;. The &lt;code&gt;template&lt;/code&gt; uses the &lt;code&gt;mapState&lt;/code&gt; helper from Pinia to access the &lt;code&gt;message&lt;/code&gt; property in the &lt;code&gt;store&lt;/code&gt;. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When the button is clicked, the &lt;code&gt;updateMessage&lt;/code&gt; method is called and it triggers the &lt;code&gt;mutation&lt;/code&gt; in the &lt;code&gt;store&lt;/code&gt;, changing the &lt;code&gt;message&lt;/code&gt; property.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Following the idea of the project above, you should be able to see the similarities between Vuex, as well as the way you can apply it to your project for state management. Good job!👏&lt;/p&gt;

&lt;h2&gt;
  
  
  Thank you for reading!
&lt;/h2&gt;

&lt;p&gt;I hope that this article helped you gain an understanding of how Pinia works in it's core, and that you can take this tool to your project in the way you need and that will help you scale more easily. &lt;/p&gt;

&lt;p&gt;Make sure to follow me on my social media to stay up to date on projects I work on or contribute to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GitHub: &lt;a href="https://github.com/bcostaaa01" rel="noopener noreferrer"&gt;https://github.com/bcostaaa01&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Twitter: &lt;a href="https://twitter.com/bruno2001costa" rel="noopener noreferrer"&gt;https://twitter.com/bruno2001costa&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I look forward to seeing you on my next one!👋&lt;/p&gt;

&lt;p&gt;Until then,&lt;br&gt;
Happy Coding!👩‍💻&lt;/p&gt;

</description>
      <category>vue</category>
      <category>javascript</category>
      <category>statemanagement</category>
      <category>pinia</category>
    </item>
    <item>
      <title>Computer Science: Basic Concepts of Data Processing</title>
      <dc:creator>Bruno</dc:creator>
      <pubDate>Wed, 11 Jan 2023 16:40:39 +0000</pubDate>
      <link>https://dev.to/bcostaaa01/computer-science-basic-concepts-of-data-processing-54md</link>
      <guid>https://dev.to/bcostaaa01/computer-science-basic-concepts-of-data-processing-54md</guid>
      <description>&lt;p&gt;Imagine a world in which you could forecast the next big trend or know precisely what your consumers want before they do. That world, however, is not so far away, owing to the power of data processing!&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%2F5cfcddm0w9bc8z9zxr2h.gif" 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%2F5cfcddm0w9bc8z9zxr2h.gif" alt="working on the laptop with binary as background" width="1920" height="1080"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  “Data is a precious thing and will last longer than the systems themselves.” - Tim Berners-Lee, inventor of the World Wide Web
&lt;/h5&gt;

&lt;p&gt;But don't be fooled by the sophisticated name; it's not exclusively for techies and figure crunchers. "Data processing" is a fascinating and interesting area that aids in the transformation of mountains of confusing information into usable insights. &lt;/p&gt;

&lt;h3&gt;
  
  
  "Context is Everything"
&lt;/h3&gt;

&lt;p&gt;The statement &lt;em&gt;"context is everything"&lt;/em&gt; emphasizes the necessity of knowing the environment in which data is acquired and used.&lt;br&gt;
The context in data processing refers to the background information and situations that surround and give meaning to the data. The data may be misinterpreted or of limited use if the context is not understood. &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%2Fcvy5p3sdfwhnwfp3qsz4.gif" 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%2Fcvy5p3sdfwhnwfp3qsz4.gif" alt="jim carrey context is everything" width="220" height="182"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Consider a dataset of sales numbers from a retail business.&lt;br&gt;
The basic figures may not reveal the entire story. By considering the context, such as the time period during which the sales were made, the location of the business, and the demographics of the neighborhood, one can acquire a better understanding of the sales data and uncover patterns or trends that may not be obvious from the raw numbers alone. &lt;/p&gt;

&lt;h4&gt;
  
  
  Binary Code
&lt;/h4&gt;

&lt;p&gt;Binary code is used in data processing to store and transport data in digital systems. It is the foundation for all contemporary computers and the majority of the technologies we use in our everyday lives.&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%2Fthumbs.gfycat.com%2FLinedDarlingHoki-size_restricted.gif" 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%2Fthumbs.gfycat.com%2FLinedDarlingHoki-size_restricted.gif" alt="binary code" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The meaning of data expressed in binary code is determined by how it is interpreted and used. In one context, the same sequence of binary digits can represent a letter of the alphabet and a number in another.&lt;/p&gt;

&lt;h4&gt;
  
  
  Encoding
&lt;/h4&gt;

&lt;p&gt;Encoding is the process of converting data from one format to another, such as text to binary, and it's crucial to understand the context in which it's used since differing encoding methods might alter the quality and integrity of the data.&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%2Fnl20p4k58360ts48euxf.gif" 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%2Fnl20p4k58360ts48euxf.gif" alt="binary encoder" width="400" height="231"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In conclusion, while binary is the cornerstone of data representation in digital systems, the context in which it is utilized, how it is encoded and processed, is critical for understanding and making the greatest use of the data.&lt;/p&gt;

&lt;h4&gt;
  
  
  Digital Representation of Color
&lt;/h4&gt;

&lt;p&gt;The basic unit of a digital image in data processing is the pixel, which is commonly represented as a tiny square or rectangle of a single color. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Pixel - single square which is assigned a color and used to assemble a larger image.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The image is composed of a grid of pixels, each of which has its own color and brightness value. Each pixel's color is often represented by a mix of red, green, and blue (RGB) values, which are subsequently transformed to binary code for storage and processing in digital systems. &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%2Fece1wcevjgoaf17sz31f.gif" 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%2Fece1wcevjgoaf17sz31f.gif" alt="pixelated person taking a piece of cake" width="360" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The color values of each pixel in a picture are represented using binary code.&lt;br&gt;
Each color value is generally represented by 8 bits, allowing for a total of 256 distinct values (28). A pixel's brightness is commonly represented using 8 bits, allowing for a range of 256 distinct degrees of brightness.&lt;/p&gt;

&lt;p&gt;Images may be modified in a number of ways when it comes to data processing by adjusting the color and brightness values of individual pixels or groups of pixels. Image editing software, for example, may be used to adjust the general brightness or contrast of an image, as well as the color of a single object. &lt;/p&gt;

&lt;h3&gt;
  
  
  Data Messaging
&lt;/h3&gt;

&lt;p&gt;Data messaging is the process of sending data via a network between two or more devices. This can involve transmitting text messages, emails, or other digital data. Because binary code is a straightforward and efficient way to represent data in a digital format, it is utilized as the foundation for data communications.&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%2Fypdfa21zen7ngjcgp1l8.gif" 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%2Fypdfa21zen7ngjcgp1l8.gif" alt="two man laughing with binary code communication" width="220" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Binary code is employed at the hardware level to represent data as electrical signals that are transferred via the different components of a computer, including the motherboard, which serves as the primary hub for all of the computer's components, including the CPU, which processes data, the memory controller and storage controller, which govern data flow, and communication channels that link devices to the motherboard. The devices have their own controllers that manage the data encoding and decoding into binary signals.&lt;/p&gt;

&lt;h3&gt;
  
  
  💭 Final thoughts
&lt;/h3&gt;

&lt;p&gt;To summarize, Data Processing is an important part of Computer Science and how the data we interact with everyday is maintained and brought to anywhere it is needed. with several options. It is also a key part of the curriculum of Computer Science at the university and in the generality of our work as developers, analysts, data scientists and so on, therefore understanding how it all works will take you a step further in your career and studies. I hope this article helped you in that path!🙌&lt;/p&gt;

&lt;h3&gt;
  
  
  Thank you for reading!👋
&lt;/h3&gt;

&lt;p&gt;I'd like to thank you for reading my article and invite you to follow me on Dev.to, as well as my other platforms:&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/bcostaaa01" rel="noopener noreferrer"&gt;https://github.com/bcostaaa01&lt;/a&gt;&lt;br&gt;
Twitter: &lt;a href="https://twitter.com/bruno2001costa" rel="noopener noreferrer"&gt;https://twitter.com/bruno2001costa&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I look forward to seeing you on my next one!&lt;/p&gt;

&lt;p&gt;Until then,&lt;br&gt;
Happy Coding!👩‍💻&lt;/p&gt;

</description>
      <category>computerscience</category>
      <category>algorithms</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
