<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alex Hebert</title>
    <description>The latest articles on DEV Community by Alex Hebert (@alexphebert2000).</description>
    <link>https://dev.to/alexphebert2000</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%2F1287299%2F529fae01-016d-432d-ac0a-941971cd4b1c.jpeg</url>
      <title>DEV Community: Alex Hebert</title>
      <link>https://dev.to/alexphebert2000</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alexphebert2000"/>
    <language>en</language>
    <item>
      <title>Exploring Web Development: HTMX</title>
      <dc:creator>Alex Hebert</dc:creator>
      <pubDate>Mon, 24 Jun 2024 07:02:50 +0000</pubDate>
      <link>https://dev.to/alexphebert2000/exploring-web-development-htmx-4no1</link>
      <guid>https://dev.to/alexphebert2000/exploring-web-development-htmx-4no1</guid>
      <description>&lt;h2&gt;
  
  
  What is HTMX
&lt;/h2&gt;

&lt;p&gt;The last 2 weeks I have been exploring HTMX, a light-weight, front-end library that looks to bring the needs of a modern web app back to just HTML. While HTMX is written in JavaScript, using HTMX doesn't require you to write a line of JavaScript to create a fully fleshed, interactive front end. HTMX uses custom HTML attributes to allow any HTML element to perform AJAX requests, manipulate the DOM, trigger CSS transitions and animations, and handle WebSocket events. The key difference between a site running HTMX and a site running another front-end library React is ironically the server. HTMX relies on &lt;em&gt;HTML&lt;/em&gt; responses from the server rather than JSON or any other data. HTMX allows you to take the HTML response from the server and insert or replace the element anywhere in the DOM. This means the dynamic parts of the view need to be generated by your server rather than the client.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 4 "Whys" of HTMX
&lt;/h2&gt;

&lt;p&gt;HTMX's inception was based on 4 questions that address problems with bare HTML as basis for modern web applications. HTMX provides solutions to these 4 questions. But first lets look at the HTML &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; element. You use this element to get some HTML from a server and render it, replacing the DOM with the new HTML. An &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; tag in bare HTML would look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"/blog"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Link to Blog&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  HTTP Requests
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;Why should &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; tags be the only tags to make HTTP requests?&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;Modern web apps use AJAX requests to send and receive information from the different parts of the app. So why should &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; tags be the only elements that can perform these important actions. HTMX allows all elements to perform AJAX request using custom hx attributes. So we can take our &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; tag from earlier and turn it into a button that does the same thing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;hx-get=&lt;/span&gt;&lt;span class="s"&gt;"/blogs"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Click to go to Blog!&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Triggers
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;Why should only&lt;/em&gt; click &lt;em&gt;and&lt;/em&gt; submit &lt;em&gt;events trigger AJAX requests&lt;/em&gt;?
&lt;/h4&gt;

&lt;p&gt;Since only &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; can perform AJAX request in bare HTML, only &lt;em&gt;click&lt;/em&gt; and &lt;em&gt;submit&lt;/em&gt; events can trigger them. With HTMX events like &lt;em&gt;mouse over&lt;/em&gt;, &lt;em&gt;key presses&lt;/em&gt;, &lt;em&gt;change&lt;/em&gt; can trigger AJAX requests. HTMX also has special events that can trigger element requests like &lt;em&gt;load&lt;/em&gt;, &lt;em&gt;revealed&lt;/em&gt;, and polling with &lt;code&gt;hx-trigger&lt;/code&gt;. HTMX triggers can also include modifiers that can delay, throttle, and prevent multiple triggers. We can get the HTML from "/blogs" when hovering over a div instead of clicking a button.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt;
  &lt;span class="na"&gt;hx-get=&lt;/span&gt;&lt;span class="s"&gt;"/blog"&lt;/span&gt;
  &lt;span class="na"&gt;hx-trigger=&lt;/span&gt;&lt;span class="s"&gt;"mouseover"&lt;/span&gt;
&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  Hover to see the blog!
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Verbs
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;Why should only _GET&lt;/em&gt; and &lt;em&gt;POST&lt;/em&gt; methods be available?
&lt;/h4&gt;

&lt;p&gt;Generally in bare HTML, &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; tags perform GET requests and &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; tags perform POST requests. With HTMX you can use any element to perform any request type. &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Attribute&lt;/th&gt;
&lt;th&gt;Verb&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;hx-post&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;POST&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;hx-patch&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;PATCH&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;hx-get&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;GET&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;hx-delete&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;DELETE&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;hx-put&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;PUT&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Replacement
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;Why should you only be able to replace the entire screen?&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;When you receive HTML from a server when working with bare HTML, the response data replaces the entire DOM. HTMX allows you to insert or replace elements anywhere in the DOM. This allows server responses to to respond with a single HTML snippet rather than an entire page, HTMX can dynamically add, subtract or replace elements as needed to form the page from the snippets provided by the server. Elements can be targeted with CSS selectors and extended syntax that allow you to define the target easily. Keywords like &lt;code&gt;closest&lt;/code&gt; and &lt;code&gt;next&lt;/code&gt; allow you to avoid coming up with endless class names by targeting an element by referencing its relative position. The way to swap or insert can be defined with the &lt;code&gt;hx-swap&lt;/code&gt; attribute. With this we can render the a list of blog posts in a div dynamically, adding new posts to the top of a container div with each button press.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"blogs-container"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;&lt;span class="c"&gt;&amp;lt;!--- Blogs Go Here ---&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;button&lt;/span&gt;
  &lt;span class="na"&gt;hx-get=&lt;/span&gt;&lt;span class="s"&gt;"/blog"&lt;/span&gt;
  &lt;span class="na"&gt;hx-target=&lt;/span&gt;&lt;span class="s"&gt;".blogs-container"&lt;/span&gt;
  &lt;span class="na"&gt;hx-swap=&lt;/span&gt;&lt;span class="s"&gt;"afterbegin"&lt;/span&gt;
&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  GET BLOG!
&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Final thoughts
&lt;/h2&gt;

&lt;p&gt;I find HTMX to be a very appealing technology. It is a very light, independent library. I think relying on the back-end to handle data and front-end to simply render and ask for changes falls more in line with the spirit of REST and simplifying the front-end back to HTML and CSS is something I find quite novel in this era of web development. There is increased risk of XSS attacks if HTMX is not implemented and sanitized correctly, and it feels a bit sacrilegious to use JavaScript as the server with Node and remove the JavaScript from the front end with HTMX. Overall I am planning and excited to use HTMX in the future. If you are also interested in trying HTMX, see their &lt;a href="https://htmx.org/docs/"&gt;great docs&lt;/a&gt; to get started. Good luck and happy coding!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Exploring Web Development: Ruby on Rails</title>
      <dc:creator>Alex Hebert</dc:creator>
      <pubDate>Mon, 10 Jun 2024 04:07:21 +0000</pubDate>
      <link>https://dev.to/alexphebert2000/exploring-web-development-ruby-on-rails-519f</link>
      <guid>https://dev.to/alexphebert2000/exploring-web-development-ruby-on-rails-519f</guid>
      <description>&lt;h2&gt;
  
  
  What is Ruby?
&lt;/h2&gt;

&lt;p&gt;Ruby is a general purpose programming language that features simple and beginner-friendly syntax while being a powerful tool for experienced developers. Ruby is an interpreted language and is dynamically typed similarly to JavaScript and Python making my transition to Ruby fairly simple. &lt;/p&gt;

&lt;p&gt;There are a few things I found while learning ruby that I found interesting. For example, ruby has an unless statement along with the if statement that is a negated version of an if. Ruby is a generally more readable language than more symbol filled languages like JavaScript. &lt;/p&gt;

&lt;h2&gt;
  
  
  What is Rails?
&lt;/h2&gt;

&lt;p&gt;Rails is a full-stack web framework for Ruby that is "Optimized for happiness." It uses the MVC framework pattern which they call "Active Records", "Action Views", and "Action Controllers".  Ruby on Rails was made to take the tedium and repetition out of web development. The main way it does this is 'Convention over Configuration.' &lt;/p&gt;

&lt;p&gt;Rails is a very opinionated and strict framework in order to make all its magic work. Things like naming conventions are very important to the Rails framework to make everything work correctly. To this end, the amount of customization you get with Rails is fairly limited compared to something like created a MERN stack app. But because the configuration is baked in its very easy to jump straight into the hacking with Rails. &lt;/p&gt;

&lt;p&gt;The lack of configuration does not hold Rails back either, many very large and popular sites are built with rails like GitHub, AirBnB, Shopify and Square. Before jumping into project set up, lets take a look at the 3 main components of the Rails MVC framework.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Setup
&lt;/h2&gt;

&lt;p&gt;Lets make a to-do app with Rails! We will walk through project setup, defining a route, generating a controller and writing a view.&lt;/p&gt;

&lt;h3&gt;
  
  
  Install Rails
&lt;/h3&gt;

&lt;p&gt;Assuming you have Ruby and your preferred database installed, we need to install Rails. Running this command will download the gem:&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;gem &lt;span class="nb"&gt;install &lt;/span&gt;rails 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Creating the App
&lt;/h3&gt;

&lt;p&gt;Rails makes it very simple to get your development environment set up. The rails cli command will create your directory for you:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ rails new &amp;lt;app-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's it, the skeleton for the app is set up. The majority of the work is done in the &lt;code&gt;app&lt;/code&gt; directory. Here you'll find the models, views, controllers and helpers for your app. The config directory houses all the configuration for the app including for the database and routes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Running the Server
&lt;/h3&gt;

&lt;p&gt;Since rails took care of all the set up work for us, we can immediately run our server with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ bin/rails server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will spin up a server on localhost:3000 that watches for changes made and restarts automatically.&lt;/p&gt;

&lt;h2&gt;
  
  
  Making the App
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Define a Route
&lt;/h3&gt;

&lt;p&gt;The first thing to do to implement new functionality to a Rails app is to make a route to accept and map a request to a controller. The route configuration is in &lt;code&gt;config/routes.rb&lt;/code&gt;. Here is where you will define all the endpoints for your app. For now lets add a route to get the to-dos. Routes are written in Ruby DSL(Domain-Specific Language) and take the shape of &lt;code&gt;&amp;lt;HTTP Verb&amp;gt; &amp;lt;enpoint&amp;gt;, to: &amp;lt;controller&amp;gt;#&amp;lt;action&amp;gt;&lt;/code&gt;. to map &lt;code&gt;GET /todos&lt;/code&gt; to the &lt;code&gt;index&lt;/code&gt; action of the &lt;code&gt;TodosController&lt;/code&gt; we add this to &lt;code&gt;config/routes.rb&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="no"&gt;Rails&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;routes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;draw&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;get&lt;/span&gt; &lt;span class="s2"&gt;"/todos"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;to: &lt;/span&gt;&lt;span class="s2"&gt;"todos#index"&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Generate a Controller
&lt;/h3&gt;

&lt;p&gt;With Rails, rather than writing controllers from scratch, they can be generated. When Rails generates a controller, it also generates associated unit tests and helpers for the controller. To generate a controller for the &lt;code&gt;GET /todos&lt;/code&gt; route we just added, run the command:&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;bin/rails generate controller Todos index &lt;span class="nt"&gt;--skip-routes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command generates a &lt;code&gt;TodoController&lt;/code&gt; with an &lt;code&gt;index&lt;/code&gt; action. We use &lt;code&gt;--skip-routes&lt;/code&gt; since we already defined the route we want to use.&lt;br&gt;
The controller we just generated is housed in &lt;code&gt;app/controllers/todos_controller.rb&lt;/code&gt;. Right now our controller should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;TodosController&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ApplicationController&lt;/span&gt;
  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;index&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the lack of code here. This is a great example of "Convention over Configuration." If an action does not render a view explicitly it will default to rendering the view that matches the controller.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a View
&lt;/h3&gt;

&lt;p&gt;One of the things generated alongside our controller was the file &lt;code&gt;app/views/todos/index.html.erb&lt;/code&gt;, the default view for the &lt;code&gt;TodoController&lt;/code&gt;. Here we can use HTML and Ruby code to make a template for our data. For now lets just change the file to say hello by adding&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Hello! Welcome to your Todo List!&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can navigate to &lt;code&gt;http://localhost:3000/todos&lt;/code&gt; to see our welcome message. With a handful of commands and even fewer lines of code we now have a &lt;em&gt;route&lt;/em&gt; that accesses a &lt;em&gt;controller&lt;/em&gt; with an &lt;em&gt;action&lt;/em&gt; that renders a &lt;em&gt;view&lt;/em&gt;! &lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Rails is a genuinely fun framework to work with. Removing the tedium of writing the same logic over and over for each feature makes development lightning fast. Not only is Rails simple but its also fully fleshed out and powerful, no wonder so many companies opt to use rails for their web apps. While there is a bit of a learning curve once you get into the nitty gritty of fleshing out an app with Rails, I think it is well worth the work. If youre interested in continuing to explore rails, I recommend heading over to the &lt;a href="https://guides.rubyonrails.org/getting_started.html"&gt;Rails guides&lt;/a&gt; and following their getting started tutorial. Good luck and have fun developing!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Exploring Web Development: Python + Django</title>
      <dc:creator>Alex Hebert</dc:creator>
      <pubDate>Sun, 26 May 2024 01:51:56 +0000</pubDate>
      <link>https://dev.to/alexphebert2000/exploring-web-development-python-django-acb</link>
      <guid>https://dev.to/alexphebert2000/exploring-web-development-python-django-acb</guid>
      <description>&lt;p&gt;The more I have learned about full-stack development with stacks like MERN, the more curious I have become about how other tech stacks compare, how they look, and how hard would it be for me to learn them now that I have a foundational understanding of full-stack development. So I decided to challenge myself over the next 6 weeks: to learn 3 new tech stacks and write a todo app with each one. After 2 weeks of learning the tech and writing the app I will log my experience here, give a brief overview of what I learned, and share my opinions on working with the technologies.&lt;/p&gt;

&lt;p&gt;The first tech stack I chose is Django. I chose Django for 2 main reasons: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;I already know a decent amount of python from my college projects&lt;/li&gt;
&lt;li&gt;Python is one of the most popular languages right now and freshening up a bit on my Python knowledge seemed like a pretty good use of my time&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Excited to dive back into python after being fully immersed in JavaScript, I dove in head first.&lt;/p&gt;

&lt;h1&gt;
  
  
  Django Basics
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Welcome to Django
&lt;/h2&gt;

&lt;p&gt;Django is a python web-app framework that focuses on development speed. Their homepage says: "Django was designed to help developers take their applications from concept to completion as quickly as possible," and I feel that they are definitely succeeding in that goal. Developing with Django felt incredibly straight-forward and it did not take much time at all for me to get from an empty directory to basic functionality. &lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up the app
&lt;/h2&gt;

&lt;p&gt;Django makes setting up your workspace super easy. Once you're in your project directory run &lt;code&gt;django-admin startproject todo-project&lt;/code&gt; to start a new project called todo-project. Django will make a new directory called todo-app with this file structure:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpkk6hxh5b4mrzp5fsuj8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpkk6hxh5b4mrzp5fsuj8.png" alt="files generated by startproject" width="212" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;manage.py&lt;/code&gt; is a key part of django, running it is how we will make changes to our database, start our server and do most other interactions we will need to do with our app. &lt;code&gt;__init__.py&lt;/code&gt; is an empty file that's used by python to denote the directory as a python package. For the time being we wont worry about settings, asgi, or wsgi, instead we should start our first app. In Django, projects are collections of apps and apps are the functional components. Apps are like modules that can be implemented into many projects - like web app Legos! &lt;/p&gt;

&lt;p&gt;To start our app we can use &lt;code&gt;manage.py&lt;/code&gt; to set up our app skeleton with &lt;code&gt;python manage.py startapp todos&lt;/code&gt; that will generate this directory: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxsgdli5a4ztcphpaosvu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxsgdli5a4ztcphpaosvu.png" alt="files generated by startapp" width="228" height="291"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After our app is set up by Django we need to add it to our project. To do this we need to edit the &lt;code&gt;INSTALLED_APPS&lt;/code&gt; array in the &lt;code&gt;settings.py&lt;/code&gt; in the todo_project directory.&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="n"&gt;INSTALLED_APPS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;django.contrib.admin&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;django.contrib.auth&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;django.contrib.contenttypes&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;django.contrib.sessions&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;django.contrib.messages&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;django.contrib.staticfiles&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;todo&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;Next we need to add a url for the project to use the todo app. In &lt;code&gt;urls.py&lt;/code&gt; add a new path to end of the urlspatterns array.&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;from&lt;/span&gt; &lt;span class="n"&gt;django.contrib&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;admin&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.urls&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;include&lt;/span&gt;

&lt;span class="n"&gt;urlpatterns&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="nf"&gt;path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;admin/&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;admin&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;site&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;urls&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nf"&gt;path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;todos/&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;include&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;todo.urls&lt;/span&gt;&lt;span class="sh"&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 just like that our app is integrated into our project! We can now start working on our functionality.&lt;/p&gt;
&lt;h2&gt;
  
  
  Building out the App
&lt;/h2&gt;

&lt;p&gt;To get a something rendering we need to add a view to our app. In &lt;code&gt;views.py&lt;/code&gt; we need to &lt;code&gt;from django.http import HttpResponse&lt;/code&gt;. This will allow us to render a string to our page. All views take in a request and return some response. This response could be &lt;br&gt;
a simple string like &lt;code&gt;return HttpResponse('This is where I would put my todo... If I had one!')&lt;/code&gt; or can respond with html with django's render shortcut. For now lets send back that string by adding this to &lt;code&gt;views.py&lt;/code&gt;:&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;from&lt;/span&gt; &lt;span class="n"&gt;django.http&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;HttpResponse&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;todo_render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;HttpResponse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;This is where I would put my todo... If I had one!&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;Now to actually access this view we need to set up an endpoint to use it. We can start by creating a new file in the &lt;code&gt;todo&lt;/code&gt; directory called &lt;code&gt;urls.py&lt;/code&gt;. This file is similar to the &lt;code&gt;urls.py&lt;/code&gt; in the project directory but these endpoints will be added to the end of /todos. We can set up the view we just made as the default view for /todos by adding this to &lt;code&gt;urls.py&lt;/code&gt; in todo:&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;from&lt;/span&gt; &lt;span class="n"&gt;django.urls&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;.&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;views&lt;/span&gt;

&lt;span class="n"&gt;app_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;todos&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;urlpatterns&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="nf"&gt;path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;todo_render&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;index&lt;/span&gt;&lt;span class="sh"&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 just like that we have a incredibly simple but functional app with Django!. Now lets go checkout all our hard work.&lt;/p&gt;
&lt;h2&gt;
  
  
  Running the app
&lt;/h2&gt;

&lt;p&gt;To start our server to look at our site in the browser all we need to do is run &lt;code&gt;python manage.py runserver&lt;/code&gt; and navigate to &lt;code&gt;localhost:8000/todos/&lt;/code&gt;. Thats where this little tutorial will end but if this at all interests you should definitely go to &lt;a href="https://docs.djangoproject.com/en/5.0/intro/tutorial01/"&gt;Django Docs&lt;/a&gt; and follow their tutorial where they walk through building a polls app. &lt;/p&gt;
&lt;h1&gt;
  
  
  My Thoughts
&lt;/h1&gt;

&lt;p&gt;I found working with Django to be an extremely streamlined process. Django handled a lot of the tedium of set up and lets you get right into the coding. This is both a blessing and a curse. I like to know how things are working behind the scenes and the degree of abstraction Django uses to get the development as quick as possible feels very hand wavy. I walked away from making the app knowing how to get all the code in the right places but not sure why or how the code works, which is a feeling I am not a big fan of. It reminds me of this gem from 2015. &lt;/p&gt;
&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://tenor.com/view/todd-howard-it-just-works-bethesda-this-all-just-works-gif-20598651" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://res.cloudinary.com/practicaldev/image/fetch/s--qpEq3ww9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://media1.tenor.com/m/rkI1a8s2Z6QAAAAC/todd-howard-it-just-works.gif" height="278" class="m-0" width="498"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://tenor.com/view/todd-howard-it-just-works-bethesda-this-all-just-works-gif-20598651" rel="noopener noreferrer" class="c-link"&gt;
          Todd Howard It Just Works GIF - Todd Howard It Just Works Bethesda - Discover &amp;amp; Share GIFs
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          Click to view the GIF
        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://res.cloudinary.com/practicaldev/image/fetch/s--6OlyXz05--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://tenor.com/assets/img/favicon/favicon-16x16.png" width="16" height="16"&gt;
        tenor.com
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
With that said, I can see myself learning more and using Django in the future to quickly get an idea into practice. One of the things I really like about Django is the included admin view that allows you to interact with your app in an easy to use GUI. I also like the html templating that I find to be very straight forward and easy to pick up. Django is a well-oiled machine and makes web development much more accessible by removing the most intimidating parts, setup.&lt;/p&gt;

&lt;h1&gt;
  
  
  Resources
&lt;/h1&gt;

&lt;p&gt;I relied on the &lt;a href="https://docs.djangoproject.com/en/5.0/intro/tutorial01/"&gt;Django Docs&lt;/a&gt; to learn. The documentation is great and the tutorial covers everything you need for the basics.&lt;/p&gt;

&lt;p&gt;I hope you try out Django, it is a powerful tool to have in your back pocket if you need an idea in code quickly. Have fun and good luck!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Godot: Lowering the Barrier to Entry of Game Dev</title>
      <dc:creator>Alex Hebert</dc:creator>
      <pubDate>Sun, 21 Apr 2024 19:00:50 +0000</pubDate>
      <link>https://dev.to/alexphebert2000/godot-lowering-the-barrier-to-entry-of-game-dev-3gam</link>
      <guid>https://dev.to/alexphebert2000/godot-lowering-the-barrier-to-entry-of-game-dev-3gam</guid>
      <description>&lt;p&gt;Now that I am getting towards the latter third of my coding bootcamp, I have been asked a few times: "What do you want to do when you're done?" And while I feel it may be a bit early to make that kind of decision, it is certainly not too early to start considering my options. &lt;/p&gt;

&lt;p&gt;One that has always enticed but intimidated me was game development. I have been playing video games for essentially my whole life and game design seems to be a perfect blend of exploring my creativity and software engineering. However, any foray into the world of game design in my past has led me to back away from the prospect because of the intimidating complexity and saturated market. In recent years, with the extreme success of smaller studios starting to outclass the success of large game studios, I have begun to gain some hope that I could find some success as a smaller creator. This combined with my newly gained confidence with coding, I figured now was as good of a time as any to leap back into learning about game development, this is where I found &lt;em&gt;Godot&lt;/em&gt;.&lt;/p&gt;

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

&lt;h1&gt;
  
  
  What is Godot?
&lt;/h1&gt;

&lt;p&gt;Godot (&lt;em&gt;pronounced "guh-doh"&lt;/em&gt;) is a game engine that has gained a lot of popularity in the last couple of years. Godot makes game development accessible to anyone who wants to give development a try. There is a very low barrier to entry since the engine is free and can run on most modern systems. No need for a subscription or a beefy PC. Godot has also fostered an active and talented community because of the open source code, allowing the community to develop Godot to their needs, furthering the accessibility and functionality of the engine. I don't think I could do better than the Godot developers themselves at describing their product. Their short write-up says:&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Godot Engine is a feature-packed, cross-platform game engine to create 2D and 3D games from a unified interface. It provides a comprehensive set of common tools, so that users can focus on making games without having to reinvent the wheel. Games can be exported with one click to a number of platforms, including the major desktop platforms (Linux, macOS, Windows), mobile platforms (Android, iOS), as well as Web-based platforms and consoles.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Godot is completely free and open source under the permissive MIT license. No strings attached, no royalties, nothing. Users' games are theirs, down to the last line of engine code. Godot's development is fully independent and community-driven, empowering users to help shape their engine to match their expectations. It is supported by the Godot Foundation not-for-profit.&lt;/em&gt; &lt;a href="https://docs.godotengine.org/en/stable/about/introduction.html#:~:text=and%20Forum.-,About%20Godot%20Engine,%C2%B6,-A%20game%20engine"&gt;Godot Docs&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Now, that has a lot of jargon packed into a short space, so let's break it down before getting into the basics of Godot.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;Godot is a feature-packed, cross-platform game engine&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;Godot provides a lot of the same features that other engines like Unity or Unreal provide but trims the fat leaving only the key features that developers need. This package is wrapped up in a download that is only just over 1.4 GB, less than half of other engines. This small and efficient size allows Godot to be run on most modern systems. Godot also supports all operating systems including Linux.  &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;... to create 2D and 3D games from a unified interface.&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;Godot has one interface whether working in 2D or 3D and neither feels like it takes precedence over the other. Godot provides equally useful and intuitive tools for working with either style and concepts transfer seamlessly from developing in one to the other.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;Games can be exported with one click to a number of platforms&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;Godot allows developers to make games for any modern platform including PC, iOS, and Android, as well as consoles like PlayStation, Xbox, and Switch. Since there is support for all these platforms, it is possible to develop a single game and export it to all these platforms with little work from the user.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;Godot is completely free and open source&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;Of the major game engines, Godot is the only completely free and open-source software. This means all the source code for the Godot engine is completely available and can be copied and edited to the needs of the developer without any paywall to access this. This allows for an expansive extension library from the Godot community that provides developers with even more tools. Godot's community is quite large and very passionate, in some ways the Godot engine feels more like a community project rather than a for-profit software.&lt;/p&gt;




&lt;h1&gt;
  
  
  Godot Basics
&lt;/h1&gt;

&lt;p&gt;Now that you have an understanding of what Godot Engine is, let's take a look inside and see how game development works in Godot.&lt;/p&gt;

&lt;p&gt;Games are comprised of scenes made of one or more node trees. The nodes can be wired together using signals. &lt;/p&gt;

&lt;h2&gt;
  
  
  Scenes
&lt;/h2&gt;

&lt;p&gt;Scenes are reusable sets of nodes that can represent any entity in the game. Characters, items, and environments are all scenes. Scenes use a root node that children and sibling nodes are added to to build out the scene. Scenes are then able to be nested to add things like the character and items to the environment.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Nodes
&lt;/h2&gt;

&lt;p&gt;Nodes are the building blocks of the Godot engine. Nodes join together to form scenes through relationships called trees. Nodes can be added to other nodes to provide the parent node with the functionality of the child node. For example, a basic player scene could use a &lt;code&gt;CharacterBody2D&lt;/code&gt; node as the root node. To add a sprite to the player you can add a &lt;code&gt;Sprite2D&lt;/code&gt; node as a child. Adding things like a collision node and camera node will add more functionality to the player allowing it to interact with other scenes with collision shapes and providing a locked camera to the player. Nodes can also have attached scripts to further enhance the node's functionality and interact with signals.&lt;/p&gt;

&lt;h2&gt;
  
  
  Signals
&lt;/h2&gt;

&lt;p&gt;Godot nodes use a system of signals that trigger whenever certain events occur. These signals can be used to have nodes communicate without connecting them through code. Signals can also be used to trigger code execution. For example, buttons emit signals when pressed, this can be used to trigger a code execution to exit the game, change scenes, open a menu, or any number of other actions. Other signals like collisions make coding out interactions between scenes very straightforward.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  GDScript
&lt;/h2&gt;

&lt;p&gt;Godot's purpose-built scripting language. GDScript was inspired by Python and it shows in its simple syntax and use of indentation to structure code blocks but has many differences that make it great for game development. Baked in linear algebra use, fast compilation times, and no garbage collection are a few of the features of GDScript that, in conjunction with the simple syntax and low learning curve, make GDScript a vital part of making Godot accessible to beginners&lt;/p&gt;

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

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;This is a very cursory glance at Godot engine, if this interests you at all, I strongly encourage you to take a crack at making a game. There are more than a handful of tutorials out there that can walk you through your first game. I followed &lt;a href="https://youtu.be/S8lMTwSRoRg?si=akXoH34AOG9pUo45"&gt;freeCodeCamp's on Youtube&lt;/a&gt; that, while a little out of date, covered everything in good detail. Checkout &lt;a href="https://godotengine.org/"&gt;Godot's docs&lt;/a&gt; if you want to read more and download the engine. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Coding!&lt;/strong&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>RegEx: Decoding the Symbols</title>
      <dc:creator>Alex Hebert</dc:creator>
      <pubDate>Sun, 14 Apr 2024 19:20:03 +0000</pubDate>
      <link>https://dev.to/alexphebert2000/regex-decoding-the-symbols-432m</link>
      <guid>https://dev.to/alexphebert2000/regex-decoding-the-symbols-432m</guid>
      <description>&lt;p&gt;My first encounter with regular expressions was in a solution for a coding problem on &lt;a href="https://www.codewars.com/"&gt;Codewars&lt;/a&gt;, specifically &lt;a href="https://www.codewars.com/kata/583203e6eb35d7980400002a"&gt;&lt;em&gt;Count the smiley faces!&lt;/em&gt;&lt;br&gt;
&lt;/a&gt; Which asks you to count the number of smiley faces in a given array but the catch is each smiley can have 1 of 2 kinds of eyes (: or ;), may or may not have a nose represented by 1 of 2 symbols (- or ~), and 1 of 2 symbols (D or ) ) for the smile. In total there are 12 different combinations that are a valid smiley. I, being the young and naive programmer I was, hard coded all 12 of those faces and checked every element against that list. And it worked! But the top solution included some strange syntax that I had never seen before&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function countSmileys(arr) {
  return arr.filter(x =&amp;gt; /^[:;][-~]?[)D]$/.test(x)).length;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What in the world is &lt;code&gt;/^[:;][-~]?[)D]$/&lt;/code&gt;? How does this jumble of characters do anything to filter the array? After looking at it for a little while I noticed a some things that made some sense. All the symbols that can make up a face are there, grouped together by the facial feature they represent but as for how all the other symbols played into filtering out the non faces, not a clue. &lt;/p&gt;

&lt;p&gt;After this brief run in, I saw it a few more times in other solutions but I still couldn't understand them. I did figure out that these were &lt;strong&gt;Regular Expressions&lt;/strong&gt; or Regex. Researching did little to help me read them, alot of symbol and explinations that went right over my head, but I did get a better understanding of what regular expressions could do from &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions"&gt;MDN&lt;/a&gt;: "Regular expressions are patterns used to match character combinations in strings." So thats what the solution for &lt;em&gt;Count the Smiley Faces&lt;/em&gt; was doing, it was searching each string for a pattern that is a valid smiley. &lt;/p&gt;

&lt;p&gt;Now I understood that RegEx is a tool that I can use to find patterns in strings and javascript allows me to do various things with them, like testing if the pattern exists in the string or getting an array of all the times that pattern appears in a string. I still didn't know how to write regular expressions but I could identify when I might want to use them and it took a little while but that time came in the form of rewriting JSON.parse. I figured parsing a JSON string would be a great use for regular expressions since I can look for patterns like open and close brackets for arrays or curly braces for objects. While I was unsuccessful in parsing json with regular expressions, (&lt;em&gt;nested arrays and objects with multiple entries put the nail in the coffin there&lt;/em&gt;) I did finally learn how to write regular expressions and wrote these 3 monsters to parse out object keys, &lt;code&gt;/(?&amp;lt;!(: ?)|["\w]|(: ?{))(".*?")(?=:)(?!,|})/g&lt;/code&gt;, &lt;code&gt;/(?&amp;lt;= |:)(\[.*?])|(?&amp;lt;=: ?)([^\s]*?}*)(?=,|( *}))/g&lt;/code&gt;, and &lt;code&gt;/({.*?})|(\[.*?]+)|((?&amp;lt;= ?).*?(?=,| ))|((?&amp;lt;=, ?)[^\s]*)/g&lt;/code&gt;. And I learned that while intmidating at a glance, regular expression are actually not that hard to read and understand.&lt;/p&gt;

&lt;h1&gt;
  
  
  Basic Syntax
&lt;/h1&gt;

&lt;p&gt;Let’s take a look at some of the basic syntax for regular expressions. &lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a Regular Expression
&lt;/h2&gt;

&lt;p&gt;In JavaScript, regular expressions are actually a complex data type like arrays and objects, as such there is 2 ways to create a new regular expression. The most common way I’ve seen is with literal syntax, encapsulating your pattern with forward slashes and adding the optional flags at the end like so: &lt;code&gt;/pattern/flags&lt;/code&gt;. You can also use the &lt;code&gt;new&lt;/code&gt; keyword and  define a regular expression like so: &lt;code&gt;new RegExp(“pattern”, “flags”)&lt;/code&gt;. Either way you can save them as variables and have access to the &lt;code&gt;.test()&lt;/code&gt; method of regular expressions in JavaScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  Composing the Pattern
&lt;/h2&gt;

&lt;p&gt;Writing a pattern involves a combination of simple characters and special characters. &lt;/p&gt;

&lt;h3&gt;
  
  
  Simple Characters
&lt;/h3&gt;

&lt;p&gt;Simple characters are the literal characters you see in the string. For example &lt;code&gt;/a/&lt;/code&gt; will find the first lowercase a in a string whereas &lt;code&gt;/cat/&lt;/code&gt; will find the first time the letters c-a-t appear in the string.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;NOTE&lt;/em&gt;&lt;/strong&gt; : &lt;em&gt;its important to keep in mind the the regular expression above is not looking for the word “cat” explicitly, just the letters c-a-t. So a word like “catastrophe” or “educate” will pass a test with that regular expression.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Special Characters
&lt;/h3&gt;

&lt;p&gt;Regular expressions also use many special characters to represent multiple characters, group characters together and modify the pattern in some way. &lt;/p&gt;

&lt;h4&gt;
  
  
  Character Classes
&lt;/h4&gt;

&lt;p&gt;Regular expressions have many character classes that can represent a group of characters with a single symbol. Each character class has a negated form that is used by capitalizing the letter. The character classes are: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;\w =&amp;gt; word character, includes all capitalized and lowercase letters.&lt;/li&gt;
&lt;li&gt;\d =&amp;gt; digits, incudes numbers 0-9 &lt;/li&gt;
&lt;li&gt;\s =&amp;gt; white space character, includes space, tab, and any other white space Unicode character &lt;em&gt;(like \n)&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;. =&amp;gt; includes all characters except \n&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Custom character classes can be made with the use of brackets. These custom character classes match one of the included characters. For example, &lt;code&gt;[a4t]&lt;/code&gt; will accept an “a”, “4” or a “t” in that point in the pattern. Looking back at the regex in the solution for &lt;em&gt;Count the Smiley Faces&lt;/em&gt; earlier &lt;code&gt;/^[:;][-~]?[)D]$/&lt;/code&gt;, we can find 3 custom character classes &lt;code&gt;[:;]&lt;/code&gt;, &lt;code&gt;[-~]&lt;/code&gt; and &lt;code&gt;[)D]&lt;/code&gt;. Creating custom character classes to represent the eyes, nose and mouth of the smiley faces. But if you remember from the prompt, the nose may or may not be included. That is where quantifiers come into play.&lt;/p&gt;

&lt;h3&gt;
  
  
  Quantifiers
&lt;/h3&gt;

&lt;p&gt;Quantifiers are added after a character to affect the amount of that character the regex will look for in the string to match the pattern. Like character classes you can make your own custom quantifiers but there are shorthands for some of the most common quantifiers. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;* =&amp;gt; 0 or more times&lt;/li&gt;
&lt;li&gt;+ =&amp;gt; 1 or more times&lt;/li&gt;
&lt;li&gt;? =&amp;gt; 0 or 1 times&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Custom quantifiers use curly brace and take 3 different forms. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;{n} =&amp;gt; exactly n times&lt;/li&gt;
&lt;li&gt;{n,m} =&amp;gt; n to m times&lt;/li&gt;
&lt;li&gt;{n,} =&amp;gt; n or more times.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Back to the solution for &lt;em&gt;Count the Smiley Faces&lt;/em&gt; &lt;code&gt;/^[:;][-~]?[)D]$/&lt;/code&gt; incudes a &lt;code&gt;?&lt;/code&gt; following the character group for the nose symbols to say there can be no nose or exactly 1 nose in a valid face.&lt;/p&gt;

&lt;h3&gt;
  
  
  Anchors
&lt;/h3&gt;

&lt;p&gt;Anchors preform a little differently than other parts of the pattern as they deal with the position within the string as opposed to a character within the string. Anchors can be used to ensure the pattern occurs at a certain location in the string.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;^ =&amp;gt; beginning of the string&lt;/li&gt;
&lt;li&gt;$ =&amp;gt; end of the string&lt;/li&gt;
&lt;li&gt;\b =&amp;gt; word boundary, position between a word characters and non-word character including the beginning and end of the string.&lt;/li&gt;
&lt;li&gt;\B =&amp;gt; opposite of \b&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The solution we have been breaking down (&lt;code&gt;/^[:;][-~]?[)D]$/&lt;/code&gt;) includes both the &lt;code&gt;^&lt;/code&gt; and &lt;code&gt;$&lt;/code&gt; anchors to ensure nothing comes before or after the smiley face in the string. &lt;/p&gt;

&lt;h3&gt;
  
  
  Capture Groups
&lt;/h3&gt;

&lt;p&gt;Regex allows you to group a part of the pattern together to apply a quantifier to the whole group. Simply placing parentheses around part of the pattern groups it together. For example if you wanted to extract my first name and my last name if its there you could make a regex that looks like this: &lt;code&gt;/Alex( Hebert)?/&lt;/code&gt;. In this example “ Hebert” is in a capturing group so the &lt;code&gt;?&lt;/code&gt; quantifier apples to that whole group.&lt;/p&gt;

&lt;h2&gt;
  
  
  Changing Settings with Flags
&lt;/h2&gt;

&lt;p&gt;The other part of regular expressions are the flags. Flags are added to the end of a regular expressions and can affect how certain special character work, how the entire pattern is read, or where in the string is looked for the pattern. Flags are powerful but ultimately optional and many regular expressions forgo flags. Some of the most common flags are: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;g =&amp;gt; global flag, searches the string for all matches - rather than just the first.&lt;/li&gt;
&lt;li&gt;i =&amp;gt; case insensitive - all letters are matched without regard to case&lt;/li&gt;
&lt;li&gt;s =&amp;gt; “dotall” mode, the “.” character includes all characters including “\n”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While there are other flags like y,u and m, I find that they are less common - and more complicated - than the g, i, and s flags. &lt;/p&gt;

&lt;h1&gt;
  
  
  Further Readings
&lt;/h1&gt;

&lt;p&gt;I used a number of different resources to learn regular expressions and there is a lot that I didn’t cover here that can really power up your regex, like look-arounds and reference with capture groups. I recommend taking a look at the following resources to really dive into the word of regex.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="//regexr.com"&gt;RegExr.com&lt;/a&gt; =&amp;gt; Allows you to visualize and break down your regular expression with a string.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions"&gt;MDN&lt;/a&gt; JavaScript offical docs on Regular Expressions.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.regular-expressions.info/quickstart.html"&gt;RegExp.info&lt;/a&gt; A great resource to learn everything about Regex across languages.&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Binary: How Computers Count</title>
      <dc:creator>Alex Hebert</dc:creator>
      <pubDate>Sun, 07 Apr 2024 19:12:47 +0000</pubDate>
      <link>https://dev.to/alexphebert2000/binary-how-computers-count-1800</link>
      <guid>https://dev.to/alexphebert2000/binary-how-computers-count-1800</guid>
      <description>&lt;p&gt;Many people are familiar with the trope of a tunnel of green 0s and 1s zooming by as a movie character hacks the mainframe or enters the computer world, but few know the signifigance these 0s and 1s have to comuting. Most modern programming languages have abstracted away the need for directly interacting with the binary foundation they rely on, so many programmers are left without an understanding of how the binary number system works or its importance to computing. &lt;/p&gt;

&lt;h2&gt;
  
  
  What is Binary
&lt;/h2&gt;

&lt;p&gt;Simply, binary is counting with base 2. The counting system we are familiar with is base 10. A counting systems base can be thought of as the number you count to before moving to the next position. For example, in base 10, counting from 0 to 9 only uses a single position but counting from 10 to 99 uses two. The term base comes from the fact each position of the number is representative of an amount of the base raised to a power. In base 10 the ones place is representative of 10^0, the tens place is 10^1, the hundreds is 10^2 and so on. This allows us to construct numbers to represent a certian combination of the base 10 exponents based on the position of the digit. So 143 is 1*10^2 + 4*10^1 + 3*10^0 or 100 + 40 + 3.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyzt7mxwq2ki4tmhcf426.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyzt7mxwq2ki4tmhcf426.png" alt="Image description" width="800" height="197"&gt;&lt;/a&gt;&lt;br&gt;
This carries over to binary but instead of using 10 as the base, we use 2. So the first place is 2^0, then 2^1, 2^2, and so on. This is where the zeros and ones come in. Since in binary you only count to 1 before moving to the next place the only digits seen in binary counting are 0 and 1. In binary 143 would be 1*2^7 0*2^6 0*2^5 0*2^4 1*2^3 1*2^2 1*2^1 1*2^0 or 128 + 8 + 4 + 2 + 1 or 10001111.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why is binary imprortant?
&lt;/h2&gt;

&lt;p&gt;Computing is all about logic and binary provides a great representation of the simplest unit of logic, true and false. Since there can be no in between with true and false, binary is the perfect fit since it only uses two numbers. Before digital computers were even considered a possiblity, 1854, George Boole published a paper utilizing binary to formalize what is known as Boolean Algebra. Boolean Algebra would later become the cornerstone to digital computing, providing an avenue for completing ariethmetic and logical calculations with digital circuts. These are still the foundations of modern computing, all made possible thanks to binary. &lt;/p&gt;

&lt;p&gt;Further Reading: &lt;br&gt;
Wikipedia article detailing the binary number system&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://en.wikipedia.org/wiki/Binary_number#"&gt;https://en.wikipedia.org/wiki/Binary_number#&lt;/a&gt; 
Paper detailing boolean algebra&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://plato.stanford.edu/entries/boolalg-math/"&gt;https://plato.stanford.edu/entries/boolalg-math/&lt;/a&gt;
Simulator to help understand Binary&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mathszone.net/mw/bases/binary/index.html"&gt;http://mathszone.net/mw/bases/binary/index.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Intro to Git: Command Basics</title>
      <dc:creator>Alex Hebert</dc:creator>
      <pubDate>Fri, 01 Mar 2024 16:21:45 +0000</pubDate>
      <link>https://dev.to/alexphebert2000/intro-to-git-command-basics-30nh</link>
      <guid>https://dev.to/alexphebert2000/intro-to-git-command-basics-30nh</guid>
      <description>&lt;p&gt;Understanding the workflow using git is essential in modern software engineering. Git is an immensely useful tool whether working solo or collaboratively. &lt;/p&gt;

&lt;h2&gt;
  
  
  So, What is Git?
&lt;/h2&gt;

&lt;p&gt;Git is a way to track changes and save a set of files inside a directory. Git creates a timeline of snapshots of the files it tracks. Each of these snapshots is called a &lt;strong&gt;commit&lt;/strong&gt;, and commits are saved along a timeline called a &lt;strong&gt;branch&lt;/strong&gt;. Git allows multiple of these branches to run in parallel and be merged later allowing for experimental changes and cooperative coding. Git is the backbone of cooperative coding because it allows multiple people to work on a project simultaneously without interfering with one another. &lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up your first repository
&lt;/h2&gt;

&lt;p&gt;To set up your first repository (or repo) is quite simple. To start, install git here:&lt;/p&gt;
&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;a href="https://git-scm.com/downloads" rel="noopener noreferrer"&gt;
      git-scm.com
    &lt;/a&gt;
&lt;/div&gt;
 For Windows users, this will give you access to a terminal called git bash. Open git bash and navigate to the directory you want to track with git. To do this use &lt;code&gt;ls&lt;/code&gt; to get a list of files inside the current directory and &lt;code&gt;cd &amp;lt;directory&amp;gt;&lt;/code&gt; to enter a child directory. To go back into the parent directory use &lt;code&gt;cd ..&lt;/code&gt;. If you want to make a new directory use &lt;code&gt;mkdir &amp;lt;name&amp;gt;&lt;/code&gt; to create a directory inside the current directory. Once at the directory you want to track with git use the command &lt;code&gt;git init&lt;/code&gt; to initiate a new git repository. Congratulations, you now have a git repo!
&lt;h2&gt;
  
  
  Making commits
&lt;/h2&gt;

&lt;p&gt;To save changes to your repository you need to make a commit. First make sure your terminal is at your repo, using &lt;code&gt;ls&lt;/code&gt; is a quick way to do this. Then use the &lt;code&gt;git add &amp;lt;file&amp;gt;&lt;/code&gt; command to stage the changes you've made to that file. If you have multiple files that have modifications you can use &lt;code&gt;git add .&lt;/code&gt; to add all of them in one command. Once all your changes are staged use &lt;code&gt;git commit -m &amp;lt;message&amp;gt;&lt;/code&gt; to make the commit. Each commit needs a message that briefly explains the changes made since the last commit. This commit will be added to the branch, you can see the commits that make up the current branch with &lt;code&gt;git log&lt;/code&gt; which will show you a list in reverse chronological order of the commits on the current branch.&lt;/p&gt;
&lt;h2&gt;
  
  
  Branching out
&lt;/h2&gt;

&lt;p&gt;Git allows you to make branches separate from the main codebase allowing you to make changes without affecting the main branch. To see a list of all the branches you can access use &lt;code&gt;git branch&lt;/code&gt; the current branch you're on should be highlighted. To make a new branch use &lt;code&gt;git branch &amp;lt;name&amp;gt;&lt;/code&gt; and then to switch between these branches use &lt;code&gt;git switch &amp;lt;branch&amp;gt;&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;These are a few of the most common commands you'll use when working with git. Your journey into git shouldn't stop here. To read up more on git check out this free e-book that will walk you through everything git! &lt;/p&gt;
&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;a href="https://git-scm.com/book/en/v2" rel="noopener noreferrer"&gt;
      git-scm.com
    &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>beginners</category>
      <category>git</category>
      <category>linux</category>
    </item>
    <item>
      <title>Intro to Control Flow</title>
      <dc:creator>Alex Hebert</dc:creator>
      <pubDate>Thu, 22 Feb 2024 02:36:34 +0000</pubDate>
      <link>https://dev.to/alexphebert2000/intro-to-control-flow-5hcg</link>
      <guid>https://dev.to/alexphebert2000/intro-to-control-flow-5hcg</guid>
      <description>&lt;h2&gt;
  
  
  What is control flow?
&lt;/h2&gt;

&lt;p&gt;Control flow is the order in which code is executed. Control flow in JavaScript generally runs from line 1 to the last line of code in order, however there are many statements that can affect the control flow and are a key part of programming.&lt;/p&gt;

&lt;h2&gt;
  
  
  If, Else, and Else If
&lt;/h2&gt;

&lt;p&gt;One of the most basic and intuitive control flow statements is the if, else, and else if statements. These are used to prevent or allow blocks of code to be executed &lt;em&gt;if&lt;/em&gt; a defined condition is met. Some if statements are accompanied by an else statement that will only execute if the condition of the accompanying if statement is not met. These if-else statements can be chained together to check for one of multiple conditions where only the first code block with a met condition will execute, by-passing all subsequent blocks in the else if chain. If statements without else statements can be chained together to check for multiple conditions where every condition that is met will run a code block.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if(condition_1){
  codeBlock;
}
else if(condition_2){
  codeBlock;
}
else{
  codeBlock;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The syntax for if else statements start with the word if followed by a condition in parentheses that will be evaluated to and type coerced to a boolean value. Following this is a block of code encapsulated by curly braces. Then the next condition is preceded by “else if” and then follows the same general syntax. The final else statement does not have a condition and just has a code block.&lt;/p&gt;

&lt;h2&gt;
  
  
  Switch
&lt;/h2&gt;

&lt;p&gt;Similar to if else statements, switch case statements execute code blocks based on a defined condition, however switch case conditions all share a common condition whose value determine which code blocks are run. Like else if statements, switch cases can be used to execute mutually exclusive blocks of code by ending each block with the break statement. Unlike chained if statements, all code following the passing case will be run until a break statement is reached, regardless if the following cases are true.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;switch(expression){
  case A:
    codeBlock;
    break;
  case B:
    codeBlock;
  case C:
    codeBlock;
    break;
  default:
    codeblock;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The syntax for switch statements starts with the word switch followed by an expression in parentheses. Inside a set of curly braces a set of case statements followed by a case expression to match against the switch expression precedes a block of code. In this example A is mutually exclusive from B and C but if the expression evaluates to B then both the B code block and C code block will be executed since the B code block does not have the break statement. At the end there is an optional default case that will run if the expression does not evaluate to A B or C.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
