<?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" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[StartCode - Medium]]></title>
        <description><![CDATA[StartCode is a publication dedicated to all kind of programming enthusiasts - Medium]]></description>
        <link>https://medium.com/startcode?source=rss----ae3580043a53---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>StartCode - Medium</title>
            <link>https://medium.com/startcode?source=rss----ae3580043a53---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 12:53:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/startcode" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Javascript Basics: Data Types — Part 1]]></title>
            <link>https://medium.com/startcode/javascript-basics-data-types-part-1-b6dc500c74ff?source=rss----ae3580043a53---4</link>
            <guid isPermaLink="false">https://medium.com/p/b6dc500c74ff</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Cartas Cosmin]]></dc:creator>
            <pubDate>Sat, 28 Sep 2019 13:24:44 GMT</pubDate>
            <atom:updated>2019-09-28T15:43:09.972Z</atom:updated>
            <content:encoded><![CDATA[<h3>Javascript Basics: Data Types — Part 1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*rs8vlljpF__ieASNdqwUtA.jpeg" /></figure><p><em>Definition: The data type of a variable tells the interpreter (or the compiler) how we intend to use that variable.</em></p><p>If we would like to categorize programming languages based on data types we can split them in two categories: <strong>statically typed</strong> and <strong>dynamically typed</strong>. Javascript is part of the second category and that makes the development process easy and fast. However there is a downside of this aspect when comes to bug fixing and debugging process (it’s harder to understand your code when you look at it 3 weeks later if you didn’t added comments and respected clean code principles).</p><p>If you are interested in other topics related to Javascript Basics please check them out:</p><ul><li><a href="https://medium.com/startcode/javascript-basics-variables-389d4f2401d7">Javascript Variables</a></li></ul><blockquote><strong>What are the data types supported by Javascript?</strong></blockquote><ul><li><strong>Primitives:</strong> undefined, null, Number, String, Boolean, BigInt, Symbol;</li><li><strong>Objects</strong></li></ul><h3>Primitives</h3><p><em>Definition: A primitive is represented by data that is not an object and contains no methods.</em></p><h4>1.1 undefined — data type</h4><blockquote>Note: Don’t explicitly initialize a variable with undefined as a developer. You have null!</blockquote><p><em>Definition: Undefined is a data type used by </em><strong><em>Javascript engine</em></strong><em> in order to tell the developer that there is no memory allocated for a piece of data or a variable has not been initialized.</em></p><blockquote><strong>What does that mean?</strong></blockquote><p><strong>Example 1:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/75decc7676d98d59de67eae0664cec24/href">https://medium.com/media/75decc7676d98d59de67eae0664cec24/href</a></iframe><p>In this example we are trying to print in the browser’s console a variable named <strong>b </strong>but that variable is not declared anywhere in our Javascript file. The interpreter is smart enough to notice that and throws a <strong>ReferenceError </strong>with a specific message.</p><p><strong>Example 2:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/300478712accd0f97fef674baa9505a5/href">https://medium.com/media/300478712accd0f97fef674baa9505a5/href</a></iframe><p>The difference between first and second example is at the <strong>line 5</strong> where we added the declaration of variable <strong>b</strong>. Our script is not throwing an error anymore and the engine is telling us that <strong>b</strong> is <strong>declared</strong> but there is <strong>no value</strong> associated with it (undefined).</p><p><strong>Example 3 (hoisting mechanism):</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/104c32ebc1fc8191651248634a11016b/href">https://medium.com/media/104c32ebc1fc8191651248634a11016b/href</a></iframe><p>If we are taking a look at the <strong>1st line of code</strong> we’re trying to print at the console the value of variable <strong>b</strong>, you would expect to see an error thrown because we are trying to access a piece of data that wasn’t declared and initialized yet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/1*JLZpPfU5D27vsrWjMIdigQ.png" /><figcaption>Fig.1.1.4 Global variable window</figcaption></figure><p>By analyzing the global variable <strong>window </strong>before we are trying to run our code, we can notice that variables <strong>a</strong> and <strong>b </strong>exists in memory but there are no values associated with them.</p><blockquote><strong>Why is this happening?</strong></blockquote><p>Javascript interpreter analyzes our code and allocates memory for each variable found in the global execution context. The variables won’t be initialized until the execution reach the specific lines of code (in our example line 5 and 6). This behavior is different when it comes to functions but this aspect will be covered in another article.</p><h4>1.2 null — data type</h4><p><em>Definition: Null data type is the equivalent of undefined but specific to developers. In order to declare a variable and tell the engine that it doesn’t contain any value, we initialize it with </em><strong><em>null</em></strong><em>.</em></p><p><strong>Example:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/559cbe79613dbf34c1a2f2de89628a8c/href">https://medium.com/media/559cbe79613dbf34c1a2f2de89628a8c/href</a></iframe><p>In this example we take two variables <strong>a</strong> and <strong>b </strong>initialized with <strong>undefined</strong> and <strong>null</strong>. On the <strong>line 7</strong> it can be noticed that the javascript engine treats the two values the same that’s why the printed value is <strong>true. </strong>When the check for data type is performed (line 8) the result is evaluated to false.</p><h4>1.3 Number — data type</h4><p><em>Definition: Javascript treats floating point values and integers as a single data type called </em><strong><em>number</em></strong><em> that is the equivalent of double’s size (64 bits).</em></p><p><strong>Example 1:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c4d8cc9ebb40b79dfda5433362a1ac75/href">https://medium.com/media/c4d8cc9ebb40b79dfda5433362a1ac75/href</a></iframe><p>As it was mentioned above, numbers are treated as a single data type and offers a mechanism to parse strings to integers or floats.</p><p><strong>Example 2:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a600c7b1536e815405c4ee3f03f92d5/href">https://medium.com/media/7a600c7b1536e815405c4ee3f03f92d5/href</a></iframe><p>Constant values are provided for checking the boundaries supported by the language for integers and floating point numbers:</p><ul><li><strong>MIN_SAFE_INTEGER</strong> &amp; <strong>MAX_SAFE_INTEGER</strong>: min and max value supported by a number used as an integer;</li><li><strong>MIN_VALUE</strong> &amp; <strong>MAX_VALUE</strong>: min and max value supported by a number used as floating point numbers;</li></ul><blockquote>Note: Don’t make a confusion between the two!</blockquote><p><strong>Example 3:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac5067f54975bfe9936d87c0af7e200c/href">https://medium.com/media/ac5067f54975bfe9936d87c0af7e200c/href</a></iframe><p>The language provides a set o special values: <strong>NaN</strong>, <strong>Infinity</strong> and <strong>-Infinity </strong>in order to prevent bugs from computation of too big numbers or non numeric parsing.</p><blockquote>Note: NaN === NaN is false!</blockquote><h4><strong>1.4 String — data type</strong></h4><p><em>Definition: Just like any other programming language String data type is used to represent a sequence of characters.</em></p><p><strong>Example 1:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sektIENaBnJSwrJImk-J3w.png" /><figcaption>Fig.1.4.1 Basic string initialization</figcaption></figure><p>We can initialize string variables by using string literals (direct initialization using ‘’ or “”) or by using String data type.</p><p><strong>Example 2:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wg1XBMvxk9na_70z1JgjPQ.png" /><figcaption>Fig.1.4.2 String concatenation</figcaption></figure><p>String concatenation can be done with different data types by using <strong>+</strong> operator and the coercion is done automatically. Not that for <strong>Symbols</strong> you cannot perform direct concatenation and <strong>toString()</strong> method has to be called.</p><p><strong>Example 3:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EUB19rlI1_k6ytiGoDZAsw.png" /><figcaption>Fig.1.4.3 String interpolation</figcaption></figure><p>Having multiple variables that needs to be concatenated into a single string could lead to unreadable code. String concatenation was made easier from the introduction of string interpolation in ES6 (using back ticks `` and ${} for variable values).</p><h4>1.5 Boolean — data type</h4><p><em>Definition: Boolean is one of the most important data types from the language and is used for evaluating expressions to </em><strong><em>true</em></strong><em> or </em><strong><em>false</em></strong><em>.</em></p><p><strong>Example:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/052aba9182ee026658a3cb57710a44d3/href">https://medium.com/media/052aba9182ee026658a3cb57710a44d3/href</a></iframe><p>Iterating through to all data types used in this example we can notice the following behavior:</p><ul><li>Number — Initializing a Boolean variable with <strong>any non-zero</strong> value is evaluated to <strong>true</strong>;</li><li>String — Initializing a Boolean variable with anything <strong>different</strong> than an <strong>empty string</strong> is evaluated to <strong>true</strong>;</li><li>Null &amp; Undefined — Boolean evaluates <strong>null</strong> and <strong>undefined</strong> to <strong>false</strong>;</li><li>BigInt — Boolean evaluates any value different than <strong>0n</strong> to true (not presented in the example);</li><li>Symbol — Boolean evaluates any symbol to <strong>true</strong>;</li></ul><h4>1.6 BigInt — data type</h4><p><em>Definition: BigInt is a new primitive data type that allows initialization of variables with values bigger than the </em><strong><em>MAX_SAFE_INTEGER </em></strong><em>or smaller than </em><strong><em>MIN_SAFE_INTEGER</em></strong><em>.</em></p><p><strong>Example:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8dab930639dfda458b624c8106c18940/href">https://medium.com/media/8dab930639dfda458b624c8106c18940/href</a></iframe><p>BigInts have a <strong>’n’ </strong>appended after the numeric value. Even though BigInt is a numeric data type, they cannot be used with the current Math library or with the coercion mechanism applied to basic operations with numbers. (<strong>line 5 and 6</strong>).</p><h4><strong>1.7 Symbol — data type</strong></h4><p><em>Definition: Symbol is a type introduced in ES6 that provides a mechanism to create unique identifiers. They provide an argument used as a descriptor for that specific symbol.</em></p><blockquote>Their true purpose is to do meta-programming but this will not be covered in the basics topics.</blockquote><p><strong>Example 1:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e5c9c97508c7fba3d7be42ee676c9f86/href">https://medium.com/media/e5c9c97508c7fba3d7be42ee676c9f86/href</a></iframe><blockquote>Note that symbols are primitives just like the other data types presented above and cannot be used with the new keyword or with a shorthand initialization.</blockquote><p>Even though we initialize two symbols with the same descriptor, they are represented as two different values (<strong>see line 6</strong>).</p><p><strong>Example 2 (objects):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CPfP3uySQS4YHnedWFHyBA.png" /><figcaption>Fig.1.7.2 Object with no encapsulation</figcaption></figure><p>If we would like to create an object with some sensitive property like the <strong>IBAN </strong>is, the desired behavior would be to prevent the modification of the property outside of the class. In this example the <strong>IBAN</strong> is changed without any problems as it can be noticed in the printed values from the console.</p><p><strong>Example 3 (objects and symbols):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fJf06AGe1n7kPt0Fmd1qzg.png" /><figcaption>Fig.1.7.3 Object encapsulation using Symbol</figcaption></figure><p>We can achieve the encapsulation of BankAccount with the definition of IBAN as a Symbol and manipulate its value inside the object. The property is not visible when we run <strong>Object.entries</strong> or <strong>Object.keys</strong>. Unfortunately the property is not fully private since it can be accessed by using <strong>Object.getOwnPropertySymbols</strong>.</p><blockquote>Note: Symbol properties can be modified by using reflection mechanism!</blockquote><p>In the <strong>second part</strong> of this article we will present how <strong>Object</strong> data type works in Javascript.</p><blockquote>If you have any questions related to this article please leave a comment below. Subscribe to our publication in order to find more articles like this and enhance your developer skills on various topics. Thanks!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6dc500c74ff" width="1" height="1" alt=""><hr><p><a href="https://medium.com/startcode/javascript-basics-data-types-part-1-b6dc500c74ff">Javascript Basics: Data Types — Part 1</a> was originally published in <a href="https://medium.com/startcode">StartCode</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Javascript Basics: Variables]]></title>
            <link>https://medium.com/startcode/javascript-basics-variables-389d4f2401d7?source=rss----ae3580043a53---4</link>
            <guid isPermaLink="false">https://medium.com/p/389d4f2401d7</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Cartas Cosmin]]></dc:creator>
            <pubDate>Thu, 19 Sep 2019 17:44:06 GMT</pubDate>
            <atom:updated>2019-09-28T13:29:05.011Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*GkKR9ykg7ahFCHAhbT4DtQ.png" /></figure><p><em>Definition (Wiki): A variable is a storage location in memory paired with a symbolic name (identifier), which contains some known quantity of information referred to as a value.</em></p><p>Just like any other popular programming language, Javascript can store information in <strong>variables</strong>.</p><p>If you are interested in other topics related to Javascript Basics please check them out:</p><ul><li><a href="https://medium.com/startcode/javascript-basics-data-types-part-1-b6dc500c74ff">Data Types — Part 1</a></li></ul><h4>1. Basic syntax</h4><p>If we would want to declare a variable identified with the symbolic name <strong><em>a </em></strong>that contains the value <strong><em>10</em></strong> we would use the following syntax:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2090de34d05374e929796a3e499f81ee/href">https://medium.com/media/2090de34d05374e929796a3e499f81ee/href</a></iframe><p>However our code is not complete, even though it runs and we have no error thrown in browser’s console tab. The complete version of the example would look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bea9793eabc67f5483ad67fe3c19a200/href">https://medium.com/media/bea9793eabc67f5483ad67fe3c19a200/href</a></iframe><p>Our new version of the code contains a keyword called <strong><em>var </em></strong>before the declaration of <strong><em>a </em></strong>and explicitly marks it as a variable. This approach will help other programmers that will take a look at our code in order to understand our logic.</p><blockquote>But why we didn’t got an error from running the first example?</blockquote><p>Javascript is not a compiled programming language and it’s interpreted by a tool named <strong>Javascript Engine. </strong>One of the components of the Javascript Engine is the <strong>Syntax Parser </strong>that analyzes our code and makes sure that it is correct from a syntactic point of view. So if you forgot to add the <strong>var </strong>keyword, the Syntax Parser will add it for you. Be careful though because you shouldn’t relay on this approach because your code won’t be readable by other developers.</p><h4>2. Variable shadowing</h4><p><em>Definition: The shadowing concept refers to the declaration of a variable with the same name in a different scope (decision block, method, inner class).</em></p><p><strong><em>Example 1:</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c03be017a419b919ba2763f95df825a/href">https://medium.com/media/5c03be017a419b919ba2763f95df825a/href</a></iframe><p>When <strong>syntax parser </strong>analyzes the first example, it finds the first declaration of the <strong>a </strong>variable in the <strong>global execution context</strong>. On the call of the function <strong>shadowing </strong>a new <strong>execution context </strong>is created and the parser allocates the memory for variable <strong>a </strong>on the stack. There are no instructions left to be executed and the context is destroyed. That means that the variable <strong>a </strong>declared in the function <strong>shadowing</strong> doesn’t exist in memory anymore. The last instruction <strong>console.log(a) </strong>will look for variable a and print its value. The parser finds the associated name variable in the global execution context with the value 10 and prints it.</p><p><strong>Example 2:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2456b5a4298120e4991777acacb73c0e/href">https://medium.com/media/2456b5a4298120e4991777acacb73c0e/href</a></iframe><p>The difference between first and second example is the missing keyword from the instruction <strong>a = 20</strong>. When the execution context of the function <strong>shadowing</strong> is created it looks for a variable with associated name a and the parser finds it in the global execution context. The instruction changes the value of variable a from 10 to 20, so when <strong>console.log(a)</strong> is executed it will print 20.</p><h4>3. Block scoped variables</h4><p>In 2015 when ECMAScript 6 (conventionally named <strong>ES6</strong>) was released, it introduced a new concept called block scoped variable.</p><p><em>Definition: A block scoped variable is declared inside of a pair of curly brackets and it’s visible only in that specific scope.</em></p><p><strong>Example 1:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f0edfdcb940b83bf08436049425be8a/href">https://medium.com/media/9f0edfdcb940b83bf08436049425be8a/href</a></iframe><p>When the <strong>blockScoped</strong> function is called a new execution context is created and the parser looks for the <strong>a</strong> variable that is found in the global execution context (with the associated value 10). The condition of the control structure <strong>if</strong> is passed because <strong>10 &gt; 5</strong> and the variable a is created in the block associated with the control structure. After the execution of <strong>let a = 20</strong> the next instruction <strong>console.log(a)</strong> will look for the variable a that is only visible from the global execution context, so the printed value is 10.</p><p><strong>Example 2:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0358fb797530d1b6888712340792321c/href">https://medium.com/media/0358fb797530d1b6888712340792321c/href</a></iframe><p>Moving the <strong>console.log(a)</strong> instruction inside the control structure will make the functions <strong>blockScoped</strong> to behave in a different way and the printed result will be 20.</p><h4><strong>4. Immutable variables</strong></h4><p>Another type that was released in ES6 gives the developers the possibility to create immutable variables by using <strong>const</strong> keyword.</p><p><em>Definition: An immutable variable is a variable whose value cannot be modified after it was created.</em></p><p><strong>Example 1:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a2e3bb4d00cbc644f027044209af9ede/href">https://medium.com/media/a2e3bb4d00cbc644f027044209af9ede/href</a></iframe><p>If we would remove the second line from the example our code will run without any problems and the printed value will be 20.</p><blockquote>Note: Immutability of const variables is only applied to primitives. However if we would declare an object instead, we could add new properties and modify them.</blockquote><h4>5. Variable’s behavior in closures</h4><p><em>Definition: A closure is the combination of a function and the lexical environment within which that function was declared.</em></p><p><strong>Example 1 (using var keyword):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OSEYXcyv50HPIaaxPJrOuw.png" /><figcaption>Fig.5.1 Variable’s behavior in closures (Example 1)</figcaption></figure><p>Let’s break the 3rd example into smaller pieces starting from the call of the function <strong>print()</strong> and storing its returned value into a variable <strong>printer</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/253/1*MgA-YIejawpf0mBbfgnAKQ.png" /><figcaption>Fig.5.2 Call Stack</figcaption></figure><p>Let’s see if you can guess the printed values for the code above. You’re right, in the console you will see 3 3 3.</p><blockquote>How is this value obtained?</blockquote><p>Analyzing the for block iteration by iteration we will obtain the following values for i:</p><p><strong>FIRST ITERATION (i = 0):</strong></p><ul><li>0 &lt; 3 is true;</li><li>Add to the functions array the function with the instruction console.log(i);</li><li>i++;</li></ul><p><strong>SECOND ITERATION (i = 1):</strong></p><ul><li>1 &lt; 3 is true;</li><li>Add to the functions array the function with the instruction console.log(i);</li><li>i++;</li></ul><p><strong>THIRD ITERATION (i=2):</strong></p><ul><li>2 &lt; 3 is true;</li><li>Add to the functions array the function with the instruction console.log(i);</li><li>i++;</li></ul><p>After the third iteration <strong>i</strong> does not meet the condition <strong>i &lt; 3 (i = 3 now)</strong> and the loop is finished. There are no other instructions to be executed in the function so the <strong>execution context</strong> of function <strong>print()</strong> is destroyed and removed from the <strong>call stack</strong>. The engine is smart enough to see that we used the variable <strong>i</strong> in another function that is not called yet so it will keep in memory the last value of <strong>i</strong>, which is <strong>3</strong>.</p><p><strong>Example 2 (using let keyword):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*yPeIUaUO6PDPZxcLSIDtfw.png" /><figcaption>Fig.5.3 Variable’s behavior in closures (Example 2)</figcaption></figure><p>Running the second example we will see a different result in the console: 0, 1, 2.</p><blockquote>Why is this happening?</blockquote><p>The call stack with the execution contexts (<em>Fig.5.2</em>) is the same for this example, but the single difference is made by the <strong>let</strong> keyword from the <strong>for loop.</strong> Instead of holding one reference to the last value of <strong>i </strong>(take a look to the previous example), the engine will hold a reference of <strong>i</strong> for each iteration block.</p><blockquote>If you have any questions related to this article please leave a comment below. Subscribe to our publication in order to find more articles like this and enhance your developer skills on various topics. Thanks!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=389d4f2401d7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/startcode/javascript-basics-variables-389d4f2401d7">Javascript Basics: Variables</a> was originally published in <a href="https://medium.com/startcode">StartCode</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Overview of Rust in web development]]></title>
            <link>https://medium.com/startcode/overview-of-rust-in-web-development-31f502a88a64?source=rss----ae3580043a53---4</link>
            <guid isPermaLink="false">https://medium.com/p/31f502a88a64</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[electron]]></category>
            <dc:creator><![CDATA[Cartas Cosmin]]></dc:creator>
            <pubDate>Mon, 09 Sep 2019 14:21:19 GMT</pubDate>
            <atom:updated>2019-09-09T14:31:08.269Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5FX4R1Gkq2ts6EMNdrrTiw.jpeg" /></figure><h3>What is Rust?</h3><p>Rust is a system programming language that caught my attention few years ago. It is developed by Mozilla and uses a special mechanism for memory management. I’m not going to touch so many details about Rust basics in this article but if you want to get your hands on, you can start with <a href="https://doc.rust-lang.org/book/">The Rust Programming Language book</a>.</p><p>I will mention just two things that makes Rust special:</p><ul><li>You get out of the box the feeling of a high level language with the speed and resource consumption of a low level language because of the Zero Cost Abstraction.</li><li>It doesn’t have a garbage collector and uses a mechanism for memory management called borrow checker.</li></ul><h3>Gain a boost in performance with Rust</h3><p>When we are talking about web applications from a high level perspective, if you are using a <strong>client-server</strong> approach or a <strong>serverless</strong> architecture, Rust can boost your performance.</p><h4>Client-Server Architecture</h4><ul><li>As you might already heard there is a new buzzword called <strong>WebAssembly</strong> that process client side operations at near native speed performance. Rust code can be compiled into <strong>wasm </strong>using two packages: <a href="https://rustwasm.github.io/docs/wasm-bindgen/">WASM Bindgen</a> that facilitate the bindings between wasm modules and JavaScript and <a href="https://rustwasm.github.io/docs/wasm-pack/">WASM Pack</a> that packs your code into wasm module for the desired platform. A quick tip before you get hyped and start code an web assembly module because of the maturity of the technology. There are downsides of the approach when the operations that you want to perform are synchronous and JavaScript treats them as asynchronous. A concrete example of the problem would be reading files from the filesystem that is not possible at the moment because WASM Sandbox don’t have access to the files from disk. <a href="https://emscripten.org/">EMScripten</a> supports a workaround for this problem that creates a virtual filesystem and can be accessed from WASM Modules.</li><li>The performance of a backend that is developed using <strong>NodeJS</strong> could be improved using Rust in Native Node Modules. Because Rust have a great community this process can be realized very easy using <a href="https://neon-bindings.com/">Neon Bindings</a>. You can write your native module from scratch in Rust or use your existing codebase and use it in a wrapper that uses <strong>neon</strong>. Be careful when publishing the node module because it has to be recompiled for the target platform that is installed on (Node-GYP for the rescue). Now the possibilities offered with this approach got no limits because native node modules can be used with <a href="https://electronjs.org/">Electron</a>. So all of a sudden you have access to a set of tools that help you to develop cross platform applications that runs at native performance. If you don’t know already, there is a lot of hate pointed into electron because it’s heavy and slow, but from my point of view is the single viable solution for delivering cross platform production ready applications.</li></ul><h4>Serverless Architecture</h4><p>Rust is supported in<strong> AWS Lambda</strong> and <strong>Azure Functions </strong>and can be used out of the box to develop your application logic. Using Rust as runtime can lead to major improvements over other programming languages but the learning curve can be one of the downsides of this approach.</p><h3>Conclusion</h3><p>This article just showcases the scenarios where Rust can be applied in current web development but the language is not limited to that since it’s developed as as system programming language. I will post a series of articles where I touch in detail every topic that was mentioned here.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31f502a88a64" width="1" height="1" alt=""><hr><p><a href="https://medium.com/startcode/overview-of-rust-in-web-development-31f502a88a64">Overview of Rust in web development</a> was originally published in <a href="https://medium.com/startcode">StartCode</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>