<?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[Stories by Mohammad Kermani on Medium]]></title>
        <description><![CDATA[Stories by Mohammad Kermani on Medium]]></description>
        <link>https://medium.com/@kermani?source=rss-3b39f09b2995------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*eomQbAhjPjzcKuV8mEKBvQ.gif</url>
            <title>Stories by Mohammad Kermani on Medium</title>
            <link>https://medium.com/@kermani?source=rss-3b39f09b2995------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 22:04:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kermani/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Statistical look over React, Angular and Vue]]></title>
            <link>https://medium.com/swlh/statistical-look-over-react-angular-and-vue-b4ab396744f3?source=rss-3b39f09b2995------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4ab396744f3</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[vue]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Mohammad Kermani]]></dc:creator>
            <pubDate>Fri, 08 Nov 2019 01:09:06 GMT</pubDate>
            <atom:updated>2024-08-02T07:34:55.791Z</atom:updated>
            <content:encoded><![CDATA[<h3>A statistical analysis of React, Angular and Vue</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E5UJN85AzcXOiGjp7oV91g.jpeg" /></figure><p><strong>Many people look at GitHub stars when they’re deciding to trust and use an open-source project. And some people easily compare or judge projects based on the number of stars a repository has. Making decisions based solely on GitHub stars is not always the best idea, though — and you should put your requirements, framework features, and architecture first.</strong></p><p>None of these frameworks or libraries are “bad.” We should always be aware that many experts put countless hours of their time into developing these projects. So, if you’re a fanatic for a specific framework, let your guard down for some minutes, just relax, and continue in peace.</p><blockquote>We all are working towards the same goal, all these framework authors are trying to provide you with something that helps you to build web apps as efficiently as possible — Evan You (creator of Vue.js)</blockquote><h3>What is this post about precisely?</h3><p>This post is not a comparison between these three web frameworks. This is because most of the time, comparisons are made by people who want to advertise their preferred frameworks. Or they’re made by people who do not really understand what it takes to create a framework, so they can’t see different aspects of those frameworks.</p><p>This post is simply a statistical look at Angular, React and Vue, and their movements over the years. Here is what we’re going to learn about:</p><ol><li>Angular, React and Vue’s GitHub repositories over time</li><li>Stackoverflow question/answers</li><li>Job Statistics</li><li>Conclusion</li></ol><p><strong>So, let’s get started</strong></p><h3>Angular, React and Vue’s GitHub repositories over time</h3><p><strong>291,934 unique GitHub users </strong>have<strong> </strong>starred at least one of Angular, Angular.js, React, and Vue’s repositories. It took me around two weeks to crawl all of these user pages for statistical and demographical purposes (you can access these collected data <a href="https://github.com/m98/react-angular-vue-starers">on GitHub</a>). <strong>So, what can we learn from these collected data?</strong></p><h4>What are the repository averages?</h4><p>The table below shows the averages of some of GitHub’s main metrics. As you can see, there is a short gap between each of these averages. I’m just trying to provide information and I’ll not interpret anything.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XDhqtYPoKnYJKL5NikO2HQ.jpeg" /></figure><p>In order to better understand the growth rates of these repositories over the last few years, I have prepared their star count over time in the following chart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*XwBY_qEXn6XJ3fyAbwiz-A.jpeg" /><figcaption>Number of GitHub stars over time</figcaption></figure><h4>Common starers</h4><p>The diagram and table below show the number of users who starred more than one repository. As you can see, React and Vue have more starers in common, and Angular has almost the same number of common users between React and Vue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-O7wREYwK2TeWPXNnau96g.jpeg" /></figure><h4>Git commits through time</h4><p>The number of commits is a good way to know how actively the project is being developed.</p><p>The below bar chart race shows the number of commits over time. Unlike Vue, Angular and React contributors commit a lot to their repositories.</p><p>Number of commits per time</p><p>Here is another chart of the same data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*hdJsY8ISFOjUgL2p2k35iw.jpeg" /><figcaption>Angular, React and Vue’s number of commits</figcaption></figure><h4>Number of contributors</h4><p>The number of contributors is one of the things that makes a repository stronger because there are more people who know how to develop and improve the framework or library. They can simply push the project forward, which means there is a greater opportunity to discover and fix more bugs and issues and enhance them more quickly.</p><p>In fact, it’s also good for the community because more participants can address specific questions from programmers. It can also be a sign of the main contributors’ openness.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*sjNGqu-57fOelBtXRwiWMA.jpeg" /></figure><h3>Stackoverflow question/answers</h3><p>There is no doubt that, over the past few years, Stack Overflow has become one of the most important and powerful platforms that developers use to learn and solve their coding problems.</p><p>The number of questions asked on Stack Overflow represents the number of people who are using or learning a particular technology. I used StackExchange data explorer and wrote an <a href="https://data.stackexchange.com/stackoverflow/query/1126512/tag-question-count-history">SQL query</a> to fetch each tag’s count grouped by year and month. The following charts show the number of asked questions by each tag over time.</p><p>Number of asked questions on Stackoverflow over time</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*KndAlRmEKo72QNENMJaszg.jpeg" /></figure><h3>Job Statistics</h3><p>The job market shows what technologies companies are using. Software engineers and engineering managers usually compare frameworks or libraries in order to choose which one(s) suits their needs. They also care about how easy it is to find a developer who is skilled in that particular platform. Therefore, the more popular the framework or library, the more potential it has to be selected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*Ft4Mm_DDAHTHidqgDkJKkw.jpeg" /><figcaption>Angular, React and Vue jobs in some popular job listing websites</figcaption></figure><h3>Conclusion</h3><p>This article aims to provide a nuanced perspective on popular web frameworks, encouraging readers to evaluate them based on their architecture and features rather than just their GitHub star count. Relying solely on such statistical measures often fails to reflect a framework’s true value in real-world applications.</p><p>My goal is to contribute, even in a small way, to reducing the often contentious debates among developers regarding their preferred tools. I hope to persuade those who passionately defend their favorite frameworks to recognize the merits of others. All these frameworks have their strengths and are performing admirably in various contexts.</p><p>The process of learning should be both rewarding and enjoyable. Consider experimenting with a new framework in your side projects or continue using your preferred tools without being swayed by superficial statistics. Ultimately, what matters is the practical experience and knowledge gained from working with these technologies.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4ab396744f3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/statistical-look-over-react-angular-and-vue-b4ab396744f3">Statistical look over React, Angular and Vue</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular Server-side rendering using Angular-CLI]]></title>
            <link>https://codeburst.io/angular-server-side-rendering-using-angular-cli-bbde0c0eefe9?source=rss-3b39f09b2995------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbde0c0eefe9</guid>
            <category><![CDATA[angular-cli]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[server-side-rendering]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Mohammad Kermani]]></dc:creator>
            <pubDate>Thu, 14 Sep 2017 13:21:25 GMT</pubDate>
            <atom:updated>2018-01-24T07:21:48.741Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<h3>Angular Server-side rendering by using Angular-CLI</h3><p>In this tutorial we are going to learn how to add server-side rendering (aka <a href="http://universal.angular.io/">Universal</a>, and <a href="https://github.com/angular/angular/tree/master/packages/platform-server">Platform-server</a>) support for Angular 4 applications by using the <a href="http://cli.angular.io/">Angular CLI</a>.</p><p>Codes used in this tutorial is available on GitHub:</p><p><a href="https://github.com/m98/universal-cli-starter">https://github.com/m98/universal-cli-starter</a></p><h3>Brief history</h3><p>These days websites are amazing, they are rich and are using lots of JavaScript to generate their pages. JavaScript front-end library and frameworks allowed developers to create web apps that scale, it’s all good for both developers and users, but not for crawlers.</p><p>Back in 2014 <a href="https://webmasters.googleblog.com/2014/05/understanding-web-pages-better.html">Google announced</a> that they can execute and crawl JavaScript websites, like what common users can do by using a browser , but social medias and other search engines encourage you to make your website crawlable, and that’s why we need server-side rendering. Here are some benefits of rendering your app on the server-side:</p><ul><li>All your routes are crawlable and understandable for social medias and search engines</li><li>All your routes can have their own meta tags and titles</li><li>Once the webpage is rendered on the server, you can cache it and serve it very faster than before.</li><li>All the first HTTP requests are made on the server side and users should not wait for them on the client-side (<a href="https://research.googleblog.com/2009/06/speed-matters.html">page speed matter</a>)</li><li>Older browsers are supported</li><li>Easier to execute for low power devices, or JavaScript disabled browsers</li></ul><p>Implementing server-side rendering is somehow tricky on some front-end frameworks, but Angular has its own solution for helping us to render our application on the server. So, let’s get started.</p><h3>Getting Started</h3><h4>1. Generate a new project using Angular CLI</h4><pre>$ ng new universal-cli-starter</pre><h4>2. Install the tools</h4><p>We should install Angular dependencies for server-side rendering.</p><ul><li>@angular/platform-server is what will help us to render the website on the server</li><li>@nguniversal-express-engine is an Express Engine for running Angular Apps on the server</li><li><a href="https://github.com/rbuckton/reflect-metadata">reflect-metadata</a></li><li><a href="https://www.npmjs.com/package/cpy">cpy-cli</a> helps us to copy files</li></ul><pre>$ npm install --save @angular/platform-server @nguniversal/express-engine reflect-metadata`</pre><pre>$ npm install --save-dev cpy-cli</pre><h4>3. Enable transition to the client app</h4><p>A server-rendered app shows a view of your app while the real client app loads, it’s just an static HTML page with styles until browser downloads client app scripts in background and Angular will show the dynamically rendered view of the live application.</p><p>We need to add withServerTransition() into AppModule that will configures a browser-based application to transition from a server-rendered application and it will make sure the server-rendered application can transit into browser module.</p><p>withServerTransition()receives appId as parameter which can be any string and it must match between the client and server applications. Angular adds the appId to styles of the server-rendered pages, so that they can be identified and removed when the client app starts.</p><p>Open app.module.ts, and change BrowserModulelike bellow:</p><pre>// GitHub source: <a href="https://github.com/m98/universal-cli-starter/blob/master/src/app/app.module.ts#L11"><strong>src/app/app.module.ts</strong></a><br>imports: [ <br>BrowserModule.withServerTransition({ appId: &#39;universal-cli&#39; }),<br>]</pre><h4>4. Create server module</h4><p>The appModule which lives in <a href="https://github.com/m98/universal-cli-starter/blob/master/src/app/app.module.ts">src/app/app.module.ts</a>is the root application module, and @NgModule decorator tells Angular how to compile and run module code, and describes how the application parts fit together. Now we need to create a new module for our application when it’s running on server. Conventionally we call it AppServerModule</p><p>Create an app.server.module.ts file in the src/app (alongside app.module.ts file) with the following code:</p><pre>// GitHub source: <a href="https://github.com/m98/universal-cli-starter/blob/master/src/app/app.server.module.ts"><strong>src/app/app.server.module.ts</strong></a><br>import {NgModule} from &#39;@angular/core&#39;;<br>import {ServerModule} from &#39;@angular/platform-server&#39;;<br><br>import {AppModule} from &#39;./app.module&#39;;<br>import {AppComponent} from &#39;./app.component&#39;;<br><br>@NgModule({<br>  imports: [<br>    // The AppServerModule should import your AppModule followed<br>    // by the ServerModule from @angular/platform-server.<br>    AppModule,<br>    ServerModule<br>  ],<br>  // Since the bootstrapped component is not inherited from your<br>  // imported AppModule, it needs to be repeated here.<br>  bootstrap: [AppComponent],<br>})<br>export class AppServerModule {}</pre><h4>5. Create the server main file and TypeScript configs</h4><pre>// GitHub source: <a href="https://github.com/m98/universal-cli-starter/blob/master/src/main.server.ts"><strong>src/main.server.ts</strong></a><strong><br></strong>import { environment } from &#39;./environments/environment&#39;;<br>import { enableProdMode } from &#39;@angular/core&#39;;<br>if (environment.production) {  <br>   enableProdMode();<br>} <br>export {AppServerModule} from &#39;./app/app.server.module&#39;;</pre><p>The new typescript config we need to set for the server-side rendering is almost same as the current config we have in src/tsconfig.app.json, so just copy the tsconfing.app.json to tsconfig.server.json. Add a new section for angularCompilerOptions and set root module of the client application in entryModule(expressed as path/to/file#ClassName), also change the build target to commonjs.</p><pre>// GitHub source: <a href="https://github.com/m98/universal-cli-starter/blob/master/src/tsconfig.server.json"><strong>src/tsconfig.server.json</strong></a><br>{<br>  &quot;extends&quot;: &quot;../tsconfig.json&quot;,<br>  &quot;compilerOptions&quot;: {<br>    &quot;outDir&quot;: &quot;../out-tsc/app&quot;,<br>    &quot;baseUrl&quot;: &quot;./&quot;,<br>    // Set the module format to &quot;commonjs&quot;:<br>    &quot;module&quot;: &quot;commonjs&quot;,<br>    &quot;types&quot;: []<br>  },<br>  &quot;exclude&quot;: [<br>    &quot;test.ts&quot;,<br>    &quot;**/*.spec.ts&quot;<br>  ],<br>  // Add &quot;angularCompilerOptions&quot; with the AppServerModule you wrote<br>  // set as the &quot;entryModule&quot;.<br>  &quot;angularCompilerOptions&quot;: {<br>    &quot;entryModule&quot;: &quot;app/app.server.module#AppServerModule&quot;<br>  }<br>}</pre><h4>6. Create the web server</h4><p>The web server is using <a href="https://github.com/angular/universal/tree/master/modules/ng-express-engine">@nguniversal/express-engine</a> and the renderModuleFactory function from @angular/platform-server to responds to client’s requests with server-rendered HTML page. For the web server, create server.js in project root.</p><pre>// GitHub source: <a href="https://github.com/m98/universal-cli-starter/blob/master/server.js"><strong>server.js</strong></a><br>require(&#39;zone.js/dist/zone-node&#39;);<br>require(&#39;reflect-metadata&#39;);<br>const express = require(&#39;express&#39;);<br>const fs = require(&#39;fs&#39;);</pre><pre>const { platformServer, renderModuleFactory } = require(&#39;<a href="http://twitter.com/angular/platform-server">@angular/platform-server</a>&#39;);<br>const { ngExpressEngine } = require(&#39;<a href="http://twitter.com/nguniversal/express-engine">@nguniversal/express-engine</a>&#39;);</pre><pre>// Import the AOT compiled factory for your AppServerModule.<br>// This import will change with the hash of your built server bundle.<br>const { AppServerModuleNgFactory } = require(`./dist-server/main.bundle`);</pre><pre>const app = express();<br>const port = 8000;<br>const baseUrl = `<a href="http://localhost:${port}`">http://localhost:${port}`</a>;</pre><pre>// Set the engine<br>app.engine(&#39;html&#39;, ngExpressEngine({<br>  bootstrap: AppServerModuleNgFactory<br>}));</pre><pre>app.set(&#39;view engine&#39;, &#39;html&#39;);</pre><pre>app.set(&#39;views&#39;, &#39;./&#39;);<br>app.use(&#39;/&#39;, express.static(&#39;./&#39;, {index: false}));</pre><pre>app.get(&#39;*&#39;, (req, res) =&gt; {<br>  res.render(&#39;index&#39;, {<br>    req,<br>    res<br>  });<br>});</pre><pre>app.listen(port, () =&gt; {<br>  console.log(`Listening at ${baseUrl}`);<br>});</pre><h4>7. Prepare .angular.cli.json to build server application</h4><p>In .angular.cli.json under the &quot;app&quot; array there is an object which is your client application configurations, copy and paste the configuration and add a new key &quot;platform&quot; and set it to &quot;server&quot;, remove &quot;polyfills&quot; because they are not needed on server, adjust tsconfig, main and outDir.</p><pre>// GitHub source: <a href="https://github.com/m98/universal-cli-starter/blob/master/.angular-cli.json"><strong>.angular.cli.json</strong></a><br>{<br>      &quot;platform&quot;: &quot;server&quot;,<br>      &quot;root&quot;: &quot;src&quot;,<br>      &quot;outDir&quot;: &quot;dist/dist-server&quot;,<br>      &quot;assets&quot;: [<br>        &quot;assets&quot;,<br>        &quot;favicon.ico&quot;<br>      ],<br>      &quot;index&quot;: &quot;index.html&quot;,<br>      &quot;main&quot;: &quot;main.server.ts&quot;,<br>      &quot;test&quot;: &quot;test.ts&quot;,<br>      &quot;tsconfig&quot;: &quot;tsconfig.server.json&quot;,<br>      &quot;testTsconfig&quot;: &quot;tsconfig.spec.json&quot;,<br>      &quot;prefix&quot;: &quot;app&quot;,<br>      &quot;styles&quot;: [<br>        &quot;styles.css&quot;<br>      ],<br>      &quot;scripts&quot;: [],<br>      &quot;environmentSource&quot;: &quot;environments/environment.ts&quot;,<br>      &quot;environments&quot;: {<br>        &quot;dev&quot;: &quot;environments/environment.ts&quot;,<br>        &quot;prod&quot;: &quot;environments/environment.prod.ts&quot;<br>      }<br>    }</pre><h4>9. Build and run</h4><p>Now our application is ready for server-side rendering, and we should add serve and build command into &quot;scripts&quot; sections of package.json.</p><pre>// GitHub source: <a href="https://github.com/m98/universal-cli-starter/blob/master/package.json#L12-L13"><strong>package.json</strong></a><br>&quot;scripts&quot;: {<br><strong>&quot;build:universal&quot;</strong>: &quot;ng build --prod &amp;&amp; ng build --prod --app 1 --output-hashing=false &amp;&amp; cpy ./server.js ./dist&quot;,<br><strong>&quot;serve:universal&quot;:</strong> &quot;npm run build:universal &amp;&amp; cd dist &amp;&amp; node server&quot;<br>}</pre><p><strong>build:universal</strong> will first build the client app, then build the server app and copy the server.js into dist directory. You can go into dist directory, and using node server.js to run the web server. The other command, <strong>serve:universal</strong> runs the <strong>build:universal</strong> command first, then runs the server.</p><p>Let’s run the <strong>serve:universal</strong> command:</p><pre>$ npm run serve:universal</pre><p>Browser the <a href="http://localhost:8000/">http://localhost:8000/</a> to see the result.</p><h3>Conclusion</h3><p>Did you see the server-rendered application? The result should look like what ng serve gives you. but what’s the different?</p><p>When you build your application using ng build, or just serving it using ng serve, your application is rendering on the client-side, but when you run the npm run serve:universal (or npm run build:universal) the requested pages render by the server <em>(not a browser)</em>. means if you use Chrome <strong>view page source </strong>(Windows and Linux: <em>ctrl + u</em>, Mac: <em>⌘ + Option + u</em>), the page source of the client-rendered application is not what you can see in the page (like texts, links, images,…), but when you run the server-rendered application, you will see page source is different and what you see in the page is in source as well, and that’s how Crawlers understands your content.</p><p>I used almost the same technique to provide server-side rendering for <a href="http://footballi.net/">footballi.net</a> and it’s working perfectly fast and reliable.</p><p>If you have any trouble or questions please fill an issue on <a href="https://github.com/m98/universal-cli-starter">universal-cli-starter</a>, and If you want to learn more, you can check links bellow:</p><h4>Read more and references:</h4><p><a href="https://github.com/angular/angular/pull/18707">Angular repository: Pull request about Universal doc</a></p><p><a href="https://github.com/angular/universal-starter/pull/418">Angular/universal-starter: upgrade to CLI pull request</a></p><p><a href="https://github.com/angular/angular-cli/wiki/stories-universal-rendering">Angular CLI wiki: universal rendering</a></p><h3>Update (December 2018)</h3><p>The above article is still helpful to understand how does Universal work, and why you should use it.</p><p>Angular official document added more information about <a href="https://angular.io/guide/universal">server-side rendering</a> using CLI, and you can follow <a href="https://github.com/angular/universal-starter">Angular/universal-starter</a> repository as a trusted source to learn how to implement Universal into your project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbde0c0eefe9" width="1" height="1" alt=""><hr><p><a href="https://codeburst.io/angular-server-side-rendering-using-angular-cli-bbde0c0eefe9">Angular Server-side rendering using Angular-CLI</a> was originally published in <a href="https://codeburst.io/">codeburst</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to use JavaScript libraries in Angular 2+ apps]]></title>
            <link>https://medium.com/hackernoon/how-to-use-javascript-libraries-in-angular-2-apps-ff274ba601af?source=rss-3b39f09b2995------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff274ba601af</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[angular2]]></category>
            <category><![CDATA[angular-4]]></category>
            <category><![CDATA[angular-cli]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Mohammad Kermani]]></dc:creator>
            <pubDate>Thu, 29 Jun 2017 09:13:58 GMT</pubDate>
            <atom:updated>2019-04-09T18:15:46.219Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FDIQCYA3BNp9Ek-tqGeQjA.png" /></figure><p><em>Do you remember when you were learning AngularJS (version 1), tutorials kept telling you that you don’t need to add JQuery into your project?</em> That still did not change, you don’t need to add JQuery to your Angular 2+ project, but for any reason you might need to use some JavaScript libraries and you need to know how to use them in Angular. So, let’s get started from zero</p><p><em>I’m going to add </em><a href="http://underscorejs.org/"><em>underscore.js</em></a><em> to a project and show you how it works.</em></p><h4>1. Create a new project using Angular CLI</h4><p>If you already don’t have CLI installed on your machine, <a href="https://cli.angular.io/">install it</a>, after installation, create a new project (if you already don’t have one)</p><pre>ng new learning</pre><p>now you will have a new Angular project named “<strong>learning</strong>”</p><h4><strong>2. Install the package into your project</strong></h4><p>Go to the project we just made:</p><pre>cd learning</pre><p>Use your preferred package manager to install the library you’re going to use; I use npm to install underscore.js</p><pre>npm install --save underscore</pre><h4>3. Import the library into Angular (TypeScript)</h4><p>We are writing codes in TypeScript, and we should follow its rules. TypeScript needs to understand underscore.js</p><p>As you might know TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. TypeScript has its own syntax, function and variables can have defined types, but when we are going to use an external library such as underscore we need to declare type definitions for TypeScript.</p><p>In JavaScript, type of arguments are not important and you will not get an error while you’re writing code, but TypeScript won’t let you to give an array to a function that accepts string as input. Then here is the question that should we rewrite the underscore.js in TypeScript and define types there?</p><p>Of course not, TypeScript provides declaration files <em>(*.d.ts) </em>which define types and standardize a JavaScript file/libraries for TypeScript.</p><p>Some libraries includes typing file and you don’t need to install TypeScript’s type destination for them. But in case a library does not have .d.ts file, you need to install it.</p><p>We just need to find and import underscore.js type definition file. I suggest you to use <a href="https://microsoft.github.io/TypeSearch/">Type Search</a> to find declaration file for the libraries you need.</p><p>Search for underscore in <a href="https://microsoft.github.io/TypeSearch/">Type Sceach</a> and it redirects you to <a href="https://www.npmjs.com/package/@types/underscore">types/underscore</a>. Install the declaration file using the following command:</p><pre>npm install --save @types/underscore</pre><h4>4. Import type declaration into Angular app</h4><p>Let’s say you’re going to use underscore in your app.component.ts file, open the app.component.ts by your IDE and add the following code in top of the file:</p><pre>import * as _ from &#39;underscore&#39;;</pre><pre>/**<br>* OR simply:<br>* import &#39;underscore&#39;;<br>*/</pre><p>TypeScript in that component now understand _ and it easily works as expected.</p><h4>Question: How to use a library which does not have type definition (*.d.ts) in TypeScript and Angular?</h4><p>Create if the src/typings.d.ts does not exist, otherwise open it, and add your package to it:</p><pre>declare var yourLibrary: any;</pre><p>In your TypeScript now you need to import it by the given name:</p><pre>import * as yourPreferedName from &#39;yourLibrary&#39;;<br>yourPreferedName.method();</pre><h4>Conclusion</h4><p>As conclusion let’s make a simple example to see a working example of _. Open app.component.ts and inside the appComponent class write a constructor which returns the last item of an array using underscore _.last() function:</p><pre>...<br>import * as _ from &#39;underscore&#39;;<br>...<br>export class AppComponent {<br>  constructor() {<br>    const myArray: number[] = [9, 1, 5];<br>    const lastItem: number = _.last(myArray); //Using underscore<br>    console.log(lastItem); //5<br>  }<br>}</pre><p>If you open your Angular app now, you will get 5 in the console which means we could correctly add underscore into our project and it’s working as expected.</p><p>You can add any JavaScript libraries to your project just by following the same steps.</p><p>You can follow <a href="https://medium.com/@kermani">me</a> for more articles on technology and programming</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fdde502%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Fdde502%2F&amp;image=https%3A%2F%2Fucarecdn.com%2F57662ddc-da7c-407b-afcb-cb45184b2705%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/d25dd15e8727342107fbe0b6d67b030e/href">https://medium.com/media/d25dd15e8727342107fbe0b6d67b030e/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff274ba601af" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/how-to-use-javascript-libraries-in-angular-2-apps-ff274ba601af">How to use JavaScript libraries in Angular 2+ apps</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to win at life: advice from code champions]]></title>
            <link>https://medium.com/free-code-camp/winning-life-advice-from-code-champions-c6c56c150aa9?source=rss-3b39f09b2995------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6c56c150aa9</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[life-lessons]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Mohammad Kermani]]></dc:creator>
            <pubDate>Tue, 28 Jun 2016 01:35:40 GMT</pubDate>
            <atom:updated>2016-12-25T22:00:41.445Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZFkucRXl5pNOeML36E_QuA.jpeg" /><figcaption>From left: Misko Hevery, Jon Skeet, Salvatore Sanfilippo.</figcaption></figure><p>I had the honor of asking three of the world’s most famous software engineers six questions.</p><ul><li><a href="https://twitter.com/antirez"><strong>Salvatore Sanfilippo</strong></a><strong> </strong>is a well-known open-source contributor and creator of <a href="http://redis.io/">Redis</a> and <a href="https://github.com/antirez/disque">Disque</a>.</li><li><a href="https://twitter.com/jonskeet"><strong>Jon Skeet</strong></a><strong> </strong>is the most famous <a href="http://stackexchange.com/leagues/1/alltime/stackoverflow/2008-07-31/22656#22656">Stack Overflow</a> user, and a senior software engineer at Google.</li><li><a href="https://twitter.com/mhevery"><strong>Misko Hevery</strong></a> created the popular JavaScript framework <a href="https://angularjs.org/">AngularJS</a>.</li></ul><h4><strong>Question #1: </strong>What role has your university degree played in your professional career? Do you think you could become the person you are without a degree?</h4><p><strong>Jon Skeet:</strong> Well, my main degree was in maths, and then I did an MA-equivalent in computer science. I wouldn’t say I’ve used much of the theoretical side in day-to-day programming, but earning a degree is as much about honing how you think as about what you learn.</p><p>There are plenty of better programmers than me who don’t have degrees — but I think my time at university helped me a lot as a developer… partly in terms of people I met and things I did outside my official studies. Of course, if I hadn’t gone to university I’d have had a <em>different</em> four years which would no doubt have had other benefits.</p><p><strong>Salvatore Sanfilippo: </strong>I’ve no university degree, so I’m pretty sure a degree didn’t contributed much to my career :-)</p><p><strong>Misko Hevery: </strong>My degree is in Computer Engineering which is an equal mix of hardware and software. Typically, with CE, you either design the silicon, boards with chips, or you write low level firmware for those boards.</p><p>While at university, I have laid out silicon, then in my internships I designed firmware.</p><p>After graduation, I slowly transitioned from drivers, to libraries, to server side code, then databases, and finally to front end development with frameworks such as Angular.</p><p>I think having such background gives me a unique perspective to what is going on in the machine. Everything from HTML all the way down to individual ransitiors.</p><p>It is hard to say if I use my degree on daily basis. There are times when knowing what is going down in the machine helps, as is the case when trying to understand the performance of your code. But most of the time I draw on my knowledge of programming (which I learned before university) or skills I have learned in workplace.</p><p>I would say that having a degree in software is helpful, but not fully required. (The hardware world is different, there a formal education is a lot more valuable / required / essential.)</p><p>Software is a great deal about experience and discovery. It is more art than science, and for that reason what matters most in software is just the raw number of hours spent writing code, failing, rewriting, and reflecting.</p><p>Something which is driven by the number of hours spent on the problem, rather than a formal education. I think my success can be directly attributed to the number of hours I have spent coding. I have been coding since I was 10 years old, way before my university education. Which means, by now, I have accumulated about 30 years of writing code; and that is the real differentiator.</p><h4><strong>Question #2</strong>: What skill or field of study not directly related to computers, has helped you most as a developer? And what do you wish you knew more about?</h4><p><strong>Jon Skeet:</strong> Simply writing readable text is probably the most important non-computer-specific skill a developer can have. Programming involves communicating with both a computer and with other developers reading your code — I think too many people focus on the former and ignore the latter.</p><p>There are lots of things I wish I knew more about. I’m currently learning a huge amount about feminism (and other fights against inequality) — that’s opened my eyes a lot and will continue to do so, I’m sure. I don’t know that it’s helped me as a developer, but it’s helped me as a human being.</p><p><strong>Salvatore Sanfilippo: </strong>Studying architecture for a couple of years I think gave me a sense of design, and of the sacrifice in the design needed in order to obtain certain goals, in the presence of tensions. I think I applied these ideas later while designing systems.</p><p>I wish I knew more about formal methods.</p><p><strong>Misko Hevery: </strong>Empathy. I don’t think I even knew what the word meant until few years ago. Being socially awkward is almost a right of passage for software developers, but it should not be. And it does not have to be, if we would teach it in school along with literature, math, and sciences.</p><p>The reason why empathy is so important is that it is the glue which allows you to work in teams, and there are real limits of what you can achieve as an individual. Being empathetic allows you to build a great team. Empathy is contagious. Having an empathetic team means having a much more productive team.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UwFysHpaD9xqU0hsf_arug.jpeg" /></figure><h4><strong>Question #3</strong>: Many people have problems learning something new. How do you learn new things simply and effectively? What do you want to learn next?</h4><p><strong>Jon Skeet:</strong> Try to learn one thing at a time. If you’re learning a new language, work out the context in which that’s going to be simplest to try things out and debug — in many cases that means writing console apps. Any time you introduce a user interface into things, that introduces a lot of complexity which can be overwhelming if you’re not already comfortable with the basics.</p><p>As for what I want to learn next… I’m trying to keep up with .NET Core and the tooling around it, as I find that a tremendously exciting opportunity. One of these days I should really learn F#, Ruby or Python properly… but I’ve been saying that for years and not done anything about it, so I’m not expecting to find the time to do it soon…</p><p><strong>Salvatore Sanfilippo: </strong>What I try to do is to refuse to learn something that is at the same time complex and whose purpose is not clear, or is just justified by a greater level of “organization”, or is considered best practice. If I<br>need to learn something it requires to make a real big different in my<br>day to day work. This is my filter.</p><p>Similarly I want to learn things that last decades, so I avoid hyped<br>technologies that are hard to learn as much as possible.</p><p>The next thing I want to learn better is how to work better with<br>threads, especially advanced lock-free data structures and abstraction<br>layers over the basic threaded model in order to avoid errors and<br>simplify implementations. I’ve used them a couple of times just for<br>fun, but I want to understand how to apply lock-free data structures<br>to real system programming in the best way.</p><p><strong>Misko Hevery: </strong>Learning new things is hard. It pushes you out of comfort zone, and makes you feel dumb. Admitting that you don’t know something is hard to admit to yourself, and even harder to admit to others. I always tell my kids: Being frustrated is how you know that you are learning.</p><p>My secret weapon is realizing that frustration is part of learning and bulldozing through it. What I tell myself is that my future self will not remember the frustration, but will enjoy the fruits for a long time to come.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WUD-MEgAjuVEjyQ2rbJfuw.jpeg" /></figure><h4><strong>Question #4</strong>: For people who are beginners, what advice would you offer them? Did you compare yourself with other software engineers or programmers who were better than you when you were a beginner?</h4><p><strong>Jon Skeet: </strong>See my previous answer — start simple :) If you’ve got a big problem which will involve learning multiple new concepts, don’t start off trying to write the final code -start with throw-away code which will teach you about one of those concepts at a time.</p><p>I’ve compared myself with other engineers before, and will no doubt do so again. Even within topics where I’m supposedly knowledgeable, I can easily point to loads of other people with more expertise. It’s helpful to learn from more experienced engineers, but I think comparing yourself with them in a “trying to be more like them” way is unhelpful.</p><p><strong>Salvatore Sanfilippo: </strong>My advice for people joining our field is that there is a lot of space to contribute interesting things, even without resorting to crazy ideas. New programmers should not consider them unable to contribute at the top level, our current systems are full of flaws and need a lot of improvements.</p><p>I also think that new programmers should try to reinvent the wheel in order to understand very well how things work. Also experimenting with ideas that are considered to be abandoned or too strange to work can be stimulating.</p><p>Also to be humble and to try to find the simplest solution that can<br>address a problem are two things I value a lot.</p><p><strong>Misko Hevery: </strong>Try, practice, fail early and often, and learn from it. Make your own theories. Try to puzzle a problem through yourself before looking up an answer. A lot of times you will discover that you have a novel solution. Always explore new things. Don’t compare yourself to others, it will only lead to frustration. The grass is greener on the other side, and you only see a facade anyway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EPT9SCZMwgCJrhfSKKFBEw.jpeg" /></figure><h4><strong>Question #5</strong>: Some people think that being busy with a family, will hurt their career. Do you think your work has had an impact on your family life? Do you feel like you have to choose between work and family?</h4><p><strong>Jon Skeet:</strong> I think of it the other way round: that spending too much time on your career can hurt your family life. For me, life outside work is the baseline — some of that is still in software of course, but it’s not paid work.</p><p>I try very hard not to define myself by my career. I take pains to make my work/life balance reasonable for both my family and my colleagues. Now that sounds simple, but I’m very privileged to be in a job that I love, working for a company which also takes work/life balance seriously — and my wife also works very flexibly in a career she loves. Not everyone is as fortunate.</p><p><strong>Salvatore Sanfilippo: </strong>It is definitely hard to be good parents and at the same time to have a demanding work. Honestly I think that overall I’m paying a bit in terms of family and free time what I do in my work. I try to minimize the impact of my work to my family, and I try to don’t work for crazy long hours, but still sometimes I feel that it is not possible to completely detach from the work for a long period, that is something that I used to do years ago.</p><p>I think that an approach that can work is to say, I can work these hours every week, no more, and I work these hours at the best of my abilities. However whatever happens will happen and I cannot do more than that. With such an attitude, you can stop working after 8 hours every day and go enjoy life.</p><p><strong>Misko Hevery: </strong>There are only 24 hours in a day, and it is unreasonable to assume that having a family will not impact what you could achieve. But that is the wrong question. Not having a family is to miss out on a huge source of personal accomplishment. My family brings me a lot of joy. Work and family are on different axis and can’t really be traded one for the other. Having one without the other would leave emptiness in my heart.</p><h4><strong>Question #6. What is your favorite quote that has had an effect on your life?</strong></h4><p><strong>Jon Skeet: </strong>I don’t think there have been any specific quotes that have had a profound effect. I do like this though: <em>Never attribute to malice that which is adequately explained by stupidity.</em></p><p><strong>Salvatore Sanfilippo: </strong>I’m not even sure this quote is correctly attributed to Alan Kay, but “the best way to predict the future is to invent it” is something that had an impact on me in the past.</p><p><strong>Misko Hevery: </strong>I am not sure if it is a quote, but I subscribe to the idea of leaving things in a better state than I found them.</p><p>I hope these questions and answers help you and motivate you to be a better programmer and more successful software engineer. I believe if you want to be a successful person, you have to learn from people who are successful.</p><p>Finally, I would like to thank <a href="https://www.pinterest.com/connielynno/"><strong>Connie Osness</strong></a>, <a href="https://www.linkedin.com/in/zafar-khaja-97188589"><strong>Zafar Khaja</strong></a><strong> </strong>and <a href="https://twitter.com/mdibaiee"><strong>Mahdi Dibaiee</strong></a> for their help.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6c56c150aa9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/free-code-camp/winning-life-advice-from-code-champions-c6c56c150aa9">How to win at life: advice from code champions</a> was originally published in <a href="https://medium.com/free-code-camp">We’ve moved to freeCodeCamp.org/news</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>