denodb VS MySQL

Compare denodb vs MySQL and see what are their differences.

denodb

MySQL, SQLite, MariaDB, PostgreSQL and MongoDB ORM for Deno (by eveningkid)

MySQL

A pure node.js JavaScript Client implementing the MySQL protocol. (by mysqljs)
Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
denodb MySQL
5 34
1,906 18,130
- 0.1%
1.0 0.0
5 months ago 3 months ago
TypeScript JavaScript
MIT License MIT License
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

denodb

Posts with mentions or reviews of denodb. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-11-29.

MySQL

Posts with mentions or reviews of MySQL. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-12-01.
  • Servidor para Blog, com Autenticação JWT - Node.Js & Mysql
    4 projects | dev.to | 1 Dec 2023
  • Help with SQL and Serialport
    3 projects | /r/arduino | 13 Feb 2023
  • The Complete Beginner's Guide to a Career in Web Development
    8 projects | dev.to | 21 Sep 2022
    The above example demonstrates the use of the tag in the header applying a green colour to all

    elements.

    Within the HTML itself the second

    element has a style attribute which is setting the color property to red. This has more specificity than the tag selector, so the second paragraph element will render as red.

    To demonstrate the third and most common option (a .css file) we are going to construct a more complex example and take the time to break each selector and property down to get some experience working with something that looks more like a stylesheet you might encounter in a real world site.

    Begin by creating an index.html file in the root directory of a project (you can use the one you already created it you are following along) and paste the following code into it:

    index.html

    
     lang="en">
      
         charset="UTF-8" />
        </span>My Animal Blog<span class="nt">
         rel="stylesheet" href="style.css" />
      
    
      
        
          

    My Favourite Animals

    Enjoy these furry friends

    class="card"> src="https://res.cloudinary.com/dqse2txyi/image/upload/v1657421273/blogs/intro-to-web-development/cat_k4fcww.png" alt="Cat Playing Chess" /> class="card__container">

    Chess Cat

    He's planning his next move.

    © 2022

    Enter fullscreen mode Exit fullscreen mode

    The key line to look at in the above example is this one:

     rel="stylesheet" href="style.css" />
    
    Enter fullscreen mode Exit fullscreen mode

    This element tells your browser that you want to link an external stylesheet, and the filename is style.css. It looks in the root directory by default. As of right now, you do not have a style.css file in the root directory of your project.

    Without any CSS at all, this page looks like:

    Unstyled Page Example

    Not too bad, but we can make it look a lot better. Create a new file in the root directory next to index.html and call it style.css.

    Leave it empty to start. We're going to add some CSS little by little to clean it up a bit and give you an idea how to craft an extremely simple, but still modern and responsive page design. We'll also explain each piece in detail as we go.

    So feel free to add each of these pieces to your style.css file as you read them, one after the other (it's not necessary though if you would prefer to just read, we'll post the full file contents at the end).

    So let's begin styling our animal blog:

    body {
      color: #333333;
      font-family: Helvetica, sans-serif;
      margin: auto;
      max-width: 800px;
    }
    
    Enter fullscreen mode Exit fullscreen mode

    The body in HTML defines where all the content is. The body is inside the element, which by default will span the entire width of the page.

    Let's look at each property in the body tag selector, to see what they do and why we chose them.

    max-width: 800px;

    Typically in many modern web pages you'll find it common for the actual content not to span the entire width of a user's screen. People often use very wide monitors these days and it can be challenging to read content, particularly text that spans from one edge to the other.

    For an easy example of this go to Google and search. You'll see that the search results only span a small portion of the screen before the text wraps (on my 1920px monitor the results are 600px wide).

    We are doing something similar for our blog. Body content can only be a maximum of 800px wide, and will shrink down automatically on smaller screens.

    margin-auto;

    With only max-width our content will still be left justified on the page. We would like it to be centred. That's what having an auto margin does in this context.

    On the top and bottom it will do nothing since the default height of is only the height of our content; however the width is the width of thr full screen. The difference between that screen width and the 800px content will automatically become margin on the left and right.

    This has the result of placing the content in the centre.

    color: #333333;

    Pure black text on a pure white background creates a fairly stark contrast. It's not terrible, but it's fairly common to use a not-quite-black color instead of black for text on a white background.

    Here we have chosen a hex colour that is close to black, but not quite.

    font-family: Helvetica, sans-serif;

    After setting the color we are also setting the default font of our site. We've chosen Helvetica because it is one of the safe web fonts that are available on the majority of web browsers and operating systems.

    The font-family property allows as many font names as you like separated by commas. It will chose the first one it finds from left to right that exists on a user's system. The final option sans-serif simply says worst case give me any sans-serif font you have.

    Here's a look at what we have so far with our body styles:

    CSS Example 1

    main {
      margin-bottom: 40px;
    }
    
    header,
    footer {
      text-align: center;
    }
    
    h1 {
      font-family: Arial, sans-serif;
    }
    
    h2 {
      font-style: italic;
      font-weight: lighter;
    }
    
    Enter fullscreen mode Exit fullscreen mode

    margin-bottom: 40px;

    We added this to give a bit of space at the bottom of all the main content before the footer, so the copyright symbol doesn't press up directly against the text.

    text-align: center;

    As described, this centre aligns the text in the header and footer. Since the header includes both an

    and

    element each one will automatically inherit that property.

    font-family, font-style, font-weight

    Each property sets the font properties as described.

    Similar to the previous, but now our fonts are updated and our texts are centred:

    CSS Example 2

    .card {
      width: 350px;
      margin: auto;
      box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
      border-radius: 10px;
      overflow: hidden;
    }
    
    Enter fullscreen mode Exit fullscreen mode

    width: 350px;

    We are going to set our card elements to be 350px wide. This is simply a value I have chosen based on common screen sizes. Very few modern smartphones have a width smaller than 375px, so setting our cards to 350px means they will fit nicely (without having to be shrink) on nearly every device.

    margin: auto;

    Used again for centring, this time to centre the card inside the . Since the card is 350px and the body is 800px this will set margins on either side to fill the difference and centre the element.

    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);

    Easily the most complex of all our properties, but a good example to break down because it will not be uncommon to encounter this type of property in your CSS journey.

    First the property itself, box-shadow creates a shadow like effect around the edge of an element. The thickness of it depends on some numeric values. In this case it is the four numeric values you see 0 4px 8px 0

    Whenever you see a CSS property with four consecutive numeric values it typically refers to the sides of a box in clockwise order from the top. This image from MDN illustrates:

    CSS Four Side Properties

    So in our example, there is no shadow on the top, 4px on the right, 8px on the bottom and no shadow on the left. In CSS when using the number 0 it is standard to leave off the unit.

    The final fifth value on box shadow indicates the colour. For an rgba colour 0, 0, 0 is black and the final value is the alpha; think of as the opacity. That's what makes the shadow look more natural and diffuse rather than a solid black at 0.2.

    If you managed to follow this one, well done! If not, don't feel bad about skipping over it. This type of syntax will grow on you naturally as you encounter it more often.

    border-radius: 10px;

    A border radius will give us rounded corners. The larger the value the more rounded. It's common to use this property to create circles by giving a radius of 50%. For our case 10px give a nice rounded edge to the card.

    overflow: hidden;

    This is necessary to keep the image from going over our rounded corners. Since the image has rectangular images and sits above the card

    it would hide the rounded corners of the card.

    Hiding the card's overflow keeps the image inside the card and the edges visibly round.

    .card > img {
      width: 100%;
      height: auto;
    }
    
    Enter fullscreen mode Exit fullscreen mode

    Setting the width of our image (using the direct child combinator) to 100% will stretch it to the edge of its part, the 350px card. Setting the height to auto ensures that the aspect ratio remains correct.

    .card__container {
      padding: 16px;
    }
    
    Enter fullscreen mode Exit fullscreen mode

    For our class selector here we have used a common practice to help with CSS scoping. Imagine we had just called this class container. It's a pretty common term, what if we have a container somewhere else on the site? The styles of that container class would overlap and mix unintentionally with these ones.

    I've chosen to prefix the class name with the name of the parent card with two underscores between. This is a common practice based on a methodology called BEM or block-element-modifier.

    Essentially it's just a way of naming things to avoid unintentional collisions between unrelated elements. There are many different ways of doing this, you should choose whatever feels right to you as you gain more experience.

    The property itself padding: 16px will create a buffer of space inside the border of the element. This keeps the text from pressing up against the edge of the box border, and makes things look a lot cleaner.

    Now finally with all properties applied, or styling for this example is done. Take a look:

    CSS Example 3

    What else do I need to know about CSS?

    The "cascade" is how CSS decides which styles actually get applied to an element when multiple different rules are applying values to the same property.

    The box model describes the way every element in CSS is rendered on the page and all the factors (padding, margin, border) etc that go into deciding its size and how it flows with the rest of the content.

    Flexbox is one of the most popular ways of laying out content on a web page. Modern browsers will support Grid which is even more powerful for full 2D layouts, but any modern CSS developer must understand Flexbox when contributing to web projects professionally:

    Media queries are used to change which CSS styles are applied depending on what media the user is using to view it. Most commonly used to change styles for mobile devices.

    There are many different units in CSS (px, em, rem, etc) and it's important to understand the difference between them.

    What are the best free resources for learning CSS?

    Javascript

    What is Javascript?

    Javascript is a programming language, originally developer to run code in web browsers to make pages more interactive. Since then its potential usages have expanded significantly, however for the purposes of this tutorial, web page manipulation is the use we are going to focus on.

    How do I use Javascript?

    There are a lot of ways to use Javascript. If you just want to write your very first code you can do so in a matter of seconds. THe quickest and easiest place to write and run Javascript code is directly in your web browser.

    Hit the F12 button to open up the browser's development console (alternatively you can look for a "Dev Tools" option in your browser's settings menu).

    It will open be an attached bar, on either the bottom or the right side of the browser window (depending on the browser). You will see a number of tabs across the top, these values will vary between browsers, but all the major ones (Edge / Firefox / Chrome) will have a tab called console as highlighted in the below screenshot.

    Browser Console

    Within the browser's console you can type and run any code you like. We'll begin by running the simplest possible Javascript code, the traditional "hello world!" program. Type the following into your browser's console and hit enter:

    console.log("hello world!");
    
    Enter fullscreen mode Exit fullscreen mode

    Your output should match what you see in the screenshot above. Below the code the text "hello world!" is printed out. Your code asked for the browser's console to use its log method and print out the "hello world!" string (a string is a sequence of text characters).

    Strings are a primitive value in Javascript. A type of data that is built-in and supported by the language. Another example is the number data type. You can read more about primitive data types here if you like.

    Now as you can probably imagine, very few people write their Javascript directly in the browser console. For many reasons, but the simplest of which is that the code is gone as soon as you close your browser. We'd like to be able to write some Javascript that sticks around! To do that we need the HTML </code> tag.</p> <p>Before we return to our code from the previous section, let's use the simplest example we can. Create an <code>index.html</code> file that looks like the following:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight html"><code><span class="cp"><!DOCTYPE html></span> <span class="nt"><html</span> <span class="na">lang=</span><span class="s">"en"</span><span class="nt">></span> <span class="nt"><head></span> <span class="nt"><meta</span> <span class="na">charset=</span><span class="s">"UTF-8"</span> <span class="nt">/></span> <span class="nt"><title></span>My First Javascript Project<span class="nt"></title></span> <span class="nt"><script></span> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="dl">"</span><span class="s2">hello world!</span><span class="dl">"</span><span class="p">);</span> <span class="nt">

    My Javascript Test Page

    Enter fullscreen mode Exit fullscreen mode

    Notice that we have included some Javascript code in the </code> tag? Try opening up your page on your local web server and checking your result. You should see the "My Javascript Test Page" text from the <code>body</code> as expected, but if you open your browser console again you will see your message.</p> <p>Just as before, using the <code>console.log</code> function we have instructed out browser to print the "hello world!" string in the console.</p> <p><a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ReM_SuU1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/0FSQgNi.png" class="article-body-image-wrapper"><img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ReM_SuU1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/0FSQgNi.png" alt="Javascript Test Page" loading="lazy" width="370" height="255"></a></p> <p>Great, but there's still one final step. Similar to CSS, although originally the standard was to write Javascript code directly in your HTML, at some point everyone realized that it made more sense to separate it into its own file. Let's look at how to load a Javascript file into our site.</p> <p>Begin by creating a <code>script.js</code> file (again the filename doesn't matter, you can call it anything you like as long as it ends with a <code>.js</code> extension):</p> <p><code>script.js</code><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight javascript"><code><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="dl">"</span><span class="s2">hello world!</span><span class="dl">"</span><span class="p">);</span> </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>And then update your HTML file:</p> <p><code>index.html</code><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight html"><code><span class="cp"><!DOCTYPE html></span> <span class="nt"><html</span> <span class="na">lang=</span><span class="s">"en"</span><span class="nt">></span> <span class="nt"><head></span> <span class="nt"><meta</span> <span class="na">charset=</span><span class="s">"UTF-8"</span> <span class="nt">/></span> <span class="nt"><title></span>My First Javascript Project<span class="nt"></title></span> <span class="nt"><script </span><span class="na">src=</span><span class="s">"script.js"</span><span class="nt">>

    My Javascript Test Page

    Enter fullscreen mode Exit fullscreen mode

    Notice how our </code> tag changed:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight html"><code><span class="nt"><script </span><span class="na">src=</span><span class="s">"script.js"</span><span class="nt">>

    Enter fullscreen mode Exit fullscreen mode

    The src attribute is the filename and path of the file that you want to load.

    Save both files and refresh your index.html page. You'll see once again that "hello world!" appears in the console, but this time the code is being loaded in from the .js file.

    At this point you now have the knowledge of how to set up a working Javascript environment and run any code you like. Of course this is only the tip of the iceberg, the ocean of JS is very deep, but the wonderful thing is that you can even as a beginner you can accomplish a lot with just a little.

    Teaching the Javascript language itself is beyond the scope of this tutorial (I would highly recommend MDN's tutorial as usual for that) but we will take the time to explore just a little bit deeper into some of the most common use cases.

    One of the main usages of Javascript is for manipulating the DOM. The DOM is a term you will come across frequently in web development and it can be a little confusing at first, but we'll make sure to describe exactly what it is in the next section, and how you can use that knowledge to make your web pages more interactive.

    The DOM

    What is the DOM?

    The DOM stands for Document Object Model and most simply put it just means the actual structure of the page built by your browser when following the instructions described by your HTML.

    Think of your HTML file as the blueprints of a house, and the DOM as the house itself.

    You can use a single set of blueprints (HTML) to build as many houses (pages in the browser) as you want. Maybe in one of those houses you might choose to change the colour of the exterior paint from white to blue. This change of paint colour would be analogous to what Javascript does.

    When you change the paint colour of your house you change it on the house itself, you don't necessarily update the blueprints to say "all houses must be blue." Similarly, when you use Javascript to change the background colour of your page, you are changing it on the DOM and it's updating the background colour of the page in your browser. It's not changing the HTML file itself.

    The DOM is represented in the browser as a tree structure. Don't worry if that looks confusing, you've already used the structure before when writing your HTML. Your elements have a hierarchy and elements can be nested inside of other elements. This represents the tree structure. All elements (except for the element) have a parent element.

    How do I view the DOM?

    Browsers make it very easy to take a look at the DOM directly. Open up your web page again and right click on the "My Javascript Test Page" text. You will se an option to Inspect. This option is available on all browsers.

    Browser Inspect

    Inspecting the element will open up the dev tools console, but this time it will default to the DOM tab (it may be called "Elements" or "Inspector" depending on your browser.) Here you can see the DOM structure that has been built by your browser based on the instructions provided by the HTML.

    DOM Example

    With a simple page it is likely that the DOM structure will look identical to your HTML file. This isn't absolutely necessary though. We could have some Javascript that changed the DOM structure after it has built so that it no longer looks the same. Let's try that now.

    Click on the Console tab of your browser's dev tools like we did before so that we can write some Javascript. This time, instead of using the console.log function we are going to call a different function.

    All browsers provide Javascript with an interface for interacting with the DOM through code. You can change, add, remove, clone, and generally just do almost anything you can think of with the elements on the page.

    First type the following code into the browser console and press enter:

    document.querySelector("p");
    
    Enter fullscreen mode Exit fullscreen mode

    When you hit enter you will see the result of your code directly below, it looks like a little

    element.

    Query Selector

    Let's break this line down and see exactly what it's doing:

    • document - This is a Javascript variable provided by the browser. It represents a reference to the page you are currently looking at (for example in your current tab). You can use it to find out all kinds of information, for example the width of the user's page, the current URL, and many more. In this example we are using it so we know which specific page to search for the element we want to change.

    • querySelector - Is a function that exists on the document. It's an incredibly powerful function that allows you to use CSS Selectors that we have already learned about to target particular elements on our page with Javascript. It's great because it lets you leverage skills you already learned in CSS and apply them to Javascript.

    • "p" - in this context "p" is a Javascript string that represents our CSS selector. As you may remember, just p on its own is a tag selector. Our goal is to select the

      element on our page. Although this is a very simple one, you can use any kind of CSS Selector you like. For example document.querySelector("#example") is a valid function that would get a reference to any element with id="example" that exists in the DOM.

    So when you combine the three of these together you get a Javascript function that searches the DOM for a

    element and returns it to you (if there is more than one

    element on the page it will return the first one it finds, starting from the top and moving down the tree).

    Once you have that reference you have the ability to modify it. As we mentioned before we just want to change the content that is inside of the tag, the text that says "My Javascript Test Page".

    When you ran the querySelector function in your console you got that little

    element returned on the next line. If you haven't done so already click on it. You might be overwhelmed at first by try not to be. There are far more options and bits of information on a DOM node than the average developer will ever need. Just let them wash over you like background noise.

    Look for one called innerText that should have a string version of the text that we put inside of our

    element. This is the one we are going to update to change our page.

    (In case you are wondering why we chose innerText instead of innerHTML, which looks exactly the same at a glance, the answer is that if you are just working with text (like we are) rather than adding new HTML, then innerText is safer (though both would technically work). More information here if you are curious)

    DOM innerText

    So now that we know the element that we want to change, how do we change it? When we run our querySelector we get that

    element back, but we don't know how to change it yet.

    There are a number of options available, but this would be a good opportunity to introduce the concept of variables. You can use variables to store information in your program that you will need at a later time.

    Let's demonstrate how to save a reference to our

    DOM node in a variable:

    var myParagraph = document.querySelector("p");
    
    Enter fullscreen mode Exit fullscreen mode

    This is the same code as before, except this time we have declared a variable that we've named myParagraph and set it equal to the paragraph node in the DOM. This gives us an easy way to reference and make changes to that node.

    To bring it all together, the code to update our paragraph node on our page looks like this.

    var myParagraph = document.querySelector("p");
    myParagraph.innerText = "My Updated Javascript Test Page";
    
    Enter fullscreen mode Exit fullscreen mode

    (If you're wondering about the name of the myParagraph variable, Javascript uses a naming convention called camelCase. This is not mandatory, but is considered a best practice.)

    You can run it in the console yourself to see:

    Updating the DOM

    Now that we've seen how we can interact with the DOM, let's move this code over to our script.js file so that it runs every time we load the page. With this in place you will essentially never see the "My Javascript Test Page" text, since the script will run immediately on page load and replace it with the "My Updated Javascript Test Page" text.

    There are two necessary steps. First, update your script.js file:

    script.js

    var myParagraph = document.querySelector("p");
    myParagraph.innerText = "My Updated Javascript Test Page";
    
    Enter fullscreen mode Exit fullscreen mode

    And a reminder that your index.html should look like:

    index.html

    
     lang="en">
      
         charset="UTF-8" />
        </span>My First Javascript Project<span class="nt">
        <span class="na">src=</span><span class="s">"script.js"</span><span class="nt">>
      
      
        

    My Javascript Test Page

    Enter fullscreen mode Exit fullscreen mode

    If you load the page now, even though this is the same code we used in the console, you'll notice that it doesn't work! Why not?

    The reason it doesn't work in this case is because of the oder we are running it in. In the console we were running our document.querySelector function in the console after the page had finished loading.

    If you look at our index.html file above, imagine you are the browser parsing the file from the beginning and working your way down. You will get to the </code> element and run that <code>.js</code> file before you've even reached and created the <code><p></code> element. So the <code>querySelector</code> runs, finds nothing, and then its done its job. Nothing is telling it to run again after the page has loaded.</p> <p>There is a very easy fix for this, all we need to do is instruct out <code><script></code> element to hold off and wait to run that code until the page has finished loading. We use the <code>defer</code> attribute for this. Update your <code><script></code> element to:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight html"><code><span class="nt"><script </span><span class="na">defer</span> <span class="na">src=</span><span class="s">"script.js"</span><span class="nt">>

    Enter fullscreen mode Exit fullscreen mode

    And try refreshing the page again., you should see "My Updated Javascript Page" as expected as soon as the page is loaded.

    At this point you now have a very basic familiarity with Javascript, including how to run your code and some of the ways it can be used to manipulate DOM nodes on your page (remember that _DOM nodes is just the term used to describe HTML elements that have been built into a page in the browser)_

    The last section in our Javascript introduction will go through an example of using Javascript to solve a real-world problem you might encounter.

    We'll continue where we left off at the end of the CSS section with our "Animal Blog" and the cool little card that we created.

    How do I add Javascript to a website?

    Let's say we've been tasked with adding some new functionality to our animal blog. We want people to be able to "like" the images of cats that we are adding to our blog. A user need to be able to interact and make a change to our element, so we recognize immediately that it's a perfect use case for Javascript.

    First we will pull up our previous example. In case you don't have it handy, we need three files:

    • index.html
    • style.css
    • script.js

    index.html

    
     lang="en">
      
         charset="UTF-8" />
        </span>My Animal Blog<span class="nt">
         rel="stylesheet" href="style.css" />
        <span class="na">defer</span> <span class="na">src=</span><span class="s">"script.js"</span><span class="nt">>
      
    
      
        
          

    My Favourite Animals

    Enjoy these furry friends

    class="card"> src="https://res.cloudinary.com/dqse2txyi/image/upload/v1657421273/blogs/intro-to-web-development/cat_k4fcww.png" alt="Cat Playing Chess" /> class="card__container">

    Chess Cat

    He's planning his next move.

    onCLick="likeButton()">Like

    © 2022

    Enter fullscreen mode Exit fullscreen mode

    style.css

    body {
      color: #333333;
      font-family: Helvetica, sans-serif;
      margin: auto;
      max-width: 800px;
    }
    
    main {
      margin-bottom: 40px;
    }
    
    header,
    footer {
      text-align: center;
    }
    
    h1 {
      font-family: Arial, sans-serif;
    }
    
    h2 {
      font-style: italic;
      font-weight: lighter;
    }
    
    .card {
      width: 350px;
      margin: auto;
      box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
      border-radius: 10px;
      overflow: hidden;
    }
    
    .card > img {
      width: 100%;
      height: auto;
    }
    
    .card__container {
      padding: 16px;
    }
    
    Enter fullscreen mode Exit fullscreen mode

    At the moment we don't have any content in our script.js file, leave it empty for now.

    There is a single difference between this file and the final versions of the examples at the end of our CSS section, in index.html we have added a Like button inside the card:

    Like
    
    Enter fullscreen mode Exit fullscreen mode

    When you serve the page in your browser you'll see it rendered:

    Animal Blog With Button

    Of course at this point clicking it does nothing. In order to connect some Javascript to our button, first we have to write a Javascript function, give it a name, and finally attach it to our button.

    A function is essentially a block of JS code that you don't want to run right away. Another common use for functions is to create blocks of code that you might want to run more than once. Both are great reasons to create a function.

    There are a number of ways to create functions as the JS language has evolved over many years. Here for simplicity we will teach the traditional method that works in all browsers. Later as you get more comfortable you can learn about the various shorthand forms.

    script.js

    function likeButton() {
      alert("Like button has been pressed");
    }
    
    Enter fullscreen mode Exit fullscreen mode

    When you load your script.js file, the code inside of this function block (the code between the curly braces) is not run right away. You have to first call the function (sometimes called invoke) which basically means "run the code inside the function when i tell you to". The syntax in Javascript to call a function is the function name followed by open and closed parentheses.

    So calling our likeButton function would look like:

    likeButton();
    
    Enter fullscreen mode Exit fullscreen mode

    The alert function is another built-in browser function like console.log, but this time instead of printing a string to the console, it pops it up in your face with one of those annoying pop up messages. Great for testing, but never ever use them for a real site.

    So now that we have this function declared, we can update the element in index.html to call the function whenever the button is click. We learned the syntax for calling the function, so the final thing we need to learn is how to connect them. We do that with the HTML onclick attribute.

    The onclick attribute is available and most any elements in HTML, but for accessibility reasons you want to aim to use it primarily on elements that are designed to be click (like buttons or links).

    We can tell our

    in our index.html file to run the function when it is clicked by updating it like so:

     onclick="likeButton()">Like

    Enter fullscreen mode Exit fullscreen mode

    As you can see, inside of the onclick attribute we can technically write any Javascript code that we want. Even as much as you want (separated by semicolons) although that gets very messy very fast, and is considered bad practice. If you want a button to perform multiple tasks, put them all into a function and simply call that function.

    When we load our page and click the like button we are greeted with:

    Press Like Button

    Excellent! Our page is interactive now. If your button does not work try some common troubleshooting tips:

    • Verify your script.js is being loaded in index.html like
    • Verify that you've saved all your files after editing them
    • Check your spelling and case. Javascript is case sensitive so onclick and likeButton are very particular.
    • Make sure you are calling the function: it's onclick="likeButton()" and not onclick="likeButton"

    At this point we've verified that we can create a function, and call it by clicking a button. That's fantastic progress. The next step is to update the button to show it has been "liked".

    Here is the code for your script.js file. Remove the old function and replace it with the following.

    script.js

    var likes = 0;
    
    // Adds 1 to the number of likes, and updates the text of the button
    function likeButton() {
      likes = likes + 1;
    
      var myButton = document.querySelector("button");
      myButton.innerText = "👍 " + likes;
    }
    
    Enter fullscreen mode Exit fullscreen mode

    Let's break down each piece above to see what it does:

    var likes = 0;
    
    Enter fullscreen mode Exit fullscreen mode

    We create a new variable named likes that stores a number. This number keeps track of how many likes our animal picture has received so far. By default we will start at zero.

    // Adds 1 to the number of likes, and updates the text of the button
    
    Enter fullscreen mode Exit fullscreen mode

    This is something we haven't used yet, it's an extremely common part of programming called a comment. They are used to provide information to other team members (or yourself in the future) looking at your code to help explain what the code does.

    You do not need to add comments for every line, the vast majority of code (if you use descriptive variable names like likes = 0 rather than x = 0) will be self-descriptive. Comments would only serve to add bloat. Reserve your comments for code that is less easy to understand fro ma quick glance, or to describe the entirely of what a function does as we have above.

    Comments are supported in HTML, Javascript and CSS. Each one uses a slightly different syntax:

    • HTML
    • CSS /* This is a comment */
    • Javascript // This is a one-line comment
    • Javascript /* This is a comment that can span multiple lines */

    In the real world most developers, particularly senior level developers, will actually spend more of their time reading code than writing it, so good commenting and clean formatting are essential.

    function likeButton() {
    
    Enter fullscreen mode Exit fullscreen mode

    This creates a function called likeButton. The code inside the curly braces will not be run when the .js file is loaded, but we can call the likeButton() function at a later time to run the code when we choose.

    likes = likes + 1;
    
    Enter fullscreen mode Exit fullscreen mode

    This takes out likes variable and increments it by one. THe new value is equal to the current value plus one. The first time the button is pressed it will become one (0 + 1). The second time two (1 + 1) etc.

    var myButton = document.querySelector("button");
    
    Enter fullscreen mode Exit fullscreen mode

    As we learned in the introduction, document.querySelect uses CSS selector syntax to search for elements on a page. This will save a reference to the first it finds, so it's operating on the very fragile assumption that we only have one.

    If you were to add more buttons in the future you would need to return and refactor (update) this code. One option would be to add a class, say

    Like. You could then target that specific button with the CSS class selector like so: document.querySelector(".like-button"). Notice the . prefix indicating it's a class selector.

    For the moment however, the Like button is our only button, and this code gets the job done just fine.

    myButton.innerText = "👍 " + likes;
    
    Enter fullscreen mode Exit fullscreen mode

    The final piece here is what updates the text inside the button itself. We update and replace the innerText of the button with a thumbs up emoji, then we use the + operator to concatenate the value of the likes variable onto the end of the string.

    This can be a bit tricky for newcomers as the + operator is being used for something other than math. It depends on the context. If you have two numbers on either side like 1 + 1 then Javascript will evaluate that as a math operation and return a value of 2.

    If either one of those values is a string (or both) then Javascript will instead treat them both like strings and concatenate them together. So "hello" + 1 would evaluate to "hello1". It's one of those fun quirks of the language that becomes second nature after awhile, but it certainly does cause some confusion when first learning. The best way to become comfortable with it is simply repetition and practice.

    So for our example, if the button has been clicked once, then "👍 " + likes will be the same as "👍 " + 1 which will be evaluated as "👍 1" and that's the string that will be placed as the innerText of our button.

    Of course we won't know until we try it out. Load the page with the updated Javascript, and start mashin' that like button!

    script.js

    var likes = 0;
    
    // Adds 1 to the number of likes, and updates the text of the button
    function likeButton() {
      likes = likes + 1;
    
      var myButton = document.querySelector("button");
      myButton.innerText = "👍 " + likes;
    }
    
    Enter fullscreen mode Exit fullscreen mode

    Like Button Complete

    How many likes can you get to before your hand gets tired? Congratulations, you've created the world's most uninteresting game.


    At this point we will bring our discussion on Javascript to a close. We've only just scratched the surface of what's possible, but I hope you've got enough of an introduction and confidence to begin branching out and trying new things.

    Remember don't be afraid to mess around. Copy and paste from the internet. Come up with crazy ideas and try to build them. Keep it small to start so you don't get overwhelmed, but don't be afraid to fail.

    Javascript isn't something you just "learn" and then you're done. It's an ongoing process that will probably continue for your entire career. I've been writing Javascript for six years now, and I learned something new while writing this complete beginner's tutorial.

    The best thing you can do in your development journey is keep your mind constantly open to learning new things and improving.

    What are the best free resources for learning Javascript?

    Kyle Simpson's digital book series You Don't Know JS is the gold standard for deep diving into learning all the ins and outs of the language. Highly recommend, and totally free to red online

    Written by Douglas Crockford, creator of the JSON data format, this book distills all the important stuff about the Javascript language you need to know. This is the first book I ever read about JS, and I give it a lot of credit for helping teach me the fundamentals (ok I guess this one isn't free, but it's good):

    For a quick reference for all things JS, there is no better resource than:

    Node.js

    What is Node.js

    Node.js is a program that can run Javascript code outside of a browser.

    It is one of the main reasons why Javascript has become one of the most popular programming languages in the world.

    With Node, you are no longer restricted to requiring a web browser open to run your Javascript code. You can write Javascript for things like renaming photos on your computer, or sending automated emails, or even full blown desktop applications with tools like Electon.

    To try Node yourself, simply follow the instructions on the site and download and install it. Once installed you should be able to open a command line terminal and type:

    node --version
    
    Enter fullscreen mode Exit fullscreen mode

    And get an output like v16.13.2 depending on what the latest version is when you installed it.

    To you is you simply type node followed by a Javascript file. Here's a simple example, I'll create a file called script.js in the directory we are currently in:

    script.js

    console.log("Hello world!");
    
    Enter fullscreen mode Exit fullscreen mode

    Now save it and run this command:

    node script.js
    
    Enter fullscreen mode Exit fullscreen mode

    You will see "Hello world!" appear on your terminal.

    It's as simple as that. The applications just get bigger and more complex from there.

    (Note that because your code isn't running in the browser, you will not have access to some of the common browser-specific APIs you might be familiar with. For example document.querySelector which returns a DOM node -- something that doesn't make much sense without the context of a browser)

    One of the most common uses of Node.js is to build web servers. It's very popular because it allows you to write both your website (front-end) and web server (back-end) which provides the necessary data for the front-end both in Javascript.

    Although you can write your whole web server entirely with code specific to Node itself, to simplify the process most people use a library like Express.

    What are the best free resources for learning Node.js?

    There are tons of great resources on learning Node.js out there, and they're free!

    • MDN will introduce you to Node and cover building a simple web server with a tool called Express

    • The Odin Project full free curriculum for teaching Node.js and Express

    • Node.js Crash Course great YouTube video series on Node.js from The Net Ninja

    Command Line Terminal

    If you are going to be working in any kind of web development job, you're going to need to become familiar with the command line terminal. Many of the programs you will use don't have a graphical interface and are designed to be run on the terminal.

    Fortunately you don't need to be an expert, and this tutorial will go through the basic commands you need to know.

    How do I use the command line terminal?

    How you access the terminal will depend on your system. If you are on Mac or Linux it'll be called "Terminal", on Windows you might choose to use PowerShell which is very similar. PowerShell comes bundled with Windows automatically, you can find it in your start menu.

    Or you can download something like Git bash which comes included when you install Git and will give you a unix-style terminal even if you are using Windows.

    I'll be using bash for this tutorial. Even if you are using PowerShell on Windows most of the commands will be the same or similar.

    When you open your terminal it will look something like this:

    Terminal Example

    Most terminals will show the directory directory you are in on the left. Right now I am in the ~ directory which is an alias for my "home" directory. On Windows it would be something like c:\Users\YOUR_NAME on Linux it might be something like /home/YOUR_NAME.

    Let's create a new folder called example-folder.

    mkdir example-folder
    
    Enter fullscreen mode Exit fullscreen mode

    That will create example-folder in your home directory. Now let's "change directory" into that folder with:

    cd example-folder
    
    Enter fullscreen mode Exit fullscreen mode

    Protip: use the tab key to help autocomplete when working on the terminal. It's one of the most powerful shorthands you'll be able to use for efficiency (and avoiding spelling errors).

    Our terminal directory is now in the folder we just created. Let's create a file!

    touch hello.txt
    
    Enter fullscreen mode Exit fullscreen mode

    (This one will be different on PowerShell, you'll need to type New-Item hello.txt).

    Terminal Example 2

    If you navigate to that folder in your graphical interface you'll be able to see it has been created!

    Now let's go back to the terminal and take a look at the contents of this folder.

    ls
    
    Enter fullscreen mode Exit fullscreen mode

    That command means "list" and lists the contents of the directory. You should see your hello.txt file show up.

    That's enough of that file, we can delete it with:

    rm hello.txt
    
    Enter fullscreen mode Exit fullscreen mode

    Run ls again and should be gone.

    Let's return to the parent directory.

    cd ..
    
    Enter fullscreen mode Exit fullscreen mode

    The two dots ".." is a shorthand for "parent directory" and a single dot "." is a shorthand for "this directory".

    Finally let's remove that folder we created.

    rmdir example-folder
    
    Enter fullscreen mode Exit fullscreen mode

    And that's the absolute basics of navigating around on the command line. You're now at least equipped with the ability to navigate between folders which is one of the most common operations you will use.

    What else do I need to know about the command line terminal?

    Make sure you understand the difference between absolute and relative paths. This is not just for the command line, you'll need to understand the different when writing your code as well. You often need to import "modules" from other files and you need to describe to the editor where to find those files.

    Get familiar with one of the command line text editing tools so that you can quickly make changes to text and code files without having to boot up VS Code. I prefer Nano for quick edits but there are lots of options including emacs, vi, and more.

    (If your terminal opens files in vi and you can't figure out how to get out, type escape then :q. Quitting vi is one of those rights of initiation for anyone working in a terminal).

    You'll want to know how to open up the help pages for any program you are using. Say you just installed git but have no idea how to use it. Depending on your platform it will either be:

    man git
    
    Enter fullscreen mode Exit fullscreen mode

    OR

    git --help
    
    Enter fullscreen mode Exit fullscreen mode

    You can replace git with the name of whatever program you are trying to learn about. Usually one of the other will get you what you want. The man command stands for "manual" and is intended to open up the manual.

    What are the best free resources for learning the command line terminal?

    The Odin Project command line basics

    The Art of the Command Line beginner's tutorial

    Unix/Linux Command Cheatsheet

    Git

    What is Git?

    What is a Version Control System (VCS)?

    Having a good understanding of Git is critically important for working in almost any software job. I'd go so far as to say that if you company doesn't use it (or at least an equivalent version control tool) you may want to consider another position.

    It's that important to a healthy software lifecycle. So for that reason I want to make sure I explain it well, because despite its important, it can be very daunting to learn and understand for a beginner who isn't used to thinking this way.

    Git is a version control system which is a fancy way of saying that it's a tool for taking snapshots of data at a certain point in time.

    If you've ever worked on a file and made a copy of it called Resume.doc and Resume-backup.doc and Resume-FINAL.doc etc then you can imagine why a tool like Git might need to exist.

    It works for any kind of file and is not specific to coding or software development, although that's where it's most commonly used.

    Software developers and teams use it for two primary purposes:

    1. To create a saved state at a certain point in time in case an issue comes up later and changes need to be reverted back to how they used to be, for one file or many files.

    2. To allow multiple developers to work on files in a project at the same time, in the same directory and often even the same file. Git keeps track of who is making changes where, and helps you resolve and merge those changes together, ideally automatically without any input from the people making the changes at all.

    For example, if you have a big Javascript file called my-code.js with 1000 lines, developer A could make edits to line 200, and developer B could make edits to line 300. Afterward they would perform a Git command called merge and Git would take care of combining the separate changes both devs made on their lines on their individual files into a single file with both changes.

    There are a number of ways to use Git, the most common is through the command line terminal but there are many tools out there designed to make it easier to use. See this section for more info.

    Let's take a quick look at how you can use Git

    How do I use Git?

    First you need to install it on your machine. Check out this link for instructions on how to install depending on what operating system you are on.

    You will know you are successful when you are able to open a command line terminal and type:

    git --version
    
    Enter fullscreen mode Exit fullscreen mode

    You should see a response like git version 2.35.1 or whatever version is currently the newest when you install yours. If it says anything like command "git" not found then you need to double check your installation. Sometimes you need to close and re-open your terminal for newly installed programs to be visible.

    Now I am going to create a new folder. You can create it anywhere that you like as long as you know how to navigate to it in your terminal. You can make it with the mkdir git-example command or you can just "Create New Folder" with your mouse and call it git-example.

    Git Example 1

    After the folder is created open up your editor (I'll be using VS Code) and go File -> Open Folder and find that folder you just created.

    You can see I have my VS Code terminal open there, it will automatically navigate you to the folder you have open. To open your terminal you can use ctrl + ~ or simply use the menu with View -> Terminal.

    Just before we get started you'll want to run the following command:

    git config --global init.defaultBranch main
    
    Enter fullscreen mode Exit fullscreen mode

    If you are on a newer version of git the default branch will already be named main, but if you are on an older version it will be called master. This command just makes sure that your defaults match what we will be using for this tutorial.

    The first command you will always need to use if you are creating a new "repository" (the name for a collection of folders and files tracked by the git program). The command is:

    git init
    
    Enter fullscreen mode Exit fullscreen mode

    You will receive a message that says Initialized empty Git repository in... with your folder path. That means git-example directory is now a git repository. Any files or folders created within that directory can be tracked as part of your "project".

    Note that if you join an existing project/team, you will not need to initialize Git. When you clone a copy of their work it will already have been initialized for you, we only need to git init when we are creating a new project ourselves from scratch.

    Now let's create a new file called sample.txt. To create a new file in VS Code simply right click on the left side under git-example and New File. Inside it I'm going to add some text, quite literally the phrase "Some example text".

    Now I will introduce you to a couple of the first git commands you should learn, git add and git commit.

    • git add: Will tell git to add new files to "track" in your project. Presuming that you want to keep track of every file in the directory (this is very common) then you can simply use the . character which in most terminals is a shorthand for "this directory". So git add . means "add all files in this directory to my git project.

    • git commit: Will tell git that you want to save a snapshot of all tracked files at this current moment. Most commonly you will also include the -m flag which means "message". A commit message is a description of the changes you have made since the last time you committed.

    (Worth noting that you can create a file called .gitignore in the root directory of your project and put the names of any files and directories you don't want to include in your repository, so even if you run the add . command those files will not get added. Useful if you have things like environment files that contain secrets and passwords you don't want to upload publicly with the rest of your code)

    With that new knowledge in mind our commands will be as follows:

    git add .
    git commit -m 'initial commit'
    
    Enter fullscreen mode Exit fullscreen mode

    Git Example 2

    You might be able to come up with a better message than that, though it's a common one for the first commit on a project. The common standard for commit message is to write your message as if it follows the start of the sentence "When applied, this commit will...".

    So an example would be "change the primary button colour to blue". So that is the format you should use rather than something like "I changed the primary button to blue". Consistent subject and tense makes commit messages in large projects much easier to read and understand.

    (If you want to get really deep down the rabbit hole, you can encourage your team to adopt something like conventional commits which applies strict rules about how commit messages are written.)

    So now that you have created your first commit, let's learn how to create another one, and navigate back and forth through time and change the state of our project.

    Add another line to your sample.txt file. Something like "Some more text" on the next line below the first line. Doesn't matter what the text says, we just want to update the file.

    Now run these commands again:

    git add .
    git commit -m 'add a new line of text'
    
    Enter fullscreen mode Exit fullscreen mode

    Technically the git add in this scenario does nothing since we didn't create any new files, but it's not a bad habit to get into as normally creating new files in projects is common, and you want to make sure you add them unless they are being explicitly excluded.

    Git Example 3

    Now that you have two commits, and two "saved" states of your project, you can go back to one if you need to. Let's say that you just want to "see" how things were before, but not actually lose your newest changes.

    Start with this command:

    git log
    
    Enter fullscreen mode Exit fullscreen mode

    If will show you a list of all your commits, with their messages, and a unique string character hash (purple arrow points to in image below) that you can use as an identifier. Note that yours will not be the same as mine, they are randomly generated.

    Git Example 4

    To go back to that state simply type:

    git checkout YOUR_COMMIT_HASH_HERE
    
    Enter fullscreen mode Exit fullscreen mode

    So in my case it would be git checkout c849819c6f45ef72429abc36b1ee3891c3ede779 but that value will be different for you.

    Git Example 5

    This brings us back to the first commit we did, notice that the content of your sample.txt doesn't have the second line you added. It's not gone, we are simply looking at a different state of the project in the timeline.

    At any point you wish to return to the most up to date state just use:

    git checkout main
    
    Enter fullscreen mode Exit fullscreen mode

    In this context main is the name of the branch you are on. If you have been following this tutorial you will have set your default branch to main at the start. You can always double check what branch you are currently on by typing git status.

    Branching is a critically important part of git. The idea of branching is that you create a separate place to track changes, outside of the main branch that acts as the central source of truth for your project. For example, whenever you release a new version of your website or app, that release is almost always done off main.

    If you are working on a new feature on a separate branch, those changes won't be released when the main branch is released. Only when you merge the changes from your branch into main will those changes actually be included in the main product.

    I'm not going to get into branching for this tutorial, but make sure that you are at least familiar with it before you apply for your first role. You can learn more about git branching here.

    So at this stage, if you have learned the basics of add, commit, log and checkout (to switch between branches).

    That covers most of the fundamentals you need to know to work with git locally as a solo developer.

    But as you've probably heard, git is also used to track changes in a project between developers working on different machines. How does it do that? Well that's where additional tools like Github come into play.

    What is the difference between Git and Github?

    A common source of confusion for new developers is the difference between git and Github.

    Git is a free open source program that runs on your computer and helps keep track of file changes within a project.

    Github is a website owned and operated my Microsoft that hosts git repositories online so that you can have access to your files wherever you go and share them with other developers. Think of it like Dropbox with a bunch of extra features specifically designed around working with git repositories.

    Github will always have a "copy" of your Git repository and whenever you like you can use git commands like push and pull to synchronize changes you've done on your computer with the ones hosted on Github.

    If you are working by yourself it can simply act as a backup system, and help you track issues and to-do's within your project.

    If you are working with other developers then it will act as the central location where all changes made by all team members are pushed to and synchronized.

    Let's show an example of working with a repository on Github. I'm going to create one locally and show you how to move it up to Github from the command line so that other developers can download or even contribute code to it.

    First I am going to make a new project from the command line:

    mkdir example-git-project
    cd example-git-project
    git init
    
    Enter fullscreen mode Exit fullscreen mode

    Then I am going to copy the files I created for the tutorials we did on HTML, CSS and Javascript.

    If you did not complete those tutorials, don't worry, you don't actually have to understand HTMl, CSS or Javascript for this. We're not even going to run that code, we are simply trying to save a copy of it remotely where other devs can view it.

    You can copy the three files directly from the Basic Website Example section.

    (Don't worry about what they do, that's not the focus of this tutorial, we are simply trying to show how to push those files to your remote repository.)

    After adding those files, run these commands to add them and make your first commit for this project:

    git add .
    git commit -m 'first commit'
    
    Enter fullscreen mode Exit fullscreen mode

    When complete your example-git-project directory should look like this:

    Git Example 6

    Now we are ready to move this project up to Github.

    If you don't already have a Github account, create one now.

    Once you have an account and are logged in, navigate to "Your repositories" and then look for the green "New" button to create a new repository.

    Git Example 7

    Create a project following this basic template, give it a name and a description. The name does not have to match the same folder name you used when you created your local repository, but it helps if you want to avoid confusion between the two.

    Make sure it is set to public if you want other people to be able to view and contribute to the code.

    Once it is created you will get a screen that looks like the below. It will include all the commands that you need, the only difference will be that they will use your Github username rather than mine that you see in the screenshot:

    Git Example 8

    All the commands you need are now visible on the screen for you. We would like to push the repository we created on our computer to this remote repository.

    The first step is to tell git on our machine that this repository we created is the remote version of our repository. To do that we run the following command:

    git remote add origin YOUR_REPOSITORY_URL
    
    Enter fullscreen mode Exit fullscreen mode

    This command tells git to create a new remote with the name origin. The URL that you use will depend on how you have Github setup. You can use either an HTTPS or an SSH URL. SSH is normally preferred but you will likely want to go through the What is SSH section first to set it up if you are not familiar.

    (The long and short of it is that HTTPS will require you to enter your username and password every time you interact with the Github repository. Setting up SSH means you don't need to do that because the auth key will exist on your machine and be provided automatically.)

    Once you have added the remote repository you can confirm it is correct with this command:

    git remote get-url origin
    
    Enter fullscreen mode Exit fullscreen mode

    Git Example 9

    You can see the highlighted text in the above example that the origin is correct for the repository I just created.

    With that complete you are ready to upload your code. To do that we use the git push command. Push says to "push the current state of my local repository to a remote one."

    The first time you do this to a new repository you have to state what remote branch you want to push your current local branch to. In almost all cases this is simply a remote branch with the same name. The command looks like this:

    git push -u origin main
    
    Enter fullscreen mode Exit fullscreen mode

    Where -u stands for upstream. In this example we are on the main branch, but if you were working for another branch called cool-feature for example, the command would instead be git push -u origin cool-feature.

    You only need to do this once, from now on just typing git push will default to pushing to the same upstream branch unless you change it.

    Once this push command has been run you should see some upload status messages in your command line, and when you next refresh your Github repository URL it will look like this:

    Git Example 10

    Seeing this indicates you have successfully made your first Github push. Congratulations!

    You can now share your Github URL with other people (or even yourself on other machines) and they can instantly get a copy of this project.

    Feel free to try it yourself. CLick the green "code" button and then copy the repository URL from there. Create a totally branch new directory anywhere on your machine and run this command:

    git clone YOUR_GITHUB_URL
    
    Enter fullscreen mode Exit fullscreen mode

    Where YOUR_GITHUB_URL is the URL of your repository. In my case it's git clone [email protected]:alexeagleson/example-git-project.git.

    When the command finishes you will have an exact copy of your repo with all the files you added and committed in this new directory elsewhere on your machine. You can make changes and commit them to update the remote repo with the git add, git commit and git push commands same as always.

    This applies to other developers on other machines as well!

    There's certainly more to learn, but just having these basics down will position you very strongly for using git effectively with any large project at your company.

    What else do I need to know about Git?

    Important topics you should make sure to learn about include:

    Branching

    Working With Remote Repositories like Github for example

    Merging

    What are the best free resources for learning Git?

    The Git Book

    The Odin Project curriculum on Git basics

    Learn Git Branching is a little interactive game that is great for teaching you more about the concept of branching

    Oh my Git! an open-source game designed to help people learn git.

    The Github documentation will teach you how to use git and Github at the same time.

    APIs

    What is an API?

    API stands for application programming interface and (in context of web development) it has become basically a catch all term for any system that your code communicates with outside of the code.

    The reason that we need an API is because we never want to gives users direct access to your data. Imagine you had a social network that displayed things like name, age, etc about your users.

    If you let browsers request that raw data directly, they could also choose to display things like password, or credit card numbers, or any other sensitive data that your app might have stored for one reason or another.

    Those are extreme examples but the fact is that even if something isn't critically sensitive, most of the time we want to protect our data and only share it with those people who should have access to it.

    For that reason we create APIs. I will allow my web server direct access to all my data, and then the app that is running in the browser may "request" some of that data. My web server will decide if the app / user requesting it should have access to that data, and return it if so, or return an error if not.

    A front-end developer needs to know how to read from an existing API. That might mean one developed by back-end developers on their team at their company, or even publicly available ones on the internet.

    There are many public APIs out there you can start working with when building an app. Some popular ones include the open weather API, the PokeAPI, and the cocktail API.

    These services allow you to query data and display it in your app. Regardless of what type you are working with you usually need to authenticate yourself to use them due to the fact that internet bandwidth is not free, so every time you query for data there is a cost associated with that being paid by whoever is hosting the API. (Most of them do offer free tiers for low traffic apps though.)

    If you are a back-end developer you will be responsible for creating the APIs. This means you will write the code for them in a language like Javascript, or other common back-end languages like C#, Java, Go, Python, or Rust.

    How do I create an API?

    You can create an API very easily with just Javascript and NodeJS. Make sure you have read those sections and are familiar with those tools first.

    Open up VS Code and start a new blank project. Create a single file called my-api.js with the following contents:

    my-api.js

    const http = require("http");
    
    const host = "localhost";
    const port = 8000;
    
    const requestHandler = function (req, res) {
      res.setHeader("Content-Type", "application/json");
      res.writeHead(200);
      const weatherData = { toronto: { temp: 30, humidityPercent: 80 } };
      const weatherDataString = JSON.stringify(weatherData);
      res.end(weatherDataString);
    };
    
    const server = http.createServer(requestHandler);
    server.listen(port, host, () => {
      console.log(`Listening at http://${host}:${port}`);
    });
    
    Enter fullscreen mode Exit fullscreen mode

    The first line loads the built-in HTTP module in Node.js.

    Next we define variables to set the host and post that our server will run on.

    The requestHandler is a function which is designed to take two arguments, variables that represent the request and response of an HTTP message. The values in these variables are populated by the Node HTTP module whenever requests are made to your server.

    Inside the function we call built in Node HTTP methods like setHeader and writeHead to begin crafting the response and HTTP status codes.

    If you do not understand these concepts please take the time to read up on web servers.

    Next we save some imaginary API data into the weatherData variable. In a real API this data was likely fetched from a database which itself was populated by data from some kind of hardware device like a digital thermometer. Web servers are not an appropriate place to store data since all data is lost when they are rebooted or shut down, hence why we need databases.

    For our simple example though we are just creating some dummy data as an example. This data represents an imaginary weather server response from someone who has made a request to our server for the current weather in Toronto, Ontario, Canada.

    The weatherData object is then converted into a string so that it can be sent over the network. weatherDataString is converted into JSON, a textual string representation based on Javascript objects (hence the name).

    Since it's just text, it does not technically require Javascript to use, any language can output data in JSON format. You can convert a Javascript object to a JSON string with the JSON.stringify() function.

    Finally the end method is what we call when we are done settings the headers and ready to return the data to the device which is making the request to our API.

    Let's give it a try!

    Save your my-api.js file and open the command line terminal in the same directory as your .js file and run this command:

    node my-api.js
    
    Enter fullscreen mode Exit fullscreen mode

    You will see the output Listening at http://localhost:8000

    Open up your browser and go to [http://localhost:8000] to get a response that looks like:

    API Example

    Depending on your browser it may look slightly different since different ones format JSON responses in different ways, but either way, there you have it!

    Remember that the primary purpose of most APIs is to send raw data so websites and web apps can be built using that data. Rather than actually displaying it raw like we do here your app would realistically query that URL using Javascript with something like the fetch method and then display it on the screen wrapped in some pretty HTML and CSS.

    What are the best free resources for learning APIs?

    If you simply want to learn about the concept of APIs, why they are needed and how they are designed here's a fantastic Stack Overflow response and discussion on the topic that covers all the fundamentals.

    For more information of building your own API (at least from a Javascript perspective) check out the resources listed in What are the best free resources for learning Node.js?

    Libraries and Package Management

    What is a library?

    What is a package?

    In the context of web development, a library (also sometimes called a package, or even a framework in different contexts) is typically used to refer to "someone else's Javascript code" that you download from the internet and add to your code.

    Libraries are a necessary and fundamental part of building websites and web applications. Without them it would require us to re-write the same basic code over and over again each time we start a new project.

    To give a very simple example:

    
      
        <span class="na">src=</span><span class="s">"https://cdn.jsdelivr.net/npm/[email protected]/lodash.min.js"</span><span class="nt">>
      
      
         id="p-tag">hello world

    </span> <span class="kd">var</span> <span class="nx">pTag</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="dl">"</span><span class="s2">p-tag</span><span class="dl">"</span><span class="p">);</span> <span class="nx">pTag</span><span class="p">.</span><span class="nx">innerText</span> <span class="o">=</span> <span class="nx">_</span><span class="p">.</span><span class="nx">startCase</span><span class="p">(</span><span class="nx">pTag</span><span class="p">.</span><span class="nx">innerText</span><span class="p">);</span> <span class="nt">
    Enter fullscreen mode Exit fullscreen mode

    In the above example we are loading the popular lodash Javascript library from a CDN inside the </code> tag.</p> <p>That loads all the Javascript code from that library. Lodash (hence the name) stores its functions on a variable whose name is just the underscore character.</p> <p>We then use Javascript to grab the <code><p></code> element by its ID and replace its lowercase "hello world" text with the return value of Lodash's <code>startCase</code> function. The <code>startCase</code> function transforms any string so the first letter of each world is capitalized.</p> <p>There is no built-in Javascript function which does this (only all lowercase or uppercase) so either we write one ourselves, or simply add this library to do it for us.</p> <p>Of course there are many other considerations you need to be aware of, this whole library for example has a lot more code in it than just the <code>startCase</code> function so it might slow your websites average load time down.</p> <p>Everything in web development is a trade-off so you and your team always need to consider the pros and cons when making a decision.</p> <h2> <a name="what-is-a-package-manager" href="#what-is-a-package-manager"> </a> What is a package manager? </h2> <h2> <a name="what-are-npm-and-yarn" href="#what-are-npm-and-yarn"> </a> What are NPM and Yarn? </h2> <p>NPM is something called a "package manager" and it's a tool that is automatically installed on your system when you install <a href="#what-is-node-js">Node.js</a>.</p> <p>Make sure you don't confuse NPM the tool (which you run on your command like like <code>npm install PACKAGE_NAME</code>) and NPM the online repository that stores those packages which you can explore at <a href="">https://www.npmjs.com/</a>. They both have the same name, but can mean one or the other depending on context you are talking in.</p> <p><a href="https://yarnpkg.com/">Yarn</a> is an alternative to NPM you can install on your system which works very similarly. For a beginner you will not notice any difference between Yarn and NPM, so I would only recommend you try it if you are curious, or if your project/company is using it.</p> <p>You can create a branch new NPM project in an folder with this command:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>npm init </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>After the project has been initialized you will see a <code>package.json</code> file which describes all the libraries and packages your project has access to. You can add a new one anytime from the command line like so:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>npm install PACKAGE_NAME </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>Where <code>PACKAGE_NAME</code> is the name of the package listed on <a href="">https://www.npmjs.com/</a>.</p> <p>You would learn what functions are available to use from the library in the example above) typically by reading the library's documentation.</p> <p>That documentation may exist right on the NPM page, or it might be on the Github source code for the project, or most commonly at the project's official website.</p> <p>Here's an example of the <a href="https://api.jquery.com/">API documentation for the jQuery library</a>.</p> <p>Let's take a look at a practical example using the <code>lodash</code> package.</p> <p>Create a new folder in the terminal, navigate to it and run the following commands:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>npm init npm <span class="nb">install </span>lodash </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>Remember you can replace <code>lodash</code> with any other library you find on the <a href="https://www.npmjs.com/">NPM registry</a>. That is the source for Javascript packages, and after running the <code>npm install</code> command you will be able to use them in your code as follows if you create a fill called <code>script.js</code>:</p> <p><code>script.js</code><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight javascript"><code><span class="kd">const</span> <span class="nx">_</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="dl">"</span><span class="s2">lodash</span><span class="dl">"</span><span class="p">);</span> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">_</span><span class="p">.</span><span class="nx">startCase</span><span class="p">(</span><span class="dl">"</span><span class="s2">hello world</span><span class="dl">"</span><span class="p">));</span> </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>The above will print the start-case'd "Hello World" to the console when you run <code>node script.js</code>.</p> <p>Remember that libraries available on NPM are public and free to use, so don't hesitate to play and experiment!</p> <h1> <a name="databases" href="#databases"> </a> Databases </h1> <h2> <a name="what-is-a-database" href="#what-is-a-database"> </a> What is a database? </h2> <p>In the context of web development, a database is simply the location where your website or web app will store its data. Basically a fancy hard drive that is accessible over the internet.</p> <p>The main difference between and standard hard drive and a database is that a database assumes you will be accessing data constantly and will be optimized to provide ways to search for that data extremely quickly.</p> <p>A database uses a concept called <em>indexes</em> which are exactly like you would expect if you're familiar with the index of a large book, a list of terms or keys that it creates to identify the exact location of information based on certain criteria (an index on text data might be <em>alphabetical</em> for example).</p> <p>Databases used on the web are usually classified into one of two categories: relational and non-relational (also often called SQL and NoSQL).</p> <p><em>(SQL stands for "structured query language" and is usually pronounced as "sequel", but some people prefer S-Q-L.)</em></p> <p>Some examples of popular relational databases are <em>MySQL, PostgreSQL, and Microsoft SQL Server</em>. An example of a popular NoSQL database is <em>MongoDB</em>.</p> <p>If you are just learning then deciding which one to use and learn makes little difference, either option will introduce you at least to the fundamentals of working with databases including <em>indexes, schemas, creates, reads, updates, and deletes</em>.</p> <p>Typically the responsibility for working with databases will fall on the back-end developer. The front-end developer will have little to no direct exposure to the database.</p> <p>The backend developer will be responsible for creating an <em>API</em> (see also <a href="#what-is-an-api">What is an API?</a>), which is basically code that reads information from the database and transforms it into a shape that the front-end client can use.</p> <p>If your back-end is written in Javascript, then the developer would write Javascript code that uses an <a href="https://www.npmjs.com/package/mysql">NPM package that gives them access to the database</a> and write SQL queries that are sent to Javascript functions and then onward to the database.</p> <p>Let's say that you want to build a page that shows current in-stock levels for a website that sells plants.</p> <p>In your database you have a <em>table</em> which contains both the name of each plant your store carries and the number that are in stock.</p> <p><em>(If you've used Microsoft Excel or Google Sheets before then you can think of a database as very similar, just significantly more powerful and able to store and process orders of magnitude more data.)</em></p> <p><em>(Typically in a real relational database the items and stock levels would be in separate tables and marked with an ID number, a process called normalization, but we are keeping it simple for now)</em></p> <p>A SQL query to get plant name and inventory information for plants that are <strong><em>currently in-stock</em></strong> might look something like:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight sql"><code><span class="k">SELECT</span> <span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">num_in_stock</span><span class="p">)</span> <span class="k">FROM</span> <span class="n">plants</span> <span class="k">WHERE</span> <span class="n">num_in_stock</span> <span class="o">></span> <span class="mi">0</span><span class="p">;</span> </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>Where <code>plants</code> is the name of the table and <code>name</code> and <code>num_in_stock</code> are the names of the columns that contain the data inventory data.</p> <p>Once this data is returned the back-end developer writes more code to provide an API <em>endpoint</em> that the website can send requests to in order to get that plant inventory data and display it on the page.</p> <p>An <em>endpoint</em> is simply an URL identifier designed to provide specific data, for example <code>https://www.myplantstore.com/inventory</code>.</p> <p>It's important to understand that the website itself cannot query the database directly, because to do so would require you to include the login and password of your database on the website, which would then be accessible to everyone. It wouldn't long for someone (or some bot) to gain access and control of your database.</p> <p>So one of the reasons we create and use an API is to provide a very specific interface via URL that only allows data to be requested from certain trusted sources, and is only programmed to return specific types of data.</p> <p>Maybe we also store customer names and addresses in the database, but as long as we don't write code on our back-end to query that data and provide an interface for it to be accessed, then it will be safe as long as nobody (except those with permission) have direct access to the database.</p> <p>Ultimately all you need to remember as a front-end developer is that a database is a place to permanently store data for your web app, and the back-end developer is responsible for providing you (the front-end dev) access to specific parts of it that you need in order to build your app.</p> <h2> <a name="how-do-i-use-a-database" href="#how-do-i-use-a-database"> </a> How do I use a database? </h2> <p>This question can be interpreted in a few different ways. Someone working as a DBA (database administrator) would interpret this question as <em>How do I install and setup a database?</em> likely including follow up questions like <em>what kind of data will I need to store?</em>, <em>should it be SQL or NoSQL?</em>, <em>how much data and traffic am I expecting?</em> etc etc etc.</p> <p>As a back-end developer you might <em>may or may not</em> need to include yourself in these discussions. Usually it depends on the size of the company. In small companies back-end developers often find themselves playing the role of the DBA as well as developing the <a href="#what-is-an-api">API</a>. At large companies that is less likely to be the case.</p> <p>The way we are going to answer this question is specifically on the software development side since that is the focus of this tutorial. In most cases a database will already be set up for you, and your job will be to develop an API that can query it, maybe process the data a bit, and then return it to the user (usually front-end dev) in a shape that aligns with their needs to display it on a page to the user.</p> <p>For our example we will be using a fantastic and user friendly SQL database which is totally free called <a href="https://www.sqlite.org/index.html">SQLite</a>. All the basic queries you would use for managing data in SQLite like <em>SELECT</em>, <em>INSERT</em>, <em>CREATE TABLE</em> etc are the same as you would use when working in all the industry standard SQL databases like MySQL, PostgreSQL etc.</p> <p>SQLite has bindings for Node.js, which is a fancy way of saying your can just install it as an NPM package and get up and running in seconds.</p> <p>We can create our SQLite database in one of two ways: either create it right in the code when the program loads (called doing it "in memory") or load up the database from a file on your computer.</p> <p>Loading from a file mimics a real world use case a little closer, but requires some more configuration so we'll be doing it in memory in this example. If you want to learn how to load the database from a file here's a <a href="https://www.sqlitetutorial.net/sqlite-nodejs/">tutorial you can check out</a>.</p> <p>As we have learned already in the <a href="#what-is-an-api">what is an API?</a> section, an API typically involves a web server that acts as a middleman between a website/app and a database. So we are going to extend the example we showed in the API section to now include querying from a database.</p> <p>We'll begin by navigating on our command line to the folder containing the <code>my-api.js</code> file from the <a href="#how-do-i-create-an-api">How do I create an API?</a> example and run the following command:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>npm init </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>Go through the question prompts with all the defaults then run:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>npm install sqlite3 </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p><em>(If you aren't sure what we are doing here you may need to revisit the <a href="#what-is-a-package-manager">What is a package manager?</a> section)</em></p> <p>Next, update the <code>my-api.js</code> as follows:</p> <p><code>my-api.js</code><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight javascript"><code><span class="c1">// Database setup</span> <span class="c1">// 1</span> <span class="kd">const</span> <span class="nx">sqlite3</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="dl">"</span><span class="s2">sqlite3</span><span class="dl">"</span><span class="p">).</span><span class="nx">verbose</span><span class="p">();</span> <span class="kd">const</span> <span class="nx">db</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">sqlite3</span><span class="p">.</span><span class="nx">Database</span><span class="p">(</span><span class="dl">"</span><span class="s2">:memory:</span><span class="dl">"</span><span class="p">);</span> <span class="c1">// 2</span> <span class="nx">db</span><span class="p">.</span><span class="nx">serialize</span><span class="p">(()</span> <span class="o">=></span> <span class="p">{</span> <span class="c1">// 3</span> <span class="nx">db</span><span class="p">.</span><span class="nx">run</span><span class="p">(</span><span class="dl">"</span><span class="s2">CREATE TABLE weather (city TEXT, temp INTEGER)</span><span class="dl">"</span><span class="p">);</span> <span class="c1">// 4</span> <span class="kd">const</span> <span class="nx">stmt</span> <span class="o">=</span> <span class="nx">db</span><span class="p">.</span><span class="nx">prepare</span><span class="p">(</span><span class="dl">"</span><span class="s2">INSERT INTO weather VALUES (?, ?)</span><span class="dl">"</span><span class="p">);</span> <span class="nx">stmt</span><span class="p">.</span><span class="nx">run</span><span class="p">(</span><span class="dl">"</span><span class="s2">toronto</span><span class="dl">"</span><span class="p">,</span> <span class="mi">30</span><span class="p">);</span> <span class="nx">stmt</span><span class="p">.</span><span class="nx">run</span><span class="p">(</span><span class="dl">"</span><span class="s2">vancouver</span><span class="dl">"</span><span class="p">,</span> <span class="mi">50</span><span class="p">);</span> <span class="nx">stmt</span><span class="p">.</span><span class="nx">finalize</span><span class="p">();</span> <span class="p">});</span> <span class="c1">// Web server config</span> <span class="kd">const</span> <span class="nx">http</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="dl">"</span><span class="s2">http</span><span class="dl">"</span><span class="p">);</span> <span class="kd">const</span> <span class="nx">host</span> <span class="o">=</span> <span class="dl">"</span><span class="s2">localhost</span><span class="dl">"</span><span class="p">;</span> <span class="kd">const</span> <span class="nx">port</span> <span class="o">=</span> <span class="mi">8000</span><span class="p">;</span> <span class="kd">const</span> <span class="nx">requestHandler</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">res</span><span class="p">)</span> <span class="p">{</span> <span class="nx">res</span><span class="p">.</span><span class="nx">setHeader</span><span class="p">(</span><span class="dl">"</span><span class="s2">Content-Type</span><span class="dl">"</span><span class="p">,</span> <span class="dl">"</span><span class="s2">application/json</span><span class="dl">"</span><span class="p">);</span> <span class="nx">res</span><span class="p">.</span><span class="nx">writeHead</span><span class="p">(</span><span class="mi">200</span><span class="p">);</span> <span class="c1">// 5</span> <span class="kd">let</span> <span class="nx">requestedCity</span> <span class="o">=</span> <span class="dl">""</span><span class="p">;</span> <span class="k">switch</span> <span class="p">(</span><span class="nx">req</span><span class="p">.</span><span class="nx">url</span><span class="p">)</span> <span class="p">{</span> <span class="k">case</span> <span class="dl">"</span><span class="s2">/toronto</span><span class="dl">"</span><span class="p">:</span> <span class="nx">requestedCity</span> <span class="o">=</span> <span class="dl">"</span><span class="s2">toronto</span><span class="dl">"</span><span class="p">;</span> <span class="k">break</span><span class="p">;</span> <span class="k">case</span> <span class="dl">"</span><span class="s2">/vancouver</span><span class="dl">"</span><span class="p">:</span> <span class="nx">requestedCity</span> <span class="o">=</span> <span class="dl">"</span><span class="s2">vancouver</span><span class="dl">"</span><span class="p">;</span> <span class="k">break</span><span class="p">;</span> <span class="p">}</span> <span class="c1">// 6</span> <span class="nx">db</span><span class="p">.</span><span class="kd">get</span><span class="p">(</span> <span class="dl">"</span><span class="s2">SELECT * from weather WHERE city = ?</span><span class="dl">"</span><span class="p">,</span> <span class="c1">// 7</span> <span class="p">[</span><span class="nx">requestedCity</span><span class="p">],</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">row</span><span class="p">)</span> <span class="o">=></span> <span class="p">{</span> <span class="c1">// 8</span> <span class="kd">const</span> <span class="nx">weatherDataString</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">stringify</span><span class="p">(</span><span class="nx">row</span><span class="p">);</span> <span class="nx">res</span><span class="p">.</span><span class="nx">end</span><span class="p">(</span><span class="nx">weatherDataString</span><span class="p">);</span> <span class="p">}</span> <span class="p">);</span> <span class="p">};</span> <span class="c1">// Web server start</span> <span class="kd">const</span> <span class="nx">server</span> <span class="o">=</span> <span class="nx">http</span><span class="p">.</span><span class="nx">createServer</span><span class="p">(</span><span class="nx">requestHandler</span><span class="p">);</span> <span class="nx">server</span><span class="p">.</span><span class="nx">listen</span><span class="p">(</span><span class="nx">port</span><span class="p">,</span> <span class="nx">host</span><span class="p">,</span> <span class="p">()</span> <span class="o">=></span> <span class="p">{</span> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">`Listening at http://</span><span class="p">${</span><span class="nx">host</span><span class="p">}</span><span class="s2">:</span><span class="p">${</span><span class="nx">port</span><span class="p">}</span><span class="s2">`</span><span class="p">);</span> <span class="p">});</span> </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>This is getting a bit more complex, so I'll added a few numbered comments I'll refer to below explaining what is going on here. I do not include any explanations for the web server code since it was covered in the <a href="#apis">APIs</a> section already.</p> <ol> <li>Load the <code>sqlite3</code> package that we installed from NPM. What this literally means "look at the <code>package.json</code> file in the <code>node_moudles/sqlite3</code> directory and see if there is a field called "main" which tells me the location of a Javascript file to start loading and running code from. The next line creates a new SQLite database based on the classes defined in that JS file, and <code>:memory:</code> tells it we will be creating the DB from memory and not from a file.</li> <li> <code>serialize</code> is an SQLite function that means "run all the commands inside this function one at a time making sure each one finishes before the next one starts".</li> <li>Standard SQL syntax for creating a table.</li> <li>Prepare an <code>INSERT</code> statement to add data into our database. We prepare the statement first since the statement itself doesn't change, only the values we are inserting (represented by the <code>?</code> character). Once this is finalized and run we will have two rows in our database, one for each <code>run</code> function called, with temps for Toronto and Vancouver.</li> <li>We jump ahead to the point after our web server has been initialized. We introduce one new concept to our server itself and that's <a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-routes.html">routing</a>. I wanted the user to be able to define which city they want the weather for, rather than getting every single city every time, which is a waste of resources. <code>req.url</code> will have the route portion of the request, so if the URL is <code>http://localhost:8000/toronto</code> then <code>req.url</code> will be <code>/toronto</code>. We then save that city data into a variable called <code>requestedCity</code>.</li> <li>Next we invoke the <code>get</code> function on our SQLite database and run a basic <code>SELECT</code> SQL query for the data. The <code>?</code> in the statement is replaced with the value in our variable which presumably will be either <code>toronto</code> or <code>vancouver</code> (or fail if the user requests anything else). It's important that we use the <code>?</code> syntax to insert the variables that came from the user. Remember that all user provided data must be considered potentially malicious, so using prepared statements and the <code>?</code> substitution instead of directly concatenating the value onto the strings to help project against <a href="https://developer.mozilla.org/en-US/docs/Glossary/SQL_Injection">SQL injection</a> attacks.</li> <li>This array is where the variable values are taken from to replace the <code>?</code> characters in the strings. There should be exactly as many values in this array as there are <code>?</code> characters in your statement.</li> <li>The query result is returned inside of this variable we've called <code>row</code> because it represents a row in your database <code>weather</code> table. If you're not familiar with this syntax here (the function as an argument that takes <code>row</code> and <code>err</code> as arguments) it's called a <a href="https://developer.mozilla.org/en-US/docs/Glossary/Callback_function">callback function</a> and it's one of the more challenging topics to learn as a new Javascript dev, so don't worry if you don't get it right away. This <code>row</code> is returned as an object so we can <code>JSON.stringify()</code> it and return it as the payload for our HTTP request.</li> </ol> <p>Let's give it a try! Boot up your web server with:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>node my-api.js </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>Visit <a href="">http://localhost:8000/toronto</a> in your browser to GET the weather from Toronto that is saved in your database! Try changing the route to <code>/vancouver</code> and see what happens as well!</p> <p><a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dM-BGfIu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/dqse2txyi/image/upload/v1662323831/blogs/intro-to-web-development/api2_a7bggg.png" class="article-body-image-wrapper"><img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dM-BGfIu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/dqse2txyi/image/upload/v1662323831/blogs/intro-to-web-development/api2_a7bggg.png" alt="API Database Example" loading="lazy" width="454" height="179"></a></p> <p>This example here provides you with a really solid introductory example of what a "day in the life" is like of a backend developer. You'll likely be writing SQL statements, creating and updating tables in databases, writing code to query tables in the database and returning that data to users by creating "endpoints" using routes that follow a specific set of rules you control for how data is accessed and who is allowed to access it through <a href="https://en.wikipedia.org/wiki/Authentication">authentication</a> and <a href="https://en.wikipedia.org/wiki/Authorization">authorization</a>.</p> <h2> <a name="what-are-the-best-free-resources-for-learning-databases" href="#what-are-the-best-free-resources-for-learning-databases"> </a> What are the best free resources for learning databases? </h2> <p><a href="https://www.sqlitetutorial.net/sqlite-nodejs/">SQLite Tutorial for Node.js</a> to keep going further with the Node.js based exmaple of working with SQL beyond what we've done so far.</p> <p><a href="https://university.mongodb.com/">MongoDB Univeristy</a> for those devs going the NoSQL route, MongoDB is one of the most popular databases in that space (particularly in the Node and Javascript world) and one you are likely to encounter at some point in your career.</p> <p><a href="https://www.khanacademy.org/computing/computer-programming/sql">Khan Academy's Introduction to SQL</a> includes videos and tutorials on everything SQL</p> <p><a href="https://www.youtube.com/user/CS186Berkeley/videos">CS 186 Berkeley</a> an amazing free course that covers pretty much everything you need to know about databases as a back-end developer</p> <p><a href="http://www.redbook.io/">The Red Book</a> the classic book on database theory available to read free online. Although it's extremely comprehensive, it's also fairly academic and probably more than the majority of back-end developers will need. Recommended when you have all the basics down and are ready to dive deeper into the fundamentals.</p> <h1> <a name="front-end-frameworks" href="#front-end-frameworks"> </a> Front End Frameworks </h1> <h2> <a name="what-is-a-front-end-framework" href="#what-is-a-front-end-framework"> </a> What is a front end framework? </h2> <p>New developers often hear that they "need to learn a framework" in order to get a job, and that of course begs the question: <em>"What is a framework?"</em>.</p> <p>There is no one-size-fits-all answer to that. Many people have different definitions, but the simplest one in the context of Javascript and web development is that it is <em>a library/package that provides structure and opinions on how you should organize your code, and typically also provides tools and helper functions to build the code itself.</em></p> <h2> <a name="what-are-react-angular-vue-svelte-and-jquery" href="#what-are-react-angular-vue-svelte-and-jquery"> </a> What are React, Angular, Vue, Svelte and jQuery? </h2> <p>Popular front end frameworks in the web development world include <em>React, Angular and Vue</em>. These tools are chosen because they provide much better ways of building and managing re-usable code templates for UI elements than the native browser does.</p> <p>To give an example, you could create a <a href="https://reactjs.org/">React</a> component called <code>Card</code> which includes <code><h2></code>, <code><p></code> and <code><img></code> tags wrapped in a <code><div></code>. It is created as a Javascript function that takes an object as an input argument with text/links to fill in those values. Once built you now have a "component" you can use like an HTML tag in the format <code><Card></code> over and over to build, for example, a page with a list of employee profiles.</p> <p>The language used to build these components is called <code>JSX</code> and is basically a mix of HTML and Javascript. Here's an example of how the <code>Card</code> we just described would look in React:</p> <p><em>(In the below example, <code>props</code> is a Javascript object with three properties: url, title, and text, each of which are strings)</em></p> <p><code>Card.jsx</code><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight jsx"><code><span class="k">export</span> <span class="kd">const</span> <span class="nx">Card</span> <span class="o">=</span> <span class="p">(</span><span class="nx">props</span><span class="p">)</span> <span class="o">=></span> <span class="p">{</span> <span class="k">return</span> <span class="p">(</span> <span class="p"><</span><span class="nt">div</span><span class="p">></span> <span class="p"><</span><span class="nt">img</span> <span class="na">src</span><span class="p">=</span><span class="si">{</span><span class="nx">props</span><span class="p">.</span><span class="nx">url</span><span class="si">}</span> <span class="p">/></span> <span class="p"><</span><span class="nt">h2</span><span class="p">></span><span class="si">{</span><span class="nx">props</span><span class="p">.</span><span class="nx">title</span><span class="si">}</span><span class="p"></</span><span class="nt">h2</span><span class="p">></span> <span class="p"><</span><span class="nt">p</span><span class="p">></span><span class="si">{</span><span class="nx">props</span><span class="p">.</span><span class="nx">text</span><span class="si">}</span><span class="p"></</span><span class="nt">p</span><span class="p">></span> <span class="p"></</span><span class="nt">div</span><span class="p">></span> <span class="p">);</span> <span class="p">};</span> </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>Then using your custom component on your website/app looks like:</p> <p><code>App.jsx</code><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight jsx"><code><span class="p"><</span><span class="nt">div</span><span class="p">></span> <span class="p"><</span><span class="nc">Card</span> <span class="na">url</span><span class="p">=</span><span class="s">"www.example.com/steven.png"</span> <span class="na">title</span><span class="p">=</span><span class="s">"Steven Lastname"</span> <span class="na">text</span><span class="p">=</span><span class="s">"Steven is a wonderful employee!"</span> <span class="p">/></span> <span class="p"><</span><span class="nc">Card</span> <span class="na">url</span><span class="p">=</span><span class="s">"www.example.com/nancy.png"</span> <span class="na">title</span><span class="p">=</span><span class="s">"Nancy Lastname"</span> <span class="na">text</span><span class="p">=</span><span class="s">"Nancy is here to help!"</span> <span class="p">/></span> <span class="p"></</span><span class="nt">div</span><span class="p">></span> </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>Each framework has different levels of how opinionated they get. For example React is a lot more flexible as to how you set up your file structure, but it provides very strict rules about how its components are built.</p> <p><a href="https://angular.io/">Angular</a> is also very opinionated about how components are structured, but much more than React enforces a particular directory and file structure within your project as well.</p> <p><a href="https://vuejs.org/">Vue</a> and <a href="https://svelte.dev/">Svelte</a> are much less opinionated in that regard.</p> <p>Another one you may have heard of is <a href="https://jquery.com/">jQuery</a>. In its heyday, jQuery was te go-to JS tool for providing additional functions that made creating and updating the DOM (the elements on your website) much easier. Much of the reasons developers no longer reach for it is that many of its functions have now been implemented into the Javascript built-in standard itself (for example <code>document.querySelector</code> for DOM manipulation and <code>fetch</code> for AJAX calls), so the language would not be what it is today without jQuery having paved the way.</p> <h2> <a name="what-is-a-css-framework" href="#what-is-a-css-framework"> </a> What is a CSS framework? </h2> <h2> <a name="what-are-bootstrap-and-tailwindcss" href="#what-are-bootstrap-and-tailwindcss"> </a> What are Bootstrap and TailwindCSS? </h2> <p>A <em>CSS framework</em> is a term typically used to refer to packaged code that focuses on provided pre-written CSS rather than Javascript (though many CSS frameworks including Bootstrap also include Javascript code as well to provide additional functionality).</p> <p>Two popular CSS frameworks worth knowing about are <a href="https://getbootstrap.com/">Bootstrap</a> and <a href="https://tailwindcss.com/">TailwindCSS</a>.</p> <p>Both libraries focus on simplifying and reducing the amount of CSS you need to write, and creating systems to make things like margins, paddings and layout more consistent across your site so you don't need to build and implement your own design system.</p> <p>Bootstrap popularized the <em>12 column grid system</em> you'll see in many layout tools these days, for example using a CSS class like <code>col-3</code> to represent 3/12 (or 25%) of the screen.</p> <p>Bootstrap is far more opinionated of the two (and therefore a larger footprint in terms of size in your application) but provides some great defaults for developers who are not design savvy and prefer to focus on the function of their application. Bootstrap, similar to jQuery, was far more of a standard in the earlier days of web development as has gradually fallen out of favour, but you'll still find it commonly used in many applications still in operation today.</p> <p>TailwindCSS on the other hand has seen a massive rise in popularity in recent years mostly due to its small form factor and simple to use classes, as well as being easy to customize. Tailwind is a great choice for devs and designers who want to get a nice looking up up off the ground quickly, while still leaving room to customize it to your desired look and feel.</p> <p>If you want to really quickly get a feel for what using a CSS framework is like, the simplest way is to simply include the <code><link></code> tag example from the <code>Include via CDN</code> section on the front page of <a href="">https://getbootstrap.com/</a> in your <code>index.html</code> file and use the Bootstrap documentation to try out some of the different classes.</p> <p>Here's a super minimal example of a site that loads and uses bootstrap. The <code>class="btn btn-primary"</code> and other classes on buttons is what's hooking those elements into the Bootstrap styles.</p> <p><code>index.html</code><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight html"><code><span class="cp"><!DOCTYPE html></span> <span class="nt"><html</span> <span class="na">lang=</span><span class="s">"en"</span><span class="nt">></span> <span class="nt"><head></span> <span class="nt"><link</span> <span class="na">href=</span><span class="s">"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"</span> <span class="na">rel=</span><span class="s">"stylesheet"</span> <span class="na">integrity=</span><span class="s">"sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx"</span> <span class="na">crossorigin=</span><span class="s">"anonymous"</span> <span class="nt">/></span> <span class="nt"></head></span> <span class="nt"><body></span> <span class="nt"><button</span> <span class="na">type=</span><span class="s">"button"</span> <span class="na">class=</span><span class="s">"btn btn-primary"</span><span class="nt">></span>Primary<span class="nt"></button></span> <span class="nt"><button</span> <span class="na">type=</span><span class="s">"button"</span> <span class="na">class=</span><span class="s">"btn btn-secondary"</span><span class="nt">></span>Secondary<span class="nt"></button></span> <span class="nt"><button</span> <span class="na">type=</span><span class="s">"button"</span> <span class="na">class=</span><span class="s">"btn btn-success"</span><span class="nt">></span>Success<span class="nt"></button></span> <span class="nt"></body></span> <span class="nt"></html></span> </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p><a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Hyi7sfGy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/dqse2txyi/image/upload/v1662331134/blogs/intro-to-web-development/bootstrap_u1mszp.png" class="article-body-image-wrapper"><img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Hyi7sfGy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/dqse2txyi/image/upload/v1662331134/blogs/intro-to-web-development/bootstrap_u1mszp.png" alt="Bootstrap Example" loading="lazy" width="503" height="158"></a></p> <h2> <a name="how-do-i-use-a-front-end-framework" href="#how-do-i-use-a-front-end-framework"> </a> How do I use a front end framework? </h2> <h2> <a name="how-do-i-use-react" href="#how-do-i-use-react"> </a> How do I use React? </h2> <p>Once you have a strong grasp of the HTML/CSS/Javascript fundamentals, it's a good idea to get familiar with at least one framework (the most popular of which at the time of this writing is React).</p> <p>Kent C. Dodds has a good introduction on the <a href="https://kentcdodds.com/blog/javascript-to-know-for-react">specific Javascript you'll want to know for React</a> before diving in.</p> <p>I highly recommend you get yourself to a comfortable level with Javascript and understand all of the topics in the above link before you start. Many frustrations people often experience with React when starting with it too early are actually Javascript frustrations.</p> <p>The fastest and easiest way to start writing React is to use a pre-configured tool like <a href="https://reactjs.org/docs/create-a-new-react-app.html">Create React App</a> or <a href="https://vitejs.dev/">Vite</a>.</p> <p>Create React App (CRA) has been the de-facto standard for many years, also Vite has been picking up traction recently. From the perspective of a beginner learning the basics it won't make much of a difference. Let's start a react app with CRA using the following command on the command line:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>npx create-react-app@latest my-cool-app cd my-cool-app npm run start </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>Notice the first command is <code>npx</code> and not <code>npm</code>. The third argument is just the name of the app you want to make. The second command <code>cd</code> is to change into that directory when the installation is complete.</p> <p>Then when you run <code>npm run start</code> in that new directory you browser will be opened automatically and you'll be taken to <a href="">http://localhost:3000</a> where your new app is being served on. It should look like a big animated spinning atom with some title text describing how to edit your app.</p> <p>Create React App provides a "live reload" dev server which means that changes to your app will be reflected in the browser instantly, making it very easy to make changes to your app and quickly see and debug the results. Try making changes to the <code>src/App.js</code> file and seeing what happens!</p> <h2> <a name="what-else-do-i-need-to-know-about-react" href="#what-else-do-i-need-to-know-about-react"> </a> What else do I need to know about React? </h2> <p>You should know the difference between functional components and class components. Class components are still perfectly valid, though are considered the "old" way to doing things and all modern React features and syntax are designed primarily to support functional components moving forward.</p> <p>You should know what <a href="https://beta.reactjs.org/learn#using-hooks">hooks</a> are.</p> <p>You should know what <a href="https://beta.reactjs.org/learn/render-and-commit">rendering</a> a components means in the context of React.</p> <p>You should understand React <a href="https://beta.reactjs.org/learn/managing-state">state</a> and understand why React prefers to replace values rather than mutate (hint: it's to make it easier to keep track of when something changes to know when to update the <a href="#what-is-the-dom">DOM</a>)</p> <p>You should understand what a <a href="#https://beta.reactjs.org/learn/lifecycle-of-reactive-effects">lifecycle effect</a> and how you can use a hook like <code>useEffect</code> to watch values and trigger different actions/events when those values change.</p> <p>You should know what global state management solutions are and why people use them. This includes bu not limited to ReduX, MobX, Zustand, Recoil, etc (there's tons). You should also understand the Context API and when it does and <a href="https://blog.isquaredsoftware.com/2021/01/context-redux-differences/">doesn't act as a global state management tool</a>.</p> <h2> <a name="what-are-the-best-free-resources-for-learning-react" href="#what-are-the-best-free-resources-for-learning-react"> </a> What are the best free resources for learning React? </h2> <p><a href="https://dev.to/alexeagleson/understanding-the-modern-web-stack-react-with-and-without-jsx-31c7">My Blog Post on React</a> shameless plug for my blog post where I go into more detail into how to configure a React project from the group up to get a better understanding of what's going on</p> <p><a href="https://reactjs.org/docs/getting-started.html">Official Documentation</a> and <a href="https://beta.reactjs.org/">The Official Beta Docs</a> written by the React team should be your first source of information. The beta docs are quite new, but they are much improved and updated to use modern React syntax, so you should always check them first before falling back on the original docs if you can't find what you're looking for.</p> <p><a href="https://www.reactiflux.com/learning">Reactiflux</a> mark Erikson's (developer of Redux) suggested path for learning React.</p> <p><a href="https://www.codecademy.com/catalog/language/javascript">Codeacademy</a>'s React course.</p> <p><a href="https://www.roadtoreact.com/">The Road to React</a> by Robin Wieruch. Not a free resource I admit, though I felt I should include it because I did read it while learning React and think it was extremely helpful for improving my understanding.</p> <h1> <a name="typescript" href="#typescript"> </a> Typescript </h1> <h2> <a name="what-is-typescript" href="#what-is-typescript"> </a> What is Typescript? </h2> <h2> <a name="what-is-the-difference-between-typescript-and-javascript" href="#what-is-the-difference-between-typescript-and-javascript"> </a> What is the difference between Typescript and Javascript? </h2> <p>Typescript is an absolutely incredible programming language. It is largely responsible for adoption of Javascript to build large-scale business applications that might otherwise never have been possible or realistic without it.</p> <p><strong><em>Typescript is Javascript</em></strong>. That's one of those really critical things to realize.</p> <p>Typescript is just Javascript code with additional syntax added on top of it to check for correctness and potential errors while you are writing it that otherwise would not be caught until you actually run the program with standard Javascript.</p> <p>If you are proficient in Javascript, you still may not know how to write Typescript. However, if learn Typescript, then you also know Javascript as well. A good TS developer would be more than qualified for any JS job.</p> <p>It can be difficult to explain to new developers why Typescript is so important. Often they will find it frustrating that they cannot get code to work, or it feels too complex with little payoff.</p> <p>When it comes down to it, if you want to be employed as a web developer professionally, Typescript is unquestionably the way to go. You will severely limit your job prospects if you only learn JS.</p> <p>This is probably a good time to show an example of the difference between JS and TS:</p> <p><code>script.js</code><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight javascript"><code><span class="kd">function</span> <span class="nx">addNumbers</span><span class="p">(</span><span class="nx">a</span><span class="p">,</span> <span class="nx">b</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="nx">a</span> <span class="o">+</span> <span class="nx">b</span><span class="p">;</span> <span class="p">}</span> </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p><code>script.ts</code><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight typescript"><code><span class="kd">function</span> <span class="nx">addNumbers</span><span class="p">(</span><span class="nx">a</span><span class="p">:</span> <span class="kr">number</span><span class="p">,</span> <span class="nx">b</span><span class="p">:</span> <span class="kr">number</span><span class="p">):</span> <span class="kr">number</span> <span class="p">{</span> <span class="k">return</span> <span class="nx">a</span> <span class="o">+</span> <span class="nx">b</span><span class="p">;</span> <span class="p">}</span> </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>The first JS example is pretty simple. It takes two arguments, and adds them together. If you run the following:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight javascript"><code><span class="kd">const</span> <span class="nx">result</span> <span class="o">=</span> <span class="nx">addNumbers</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">);</span> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">result</span><span class="p">);</span> </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>The output will be <code>7</code></p> <p>What if we did the following though?<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight javascript"><code><span class="kd">const</span> <span class="nx">result</span> <span class="o">=</span> <span class="nx">addNumbers</span><span class="p">(</span><span class="dl">"</span><span class="s2">3</span><span class="dl">"</span><span class="p">,</span> <span class="dl">"</span><span class="s2">4</span><span class="dl">"</span><span class="p">);</span> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">result</span><span class="p">);</span> </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>What would the output be? The answer is the strong "34" because each argument was actually a string, so Javascript just assumed you meant "concatenate" when you used the plus sign.</p> <p>Next let's take a look at the second example above that was labelled as <code>script.ts</code>. It's the same function but the parameters are annotated as <code>number</code> and <code>number</code> also appears after the parentheses to indicate that the return value should also be a number.</p> <p>The screenshot below demonstrates what you would see when writing this using VS Code:</p> <p><a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EbSHoKTl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/dqse2txyi/image/upload/v1657081289/blogs/intro-to-web-development/typescript_n4m96n.png" class="article-body-image-wrapper"><img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EbSHoKTl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/dqse2txyi/image/upload/v1657081289/blogs/intro-to-web-development/typescript_n4m96n.png" alt="Typescript Example" loading="lazy" width="695" height="198"></a></p> <p>So although this is a simple example, you can immediately see one of the many benefits. Typescript has stopped us from making a simple syntax error and using our function incorrectly.</p> <p>Remember that even if you look at this and think <em>"I would never make such a simple mistake"</em>, in reality, when working on large projects for long hours <em>everyone</em> makes small stupid mistakes. All the time.</p> <p>And even if you don't, your coworkers will.</p> <p>Typescript is there to help you with a warning as soon as you make these errors so you can correct them and get back to working on your code.</p> <p>So that's great, but how do you actually use it? <code>.ts</code> files?</p> <p>Browsers do not understand Typescript. They only understand Javascript. So modern working setups are created to allow you to write Typescript code, but then <em>transpile</em> _convert) it into Javascript code when you are ready to run it.</p> <h2> <a name="how-do-i-use-typescript" href="#how-do-i-use-typescript"> </a> How do I use Typescript? </h2> <p>The easiest way to practice and learn it is with the <a href="https://www.typescriptlang.org/play">Typescript playground</a>.</p> <p>Once you move beyond that and want to start writing your own Typescript code on your machine, the most basic setup involves the following:</p> <ol> <li><p>First, install <a href="#what-is-node-js">Node.js</a> on your machine. This will automatically install <code>npm</code>.</p></li> <li><p>Next, create a folder for your project, then navigate to that folder on the command line and run <code>npm init</code>. Just hit enter to select all the defaults.</p></li> <li><p>Run the following command:<br> </p></li> </ol> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>npm <span class="nb">install</span> <span class="nt">--save-dev</span> typescript </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>That will install Typescript in your project as a "dev dependency". You should be able to see it listed with a version number in the <code>package.json</code> file that NPM created.</p> <ol> <li>Run the following command: </li> </ol> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>npx tsc <span class="nt">--init</span> </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p><em>(Note that's <code>npx</code> not <code>npm</code>. <code>npx</code> is a "package runner" which is different from your package manager. It can run packages that are installed in your project as code directly)</em></p> <p>This will create a <code>tsconfig.json</code> file which has all the configuration for your Typescript project. <a href="https://www.typescriptlang.org/docs/handbook/tsconfig-json.html">You can learn more about tsconfig.json here</a></p> <ol> <li>Create a <code>script.ts</code> file with any Typescript code you like in it. This file should be in the project root in the same directory as your <code>tsconfig.json</code>.</li> </ol> <p>You can use the example above with the <code>addNumbers</code> function if you like, code below:</p> <p><code>script.ts</code><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight typescript"><code><span class="kd">function</span> <span class="nx">addNumbers</span><span class="p">(</span><span class="nx">a</span><span class="p">:</span> <span class="kr">number</span><span class="p">,</span> <span class="nx">b</span><span class="p">:</span> <span class="kr">number</span><span class="p">):</span> <span class="kr">number</span> <span class="p">{</span> <span class="k">return</span> <span class="nx">a</span> <span class="o">+</span> <span class="nx">b</span><span class="p">;</span> <span class="p">}</span> <span class="kd">const</span> <span class="nx">result</span> <span class="o">=</span> <span class="nx">addNumbers</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">);</span> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">result</span><span class="p">);</span> </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <ol> <li> Now you need to convert that <code>.ts</code> file into Javascript. Run the following command. </li> </ol> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>npx tsc script.ts </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>That will run Typescript on the <code>script.ts</code> file and output a <code>script.js</code> file right beside it with all the type information removed.</p> <p>That information was only there to help you with development, once you have verified there are no errors none if it is necessary anymore, which is great, because it means it does not add any size/bloat to the actual code that you will be including in your site.</p> <ol> <li> Once the <code>script.js</code> file has been generated, run it with Node! </li> </ol> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>node script.js </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>If you copied the above example the output will be <code>7</code>!</p> <h3> <a name="what-are-the-best-resources-for-learning-typescript" href="#what-are-the-best-resources-for-learning-typescript"> </a> What are the best resources for learning Typescript? </h3> <ul> <li><p><a href="https://www.typescriptlang.org/docs/">Official documentation</a> As far as I'm concerned there is no better source than the Typescript docs themselves. Lots of great examples starting at the beginner level and up from there.</p></li> <li><p><a href="https://youtu.be/LKVHFHJsiO0">No BS TS</a> Some great videos on getting up and running with Typescript quickly</p></li> </ul> <h1> <a name="web-hosting" href="#web-hosting"> </a> Web Hosting </h1> <h2> <a name="where-do-i-host-a-website" href="#where-do-i-host-a-website"> </a> Where do I host a website? </h2> <h2> <a name="how-do-i-put-my-website-on-the-internet" href="#how-do-i-put-my-website-on-the-internet"> </a> How do I put my website on the internet? </h2> <p>Web hosting is, simply put, the act of putting your website or web app files onto a machine or service somewhere that the general public can access them. There are basically a million different ways you can do this and a lot of factors that go into the decision of which one you might choose, so in this tutorial we are going to focus on the simplest ones.</p> <p>Things that are important to us right now:</p> <ul> <li>Simplicity & cost (ideally free)</li> </ul> <p>Things that are not important to us right now:</p> <ul> <li>Scalability (ability to handle large amounts of traffic, with <em>large</em> referring to hundreds of thousands of requests and beyond)</li> </ul> <p>So with those in mind I'll start by showing you two great options for hosting a simple website built with HTML, CSS and JS. This type of setup we call a <em>static site</em> which basically means all the files used are "static" in that they are already written and don't change (as opposed to a dynamic app which generates HTML automatically, something like React for example).</p> <p>The two options I would suggest depend on whether or not you have set up a <a href="#what-is-github">Github</a> account yet, and pushed your site to a repository.</p> <p>If your code is already on Github, then I recommend <a href="#static-site-hosting-option-1-github-pages">Static Site Hosting Option 1: Github Pages</a> if not, then I suggest <a href="#static-site-hosting-option-2-netlify">Static Site Hosting Option 2: Netlify</a> which is a great service with an excellent free tier for hosting projects.</p> <h3> <a name="static-site-hosting-option-1-github-pages" href="#static-site-hosting-option-1-github-pages"> </a> Static Site Hosting Option 1: Github Pages </h3> <p>This section will follow up with the <a href="#what-is-github">tutorial that teaches you how to push your site to a remote Github repository</a>. We will be using a repository that is hosting the <a href="#basic-website-example">Basic Website Example</a> but you can host your own custom site if you choose.</p> <p>Navigate to your site's repository on Github and choose <code>Settings -> Pages</code>:</p> <p><a href="https://res.cloudinary.com/practicaldev/image/fetch/s--42yx5wgS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/dqse2txyi/image/upload/v1657474898/blogs/intro-to-web-development/github-pages-1_ucsyjp.png" class="article-body-image-wrapper"><img src="https://res.cloudinary.com/practicaldev/image/fetch/s--42yx5wgS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/dqse2txyi/image/upload/v1657474898/blogs/intro-to-web-development/github-pages-1_ucsyjp.png" alt="Github Pages Example 1" loading="lazy" width="880" height="364"></a></p> <p>Use the dropdown to select which branch you want to publish (default is <code>main</code> if you followed the tutorial, but if you're on an older version of git it could be <code>master</code> and then click <code>Save</code>).</p> <p>...that's it! You're done. You'll be given a custom generated URL based on the name of your Github account and repository that you can share with anyone. Here's mine:</p> <p><a href="">https://alexeagleson.github.io/example-git-project/</a></p> <p>Github pages is an absolutely fantastic way to quickly host and share static websites.</p> <p>If you've reached a point where you are now wondering where to host more complex web apps (React apps for example) or Node apps/APIs then skip ahead to the <a href="#how-do-i-host-a-web-app">How do I host a web app?</a> section.</p> <h3> <a name="static-site-hosting-option-2-netlify" href="#static-site-hosting-option-2-netlify"> </a> Static Site Hosting Option 2: Netlify </h3> <p>If your HTML, CSS and JS files are on your computer and you haven't learned how to use Github yet don't fret, Netlify is a great option.</p> <p>Navigate to the <a href="https://www.netlify.com/">Netlify website</a> and create a free account.</p> <p>Once you have logged in your will see a dashboard that gives you three options: to host a project from Github, or use a template, or upload files manually. We are going to upload the files ourselves:</p> <p><a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wo9W_EF4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/dqse2txyi/image/upload/v1657473568/blogs/intro-to-web-development/static-site-hosting_pgwbvq.png" class="article-body-image-wrapper"><img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wo9W_EF4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/dqse2txyi/image/upload/v1657473568/blogs/intro-to-web-development/static-site-hosting_pgwbvq.png" alt="Static Site Hosting Example" loading="lazy" width="880" height="619"></a></p> <p>I'm going to click <em>"browse to upload"</em> and select the directory that has my <code>index.html</code>, <code>script.js</code> and <code>style.css</code> files in it from the <a href="#basic-website-example">Basic Website Example</a>. You can take those files for learning purposes, or upload your own site.</p> <p>The process will take a few minutes, Netlify will be configuring its web server to load your files as well as creating a custom <a href="#what-is-a-domain-name">domain name</a> (URL) for your site that you can share with other people.</p> <p>Cool! My upload is done, Once finished yours should be publicly available just like mine. Here's the link I received with the files I uploaded, feel free to check it out:</p> <p><a href="">https://stellular-brioche-c71cfe.netlify.app/</a></p> <p>That's pretty much it. If you own your own domain you can direct it to the site you just uploaded with the tools they provide and add an <a href="#what-is-ssl">SSL certificate</a> as well if you like. Otherwise the randomized Netlify domain they provide you automatically is enough to be able to share your work with others.</p> <p>Working with free services like this the main downsides you will get is that once your site reaches a certain level of traffic Netlify will likely shut it down until you registered for a paid tier.</p> <p>This practice is pretty universal, you'll find that it's easy to find free hosting for projects as long as they don't get too much traffic.</p> <p>If you're looking for a more scaleable option that you are willing to pay for with hosting, then check out services like <a href="https://aws.amazon.com/">AWS</a>, <a href="https://azure.microsoft.com/en-ca/">Microsoft Azure</a>, and <a href="https://www.digitalocean.com/">Digital Ocean</a>.</p> <p><em>(I'll take this opportunity to warn you to avoid _Godaddy</em> at all costs just in case that comes up as an option in your search, I won't waste time getting into the details, but suffice to say there are far better options. <a href="https://www.yourdigitalresource.com/post/godaddy-website-review-not-use-godaddy">Here</a> and <a href="https://stonedigital.com.au/blog/4-reasons-why-you-should-avoid-godaddy/">here</a> and <a href="https://www.reddit.com/r/webdev/comments/t8v6lp/do_yourself_a_favor_and_stay_away_from_godaddy/">here</a> can get you started on reasons if you're curious)._</p> <h2> <a name="how-do-i-host-a-web-app" href="#how-do-i-host-a-web-app"> </a> How do I host a web app? </h2> <h2> <a name="how-do-i-host-a-react-app" href="#how-do-i-host-a-react-app"> </a> How do I host a React app? </h2> <p>This section will discuss options for hosting web apps, we'll focus specifically on <em>React</em> apps, but the basic premise is the same for other popular frameworks (like Angular, Vue, etc) as well.</p> <p>First we will create a basic React app with the popular tool <a href="https://reactjs.org/docs/create-a-new-react-app.html">Create React App</a>. For a major production React app for your business, there are probably better options in 2022, but for quickly getting a simple React app up and running with little to no configuration it's still the best option out there.</p> <p><em>(Note that the following command requires <a href="#what-is-nodejs">Node.js</a> to be installed on your machine. If you haven't done that already, make sure you check out that tutorial first. It also assumes you have already learned how to hos your project on <a href="#what-is-github">Github</a>)</em><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>npx create-react-app example-react-app </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>Next I will go to my Github profile and create a project called <code>example-react-app</code>.</p> <p>Back on my terminal I'll change directory into the project directory, add the remote Github repository I just created as the <code>origin</code> and then <code>push</code> my code.<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>cd example-react-app git remote add origin YOUR_GITHUB_URL git push -u origin main </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p><a href="https://github.com/alexeagleson/example-react-app">Here</a> is my personal repository where I've pushed by React app. Yours will have a different URL.</p> <p>Next navigate over to <a href="https://www.netlify.com/">Netlify</a>, login to your account (or create one if you don't already have one), select <em>"Start new project"</em> and then <em>"Import an existing project from a Git repository"</em>.</p> <p>You will need to give Netlify permission to access your Github profile, and then either select the repository to give permission manually, or give permission to all repositories. Once permission is given you can select your React app repository.</p> <p><a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zbpYpkbM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/dqse2txyi/image/upload/v1657477051/blogs/intro-to-web-development/netlify-react_mnqaea.png" class="article-body-image-wrapper"><img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zbpYpkbM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/dqse2txyi/image/upload/v1657477051/blogs/intro-to-web-development/netlify-react_mnqaea.png" alt="Netlify React Example" loading="lazy" width="880" height="526"></a></p> <p>For configuration select the <code>main</code> branch, and unless you've altered the default configuration, you can leave all the rest of the commands as-is. Netlify will go through the process of deploying your site, and provide you with an automatically generated public URL afterward.</p> <p>That's it! It's that simple. If you want to make updates you can simply commit changes to your repository, and then choose to redeploy on Netlify. You can even configure it to watch for changes on your Github repository, and redeploy automatically whenever you push new changes to the main branch.</p> <p>Here's the result of my upload and the public URL that is generated, yours should look very similar:</p> <p><a href="">https://magenta-conkies-c988a1.netlify.app/</a></p> <h2> <a name="how-do-i-host-a-nodejs-server" href="#how-do-i-host-a-nodejs-server"> </a> How do I host a Node.js server? </h2> <h2> <a name="how-do-i-host-a-nodejs-app" href="#how-do-i-host-a-nodejs-app"> </a> How do I host a Node.js app? </h2> <p>Hosting a Node app is a little bit trickier than a standard website, but not too much so. You'll have more difficulty finding a free tier for a Node app.</p> <p>Before getting into other options, I should say I've heard very good things about <a href="https://fly.io/">fly.io</a>. I've never used it personally, but it seems like a potentially great free option for Node.js hosting. If you're interested give <a href="https://fly.io/docs/getting-started/node/">this tutorial</a> a try and let me know how it goes.</p> <p>One other common suggestions is to use <a href="https://aws.amazon.com/lambda/">AWS Lambda</a>. One benefit of lambda functions is that although you will still need to provide your credit card, they will only charge you based on actual usage. So if you and your friends are the only ones using the app, you're likely only looking at a few pennies a month.</p> <p>I personally haven't used AWS Lambda, so I'll be focusing on a different option for this tutorial, A service provided by Digital Ocean called <a href="https://www.digitalocean.com/products/droplets">droplets</a>.</p> <p>Droplets are simply a fancy name given to access to a Linux server that is fully accessible to anyone on the internet. They're great because you can run pretty much anything you want on them. The lowest tier which is more than enough to run basic Node applications is only $5 per month, and will more than serve our purposes.</p> <p>It's a pretty small price to pay for something that you can use to host almost any project you work on, including the websites and web apps we've already discussed.</p> <p>Once you have signed up for a droplet, log into your account and select it.</p> <p>You will want to make sure you can access your droplet from the command line on your machine. To do this you need to set up SSH. If you have not already created SSH keys on your machine then check out the <a href="#what-is-ssh">What is SSH?</a> tutorial to create them.</p> <p>Once you have created your public key, from your digital ocean droplet dashboard click <code>Settings -> Security -> Add SSH Key</code>. After it is added, copy the IP address for your droplet and return to your terminal.</p> <p>You can now access your remote Linux server (droplet) with this command:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>ssh root@YOUR_DROPLET_IP_ADDRESS </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>When successful, your terminal will show a welcome message (by default) and you are in a different location/directory. This will be the home directory of the root use of your droplet. You can now create additional users if you choose, or whatever you like.</p> <p>Once you have access to your droplet via SSH, you are in a good position to begin following the official guide for running a Node.js app on Digital Ocean:</p> <p>Here's a quick overview of what it will show you how to do, and why each step is necessary:</p> <ul> <li><p><strong>Step 1 — Installing Node.js</strong>: Node is not installed on Linux by default so you need to install it on your droplet yourself.</p></li> <li><p><strong>Step 2 — Creating a Node.js Application</strong>: The tutorial assumes you will be writing the application on your droplet, which most often won't be the case. This step is where you may need to deviate a bit. If you have a Node app hosted on a Github repository, then you will want to install <code>git</code> on your droplet as well and then clone your repository onto your droplet. That way the app you created and pushed will be on your droplet and ready to run.</p></li> <li><p><strong>Step 3 — Installing PM2</strong>: PM2 is an amazing robust production quality tool for running Node.js apps. Technically you could run the normal command <code>node my-app.js</code> same as you do on your machine, but what happens if it crashes? PM2 will take care of running the app, as well as automatically rebooting it if it crashes along with a number of other quality of life features like monitoring.</p></li> <li><p><strong>Step 4 — Setting Up Nginx as a Reverse Proxy Server</strong>: Nginx is one of the most popular web servers in the world and a fantastic tool. The reason you need it in this case is to control access to your app from the outside world. If your app is running on port 300 for example and you want people to access it on a domain name you bought like <code>mycoolapp.com</code>, Nginx is the one responsible for directing requests to that domain name on your droplet to your app on the correct port.</p></li> </ul> <p>So with that context provided, here is the tutorial to help get your Node app up and running live:</p> <p><a href="">https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-20-04</a></p> <h2> <a name="what-is-a-cdn" href="#what-is-a-cdn"> </a> What is a CDN? </h2> <p>CDN stands for <em>content delivery network</em> and it's basically a hosting service designed to maximize speed and uptime for resources on the web (files, images, full sites themselves, etc).</p> <p>The main difference between standard hosting and a CDN is that content on a CDN will be hosted in multiple places, potentially all over the world.</p> <p>So if one user from your site needs to load <code>Cat-Picture.jpg</code> and they are in USA, and another requests it in France, the CDN will serve the same cat picture from a physical server located in the USA to the user in the USA, and vice versa (or at least the nearest one).</p> <p>Obviously there's much more to it than that, but this definition should be more than enough to get you to know what people are talking about when they use the acronym.</p> <p>One of the biggest CDNs out there is called <em>Cloudflare</em>.</p> <p>If you want to learn more about CDNs then <a href="https://en.wikipedia.org/wiki/Content_delivery_network">Wikipedia is a great place to start</a>.</p> <h1> <a name="web-domains" href="#web-domains"> </a> Web Domains </h1> <h2> <a name="what-is-a-url" href="#what-is-a-url"> </a> What is a URL? </h2> <h2> <a name="what-is-a-domain-name" href="#what-is-a-domain-name"> </a> What is a domain name? </h2> <h2> <a name="what-is-dns" href="#what-is-dns"> </a> What is DNS? </h2> <p>A domain name is simply some text that gets converted into an <a href="https://en.wikipedia.org/wiki/IP_address">IP address</a> through a process called <a href="https://en.wikipedia.org/wiki/Domain_Name_System">DNS</a>.</p> <p>An example of a domain name is <code>www.google.com</code>. The <code>https://</code> is the <em>scheme</em> and technically not part of the domain name.</p> <p>DNS (domain name system) servers exist all over the internet and act as kind of a global dictionary of names and the IP addresses they belong to. They are constantly being updated as names and IP addresses change. There is no one single DNS server that acts as the source of truth, there are countless DNS servers out there and you can even choose which one you want to use to resolve a domain, or host your own.</p> <p>If you've ever seen the dreaded <em>"This site cannot be reached, server's DNS address could not be found"</em> then that's because your request could not find a way to translate the name into the address of an actual server that is hosting the website or app you are looking for.</p> <h2> <a name="how-do-i-get-a-custom-domain-name" href="#how-do-i-get-a-custom-domain-name"> </a> How do I get a custom domain name? </h2> <p>In order to get your own custom domain name you must purchase it first from a domain name registrar. Typically these names are purchased as an annual plan that can be renewed. You will always have first choice of renewal, but if you ever opt not to renew there is nothing to stop someone else from buying the name and preventing you from ever getting it back (or having to pay a steep price to buy it from them).</p> <p>I will not get into the nitty gritty of the business of domain names, but suffice to say it can be big business and common phrases in the <code>.com</code> space an easily go for tens or hundreds of thousands of dollars.</p> <p>Fortunately there's a near infinite number of possible names out there and as long as you aren't too picky you can probably get something close enough to what you want for as low as a few dollars a year.</p> <p>First you must choose where to purchase from. There are plenty of options. I'd recommend either <a href="https://www.gandi.net/en-CA">Gandi</a> or <a href="https://www.namecheap.com/">Namecheap</a> or <a href="https://www.cloudflare.com/products/registrar/">Cloudflare</a>. Avoid <em>Godaddy</em> if at all possible (Google their reputation around customer service before making any decisions).</p> <p>After you've purchased the name, most of the services that sell you the name will also be willing to sell you site/app hosting services as well. You can use them if you wish, but it's not necessary, they will have options available for you to point your domain name to your existing server, whether it be something like a Digital Ocean droplet or anything similar.</p> <p>The final step you need to arrange after buying and configure a domain name is called an <em>SSL certificate</em> so that you site can be accessed over secure <em>HTTPS</em> rather than insecure <em>HTTP</em>.</p> <h2> <a name="what-is-ssl" href="#what-is-ssl"> </a> What is SSL? </h2> <h2> <a name="what-is-https" href="#what-is-https"> </a> What is HTTPS? </h2> <h2> <a name="how-do-i-get-an-ssl-certificate" href="#how-do-i-get-an-ssl-certificate"> </a> How do I get an SSL certificate? </h2> <p>The full scope of exactly what HTTPS and SSL are is beyond the scope of this tutorial, but they are interesting topics if you wish to <a href="https://blog.hubspot.com/marketing/what-is-ssl">read more about them</a>.</p> <p>I will be focusing on the practical application of setting up an SSL certificate for your domain. The first thing I will stress to you is that <em>generating an SSL certificate is a completely free process</em>. I stress this because although it requires a bit of effort, there are no shortage of domain name sales services that will gladly charge you a $50+ fee to "secure" you domain for you.</p> <p>It's a completely predatory charge that targets non-technical folks who don't know any better. Don't fall for it.</p> <p>How you generate it will really depend on the hosting service you are using. For example if you are using Digital Ocean as I have discussed throughout this tutorial, then <a href="https://docs.digitalocean.com/support/how-do-i-install-an-ssl-certificate-on-a-droplet/">this guide</a> will get you up and running.</p> <p>If you are using another hosting service then simply Google their name along with "ssl" and you will almost certainly find a tutorial to generate one for free among the top results.</p> <h1> <a name="ssh" href="#ssh"> </a> SSH </h1> <h2> <a name="what-is-ssh" href="#what-is-ssh"> </a> What is SSH? </h2> <p>SSH (secure shell) is a very important concept to be familiar with, though it is often challenging for beginners to understand. I'll try to explain it as simply as possible.</p> <p>SSH provides a way for two machines to communicate securely. It is most commonly used over the command line. It provides a way to authenticate a machine without explicitly requiring a password (though a password can optionally be used).</p> <p>Though SSH can be used to transmit data for a variety of applications and uses, the most common use of it you will encounter in web developer is authenticating your machine when logging into remote servers (for example ones that may be hosting your web app) and for authenticating for version control services like Github, so that when you want to push your code to your company's repository, your machine is already authenticated and don't need to provide your username and password.</p> <h2> <a name="how-do-i-use-ssh" href="#how-do-i-use-ssh"> </a> How do I use SSH? </h2> <h2> <a name="what-are-ssh-keys" href="#what-are-ssh-keys"> </a> What are SSH keys? </h2> <p>So that explains what SSH is as a tool, now let's take a look at how to use it. SSH uses the concept of keys, specifically a <em>public</em> key and a <em>private</em> key.</p> <p><em>(The explanation of how it actually works to provide security is far above the scope of this tutorial, but it's a fascinating topic and I'd recommend you check out <a href="https://en.wikipedia.org/wiki/Public-key_cryptography">this Wikipedia page</a> if you want to learn more about it.)</em></p> <p>We will focus on the most common developer's use case, using SSH to authenticate ourselves so we can push code to Github. If you're not familiar with Github you can check out the <a href="#what-is-github">What is Github</a> section of the tutorial and return here when you reach the point of setting up your SSH keys.</p> <p>The idea behind the public and private keys is that when you generate them, your private key should remain on your machine and you should never <strong>ever</strong> share it with <strong>anyone</strong>. As soon as anyone gains access to your private key, they immediately gain the ability to impersonate you, and if you ever suspect that may have occurred (someone got access to your computer for example), you should delete your keys and generate new ones.</p> <p>The public key on the other hand can freely be shared with anyone. That is what you will add to Github, and whenever a connection request is made from your machine, Github will use that public key to verify the request being sent from your computer with the private key matches.</p> <p>The keys themselves are simply long strings of text characters, usually a few hundred depending on the algorithm used. When the keys are generated two files will be created, and you can differentiate between the public and private keys with the extension.</p> <p>The private key will be generated as <code>FILENAME</code> (the filename again will depend on the algorithm used) and the public key will be generated in <code>FILENAME.pub</code>. So remember whenever anyone or any service asks you to provide your SSH key, you want to <em><strong>always make sure you provide the one in the file with the .pub extension</strong></em>.</p> <h2> <a name="how-do-i-generate-ssh-keys" href="#how-do-i-generate-ssh-keys"> </a> How do I generate SSH keys? </h2> <p>Rather than go through the actual step-by-step instructions on how to genertae them, I will direct you to one of many great tutorials out there. Generating the keys is easy on any operating system using a free command line tool called <code>ssh-keygen</code>.</p> <p><em>(Before showing how to generate keys from the command line, I would also take the opportunity to suggest the <a href="https://developer.1password.com/docs/ssh/">SSH key generation and SSH agent in 1Password</a>. Full disclosure, this is the company I work for and I don't usually like to pitch products, but this is a rare case while I am genuinely impressed by how useful it is to manage SSH keys in 1Password and be able to share them between different machines I'm working from.)</em></p> <p>That said, it's absolutely not necessary to use at all, just a nice convenience thing. The below links show you how to generate your own keys on the command line completely free:</p> <ul> <li><a href="https://confluence.atlassian.com/bitbucketserver/creating-ssh-keys-776639788.html#CreatingSSHkeys-CreatinganSSHkeyonWindows">How to generate SSH keys on Windows</a></li> <li><a href="https://confluence.atlassian.com/bitbucketserver/creating-ssh-keys-776639788.html#CreatingSSHkeys-CreatinganSSHkeyonLinux&macOS">How to generate SSH keys on macOS/Linux</a></li> </ul> <p>Github itself also has a own <a href="https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent">tutorial</a> if for any reason you prefer to use that, but both it and the Atlassian one should give you the same result.</p> <p><em>(You have the option of adding a password to SSH keys that you need to enter each time you use them. SSH keys themselves are already very secure, I personally find adding a password on top of that not worth the inconvenience, but it's completely up to you.)</em></p> <p>Once your keys are generated, make sure you know where the <code>.pub</code> file was creating. On macOS/Linus you'll find it in the <code>~/.ssh</code> directory, and on Windows the <code>%userprofile%/.ssh</code> directory. You can view its contents by opening it in any text editor.</p> <p>To add it to your Github profile, copy the contents of the <code>.pub</code> file and go to your Github dashboard. Click your profile icon then <code>Settings -> SSH and GPG Keys</code>. Now click the green <code>New SSH Key</code> button.</p> <p>Paste the text of the key itself in the <code>Key</code> text box and give it a title. Typically the title refers to the machine the key is tied to, so if I generated it I might give it a title like "Alex's Personal Laptop" or "Alex's Work Laptop" etc. Probably good to provide even more details if you work with multiple machines.</p> <p>Once that is saved you are ready to <code>clone</code>, <code>push</code> and <code>pull</code> Github projects over SSH. Make sure that from now on you are always copying the <code>SSH</code> version of the URL and not the <code>HTTPS</code> one. You can tell which is which based on their structure, examples below:</p> <ul> <li>SSH URL Example: <a href="">[email protected]:alexeagleson/example-git-project.git</a> </li> <li>HTTPS URL Example: <a href="">https://github.com/alexeagleson/example-git-project.git</a> </li> </ul> <p>If you have already been working with a Github project over HTTPS and want to switch an existing project, you will need to change the <code>remote URL</code>. To do that, navigate to the project on your machine and run this command:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>git remote set-url origin YOUR_REPOSITORY_SSH_URL </code></pre> <div class="highlight__panel js-actions-panel"> <div class="highlight__panel-action js-fullscreen-code-action"> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-on"><title>Enter fullscreen mode</title> <path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path> </svg> <svg xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewbox="0 0 24 24" class="highlight-action crayons-icon highlight-action--fullscreen-off"><title>Exit fullscreen mode</title> <path d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"></path> </svg> </div> </div> </div> <p>That will update the default <code>origin</code> to use the SSH URL and you will no longer need to enter your username and password when pushing to it.</p> <h1> <a name="devops" href="#devops"> </a> DevOps </h1> <p>DevOps is one of those terms that can mean ten different things to ten different people. I will not make any attempt to assign any kind of formal definition to the term, my only concern is helping you understand the basic concept.</p> <p>DevOps is at its simplest the automation of the deployment process. We've talked at great length about what a website and web app is, but maybe a little bit less about deployment. <em>Deployment</em> is simply the act of getting your site or app online and available to access for your consumer. </p> <p>In the distant past there was a very clear divide between software developers and systems administrators (often called <em>SysAdmins</em> or just more generally <em>IT</em> personnel). As the industry matured it became clear that the divide between these two roles was not as large as once thought, and that a lot of benefits could be gained from having developers who were familiar with how their apps were deployed, as well as system administrators who were familiar with code, so that each could communicate their needs better to one another.</p> <p>These days very few companies manage their own infrastructure (the servers their code is deployed on) and even fewer have their own physical servers. The majority of tech companies deploy their products using <a href="https://en.wikipedia.org/wiki/Cloud_computing">cloud services</a> like <a href="https://azure.microsoft.com/en-ca/">Microsoft Azure</a> or <a href="https://aws.amazon.com/">Amazon Web Services (AWS)</a>.</p> <p>Using these services rather than purchasing and maintaining physical servers allows tech companies to focused entirely on their product and not maintain a large infrastructure team. As their application userbase grows and <a href="https://en.wikipedia.org/wiki/Scalability">scales</a> tools like AWS are designed to automatically handle that increase in traffic in real time in ways that would be far more difficult if not impossible to do if it were necessary to purchase and install more physical servers. </p> <p>That feature of course comes at a cost, but that cost presumably will be less than trying to manage your infrastructure yourself. </p> <p>Nevertheless, managing the needs of a high traffic application can be very complex. Tools like AWS are designed to be easily configured by code rather than through direct access to the servers themselves. DevOps personnel are particularly adept at building and maintaining configurations for cloud services so that developers do not need to think as much about how the code they write is actually deployed and served to the public. </p> <h2> <a name="what-is-cicd" href="#what-is-cicd"> </a> What is CI/CD? </h2> <p>In addition to managing things like cloud configuration, a good DevOps engineer also takes care of building an application's CI/CD pipeline. CI/CD stands for <a href="https://en.wikipedia.org/wiki/CI/CD">continuous integration and continuous delivery</a>. It essentially means creating the needed processes so that developers can continue to build and implement features for the application with minimal risk of introducing bugs or errors.</p> <p>DevOps engineers will use features within tools like <a href="https://about.gitlab.com/">Gitlab</a> or <a href="https://github.com/">Github</a> to ensure that in order for code to be allowed to merge into the primary <code>main</code> or <code>master</code> branch of the project, it must meet certain conditions.</p> <p>Those conditions can range in anything from simple <a href="https://en.wikipedia.org/wiki/Lint_(software)">linter checks</a> to full blow <a href="https://www.browserstack.com/guide/end-to-end-testing">end-to-end tests</a> which run real simulated user actions on your code and check to see if they match conditions you have set. If they fail, the code a developer submitted will not be allowed to merge. </p> <p><em>Continuous integration</em> refers to the idea of frequently merging new code into the priamry project branch, rather than keeping it in a separate branch. This has the benefit of keeping every developer up to date with the most recent state of the project, and avoids the risk of large merge conflicts if separate devs have been making changes to similar areas of the codebase over days or even weeks and months.</p> <p><em>Continuous delivery</em> refers to the idea of releasing these changes frequently to the customer. This provides the significant benefit of being able to quickly turn around customer feedback into real usable features or bug fixes. If your CI/CD automated pipeline is solid then you can be confident that any code changes which have passed all your tests are potentially ready to be released to your users without the need for extensive QA (though manual QA is always a good idea regardless of how good your pipeline is. </p> <h3> <a name="containers" href="#containers"> </a> Containers </h3> <h2> <a name="what-is-docker" href="#what-is-docker"> </a> What is Docker? </h2> <p><a href="https://docs.docker.com/get-started/overview/">Docker</a> is a tool that allows you package the environment for running your application along with the application itself. You can accomplish this as simply as including a single file called <code>Dockerfile</code> with your project.</p> <p>A developer might choose to use Docker because it provides guarantees that the versions of each tool installed (like Node, Python, NPM, MySQL, etc) are the same for every developer working on the project, regardless of what they have installed on their own machine.</p> <p>If you've ever had trouble getting your <em>environment setup</em> properly to start your development work, that's exactly what a tool like Docker is designed to solve.</p> <p>It uses a concept it calls <em>containers</em> which are lighter weight (require less resources) than full on <a href="https://en.wikipedia.org/wiki/Virtual_machine">virtual machines</a> to create the environment for your application. These containers are designed to be extremely <em>portable</em> which means that you can quickly deploy them anywhere, and also scale up your app quickly by simply deploying more copies of your container. </p> <p>All you need to do is define the requirements for your environment in the <code>Dockerfile</code> (for example Ubuntu 18, Node.js, etc) and every time your container is started on any machine, it will recreate exactly that environment. So you already know in advance that you will not have any issue with missing dependencies or incorrect versions.</p> <p>If you would like to learn more about Docker from the perspective of a Javascript developer I have written a brief <a href="https://dev.to/alexeagleson/docker-for-javascript-developers-41me">introductory Docker tutorial</a>.</p> <h2> <a name="what-are-the-best-free-resources-for-learning-devops" href="#what-are-the-best-free-resources-for-learning-devops"> </a> What are the best free resources for learning DevOps? </h2> <p>DevOps is more challenging to learn on your own than some other programming topics, simply because at its core its about empowering development <em>teams</em> at scale which is difficult to emulate when trying to learn as a solo developer. </p> <p>Remember that we discussed how being a good DevOps engineer is about understanding the needs of the development team. Being a good DevOps engineer requires you to have a very solid understanding of a lot of developer and sysadmin fundamentals including but not limited to: Git, Linux, bash scripting, and different cloud services (particularly the one the company you work for uses). </p> <p>Make sure you have a solid understanding of Git and Linux commands before you go any further:</p> <p><a href="#what-are-the-best-free-resources-for-learning-about-the-command-line-terminal">What are the best free resources for learning the command line terminal?</a></p> <p><a href="#what-are-the-best-free-resources-for-learning-git">What are the best free resources for learning Git?</a></p> <p>After that depending on your code repository and hosting provider you'll want to familiarize yourself using their own tutorials and documentation:</p> <p><a href="https://docs.github.com/en/actions/learn-github-actions">Learn Github Actions</a></p> <p><a href="https://www.aws.training/">AWS training</a></p> <p><a href="https://learn.microsoft.com/en-us/training/azure/">Azure training</a></p> <p><a href="https://www.reddit.com/r/devops/comments/rig8tm/devops_course_but_text_based_not_video/hoxa7t8/">This really good reddit post about DevOps resources</a></p> <p><a href="https://github.com/kelseyhightower/kubernetes-the-hard-way">Kubernetes the Hard Way</a></p> <p>I'd like to end this by acknowledging that I am certainly no DevOps expert, the resources and descriptions I have included here are best effort and hopefully do not offend any serious DevOps people. There are still further many advanced topics I have not covered that will inevitably come up if you take the plunge into the DevOps world.</p> <p>If you are interested would encourage your to at least familiarize yourself with additional tools like <em>Kubernetes, Ansible, Jenkins</em> and <em>Terraform</em>. Their use cases are mostly beyond my needs as someone who is focused primarily on the development side, but are undoubtedly critical for anyone looking to dive further into DevOps.</p> <h1> <a name="the-software-industry" href="#the-software-industry"> </a> The Software Industry </h1> <p>In this section I'll be discussing general topics and frequently asked questions as they relate to the web development career space and software industry in general.</p> <p>These responses will inevitably be a bit more opinionated than the other sections, but I do my best not to state any advice as the "only way". There are an infinite number of different paths you can take to success in this industry, it's all a matter of varying degrees of speed and effectiveness.</p> <p>The vast majority of it is simply based on my own personal experiences and years spent in online developer communities and forums reading experiences from other developers at similar stages in their career.</p> <h2> <a name="how-long-until-i-will-be-ready-to-apply-for-jobs" href="#how-long-until-i-will-be-ready-to-apply-for-jobs"> </a> How long until I will be ready to apply for jobs? </h2> <p>Everyone is different of course and there is not going to be a single answer that applies to everyone. Some people will have more time in a day to invest into their learning.</p> <p>Some people will be learning in the evenings / weekends while supporting themselves with another job, others will have the freedom to make learning itself their full time job.</p> <p>The important thing to remember is that while the process will be faster for some, everyone has the capability to make it eventually if it's something they are genuinely interested in.</p> <p>My <em>extremely ballpark'd</em> answer for the majority of people would be about one year. For those who can dedicate to learning full time, it could potentially be more like 6 months. Others who are extremely busy and only able to learn a few hours a week might be looking at closer to 2 years.</p> <h2> <a name="how-do-i-know-when-i-am-ready-to-apply-to-jobs" href="#how-do-i-know-when-i-am-ready-to-apply-to-jobs"> </a> How do I know when I am ready to apply to jobs? </h2> <p>This is a very common question, and the honest answer is that there is no specific threshold. Some companies are willing to hire people with very limited skills and experience who are willing to learn on the job, other companies have very high requirements for skill level before they are willing to hire someone.</p> <p>Often there is really no way of knowing which company is strict about the requirements they ask for, and job descriptions unfortunately are notorious for not actually defining the real requirements for the job.</p> <p>Many jobs that "require 5 years of experience" or "must know Angular" will end up hiring someone with 2 years experience who has never used Angular at all. The reality is that the market is very competitive and companies are often willing to settle for candidates that only tick <em>some</em> of the boxes who have a good attitude and sound like they will be willing to learn and train in the areas they might be missing.</p> <p>The only way to know is to apply. I'm not saying to start applying right away before you can even put together a basic project, but if you have been learning for 6 months straight and get to a point where you are comfortable with the basics of HTML, CSS and Javascript then I would encourage you to think about applying for positions, even if you don't meet all the requirements.</p> <p>The "worst case" is you get to practice interviews and get a better understanding of what companies are really looking for. The "best case" is you get hired! Honestly, both cases are a win for you.</p> <p>For more information on preparing for your first job check out the <a href="#what-are-the-most-important-factors-in-getting-hired">What are the most important factors in getting hired?</a> section.</p> <h2> <a name="where-do-i-find-jobs" href="#where-do-i-find-jobs"> </a> Where do I find jobs? </h2> <p>Your best resource will probably be <a href="https://ca.linkedin.com/">LinkedIn</a>. Keeping your LinkedIn profile up to date is critical for people looking for work.</p> <p>Start building your professional network however you can. Look for meetups, conferences, and talks in your area. Find ways to connect and start chatting with other developers. Many people find that some random network connection was the key they needed to get into their first job.</p> <p>Aside from that you should look up companies that you are interested in and view the "careers" page on their website. Often applying to a company directly is an effective tool. Make sure to include the reason the company interests you in your initial point of contact.</p> <p>If you are a student, do absolutely anything you get to get into an internship or a co-op program. The reality is that the most effective way to get a job is through existing professional experience, and internships and co-ops provide one of the easiest paths to get that experience. Do not pass up that opportunity under any circumstance.</p> <p>Lastly, while you're learning, remember to showcase your skills. Two great methods to do that are by blogging or recording videos.</p> <p>You can start to build a respectable network entirely online without actually meeting other developers in person this way.</p> <p>Remember you don't need to be an expert to write a blog. Keep your topics small and focused on things you have learned, and let the intention be to share what you have learned with others. You might be surprised at some of the contacts and opportunities you can get if you keep it up.</p> <h2> <a name="what-programming-language-should-i-learn" href="#what-programming-language-should-i-learn"> </a> What programming language should I learn? </h2> <h2> <a name="why-are-there-so-many-different-programming-languages" href="#why-are-there-so-many-different-programming-languages"> </a> Why are there so many different programming languages? </h2> <p>This is a great question, and there is no right answer for everyone. It really depends on what kind of work you want to do. You might wonder "why are there so many programming languages?" and the reason is that each different language is particularly good at something.</p> <p>Python is known for being a great first language to learn, it's good a relatively simple syntax that is easier for beginners to understand, and it has a lot of different practical use cases including task automation, data science (crunching numbers and statistics) and building web servers.</p> <p>If you want to get into mobile app development, then you'll want to learn Kotlin (for Android development) or Swift (for iOS development).</p> <p>If your goal is simply to get employed, then Javascript is definitely your best bet. Although it is region dependent (you'll want to search in your local area for what kind of jobs are available) in most parts of the world Javascript (and web development in general) remains the most in-demand skill, and all signs point to it remaining that way for the forseeable future.</p> <p>Everything these days is web driven, from apps on your phone to home appliances.</p> <p>Maybe companies use <a href="#what-is-a-framework">web frameworks</a> to help speed development, organize their code and build apps more efficiently. Some you may have heard of include <em>React, Angular, Vue and Svelte</em>. It's well worth it to learn at least one of these frameworks, but don't jump into them too quick, as each one is built on top of the fundamentals of HTML, CSS and Javascript and typically require a solid working knowledge base of those three in order to learn effectively.</p> <p>Which framework you choose is up to you, though if you are targeting employment make sure you search the jobs in your area. In the vast majority of the world, React jobs outnumber all other frameworks by a large margin (though there is a sizeable market for <em>Vue</em> in Asia).</p> <p>If web development doesn't sound like your thing, maybe systems programming is more up your alley (embedded controllers, hardware devices, internet of things (IoT) and etc).</p> <p>To become a systems programmer there are many paths to take, but most start through the C programming language and build from there. It will be important to have a stronger grasp of computer science fundamentals in this field than in web development since you will be interacting with low level concepts like the operating system and memory directly.</p> <p>Check out the section called <a href="#what-are-the-best-free-resources-for-learning-computer-science">What are the best free resources for learning computer science?</a> to find some great resources on learning systems programming concepts.</p> <h2> <a name="what-if-i-fail" href="#what-if-i-fail"> </a> What if I fail? </h2> <h2> <a name="what-if-i-get-overwhelmed" href="#what-if-i-get-overwhelmed"> </a> What if I get overwhelmed? </h2> <p>Learning software development is extremely challenging, for everyone. Any dev you see who makes it look easy almost certainly has years of practice and failure behind them, it's no different than any other skill that takes years to develop.</p> <p>Along the way you are almost certainly going to find days where nothing goes right, or everything seems way too overwhelming and it's impossible to keep up with.</p> <p>The only advice I can give here is to say that this is <em>perfectly normal</em> and part of the process. Failing at building a project will teach you a lot more about that project then not starting it at all. Sometimes you'll find that you've bitten off more than you can chew, and that's okay.</p> <p>There's nothing wrong with taking a step back and slowing down. When you encounter a topic that seems too large to digest, see if you can break it down into small pieces. Take a day to learn more about just one small aspect of it. Then move on to the next thing. And the next thing.</p> <p>And remember, there's no set amount of time when you will have "learned something." New devs often say things like "I'll give myself six months to learn Javascript". It doesn't really work like that. I've been writing Javascript for years and I'm still learning. Your goals should reflect concrete tangible targets, focus on learning specific aspects of the languages, rather than the whole language itself.</p> <h2> <a name="what-are-the-most-important-factors-in-getting-hired" href="#what-are-the-most-important-factors-in-getting-hired"> </a> What are the most important factors in getting hired? </h2> <h2> <a name="how-do-i-get-a-job-when-all-companies-want-existing-work-experience" href="#how-do-i-get-a-job-when-all-companies-want-existing-work-experience"> </a> How do I get a job when all companies want existing work experience? </h2> <p>This is the real question right here. Honestly when it comes to software development, <em><strong>finding your first job will the most difficult stage of your career by a significant margin</strong></em>.</p> <h3> <a name="work-experience" href="#work-experience"> </a> Work Experience </h3> <p>Those who are still students should do absolutely everything they can to take internships and co-op placements, having those will give you a massive leg-up over other devs in your peer group who don't when it comes to full-time hiring after graduation.</p> <p>If you're looking at bootcamps then make sure you pick one specifically that offers networking support and helps connect you with employers after graduation.</p> <p>For the rest of us getting into development later in life, the best thing you can do is allow the reality to sink in that it's going to be very challenging, accept it, and do your best not to allow it to deter you.</p> <p><strong>The vast majority of your applications will be rejected.</strong> And that's perfectly okay, it's almost certainly due to a lack of experience, not a lacking in skill or ability on your part.</p> <p>It's important to train yourself not to take it personally. Rejection does not mean <em>"I'm not good enough"</em> it simply means that particular companies needs didn't align with your skills at that moment.</p> <p>That's it and nothing more.</p> <p>The fact is that most companies are risk averse. They see someone new to the field with no proven track record of working for an organization and they don't have the confidence that you have the skills and abilities required to contribute. The reality is that if you think you do, you probably do -- but unfortunately many companies just aren't willing to take that risk.</p> <p>So since this seems like a catch-22 scenario where you can't get experience, how exactly <em>do</em> you break into the field?</p> <p>The best advice for new devs is that you have to look at it like a numbers game. If there are 100 companies out there, and 1 of them is willing to take a chance on new devs, then you need to apply to 100 companies to get your job.</p> <p>Apply like crazy! Come up with a solid but generic resume, and start sending it out. Target all the web dev jobs in your local region, look for companies online that are hiring remote. Make the expectation that most will reject you and be <em>perfectly okay with that</em>.</p> <p>Every failed interview is experience at interviewing. The more you do the more comfortable you will get. Get your resume into as many hands as possible and do as many interviews as you can.</p> <p>Be completely honest about your skills. When asked a question you don't know the best answer is always "I'm not familiar with that, but I would love to learn more about it."</p> <p>All you need to remember is this: you only need <em>one</em> company to say yes, and you're in. Once you've got that, then you'll have work experience, and everything from that point on just gets easier and easier.</p> <p>Now that we've talked about work experience, let's look at some of the other critical factors at play when it comes to getting hired.</p> <h3> <a name="networking-and-relationships" href="#networking-and-relationships"> </a> Networking and Relationships </h3> <p>When I say <em>networking</em> I'm not talking about <a href="https://en.wikipedia.org/wiki/Social_group">networking</a> I'm talking about <a href="https://en.wikipedia.org/wiki/Computer_network">networking</a>.</p> <p>Which is unfortunate because if you're like a lot of people (myself included) learning the <a href="https://en.wikipedia.org/wiki/OSI_model">OSI model</a> is a lot easier than building a professional network. Like many other things in life, the earlier you start the better off you'll be in the long run.</p> <p>One of the most helpful things when I started to internalize this was the realization that your network doesn't necessarily mean "people you've met in person". You can build a network entirely online through contacts you make on social networks, reddit, Github, Stack Overflow, Discord, etc.</p> <p>Particularly with the rise of remote work, you never know if the person you were talking to or helping out online two weeks ago could be the person who connects you with your next job. It happens all the time.</p> <p>I should clarify that having a network of developers is <em>absolutely not required</em> for finding a job. The good old fashioned method of sending out 100 copies of your resume to 100 different companies still works great too. In fact if your goal is to get employed realistically you should be pursuing <strong>both</strong> these methods.</p> <p>If you fancy yourself a writer or a speaker, don't sleep on blogs and Youtube tutorials. It's a common misconception that you need to be an expert. Certainly do your homework, but after spending some time getting confident enough with a small topic (even something as simple as loops or if statements) <a href="https://dev.to">try writing a blog about it!</a></p> <p>This is something many bootcamps heavily encourage students to do. It can be a great way to build confidence and also expand your personal network.</p> <p>Lastly, don't sleep on <a href="#where-do-i-find-jobs">LinkedIn</a>. Yes, everyone is on there to self promote, and yes the news feed can be really difficult to stomach. The good news is you don't need to use it for that. Don't even look at it. All you need is your own profile up to date, and with some experience under your belt, the recruiters will be reaching out <em>to you</em> rather then the other way around.</p> <h3> <a name="technical-knowledge-and-interview-performance" href="#technical-knowledge-and-interview-performance"> </a> Technical Knowledge and Interview Performance </h3> <h2> <a name="what-can-i-expect-from-an-interview" href="#what-can-i-expect-from-an-interview"> </a> What can I expect from an interview? </h2> <p>The standards for developer interviews are all over the map.</p> <p>One company might simply want to chat and talk about projects you have worked on. Another might want to run you through technical aptitude tests. Another might give you a take-home project to work on in your spare time.</p> <p>You should be prepared for any of these and more. As a junior developer your expectation should be a strong working knowledge of HTML, CSS and Javascript, Git, and the command line.</p> <p>You'll want to supplement that with whatever additional technologies and tooling the position is asking for. So if they are hiring for a junior React position, obviously you would want to be familiar with the basics of React as well.</p> <p>I think it's really important to taper your expectations and be ready to encounter scenarios where companies are hiring for junior positions, but after getting into the interview it becomes clear they are actually looking for a very experienced developer with the hopes of only paying them as a junior.</p> <p>Unfortunately all you can really do in these scenarios is your best, ask lots of questions, be honest about your skills, and don't let it discourage you.</p> <p>Companies will often be willing to relax their skill requirements a bit if they find someone with a good attitude who appears they are ready and willing to learn. Allow yourself to be that person.</p> <p>Don't forget you are interviewing them as well. Ask questions to try and get an idea of their workload, company culture, what an average day looks like etc.</p> <p>And don't hesitate to answer a question with <strong>"I don't know"</strong>.</p> <p>It's a much better answer than making something up or guessing wrong. You can follow it up with something like "<em>I don't know, but here's something similar I've encountered before"</em> or <em>"I don't know, but here's how I would start looking for the answer if I encountered this"</em>.</p> <h3> <a name="interview-styles" href="#interview-styles"> </a> Interview Styles </h3> <p>Show the interviewer that you are proactive when it comes to encountering situations where you don't know the answer, because as we've already discussed, these situations will happen <em>almost every day</em> in a developers career. Embrace that fact and leverage it in your interview.</p> <p>Let's take a look at some of the different styles of interviews you might encounter in your job search: Here's a realistic look at three different hypothetical interview approaches at three different companies:</p> <ul> <li><p><strong>Company A</strong>: Tell me about some projects you've worked on. Tell me about why you chose the tools you did (discussion style).</p></li> <li><p><strong>Company B</strong>: Open up this online browser tool and use Javascript/Python/whatever to reverse a string (whiteboard style).</p></li> <li><p><strong>Company C</strong>: Here's an assignment to build a landing page for a website with an interactive menu. Take it home and work on it and then send us the results tomorrow (take home style).</p></li> </ul> <p>Of course there are plenty more scenarios, but this captures sort of the three main "styles".</p> <p>The first <strong>(discussion style)</strong> is based on a conversation of you discussion your knowledge and experience.</p> <p>Personally I find these the best for junior positions. Most people starting out have a very difficult time programming while under pressure (even for simple stuff) and given an opportunity to discuss they knowledge, the interviewer can ask questions and probe to make sure they actually understand the things they're talking about.</p> <p>The second <strong>(whiteboard style)</strong> may be done with actual code or may be done on a board where you simply use a marker. The interviewer usually isn't necessarily looking for a correct or complete solution, but an approach that shows an understanding of the problem, even if there are minor errors or edge cases.</p> <p>Also important with this style of interview is the candidates ability to ask good questions and clarify assumptions. Sometimes there will even be missing information in the question intentionally and the candidate is supposed to get that information by asking questions. Despite being a coding challenge, this style of interview is very much focused on a discussion of the problem. Typically, depending on the complexity, you'll want to discuss it for up to half the allotted time before you even begin to write code.</p> <p>When you get up in the higher levels and more competitive companies (often referred to as <a href="https://en.wikipedia.org/wiki/Big_Tech">FAANG or MANGA</a> companies), these styles of interviews get more common and much more difficult than reversing strings.</p> <p>If you're interested in pushing for those top tier jobs, check out the <a href="#dsa-leetcode-and-systems-design">DSA, Leetcode and Systems Design</a> section for more information.</p> <p>The final interview style <strong>(takehome style)</strong> typically involves giving the candidate a small challenge to do on their own time. This can have the benefit of allowing you to work at your own pace without the pressure of someone watching, but it also has the downside of being time consuming, and the majority of companies will not be paying for your time.</p> <p>Early in your career I can understand agreeing to take home interviews when you are simply trying to get any job you can, but as you progress in your career you'll find yourself passing on this style of interview as you simply don't have the time to build multiple small projects for companies in your limited spare time. Fortunately this interview style is the least common of the three, and rarely used by the top tech companies.</p> <h3> <a name="soft-skills" href="#soft-skills"> </a> Soft Skills </h3> <p>Don't sleep on soft skills when it comes to finding a job in the industry. Technical skills will certainly help get you the job, but good soft skills will often fast track you should levels and promotions faster than technical skills alone.</p> <p>What do I mean when I say soft skills? I'm talking about things like <em>positive attitude</em>, the ability to <em>communicate clearly</em> (both spoken and written) and _willingness to share knowledge and help others.</p> <p>Good mentors and teachers are often looked on very highly by companies, because it shows you can contribute to improving the level of knowledge and skill within the company. If this is something you have interest and experience in (even if it's just something like blogging or videos) make sure that it's something you share during the interview.</p> <p>Many companies have what's called a <em>cultural interview</em> as one fo the steps in your interview process. While some companies might state they have metrics to quantify this value, the reality is that many simply evaluate you on their "feeling" about how well you would fit in with the company based on the attitude and disposition you display during the interview.</p> <h3> <a name="education" href="#education"> </a> Education </h3> <h2> <a name="do-i-need-to-get-a-degree" href="#do-i-need-to-get-a-degree"> </a> Do I need to get a degree? </h2> <h2> <a name="do-i-need-to-go-to-college" href="#do-i-need-to-go-to-college"> </a> Do I need to go to college? </h2> <p>One of the great things about a career in software development is that it does not <em>require</em> you to complete a four year degree or college program to get hired. I can't speak for percentages, but many companies are more concerned with a candidates skill level and ability to produce working software than their educational background.</p> <p>I don't want to discount how much of a benefit a university or college degree can bring however. If you are someone who has the time and resources, then in the long term a computer science degree will almost certainly be worth the investment you make into it, for a couple of reasons: First is that there are still many companies out there that do look for a degree before hiring a candidate, and second that the fundamental knowledge you gain in computer science will be incredibly valuable in teaching you <em>problem solving skills</em> that translate directly to work you do in the field.</p> <p>If you do go the college route one of the biggest benefits career-wise are the co-op and internship programs, do not pass up those opportunities if they are available to you, they are one of the most effective ways of breaking through that initial barrier of getting your first job, which most new devs describe as the most difficult hurdle of their career. See <a href="#how-do-I-get-a-job-when-all-companies-want-existing-work-experience">How do I get a job when all companies want existing work experience?</a>.</p> <p>Still, for those that do not have the means to complete a full degree, if you are motivated and disciplined enough it is absolutely possible to teach yourself everything you need to know through a combination of <a href="#what-are-the-best-free-resources-for-learning-web-development">free online resources</a> and building your own practice projects with the knowledge you gain from those resources.</p> <p>Another popular option these days is bootcamps. They can be a great middle ground between self teaching and a college degree. They are good for those people who feel they may not be able to motivate or direct themselves enough and benefit from having a very strict curriculum to follow.</p> <p>Bootcamps have a reputation of being very challenging and being one of those things that really gives back the effort you put into it, so make sure you are ready to invest the huge amount of time (and often money) it takes to get the full benefits. Also make sure you do your research on the quality of the bootcamps, you'll find the full array of well regarded ones and poor quality bootcamps. If possible try to find one that also includes help with job placement as part of the package.</p> <h3> <a name="luck" href="#luck"> </a> Luck </h3> <p>Let's be honest, when you ask many people how they got their first job they'll say <em>"well, I was lucky..."</em> and proceed to tell some anecdote about their good fortunate.</p> <p>As they say, <em>luck is the intersection of preparation and opportunity</em>. Many of these people who describe themselves as lucky had done preparation in advance that allowed them to take these opportunities when they presented themselves.</p> <p>Allow yourself to accept that there's always going to be some luck involved, but you can dramatically improve your chances of that luck finding you if you're well prepared.</p> <h2> <a name="which-factors-most-influence-potential-income" href="#which-factors-most-influence-potential-income"> </a> Which factors most influence potential income? </h2> <p>I've grouped these two questions together as they often go hand in hand. How much you as a candidate appeal to a company has a direct impact on your potential value.</p> <p>As you can imagine, this is a very popular question, and like many other complex questions, the most accurate answer is going to be <em>"it depends"</em>... but let's take some time to break down as best we can into exactly "what" it depends on.</p> <h3> <a name="location" href="#location"> </a> Location </h3> <p>Not necessarily a huge factor when it comes to <em>getting</em> a job -- but quite possibly the <strong>most</strong> important factor when it comes to income. Without a doubt, both average and top end software development salaries the U.S. dwarf pretty much every other country.</p> <p>That's not to say they aren't still <em>well above average</em> in pretty much every country, it's simply pointing out just how much "above" that already high baseline they are in the U.S. You can still live extremely comfortably as a software developer in pretty much any country in the world.</p> <p>Here's an <a href="https://codesubmit.io/blog/software-engineer-salary-by-country/">aggregate by country from Codesubmit</a> showing the different average values between countries. The actual values themselves are less important than the variance between countries.</p> <p>For developers in the U.S., here is the data directly from the <a href="https://www.bls.gov/oes/current/oes151252.htm#nat">U.S. Bureau of Labor Statistics</a> directly. Similar <a href="https://www.jobbank.gc.ca/marketreport/wages-occupation/22548/ca">metrics from the Government of Canada</a> here.</p> <p>If you're outside North America you should be able to find data from your government's statistics reporting with a quick Google search.</p> <p>Of course there are tons of factors that go into total income. Cities with significantly higher salaries also have higher costs of living, and there are many other quality of life considerations to take into account as well.</p> <p>Nevertheless, even when you account for regional cost of living, there's still pretty much no question that developers whose only goal is to maximize income should be aiming to relocate to the U.S.</p> <p>That said, this particular advice really only applies to the small subset of folks who aren't already in the U.S. and are also young enough and motivated enough to uplift their entire lives.</p> <p>For the rest of us (myself included in Canada) there are plenty of other factors listed ahead to consider to help maximize potential earnings without the need to relocate. The rise of remote work is (slowly) shifting the balance and bringing salaries up in non-U.S. countries, and there are more opportunities than ever to work remotely for a U.S. company while living in another country.</p> <h3> <a name="product" href="#product"> </a> Product </h3> <p>What kind of product does the company you're applying to develop? Oftentimes in the tech world, depending on the company's market, they either view software developers as "revenue generating" or an "operating cost".</p> <p>Not surprisingly, companies that view developers as a source of increased revenue tend to pay more than companies that look at devs as a cost.</p> <p>Take tech companies like Facebook for example. The more developers hey hire, potentially the more features they can release and the more revenue they can generate. Hiring good devs gives them a direct line to more money, and as such they tend to pay more.</p> <p>Alternatively consider a major restaurant chain. They need developers of course to manage their websites, maybe the software in their restaurants, and any number of internal tools they build to help manage their company, but ultimately a business like that is going to treat devs more as a "cost of doing business" rather than a source of revenue.</p> <p>So when seeking higher paying jobs, make sure you are considering the company's product. Is the main product or service they offer software based? If so chances are they're going to value their developers higher than a brick-and-mortar business, and you're likely to get a better offer from them.</p> <h3> <a name="size-and-funding" href="#size-and-funding"> </a> Size and Funding </h3> <p>Smaller companies for reasons that should be obviously simply cannot afford to pay the big software salaries that larger companies can.</p> <p>Working for a small company can be a great experience though, you'll often be able to have a much bigger impact on the product and be involved in more major decisions, but in doing so there is often a price to pay income as compared to the larger companies out there.</p> <p>That said, an exception to this rule can be small startups that are well funded. When a software focused startup company receives a large round of <a href="https://www.investopedia.com/terms/v/venturecapital.asp">VC funding</a>, often the biggest chunk of that funding is intended to go directly into hiring more staff to scale their product to a wider market -- so get in there and get your piece!</p> <h3> <a name="base-salary-vs-equity" href="#base-salary-vs-equity"> </a> Base Salary vs Equity </h3> <p>This topic is way bigger than I can possibly go into (and I'm no expert either) so I'll simply link this <a href="https://blog.pragmaticengineer.com/equity-for-software-engineers/">great blog post on the topic</a></p> <p>Suffice it to say that you short of <em>guaranteed stock</em> for an already <em>publicly traded company</em>, you are often best to consider any private equity or options as <strong>zero value</strong> when it comes to negotiating your salary.</p> <p>Because in the case of startups (early stage ones in particular) most often that's exactly what it ends up being worth.</p> <p>Having some ownership in the product you work on is great, but please don't let a company take advantage of you with promises of great value "someday" when they do public. Too many great devs have been burned by this. <strong>Make sure you get the base annual salary that you need first</strong>, no matter how small the company, if their product is solid they should be able to pay their talent. Full stop.</p> <p>Once you've got that nailed down, then you can comfortably discuss options on top of that.</p> <h2> <a name="what-other-factors-should-i-consider-when-applying-to-a-company" href="#what-other-factors-should-i-consider-when-applying-to-a-company"> </a> What other factors should I consider when applying to a company? </h2> <h3> <a name="remote-friendliness" href="#remote-friendliness"> </a> Remote Friendliness </h3> <p>Is the company you're applying to remote friendly? Do they allow permanent work from home? Hybrid model?</p> <p>Remote work has become more and more common. Even for juniors starting out it's not unrealistic to aim for a remote job.</p> <p>If it's something that's important to you, make sure you are upfront about it with the company before the interview process begins.</p> <h3> <a name="company-culture" href="#company-culture"> </a> Company Culture </h3> <p>Before beginning the interview or even applying to a company, try and gather as much information you can about what it's like to work at the company.</p> <p>Ask on developer communities like Reddit, Discord, etc if anyone has experience or anecdotes about what it's like to work for those companies.</p> <p>Check sites like <a href="https://www.glassdoor.com">Glassdoor</a>, <a href="https://www.teamblind.com/">Blind</a> and <a href="https://layoffs.fyi/">Layoffs.fyi</a> to get accounts from people who have worked at these companies.</p> <p>try to filter out the most extreme positives and negatives from these sites if you can. Companies can and will find ways to get paid positive reviews. Focus on the ones that sound the most like a "slice of life" honest account if you can. Obviously the bigger the company there more you'll find the easier it will be to get an impression.</p> <p>Finally make sure you ask in your interview as well. Don't just say <em>"what is your company culture like?"</em> because you'll just get a canned answer.</p> <p>Ask specific questions like <em>"what time do most developers start and finish work each day?"</em> to try get an idea how much team pressure there might be to "work extra" even if it's not officially "required".</p> <p>Another great question is <em>"what is your training/onboarding process like?"</em>. A question like that can give a good idea whether they've really got their act together when it comes to training new hires, or whether it sounds like you'll just be thrown into a project with nothing more than a "good luck!".</p> <p>There's tons more of course. Really the questions you want to ask are the ones that reflect things that are <em>important to you</em>. They may not be the same things that are important to someone else. Here's a <a href="https://arc.dev/developer-blog/questions-to-ask-at-an-interview/">blog post</a> with some more examples. Consider picking 2-3 that best reflect the kind of work experience you are looking for.</p> <h2> <a name="what-if-i-find-a-job-but-its-not-what-i-was-expecting" href="#what-if-i-find-a-job-but-its-not-what-i-was-expecting"> </a> What if I find a job, but it's not what I was expecting? </h2> <p>This section of the post is primarily aimed at those developers who have been been able to find work, but unfortunately find themselves struggling with unrealistic expectations, or pressure to work unpaid overtime, lack of support, or at worst -- straight up verbal harassment including insults, mocking or derision.</p> <p>Let me tell you straight up so there can be absolutely no misinterpretation: <strong>GOOD JOBS, AND GOOD COMPANIES, DO NOT TREAT PEOPLE THIS WAY. EVER. PERIOD. FULL STOP.</strong></p> <p>There are no exceptions to that statement.</p> <p>Is it possible that maybe you aren't keeping up, or you are struggling? Absolutely! Maybe it could be that you weren't quite ready for thr job you were hired for. That's an unfortunate reality, but it's not a death sentence.</p> <p>There are ways of approaching this situation that good managers and good companies will be have plenty of experience with.</p> <p>One thing I read recently that I think is really critical for developers to remember is this: <em><strong>nothing said in a performance review should ever come as a surprise</strong></em>.</p> <p>If you wake up tomorrow and have a performance review (whether it's an official one, or simply your manager talking about your performance 1-on-1) and you're told that you've failed to meet expectations, what it really means is that your manager has failed at properly addressing it earlier on when they should have (unless they follow that statement with a plan to support you).</p> <p>A good manager will approach the topic in a positive way, willing to work with you to come up with a solution. Do you need more training time? More time to shadow other developers? Are the tickets you are being assigned currently too far above your level and you need to spend more time tackling smaller ones to build experience?</p> <p>These are the kind of questions good companies will encourage managers to ask in performance reviews. You are part of the team and that's how you should expect to be treated.</p> <p>Following a discussion like this, after whatever the agreed upon period is (whether weeks or months) if you still are unable to work out an approach that helped you work at the level expected of you -- <strong>then</strong> maybe the tough discussions might start about your fit for the role.</p> <p>But the key point being made here is that it <em>should never, ever, come as a surprise.</em></p> <p>If what I am describing here sounds totally unrealistic or like some kind of "dream company," and you find yourself in a position where you think that mistreatment and unrealistic expectations are the norm -- then I'm happy to tell you that you simply have <a href="https://en.wikipedia.org/wiki/Stockholm_syndrome">Stockholm syndrome</a> (I mean that in the nicest way possible).</p> <p>There are no shortage of companies out there that don't treat people this way.</p> <p>There has <em>never been a better time to be a developer</em>. I would encourage you to polish off the resume and start your search for that career you deserve.</p> <p>There's not too many incredibly strong opinions I hold about the industry, but the belief that no matter your skill level that <strong><em>everybody deserves to be treated and spoken to with respect</em></strong> is one of the few complete dealbreakers for me. I'll put up with a lot of stuff, but that's where I draw the line. I think everybody should.</p> <p>The more we put our foot down for behaviour like that, the more companies will be forced to address it.</p> <h3> <a name="negotiating-an-offer" href="#negotiating-an-offer"> </a> Negotiating an Offer </h3> <p>A lot of people will tell you there is no harm in negotiating an offer. That's not <em>exactly</em> true, but it's still good advice.</p> <p>There's really two most likely scenarios that will occur when you try to negotiate an offer:</p> <ul> <li>The company will accept or counter (good)</li> <li>The company will stay firm at current offer (fine)</li> </ul> <p>Those are the most likely scenarios and since both are options in your favour, that's the reason most people will encourage you to negotiate.</p> <p>There is a rare third scenario where the company <em>rescinds the initial offer entirely</em> which can happen -- but the most oft repeated advice to that is that <em>"a company that does that probably isn't a company you want to work for anyway."</em></p> <p>Whether you should negotiate or not really is a personal choice. I think there are good reasons and scenarios where you might choose not too (the offer is in the range you were expecting and the company is one you are interested to work for.) I personally would never fault someone for accepting an off as-is in that scenario.</p> <p>Other factors to consider is the <em>amount</em> and your <em>leverage</em>.</p> <p>A good rule of thumb is 10%. Most companies won't be too surprised if a candidate counters at 10% above the offer that was made to them. If they company is genuinely interested in you, 10% if probably a small price to pay to close the deal.</p> <p>More than that and you should probably make sure you are confident in yourself and have leverage.</p> <p>Leverage is basically <em>evidence to show value</em>. The further you are in your career the more track record of proven value you will have and the more leverage you will have. Negotiating up as a new graduate with no experience is possible, but much riskier.</p> <p>Another way to get leverage is having multiple offers. If you are fortunate enough to have more than one offer from more than one company, and the one you would prefer to work for has offered less, you can use the other offer as leverage in a (very friendly and professional) communication that you have another offer, but would <em>prefer</em> to work for the other company if they would be able to match $X amount.</p> <p>The final point to note is that when you negotiate or try and leverage multiple offers against each other you have to be willing to lose the offer. That's part of the risk. If you aren't willing to walk away, don't take the risk.</p> <h3> <a name="pay-bands" href="#pay-bands"> </a> Pay Bands </h3> <p>Make sure you are as familiar as possible with the pay bands (salary range) of the role you are applying to at the company your are interviewing with.</p> <p>Remember that it's in your best interest not to provide this range yourself as you are much more likely to undersell yourself. Any respectable company or recruiter should be able to provide you with the potential pay range for the role you are applying for, though it may take some pressure on your end to get it out of them, it's well worth it.</p> <p>If they will not provide you with a range in advance it may be in your best interest to walk away unless you are desperate for the job. Interview processes can be very lengthy and time consuming and there is nothing worth than getting to the offer stage and finding out you had a completely different expectation than the company did. </p> <p>Be sure to educate yourself in advance using tools like <a href="#https://www.levels.fyi/">levels.fyi</a>. Remember that software developer pay range is <em>extremely</em> location dependent so you need to ensure you are filtering not only by the company you are applying to, but also your location.</p> <p>Although levels is the best indicator, particularly for tech companies, you should also make sure to check <a href="https://www.glassdoor.ca/index.htm">Glassdoor</a> and <a href="https://www.teamblind.com/">Blind</a> as well just to get the most well rounded number you can. </p> <h3> <a name="dsa-leetcode-and-systems-design" href="#dsa-leetcode-and-systems-design"> </a> DSA, Leetcode and Systems Design </h3> <p>If your goal is to maximize your income, then you've arrived at your destination.</p> <p>I mean, full disclosure -- I don't work for a <a href="https://en.wikipedia.org/wiki/Big_Tech">FAANG</a> company. I haven't done the grind myself and don't intend to. I work for a great company and could hardly ask for a better career, but I am familiar with the requirements and can certainly point folks in the right direction for all the resources they need to study to take that leap.</p> <p><em>DSA</em> stands for <a href="https://en.wikipedia.org/wiki/Data_structure">data structures</a> and <a href="https://en.wikipedia.org/wiki/Algorithm">algorithms</a>.</p> <p>If you studied computer science in college/university then this is probably old news to you, but if you're someone who has been just learning web development on their own in their spare time it might seem a bit overwhelming. And that's okay! Let's break it down.</p> <p>In order to understand why DSAs are important you need to kind of take a step back and look at the big picture of software engineering as a whole rather than web development in particular.</p> <p>Regardless of whether you've learned Javascript, or Python, or C++, or Java, or Rust, or Ruby, or C# or whatever -- each programming language when you boil them down to their core elements is really just a different flavour of approaching the same topic: representing and manipulating data.</p> <p>How that data is stored covers the <em>data structures</em> part and how it is manipulated falls into the <em>algorithms</em>.</p> <p>Big tech companies like the <em>FAANG/MANGA</em> crew and similar monoliths are in a very unique position. The small mom and pop shops in your local area have to do a lot of work to seek out developers that can both do all the odds and ends dev work that needs to be done for average to below average pay -- but the big bois can sit back while every new grad and they dog climb over themselves to try to work for them.</p> <p>This endless supply of potential dev talent means they have the luxury of being a lot pickier about who they hire than most companies.</p> <p>But how do they decide how to filter out the best of the best?</p> <p>Well as it happens, they've all done their research, and it seems like the most consistent way of identifying top talent in the software industry isn't necessarily based on work experience or knowledge of any one particular programming language -- it's a candidate's base understanding of fundamental computer science topics like data structures and algorithms.</p> <p>The idea behind it is that if you can understand the <em>thought processes</em> behind the underlying concepts, the actual language you write the code in is pretty irrelevant.</p> <p>It's <strong>much</strong> easier to teach a strong logical thinker how to <strong>write Python</strong> than it is to teach a Python developer <strong>how to think</strong>.</p> <p>So with that background established we've paved the way for the birth of platforms like <a href="https://leetcode.com/">Leetcode</a> to exist, which despite the stupid name, is unquestionably the most important resource available to you as a developer if your long term goal is to maximize your income.</p> <p>All the top paying tech companies right now like Amazon, Apple, Facebook, etc draw most of their engineering interview questions directly from the pool of questions listed on this site. Whether similar and adjusted slightly, or in many occasions almost identically word for word.</p> <p>There's no tricks or cheating involved in having access to them in advance. The whole idea is that they are challenging enough to require weeks or months of practice to internalize the concepts. If you are able to do so successfully then it demonstrates to these companies that you are capable of a level of logical thinking that they expect, and so having the solutions practices and even memorized is enough to identify you as a valuable candidate.</p> <p>This is what's called the <em>Leetcode grind</em>, and as painful as it can be, it's widely considered to be the most valuable way you can spend your time if your goal is maximizing your income. Grind out a few problems per day, work your way up into the mediums and hards, and you'll be ready for your <em>FAANG</em> interview in no time.</p> <p>For a new grad or someone with no experience, this is often enough to get your foot in the door. For those developers targeting the higher level positions at the big tech companies you'll also need to spend time studying <em>system design</em>.</p> <p>Systems design in a nutshell is simply an outline of <em>all the factors you need to consider when building a large scale software system</em>. Consider a trivial example of a website. I make a website with HTML, CSS and Javascript and host it online with Github pages, or purchase some web hosting with Godaddy and upload my files. People love it! Every day I get more and more visitors.</p> <p>Tomorrow I log on and my site is down. It got too popular! Turns out I only had 1GB of bandwidth with my hosting provider and I blew through it overnight when my site went viral. Damn. How big were the images I was hosting? What was my <a href="https://en.wikipedia.org/wiki/Web_cache">caching</a> setup? What were my plans for <a href="https://en.wikipedia.org/wiki/Scalability">scalability</a>? I didn't have any?</p> <p>Well no wonder everything fell apart.</p> <p>In a <em>systems design interview</em> you'll get an example of some kind of business idea or product that might need to be built. You'll be expected to be able to discuss as many factors or considerations that need to be accounted for in building that system.</p> <p>You'll need to discuss both functional requirements (what features does this product need to support?) as well as infrastructure (how can we handle potentially large amounts of traffic and data storage requirements?).</p> <p>What solutions are available? What are the pros and cons of each one?</p> <p>If you're still not sure exactly what we're talking about, here's a couple classic examples based on real interview questions you might encounter on this subject:</p> <ul> <li><a href="https://youtu.be/DSGsa0pu8-k">How would you design a parking lot?</a></li> <li><a href="https://youtu.be/fMZMm_0ZhK4">How would you design a URL shortener service?</a></li> </ul> <p>These videos will give you a great idea of how you will be expected to answer questions like this in a big tech interview.</p> <p>Lastly, before moving on I should like you with a couple of the foremost standard resources in this space. The book <a href="https://www.crackingthecodinginterview.com/">Cracking the Coding Interview</a> is considered the gold standard. It's not free unlike most other resources I've linked, but since you're presumably only here because you're looking to maximize your earning potential, $40 is probably a pretty small price to pay to get you there.</p> <p>For systems design there are great books too, but honestly YouTube is pretty much your best friend for this one. It's really great to just listen to people walk through their thought process for different problems. Just watch to avoid the crypto shills like <em>TechLead</em> which I will not link out of principle.</p> <p>A simple rule of thumb to follow is that if the person is only speaking about the topic and answering exactly the subject you searched for, you're probably in good hands. If they're starting or ending their video encouraging you to "check out" something totally unrelated you should proceed with extreme caution.</p> <p>Good luck! Let me know in a comment if you manage to land a sweet gig :D</p> <h1> <a name="more-learning-resources" href="#more-learning-resources"> </a> More Learning Resources </h1> <h2> <a name="what-resources-should-i-use-to-learn-web-development" href="#what-resources-should-i-use-to-learn-web-development"> </a> What resources should I use to learn web development? </h2> <p>My personal #1 recommendation to anyone trying to get into web development as a career would be to go through <a href="https://www.theodinproject.com/">The Odin Project</a></p> <p>It is an absolutely incredible resource that teaches all of the fundamentals of web development (including HTML, CSS, Javascript and Git) and more in a completely free digital environment.</p> <p>They even have a Discord server for users to help each other out while going through the curriculum.</p> <p>If you go through the entire Odin Project from start to finish and complete every step and every project I genuinely believe you will be in a position to start applying for jobs. It uses all the same technologies that real companies use and mirrors the kinds of tasks and challenges you would find in a real professional web development position.</p> <p>In addition to the Odin Project, <a href="https://www.freecodecamp.org/">Free Code Camp</a> is also very highly recommended as a free resource to learn web development.</p> <ul> <li><a href="#what-are-the-best-free-resources-for-learning-html">What are the best free resources for learning HTML</a></li> <li><a href="#what-are-the-best-free-resources-for-learning-css">What are the best free resources for learning CSS</a></li> <li><a href="#what-are-the-best-free-resources-for-learning-javascript">What are the best free resources for learning Javascript</a></li> <li><a href="#what-are-the-best-free-resources-for-learning-git">What are the best free resources for learning Git</a></li> <li><a href="#what-are-the-best-free-resources-for-learning-databases">What are the best free resources for learning Databases</a></li> </ul> <h2> <a name="what-are-the-best-free-resources-for-learning-computer-science" href="#what-are-the-best-free-resources-for-learning-computer-science"> </a> What are the best free resources for learning computer science? </h2> <p>If you are interested in learning about the more generalized field of "software development" then there are some absolutely incredible free resources for that as well.</p> <p>Anything that you learn about the development in general will almost certainly help propel your understanding of web development as well. The great thing about software is that ultimately most of the concepts are the same regardless of which specialty you choose.</p> <p>Learning how to sort an array in C++ or Python will use all the same general concepts as sorting an array in Javascript. Learning how to do it in one language one will make learning it in the other significantly faster. Often you'll even learn tips and tricks that you might not have been exposed to working exclusively in one language.</p> <p>The gold standard free resource for getting introduced to programming and software development is <a href="https://cs50.harvard.edu">Harvard's free CS50 course</a>. Seriously, watch the preview video to get an idea, it's absolutely fascinating subject material and extremely well presented. I would recommend this course to anyone who was thinking about getting into development.</p> <p>After that we have the incredible <a href="https://github.com/ossu/computer-science">OSSU</a> which is an entire university level computer science available free online. Once again, this is one of the most amazing resources you will ever encounter, and entirely free.</p> <p>We also have <a href="https://teachyourselfcs.com/">teach yourself CS</a> which is very similar to OSSU in that it aims to be a complete computer science education.</p> <p>Lastly, I'd like to also share two other great resources for people interested in the field of software development, depending on where you interest lies:</p> <ul> <li><p>If you are interesting in using software and programming to solve practical everyday problems, check out <a href="https://automatetheboringstuff.com/">Automate the Boring Stuff</a> with Python. After completing this if you're working a white collar job using Excel in an office, there's a good chance you'll find you can automate away half the stuff you do on a daily basis.</p></li> <li><p>The other is for people who are more interested in the "how does software work at the lowest level". It's a project called <a href="https://www.nand2tetris.org/">Nand to Tetris</a> and it basically goes through the process of going from electronic hardware logic gates to a working game of Tetris. Very involved and complex, but incredibly rewarding.</p></li> <li><p>If you are interested to go even lower, down to the bare metal, then you'll definitely want to check out this incredible video series from Ben Eater on <a href="https://www.youtube.com/playlist?list=PLowKtXNTBypGqImE405J2565dvjafglHU">building an 8-bit computer from scratch</a>. If you complete a big project like this you'll learn more about computers than any single college course or video lecture will be able to teach you.</p></li> </ul> <h1> <a name="simple-website-template" href="#simple-website-template"> </a> Simple Website Template </h1> <p>The following is a simple example of a complete website that uses HTML, CSS and Javascript. These files are used as the basis of a lot of examples in this tutorial such as using Github, website hosting, and learning HTML/CSS/JS.</p> <p>The purpose of this section is to link to in those other parts of the tutorials to copy these files, but it may also serve as an example of a simple website setup that shows some of the fundamental concepts of HTML, CSS and Javascript.</p> <p>Feel free to use it for any part of your learning or projects in any way that you like.</p> <p>It consists of three files called <code>index.html</code>, <code>script.js</code> and <code>style.css</code> which are all intended to go into the same folder/directory. The contents of each of those three files is as follows:</p> <p><code>index.html</code><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight html"><code><span class="cp"><!DOCTYPE html></span> <span class="nt"><html</span> <span class="na">lang=</span><span class="s">"en"</span><span class="nt">></span> <span class="nt"><head></span> <span class="nt"><meta</span> <span class="na">charset=</span><span class="s">"UTF-8"</span> <span class="nt">/></span> <span class="nt"><title></span>My Animal Blog<span class="nt"></title></span> <span class="nt"><link</span> <span class="na">rel=</span><span class="s">"stylesheet"</span> <span class="na">href=</span><span class="s">"style.css"</span> <span class="nt">/></span> <span class="nt"><script </span><span class="na">defer</span> <span class="na">src=</span><span class="s">"script.js"</span><span class="nt">>

    My Favourite Animals

    Enjoy these furry friends

    class="card"> src="https://res.cloudinary.com/dqse2txyi/image/upload/v1657421273/blogs/intro-to-web-development/cat_k4fcww.png" alt="Cat Playing Chess" /> class="card__container">

    Chess Cat

    He's planning his next move.

    onclick="likeButton()">Like

    © 2022

    Enter fullscreen mode Exit fullscreen mode

    style.css

    body {
      color: #333333;
      font-family: Helvetica, sans-serif;
      margin: auto;
      max-width: 800px;
    }
    
    main {
      margin-bottom: 40px;
    }
    
    header,
    footer {
      text-align: center;
    }
    
    h1 {
      font-family: Arial, sans-serif;
    }
    
    h2 {
      font-style: italic;
      font-weight: lighter;
    }
    
    .card {
      width: 350px;
      margin: auto;
      box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
      border-radius: 10px;
      overflow: hidden;
    }
    
    .card > img {
      width: 100%;
      height: auto;
    }
    
    .card__container {
      padding: 16px;
    }
    
    Enter fullscreen mode Exit fullscreen mode

    script.js

    var likes = 0;
    
    // Adds 1 to the number of likes, and updates the text of the button
    function likeButton() {
      likes = likes + 1;
    
      var myButton = document.querySelector("button");
      myButton.innerText = "👍 " + likes;
    }
    
    Enter fullscreen mode Exit fullscreen mode

    When placed together and hosted with a web server, this will be the output when you visit the URL:

    Website Example

    Conclusion

    I hope you found this guide useful and informative. It's been extremely challenging to try and decide the right format to present it so that it can be helpful to as many people as possible.

    If you have any suggestions or feedback please leave a comment behind. Despite the length and scope of this guide I still consider it to be a work in progress and am very open to any ideas for improvement.

    Lastly, to everyone, I wish you good luck on your learning journey. Learning a new skill, especially one as complex as software development, takes a lot of time. Go easy on yourself, and remember that the goal is not overnight success, but rather a little bit of progress each day.

    All the best,

    ~ Alex

  • Newbie here: Is using PHP still fine?
    3 projects | /r/webdev | 20 Aug 2022
    However, if you wanted to use js to interact directly with db then a framework like express would not be necessary. You’d just use a database connector that’s specific to the type of database you’re using. for example
  • Finding an Authorization Bypass on My Own Website
    8 projects | news.ycombinator.com | 5 Mar 2022
    As a security professional, I was horrified to find out that the maintainers don't consider this a security issue, though they did promise to take this seriously and change the API when they were made aware of it in 2014 (https://github.com/mysqljs/mysql/issues/731).

    So I bumped an issue, noting this is all over HN, and offered to write a pull request for the API change proposed by the maintainers:

    https://github.com/mysqljs/sqlstring/issues/60

    Doug agreed to accept such a request, so I just sat down to figure out the code and a reasonable upgrade plan.

    Three hours later, I proudly wrote Doug this email (pasting it here because the issue and codebase are locked to non-contributors so I had to send it via email):

    OK, I have a draft pull request ready. Of course, it's a big change and I expect to get a lot of feedback and have a few rounds of back and forth and fixups before it is accepted.

    This is the plan as I envision it:

    * Release SqlString 3.0.0 that has a new allowObjectValues parameter defaulting to false. This is a new major, so it shouldn't break anybody's code.

    8 projects | news.ycombinator.com | 5 Mar 2022
    the author of the library is quite funny: https://github.com/mysqljs/mysql/issues/274#issuecomment-128... really stupid that such a big library still does not have the most important feature of a sql library.
  • How does one make a fully functional professional website?
    3 projects | /r/webdev | 18 Aug 2021
  • Best pure-node migration library that's pure SQL and supports multiple db's?
    2 projects | /r/node | 27 Jul 2021
    MySQL https://www.npmjs.com/package/mysql
  • DenoDB
    15 projects | news.ycombinator.com | 17 Jun 2021
  • Is there any npm package to substitute values to sql query and preventing sql injection?
    2 projects | /r/node | 13 Jun 2021
    https://www.npmjs.com/package/mysql#escaping-query-values

What are some alternatives?

When comparing denodb and MySQL you can also consider the following projects:

PostgreSQL - PostgreSQL client for node.js.

trpc - 🧙‍♀️ Move Fast and Break Nothing. End-to-end typesafe APIs made easy.

Prisma - Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB

slonik - A Node.js PostgreSQL client with runtime and build time type safety, and composable SQL.

MongoDB - The Official MongoDB Node.js Driver

RoadRunner - 🤯 High-performance PHP application server, process manager written in Go and powered with plugins

node-mssql - Microsoft SQL Server client for Node.js

LevelUP - A wrapper for abstract-leveldown compliant stores, for Node.js and browsers.

Couchbase - Couchbase Node.js Client Library (Official)

Redis - 🚀 A robust, performance-focused, and full-featured Redis client for Node.js.

postgres - Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare