<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Anthony Behery - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Anthony Behery - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sat, 23 May 2026 22:20:00 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/author/brandgrim/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ Python VS C++ Time Complexity Analysis ]]>
                </title>
                <description>
                    <![CDATA[ Speed is important in programming languages, and some execute much faster than others. For example, you might know that C++ is faster than Python. So why is this the case? Well, C++ is a language that uses a compiler, not to mention it is a much lowe... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/python-vs-c-plus-plus-time-complexity-analysis/</link>
                <guid isPermaLink="false">66ba5e22e727ef4561965ab2</guid>
                
                    <category>
                        <![CDATA[ algorithms ]]>
                    </category>
                
                    <category>
                        <![CDATA[ C++ ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Python ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Anthony Behery ]]>
                </dc:creator>
                <pubDate>Wed, 01 Mar 2023 19:07:56 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/02/aron-visuals-BXOXnQ26B7o-unsplash.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Speed is important in programming languages, and some execute much faster than others.</p>
<p>For example, you might know that C++ is <strong>faster</strong> than Python. So why is this the case?</p>
<p>Well, C++ is a language that uses a compiler, not to mention it is a much lower-level programming language than Python. That is to say, C++ provides much less <strong>abstraction</strong> from a computer's instruction set and architecture. </p>
<p>On the other hand, Python is an interpretated language, which just means that every line of the program is evaluated as the program is running. </p>
<p>But, how much faster IS C++ compared to Python? In this article you will see 3 algorithms and how they perform in C++ and Python. These algorithms are from "Data Structures and Algorithms Using C++" by Michael T. Goodrich. </p>
<blockquote>
<p><em>Note: The computer I ran these tests on was an Acer Swift 3. The CPU was a Ryzen 7 7500U with Radeon Graphics 1.80Gz. Along with 8GB of RAM, running Windows 10 Home.</em> </p>
</blockquote>
<p>You will be looking at these algorithms and their <strong>Big O Notation</strong>. Big O is a mathematical way of expressing the worst-case scenario of the time or space complexity of an algorithm. </p>
<p>The time complexity is the amount of time it takes for an algorithm to run, while the space complexity is the amount of space (memory) an algorithm takes up. Here is a graph to help explain Big O:</p>
<p><img src="https://paper-attachments.dropbox.com/s_2D428973624E7FC84C7D69D11421DE762BEA6B6F3361231FCDCAE0425D14526F_1664885448372_Untitled.drawio+17.png" alt="Chart" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://www.freecodecamp.org/news/big-o-cheat-sheet-time-complexity-chart/">Big O Cheat Sheet – Time Complexity Chart (freecodecamp.org)</a></em></p>
<p>From now on, I'll refer to each algorithm as running with a certain time complexity. </p>
<p>For example, if I say an algorithm runs with a <strong>O(n)</strong> time complexity, this means that as the input grows, the time it takes for an algorithm to run is <strong>linear</strong>. If I say it runs with <strong>O(n^2)</strong> time complexity, this means that as the input grows, the time it takes for an algorithm to run is <strong>quadratic</strong>. </p>
<h3 id="heading-performance-of-the-1st-algorithm">Performance of the 1st Algorithm:</h3>
<pre><code>Algorithm Ex1(A):
    Input: An array <span class="hljs-string">"A"</span> storing n &gt;= <span class="hljs-number">1</span> integers.
    Output: The sum <span class="hljs-keyword">of</span> the elements <span class="hljs-keyword">in</span> A.

    s = A[<span class="hljs-number">0</span>]
    <span class="hljs-keyword">for</span> i = <span class="hljs-number">1</span> to n - <span class="hljs-number">1</span> <span class="hljs-keyword">do</span>:
        s = s + A[i]
    <span class="hljs-keyword">return</span> s
</code></pre><p>In Python, we can express this algorithm as:</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">ex1</span>(<span class="hljs-params">A</span>):</span>
    sum = A[<span class="hljs-number">0</span>]
    <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> A:
        sum = sum + A[i]
    <span class="hljs-keyword">return</span> sum
</code></pre>
<p>If you use inputs up to about 5 million you will see that this algorithm takes about 4 seconds to run with that large of an input. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/image-228.png" alt="Image" width="600" height="400" loading="lazy">
<em>Performance of the 1st Algorithm</em></p>
<p>Then you can compare this algorithm in C++, like this:</p>
<pre><code class="lang-c++"><span class="hljs-function"><span class="hljs-keyword">double</span> <span class="hljs-title">ex1</span><span class="hljs-params">(<span class="hljs-keyword">double</span> A[], <span class="hljs-keyword">size_t</span> n)</span>
</span>{
    <span class="hljs-keyword">double</span> sum = A[<span class="hljs-number">0</span>];
    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">size_t</span> i = <span class="hljs-number">0</span>; i &lt; n; i++)
    {
        s = s + A[i];
    }
    <span class="hljs-keyword">return</span> sum;
}
</code></pre>
<p>You may be wondering, what is <code>size_t</code>? <code>size_t</code> is an "unsigned integer". This just means that this variable does not have a sign. Which also just means that this variable is <strong>not negative</strong>. </p>
<p>In C++, we use <code>size_t</code> to keep track of positions in an array, since those positions cannot be negative (at least in C++, since in Python we can have negative indexes).</p>
<p>Now let's take a look at the running time of the first algorithm:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/image-230.png" alt="Image" width="600" height="400" loading="lazy">
<em>Performance of the 1st Algorithm in C++</em></p>
<p>As you can see from these two charts, the time complexity seems to be linear. This means that the time complexity of this algorithm is <strong>O(n)</strong> – as the input size for <code>A</code> grows, the time it takes for this algorithm to run grows <strong>linearly.</strong></p>
<p>But it is interesting to notice that for very large inputs of 5 million, C++ does not even break the 1 second mark. Whereas Python breaks the 3-4 second mark for inputs at about 5 million. Let's move on to our next algorithm.</p>
<h3 id="heading-performance-of-the-2nd-algorithm">Performance of the 2nd Algorithm:</h3>
<pre><code>Algorithm Ex3(A):
    Input: An array <span class="hljs-string">"A"</span> storing n &gt;= <span class="hljs-number">1</span> integers.
    Output: The sum <span class="hljs-keyword">of</span> the prefix sums <span class="hljs-keyword">in</span> A.
    s = <span class="hljs-number">0</span>
    <span class="hljs-keyword">for</span> i = <span class="hljs-number">0</span> to n - <span class="hljs-number">1</span> <span class="hljs-keyword">do</span>:
        s = s + A[<span class="hljs-number">0</span>]
        <span class="hljs-keyword">for</span> j = <span class="hljs-number">1</span> to i <span class="hljs-keyword">do</span>:
            s = s + A[j]
    <span class="hljs-keyword">return</span> s
</code></pre><p>Here, you can see that this algorithm has two for-loops. So, moving forward this is something to acknowledge when analyzing the time complexity. </p>
<p>In Python, you can express this algorithm like this:</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">ex3</span>(<span class="hljs-params">A</span>):</span>
    sum = <span class="hljs-number">0</span>
    <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(len(A)):
        sum = sum + A[i]
        <span class="hljs-keyword">for</span> j <span class="hljs-keyword">in</span> range(<span class="hljs-number">1</span>, i):
            sum = sum + A[j]
    <span class="hljs-keyword">return</span> sum
</code></pre>
<p>Let's also use inputs all the way up to 70,000. Then we will record the times and chart the data like so:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/image-235.png" alt="Image" width="600" height="400" loading="lazy">
<em>Time Performance of the 2nd Algorithm in Python</em></p>
<p>These results are much different from our previous charts from algorithm 1. Something to point out is that with an input of 70,000, this algorithm takes a whopping 91 seconds in Python. Thats a long time! </p>
<p>Also, when I tried to run inputs higher than 70,000, my computer started to become unresponsive. Yikes.</p>
<p>Let's take a look at this algorithm in C++:</p>
<pre><code class="lang-c++"><span class="hljs-function"><span class="hljs-keyword">double</span> <span class="hljs-title">ex3</span><span class="hljs-params">(<span class="hljs-keyword">double</span> A[], <span class="hljs-keyword">size_t</span> n)</span>
</span>{
    <span class="hljs-keyword">double</span> s = <span class="hljs-number">0</span>;
    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">size_t</span> i = <span class="hljs-number">0</span>; i &lt; n; i++)
    {
        s = s + A[i];
        <span class="hljs-keyword">for</span>(<span class="hljs-keyword">size_t</span> j = <span class="hljs-number">1</span>; j &lt; i; j++)
        {
            s = s + A[j];
        }
    }
    <span class="hljs-keyword">return</span> s;
}
</code></pre>
<p>For the C++ code I was able to increase the input size to ~90,000.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/image-238.png" alt="Image" width="600" height="400" loading="lazy">
<em>Time Performance of the 2nd Algorithm in C++</em></p>
<p>For an input size of 70,000 this algorithm takes ~4 seconds to run in C++. That difference is huge. Not to mention, I was able to use inputs that were about ~90,000 elements in size for C++, with it not even breaking past the 10 second mark. </p>
<p>Also, we can see that the curve is not as smooth as the Python graph. This could be due to some other processes running in the background (since I'm running on Windows 10) or some other reason. </p>
<p>Also, we can classify the time complexity of this algorithm as <strong>O(n^2)</strong>, which just means that the time complexity for this algorithm is quadratic. </p>
<p>Let's move on to the last algorithm.</p>
<h3 id="heading-performance-of-the-3rd-algorithm">Performance of the 3rd Algorithm:</h3>
<pre><code>Algorithm Ex5(A, B):
    Input: Arrays <span class="hljs-string">"A"</span> and <span class="hljs-string">"B"</span> each storing n &gt;= <span class="hljs-number">1</span> integers.
    Output: The number <span class="hljs-keyword">of</span> elements <span class="hljs-keyword">in</span> B equal to the sum <span class="hljs-keyword">of</span>
            prefix sums <span class="hljs-keyword">in</span> A.
    c = <span class="hljs-number">0</span>
    <span class="hljs-keyword">for</span> i = <span class="hljs-number">0</span> to n - <span class="hljs-number">1</span> <span class="hljs-keyword">do</span>:
        s = <span class="hljs-number">0</span>
        <span class="hljs-keyword">for</span> j = <span class="hljs-number">0</span> to n - <span class="hljs-number">1</span> <span class="hljs-keyword">do</span>:
            s = s + A[<span class="hljs-number">0</span>]
            <span class="hljs-keyword">for</span> k = <span class="hljs-number">1</span> to j <span class="hljs-keyword">do</span>:
                s = s + A[k]
            <span class="hljs-keyword">if</span> B[i] == s then:
                c = c + <span class="hljs-number">1</span>
    <span class="hljs-keyword">return</span> c
</code></pre><p>Let's take a look at this code in Python:</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">ex3</span>(<span class="hljs-params">A, B</span>):</span>
    c = <span class="hljs-number">0</span>
    <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(len(A)):
        s = <span class="hljs-number">0</span>
        <span class="hljs-keyword">for</span> j <span class="hljs-keyword">in</span> range(len(A)):
            s = s + A[<span class="hljs-number">0</span>]
            <span class="hljs-keyword">for</span> k <span class="hljs-keyword">in</span> range(<span class="hljs-number">1</span>, j):
                s = s + A[k]
            <span class="hljs-keyword">if</span> B[i] == s:
                c = c + <span class="hljs-number">1</span>
    <span class="hljs-keyword">return</span> c
</code></pre>
<p>Now, let's analyze the timings:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/image-241.png" alt="Image" width="600" height="400" loading="lazy">
<em>Time Performance of the 3rd Algorithm in Python</em></p>
<p>Woah, what's going on here? We can see that as our inputs starts to increase, the rate at which the algorithm runs also starts to increase, but it is increasing at a drastic rate. </p>
<p>In this case, we can see with an input size of 3500 that it takes 761 seconds for this algorithm to run in Python. You may be asking, "Did you actually sit through all 761 seconds?", the answer is yes. Yes, I did. </p>
<p>Now let's take a look at the C++ code:</p>
<pre><code class="lang-c++"><span class="hljs-function"><span class="hljs-keyword">double</span> <span class="hljs-title">ex5</span><span class="hljs-params">(<span class="hljs-keyword">double</span> A[], <span class="hljs-keyword">double</span> B[], <span class="hljs-keyword">size_t</span> n)</span>
</span>{
    <span class="hljs-keyword">double</span> c = <span class="hljs-number">0</span>;
    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">size_t</span> i = <span class="hljs-number">0</span>; i &lt; n; i++)
    {
        <span class="hljs-keyword">double</span> s = <span class="hljs-number">0</span>;
        <span class="hljs-keyword">for</span>(<span class="hljs-keyword">size_t</span> j = <span class="hljs-number">0</span>; j &lt; n; i++)
        {
            s = s + A[<span class="hljs-number">0</span>]
            <span class="hljs-keyword">for</span>(<span class="hljs-keyword">size_t</span> k = <span class="hljs-number">1</span>; k &lt; j; k++)
            {
                s = s + A[k];
            }
            <span class="hljs-keyword">if</span>(B[i] == s)
            {
                c = c + <span class="hljs-number">1</span>
            }
        }
    }
    <span class="hljs-keyword">return</span> c;
}
</code></pre>
<p>Let's take a look at the graph.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/image-243.png" alt="Image" width="600" height="400" loading="lazy">
<em>Time Performance of the 3rd Algorithm in C++</em></p>
<p>Similar to the second algorithm, it is interesting to see that the curve is not as smooth as the Python graph. </p>
<p>Also, we can see that we can go well above an input size of 3500. My computer started acting up once I pushed the input size past 10,000 for C++. Not to mention, with an input size of 10,000 the algorithm averaged about 544-545 seconds. </p>
<p>We can classify this algorithm as having a time complexity of <strong>O(n!).</strong> Which just means that this algorithm is factorial, which runs <strong>very slowly.</strong> </p>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>I hope you found the differences of running times between Python and C++ just as fascinating as I have. </p>
<p>Also, just because Python runs slower than C++ for every algorithm does not mean that C++ is the "better" language. Both of these languages have their own purposes for the type of software you are trying to create. </p>
<p>C++ would be the preferred language if performance is critical. If you were programming games, operating systems, or communicating between machinery, C++ would be the better choice due to its compiled and fast nature.</p>
<p>Python would be preferred if you need to develop software quickly. Due to its easier learning curve, almost anyone can pick up Python and start creating software with it. Python also provides many resources for data science and machine learning.</p>
<p>Check out the code if you would like to try these tests on your own computer:</p>
<div class="gist-block embed-wrapper" data-gist-show-loading="false" data-id="a1b590ceea0cb21fb01dfc7013b3a1da">
        <script src="https://gist.github.com/tarmacjupiter/a1b590ceea0cb21fb01dfc7013b3a1da.js"></script></div><div class="gist-block embed-wrapper" data-gist-show-loading="false" data-id="4120e8afb57db0559174b3caadbf426d">
        <script src="https://gist.github.com/tarmacjupiter/4120e8afb57db0559174b3caadbf426d.js"></script></div><p>Cheers!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Linux Shells for Beginners – Bash, Zsh, and Fish Explained ]]>
                </title>
                <description>
                    <![CDATA[ When you open up your terminal, chances are that it uses Bash as its UNIX shell environment. But other "shell" environments exist. There are other environments such as the C Shell, Korn Shell, Z Shell, and even the Fish Shell. All of these different ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/linux-shells-explained/</link>
                <guid isPermaLink="false">66ba5e1d6345dce12bfbb0e2</guid>
                
                    <category>
                        <![CDATA[ Bash ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Linux ]]>
                    </category>
                
                    <category>
                        <![CDATA[ zsh ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Anthony Behery ]]>
                </dc:creator>
                <pubDate>Tue, 13 Dec 2022 21:55:05 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/12/pexels-oleksandr-pidvalnyi-320260.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>When you open up your terminal, chances are that it uses Bash as its UNIX shell environment. But other "shell" environments exist.</p>
<p>There are other environments such as the C Shell, Korn Shell, Z Shell, and even the Fish Shell. All of these different shell environments have their own pros and cons, and you should consider them before you choose one to use on your own system.</p>
<p>In this article, I'll go over a few popular shells along with their main features to help you pick one.</p>
<h2 id="heading-the-bash-shell">The Bash Shell</h2>
<p>The Bash Shell (or the Bourne Again Shell) is a UNIX shell and command language. It was written by Brain Fox for the GNU Project as a free software replacement for the Bourne Shell (sh). </p>
<p>Bash was first released in 1989, and for most Linux distributions it's the default Shell environment. Other distros, like Kali Linux, use the Z Shell as their default shell. </p>
<p>Bash is one of the first programs that Linus Torvalds (the creator of Linux) ported to Linux. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/cli_example.png" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://www.geeksforgeeks.org/introduction-linux-shell-shell-scripting/">Image Source</a></em></p>
<p>Something you should not get confused about is that Bash is also a programming language. So it's a "Shell", but you can also program behavior in Bash. For example:</p>
<pre><code class="lang-bash"><span class="hljs-meta">#!/bin/bash</span>
<span class="hljs-built_in">echo</span> <span class="hljs-string">"Hello World"</span>
</code></pre>
<h3 id="heading-key-points-about-bash">Key points about Bash</h3>
<ul>
<li>Most users use Bash, since it is the default shell environment on most systems</li>
<li>Bash does not have an inline wildcard expression. A wildcard expression is when you would want to search for patterns in your Shell, similar to Regex. The three main wildcards are <code>*</code>, <code>?</code>, and <code>[]</code>.</li>
<li>You can't automatically change the directory name</li>
<li><code>#</code> is treated as a comment in scripting </li>
<li>It has <code>shopt</code> settings</li>
<li>Prompt has backslash escapes</li>
<li>User configuration settings are in <code>.bashrc</code></li>
</ul>
<h2 id="heading-the-z-shell">The Z Shell</h2>
<p>The Z Shell, or Zsh is also a UNIX shell that is very similar to Bash. You can also script and use the shell as a command interpreter. </p>
<p>Zsh is an extension of the Bourne shell with a lot of improvements. Zsh was released in 1990 by Paul Falstad, and it has some features that Bash, Korn Shell, and C Shell share. </p>
<p>macOS by default uses the Zsh Shell. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/nebirhos.jpg" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://ohmyz.sh/">Image Source</a></em></p>
<h3 id="heading-key-points-about-zsh">Key points about Zsh</h3>
<ul>
<li>Comes with autocompletion when using the terminal. So when you press <code>Tab ↹</code> in order to autocomplete whatever command you want to run, not only does it autocomplete for you but will bring down a drop-down of all the other possible files and directories:</li>
</ul>
<p><img src="https://i.ibb.co/bswYkn0/0f8c8e1a6016.gif" alt="Zsh Toggle" width="1440" height="810" loading="lazy"></p>
<ul>
<li>Supports inline wildcard expressions</li>
<li>Much more configurable than Bash</li>
<li>Supports plugins and themes. Here's a <a target="_blank" href="https://github.com/unixorn/awesome-zsh-plugins">list of plugins</a> available for Zsh.</li>
</ul>
<p>There are also frameworks built around the Z Shell. One of the most popular ones is <a target="_blank" href="https://ohmyz.sh/">Oh My Zsh</a>, which is a community driven, open-source framework for managing Zsh configuration. (I use Oh My Zsh 😄) </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/oh-my-zsh-mac.jpg" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://osxdaily.com/2021/11/15/how-install-oh-my-zsh-mac/">Image Source</a></em></p>
<p>Zsh and Oh My Zsh are similar but not the same exact things. To reiterate, Oh My Zsh is a way of managing your Zsh configurations, it is not the Shell itself. </p>
<h2 id="heading-the-fish-shell">The Fish Shell</h2>
<p>Fish is a UNIX shell environment with an emphasis on interactivity and usability. Unlike Zsh, Fish aims to give the user interactivity by default instead of trusting the user to implement their own configuration.  </p>
<p>It was created by Axel Liljencrantz in 2005. Fish is considered to be an "exotic shell" due to the fact that it does not comply to the POSIX shell standards. [[Source](https://en.wikipedia.org/wiki/Fish_(Unix_shell)]</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/fish-shell-screenshot.png" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://blog.sudobits.com/2015/06/05/fish-a-user-friendly-command-line-shell-for-ubuntulinux/">Image Source</a></em></p>
<h3 id="heading-key-points-about-fish">Key points about Fish</h3>
<ul>
<li>Fish has "search as you type" automatic suggestions based on your command history and the directory you are in. Similar to Bash's history search, Fish Shell's search history is <strong>always</strong> turned on. That way the user will be able to get interactive feedback when working in their terminal. </li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/fish.gif" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://taskwarrior.org/news/news.20140906/">Image Source</a></em></p>
<ul>
<li>Fish also prefers features as commands rather than syntax. This makes features visible in terms of commands with options and help texts</li>
<li>Since Fish by default comes with a lot of configurations already set, it is believed to be more beginner friendly than other <code>sh</code> options like Zsh.</li>
<li>Fish's scripting language is different than Zsh and Bash. Zsh uses more aliases whereas Fish avoids using aliases in the scripting language.</li>
</ul>
<p>If you were to just make scripts using basic commands such as, <code>cd</code>, <code>cp</code>, <code>vim</code>, <code>ssh</code>, and so on, you would not notice any difference in the way Fish and Bash's scripting languages work. </p>
<p>One of the biggest differences is when you try capturing output from a command. In Bash you may be used to this:</p>
<pre><code class="lang-bash">todays_date=$(date)
<span class="hljs-built_in">echo</span> <span class="hljs-string">"Todays date is <span class="hljs-variable">$todays_date</span>"</span>
</code></pre>
<p><img src="https://i.ibb.co/0hrF0Y3/fa71b0032fba.gif" alt="Output" width="657" height="385" loading="lazy"></p>
<pre><code>Todays <span class="hljs-built_in">Date</span> is Tue Dec <span class="hljs-number">13</span> <span class="hljs-number">15</span>:<span class="hljs-number">29</span>:<span class="hljs-number">28</span> CST <span class="hljs-number">2022</span>
</code></pre><p>Whereas in Fish, capturing output works differently. The equivalent for Fish in scripting would look like this:</p>
<pre><code class="lang-bash"><span class="hljs-built_in">set</span> date (date)
<span class="hljs-built_in">echo</span> <span class="hljs-string">"Todays Date <span class="hljs-variable">$date</span>"</span>
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/ezgif.com-gif-maker.gif" alt="Image" width="600" height="400" loading="lazy"></p>
<pre><code class="lang-bash">todays date is Tue Dec 13 21:35:03 UTC 2022
</code></pre>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Bash, Z Shell, and Fish Shell all have their merits, along with some similarities. You can use each of them effectively in your work environment now that you know a bit more about them. </p>
<p>If you want something more configurable, you could use Zsh (or even install Oh My Zsh). If you want more of an interactive terminal experience without a lot of configuration, you could use Fish Shell. If you want the classic feel, you can just keep Bash. </p>
<p>It all really comes down to your preferences as a developer - so just choose the shell that works best for you.</p>
<p><em>Hope this helped you! Thank you for reading</em> 🐚🐚🐚</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to View Your Linux Processes ]]>
                </title>
                <description>
                    <![CDATA[ You may be used to using the Activity Monitor in MacOS or the Task Manager for Windows to see the current processes running on your system.  But for those running Linux, if that includes a dual boot, virtual box, or even WSL2, you could use a useful ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/linux-top/</link>
                <guid isPermaLink="false">66ba5e206345dce12bfbb0e4</guid>
                
                    <category>
                        <![CDATA[ Linux ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Anthony Behery ]]>
                </dc:creator>
                <pubDate>Tue, 06 Dec 2022 21:09:33 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/12/Screenshot-2022-12-05-235534.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>You may be used to using the <code>Activity Monitor</code> in MacOS or the <code>Task Manager</code> for Windows to see the current processes running on your system. </p>
<p>But for those running Linux, if that includes a dual boot, virtual box, or even WSL2, you could use a useful Linux command to inspect and look at all the current processes going on in your operating system.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-8.png" alt="Image" width="600" height="400" loading="lazy">
<em>MacOS Activity Monitor</em></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-7.png" alt="Image" width="600" height="400" loading="lazy">
<em>Windows Task Manager</em></p>
<h2 id="heading-what-is-the-linux-equivalent">What is the Linux Equivalent?</h2>
<p>The <code>top</code> (table of processes) command in Linux will display all the system processes. If you were to try this command in your terminal, you would see this: </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/30fps.gif" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Thats pretty neat – the <code>top</code> program shows a dynamic list of all the running processes going on in your Linux system. </p>
<p>Usually, this command shows a summary of the information on your system that's currently being run/managed by the Linux kernel. </p>
<p>To leave <code>top</code> press <code>q</code> on your keyboard to exit the interactive shell.</p>
<h3 id="heading-what-do-the-columns-mean">What do the columns mean?</h3>
<ul>
<li><strong>PID:</strong> Shows the task's unique process ids.</li>
<li><strong>USER:</strong> Shows which user is running what task</li>
</ul>
<p>For example, you see "root" and "brandgrim". Root is, well, the root of the system running that process, whereas "brandgrim" (me!) is the user running that process. </p>
<ul>
<li><strong>PR:</strong> This number shows the process priority – the lower the number is, the higher priority. (Makes sense intuitively, right?) </li>
<li><strong>VIRT:</strong> The total virtual memory used by the task</li>
<li><strong>RES:</strong> How much RAM the process is actually using, measured in KB</li>
<li><strong>SHR:</strong> This number represents the Shared Memory size used by a specific task</li>
<li><strong>%CPU:</strong> Represents the CPU usage</li>
<li><strong>%MEM:</strong> Represents the Memory usage</li>
<li><strong>+TIME:</strong> Depicts the total CPU time that the task has used since the task started</li>
<li><strong>COMMAND:</strong> The name of the command that actually started the process</li>
</ul>
<p>When you are in the interactive shell of <code>top</code> you can press <code>h</code> to bring up the <code>Summary of Less Commands</code> which is a list of all the commands <code>top</code> has to offer.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-9.png" alt="Image" width="600" height="400" loading="lazy">
<em>Showing the "Summary of Less Commands" in <code>top</code></em></p>
<h2 id="heading-useful-flags-and-commands">Useful Flags and Commands</h2>
<p><code>top</code> has so many unique flags and commands it may seem overwhelming to know which one to use, although there are some flags that are useful right off the bat.</p>
<h3 id="heading-how-to-filter-by-user">How to Filter by User</h3>
<p>The <code>-u</code> flag specifies which processes should be listed depending on what user you specify. </p>
<p>For example, we saw that under the <strong>USER</strong> column there was "root" and "brandgrim", so if we were to try this:</p>
<pre><code class="lang-bash">top -u root
</code></pre>
<p>we would see the following:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-10.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Which lists out the processes that are being run under the "root" user. If we were to try this command, on the other hand:</p>
<pre><code class="lang-bash">top -u brandgrim
</code></pre>
<p>We'd get the following (which shows processes being run under the "brandgrim" user):</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-11.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-how-to-change-the-refresh-interval">How to Change the Refresh Interval</h3>
<p>By default, the screen refresh interval for top is set to 3.0 seconds. If you would like to increase the interval or decrease it, you can press <code>d</code> while you are in the <code>top</code> interactive shell in order to set a desired time.</p>
<p><img src="https://i.ibb.co/d0PYmJ3/281f04fc75ba.gif" alt="Image" width="1440" height="810" loading="lazy">
<em>Showing how to change the refresh interval</em></p>
<h3 id="heading-how-to-sort-processes-by-cpu-utilization">How to Sort Processes by CPU Utilization</h3>
<p>In order to sort all your Linux processes by how much CPU they use, you would need to press the <code>SHIFT + P</code> keys in order to sort them in <code>top</code>. Now you know what was hogging up your CPU – that pesky little while loop that kept running infinitely! </p>
<p>For example, when I filter my processes when I open VSCode, here's what I see:</p>
<p><img src="https://i.ibb.co/3YwQhbf/88368a8fe195.gif" alt="Processes" width="1440" height="810" loading="lazy"></p>
<p>You can see that the CPU utilization is initially very high, although it starts to decrease as VSCode loads in all my extensions and the Intellisense.</p>
<h3 id="heading-how-to-save-top-processes-inside-a-file">How to Save Top Processes Inside a File</h3>
<p>To save all the running top command results into a file, you can use these commands:</p>
<pre><code class="lang-bash">top -n 1 -b &gt; top-processes.txt
</code></pre>
<h2 id="heading-top-alternatives"><code>top</code> Alternatives</h2>
<p>There are plenty of <code>top</code> alternatives, such as <code>Htop</code>, <code>Vtop</code>, <code>Gtop</code>, <code>Gotop</code>, and many more – although I won't cover all these in this article.</p>
<p><code>Htop</code> is currently the most popular <code>top</code> alternative thanks to its interactive menu and the ability to scroll vertically and horizontally. Not to mention that <code>Htop</code> also allows you to view your processes in a tree-like structure, which is easier to visualize.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-12.png" alt="Image" width="600" height="400" loading="lazy">
<em>Htop (looks cool!)</em></p>
<h1 id="heading-conclusion">Conclusion</h1>
<p><code>top</code> is an interactive shell that allows you to view all your Linux processes in a real-time view. It displays system information along with lists of processes or threads being currently used by the Linux kernel. </p>
<p><code>top</code> comes with its own useful commands such as the <code>-u</code> flag and <code>d</code> command. There are some more mordern <code>top</code> alternatives like <code>Htop</code> which allows for a more colorful and interactive shell. </p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://tenor.com/view/how-linux-users-install-a-web-browser-linux-linux-users-gif-20223386">https://tenor.com/view/how-linux-users-install-a-web-browser-linux-linux-users-gif-20223386</a></div>
<p>Hope this helped you! Thank you for reading :)</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
