Coding Category Archives - General Assembly Blog | Page 3

How to Easily Run JavaScript in Terminal

By

TL;DR

You can run JavaScript  console in terminal or any command-line interface using Node.js, an open-source, platform-agnostic runtime that executes JavaScript outside a web browser.

Before we take a deep dive into how to run JavaScript in browser, we need to understand few basic terminologies like:

  1. Client-Side JavaScript 
  2. Server-Side JavaScript
  3. Command Line Interface

Client-Side JavaScript

  • JavaScript code executed in the web browser is known as client-side JavaScript. 
  • Client-side JS was originally used to add some interactivity on websites; for example, the Click on Submit button in a form sends form details to the server.
  • The <script> tag within your HTML page is used to write client-side JavScript, which is later executed by the browser.
<script>
  console.log("Client-side JavaScript");
</script>

Server-Side JavaScript

  • When you run JS code outside the browser-like on a web server, it becomes server-side JavaScript.
  • Server-side JS is generally used to write the back-end logic of your web application; for instance, you can check to see if a user password matches the stored DB password.
  • You can run Server-side JavaScript using any command-line interface.

But, what is Command Line Interface, a.k.a.,Terminal?

  • CLI is a text-based interface that allows users to perform some operation in a computer by typing commands.
  • The most common CLI for popular OS’s are:
    • Windows: Command Prompt, PowerShell
    • Mac: Terminal, iTerm

Let’s see how to run JavaScript in these popular CLI’s:

Running JavaScript in Terminal 

Executing JavaScript in Terminal has two steps:

  1. Installing Node.js.
  2. Accessing Node.js in Terminal/Command Prompt.
  3. Running your JS file using node.

Installing Node.js

  1. Go to https://nodejs.org/en/download/; you should see a web page like below:
  1. If you are using Windows OS, click on Windows Installer or else click on Mac Installer for macOS.
  2. Once downloaded, double-click on the installer to install Node.js.

Checking Node.js in Your Terminal/Command Prompt

To open your terminal in macOS:

  1. Open the Spotlight Search Bar (Cmd+Space bar).
  2. Type Terminal: it has an icon like below — open it.
  3. Once opened, type the following command:
node -v

If you see an output like this, v14.15.3 Node.js is installed successfully.

Writing Your JS Code

  1. Create a new file called index.js in your Desktop/folder
  2. Let’s write some code!
const greet = (name=”Everyone”) => {    console.log(`Hello ${name}`);}
greet();

Now, let’s run it!

Running JavaScript in Your Terminal/Command Prompt

  1. Go to “Desktop path” within your Terminal/Command-Prompt:
cd /Users/arwalokhandwala/Desktop/
  1. To run your JavaScript file using Node.js, type:
node index.js
  1. If you see an output like below, then Congratulations! You are successfully running your JavaScript file in your Terminal/Command-Prompt:
Hello Everyone

Passing Runtime Arguments in Node.js

Like in the browser, we use forms to pass custom values to our JavaScript. If you wish to pass runtime values, then you can use process.argv[2]

const greet = (name = "Everyone") => {
   console.log(`Hello ${name}`);
}
greet(process.argv[2]);

In your Terminal/Command-prompt, type:

node index.js ArwaHello Arwa

Conclusion

Node.js makes it very simple to run JavaScript code in your Terminal/Command-prompt and opens a door of opportunities for a web developer.

What Makes JavaScript So Popular

By

Our lives today are dependent on the interactivity that JavaScript provides. If you want to really see how much you depend on it, you can disable JavaScript in your browser for a day. Some pages will load quicker, they’ll be cleaner, you’ll have less ads, no pop-ups, and the battery life of your computer may last longer. But also parts of the webpages simply will not work. Neither will Netflix, YouTube, Google Docs, Google Maps, and much more. We are, to a good degree, dependent on JavaScript to function. Today, virtually every computing device including iPhones, Android phones, MacOS, Windows, Linux, smart TVs, etc.. in the world have JavaScript interpreters installed on them and in active use.

There are over 1.8 Billion websites in the world, and JavaScript is used on 95% of them

The popularity of JavaScript over the years.

JavaScript is by far the most used language according to Github’s 2020 Octoverse Report.

So how did JavaScript get this big? Why did it get so popular? 

The creation story of JavaScript is the foundation of its popularity. 

It begins in the year 1995 at the Netscape headquarters, where young Brendan Eich goes into a ten day sprint of coding and comes out on the other side with a new language. Wow!

As more people used browsers to use and experience the internet, there was a need for a programming language that would give life to the browser. Something that went beyond HTML and CSS. That’s where JavaScript came in to give life to the browser. It’s a language that is capable of doing what all other programming languages do but also has a special relationship with the browser. It changed the way we thought about the internet and ushered a new era of browser based applications. 

Easy setup 

Unlike many other languages, where you need to go download the language in your machine in order to access all of its features and create a development environment, with JavaScript anyone with a web browser suddenly has a development environment right in front of them. Every browser supports JavaScript!  


You can simply open your browser, like Chrome, and navigate to Developer Tools, and start coding away! To write a “Hello World” program is as simple as: 

console.log(“Hello World”); 

You can also use an Integrated development environment (IDE) or code editor like Visual Studio Code where you can create a file with the file extension .js to write JavaScript. Visual Studio Code (VS Code) is more widely used to write code but there are other editors like Atom and Sublime Text which are quite common amongst developers.  

Event-based programming
One of the most impressive features of JavaScript is that it includes event-based programming. It has built-in events like ‘onClick’ and ‘onHover’ that wait for user interaction on a website before executing a specific segment of code. For instance, when you click the night-mode toggle, that is an event which triggers a JavaScript code segment that changes the CSS across the whole website from light colors to dark colors. 

JavaScript can be used to generate dynamic contents on a website as well. Different HTML tags can be generated based on user input. For instance, if you are on Facebook and you click into a comment box to type your comment on someone’s post, in that moment your click was an event that executed a code block in JavaScript that led to the generation of an HTML tag to display your comment.

End-to-end programming with Node.JS 

While JavaScript has been given the title of The Language of the Browser, in 2009 with the release of Node.JS, a runtime environment that runs JavaScript code outside a web browser changed the fate of the language. Node.JS lets developers use JavaScript to write server-side scripting. Consequently, JavaScript’s popularity was dramatically increased because Node.JS represents the idea of “JavaScript everywhere” paradigm, unifying all of web application development around a single programming language, rather having a different language for server-side and client-side scripts. 

In other words, now developers can use one single programming language to talk to databases, make HTTP requests, generate dynamic content, and create interactive user experiences/interfaces. This led to the Rise of Web Applications that we are experiencing today. In addition to having a unified web-application development, JavaScript also became the go-to language for many companies because now the engineering teams only had to worry about a single programming language which made it easier to debug and save costs in the overall development process. 

In 2013 AirBnb launched their site and became the first to utilize the full-stack JavaScript solution. This approach allowed for code to be executed on the server-side and rendered in the browser with subsequent actions being handled by the exact same code on the client side. This inspired several other companies to do the same and today we have products and services like LinkedIn, Netflix, Uber, PayPal, eBay, Groupon, GoDaddy, CitiBank and many more using Node.JS. 

JavaScript Libraries and Frameworks

The popularity of JavaScript led to the creation of several libraries and frameworks that have made application development efficient and performant. Today, libraries like React JS, jQuery, D3.js, etc.. are used in most applications across the world. Frameworks such as Angular, Ember JS, and Vue JS provide optimal performance and organization to build large applications. 

Active Community 

Amongst the programming languages, JavaScript has one of the largest communities according to Stackoverflow. In addition to that community, Node.JS has over a billion downloads across the world and is one the most widely used technologies. 

These are just a few of the reasons why JavaScript is so popular. With the change in paradigm that led to the rise of web applications, unifying the web application development, cross browser support, and the plethora of libraries/frameworks available, the world of the internet has been fully invested in the growth of JavaScript. Furthermore, since JavaScript is a high-level interpreted language that is easy to understand, it is the one of the best languages to learn if you want to enter the world of programming and explore the amazing possibilities of web-application development. 

What is the power of JavaScript used for?

By

At a high level, JavaScript is a scripting or programming language that allows you to implement complex features on web server pages, such as displaying timely content updates, interactive maps, animations, etc. JavaScript is used for all web-related software development. It is the most widely used and popular scripting language in the world for website building.

The power of the JavaScript framework is in its popularity, ease of use, and large community. It is one of the three core technologies of the World Wide Web (www), alongside HTML and CSS. Perhaps the most powerful thing about the JavaScript function is that it includes all of the features of a programming language embedded in your web browser. Unlike other programming languages, where you have to download the language in your machine and create an environment, the JS framework does not require that. If you have a web browser like Chrome, then you can write JavaScript.

Initially, the JavaScript framework was only on the client side of programming to create user interfaces and webpages’ interactivity. With the development of Node.js, JavaScript is not used in both client-side and server-side programming — this makes it extremely versatile and valuable for a web developer.

JavaScript is the standard programming language of the web, and everybody uses the software written in JavaScript. Virtually everyone who has an internet-connected device with a screen can use applications written in JavaScript markup language.

Popular Uses of JavaScript

Adding Interactive behavior to web pages: 

  • Show or hide information on a click event. 
  • Change the colors of a button when the mouse hovers over it.
  • Slide through a carousel of images. 
  • Zoom in and out on an image.
  • Display a timer or a countdown on websites. 
  • Play audio. 
  • Embed video. 
  • Display animations and visual effects.
  • Create pop-ups and modals 
  • Use a dropdown hamburger menu 
  • Client-side form validation.
  • Autocompletion.

Creating web and mobile applications:

  • Developers have access to a plethora of JavaScript frameworks for developing and building web and mobile device apps. JavaScript frameworks are collections of JavaScript code libraries that provide developers with pre-written js code to use for routine programming tasks. 
  • Popular front-end JavaScript frameworks include React, React Native, Angular, Vue, and Ember.js. 

Building web servers and developing server applications:

JavaScript is the backbone of modern web applications, but much like the human spine, it is quite flexible and liberal in what it allows. This can sometimes be seen as a disadvantage because it makes finding problems in programs harder. However, this flexibility allows a Javascript programmer to use many techniques that are not possible in more rigid programming languages.

A superpower of JavaScript is that it is easy to learn. It is widespread and supported by all browsers. Because it is a high-level language, it takes care of a lot of nitty-gritty programming for you, whereas in other low-level languages, you have to think about memory management, etc. In addition to being easy to learn, it is also easy to use. As long as you have a browser, you can write JavaScript to create rich web content.

Every programming language has some feature that separates it from other coding languages. In addition to all the amazing features of JavaScript, the one that stands out is how functions work in the language.

“Functions are the very best part of JavaScript. It’s where most of the power and the beauty of this language is.” — Douglas Crockford

Functions in JavaScript can be seen as workhorses. They play roles that other languages fulfill with multiple distinct features like procedures, methods, constructors, classes, and modules. All of these can be covered by the versatility of functions in JavaScript.

Finally, the most powerful feature of JavaScript is its community. It has one of the largest communities for any programming language. It is consistently ranked highest in Stackoverflow, Google searches, and GitHub issues. The amount of support for beginners is amazing!

JavaScript Will Continue To Be Important

By

JavaScript is the ubiquitous scripting language of the web. Throughout its lifetime, it has had more than a few competitors, like JScript developed by Microsoft in the late Nineties and WebAssembly that has been around since 2019 (designed by W3C), but over time JavaScript has unified the way web sites are built and how browsers run. It has brought life and functionality to pure HTML and CSS static web pages by making them interactive. Currently, over 90% of all websites have some JavaScript running them. More importantly, over the last decade, JavaScript has jumped out of the browser and into other realms of application development such as back-end development, mobile development, and even machine learning. In recent times libraries and frameworks built on top of JavaScript have also been gaining popularity; in some cases, we are seeing JavaScript taking a backseat and running “under the hood.” Along with a worldwide community that maintains and develops JavaScript and its surrounding ecosystem, it seems evident that JavaScript has established its importance and is here to stay.

An Exploration of JavaScript & Its Importance

Why will JavaScript continue to be important? 

To best explore this statement, we will need to look at JavaScript holistically and highlight the programming language’s important aspects:

  1. We need to understand how JavaScript became the language it is to explore its background and history.
  2. We will need to understand where JavaScript stands performance-wise and how it compares to other scripting languages and competitors.
  3. We will look at where JavaScript is currently and the ecosystem that has been built around it.
  4. We will look at (or at least speculate) where the language is going and try to understand why it will continue to be as important.

Let’s dive in! 

Background & History

Developed internally at Netscape in 1994 by Brendan Eich and first released in 1995, JavaScript was not initially as popular as it is today. In fact, it was considered a somewhat messy and hard-to-manage language.

Here is JavaScript: The Definitive Guide v.s JavaScript: The Good Parts compared in size.

But over the years, JavaScript has become the ubiquitous programming language of the World Wide Web. Not to be confused with Java, which was the most popular programming language in the 90s when JavaScript was developed. Initially named LiveScript, and then changed to JavaScript, this caused some confusion and was later believed to be a marketing ploy by Netscape..

JavaScript was the programming language that brought life to previously static web pages by making them interactive. As its name suggests, JavaScript is a scripting language which are programs that can interact with HTML and CSS and make them do certain things – for example, when you click a submit button on a credit card input, JavaScript is there to make sure the servers receive that information and let you know what is going on with your request by changing the way the website looks. Every browser has its own JavaScript engine. There are many different engines:

  • V8: used by Chrome and Brave.
  • SpiderMonkey: used by Mozilla.
  • Chakra: used by Microsoft Edge.

Inherently, all JavaScript engines work similarly to each other with only slight differences. At their core, they compile the JavaScript code run by websites into byte code which our computer’s hardware can then interpret. 

Current Ubiquity: Inside & Outside the Browser 

In the last 10 years, JavaScript has been ubiquitous in web development because browsers use it. But in 2009, it jumped out of the browser and into the back-end with the release of node.js. By taking the Google V8 engine, developer Ryan Dahl introduced to the world JavaScript and its new ability to run servers. With the release of node.js, JavaScript allowed developers who worked purely in the client-facing parts of web development to have skills previously reserved for back-end developers. This would, over the next decade, be a huge pillar in JavaScript’s already established importance.

And not only that, within the past decade, we have seen JavaScript move into other parts of the application development ecosystems as well:

  • Back-End
    • Node.js
    • Express
    • NestJS
  • Mobile
    • ReactNative
    • NativeScript
    • Ionic
  • Machine Learning
    • TensorFlow
    • Brain.js
    • Webdnn
  • Blockchain
    • Truffle.js
    • web3.js

In a short time, JavaScript has become omnipresent in the world of application development. And the most interesting part is that so many frameworks are being built on top of JavaScript that we might not even be writing pure JavaScript one day. We see that companies are giving preference to building their applications with JavaScript frameworks like React and Typescript that allow you to develop apps without writing pure JavaScript.

JavaScript searches on Google over 5 years:

TypeScript searches on Google over 5 years:

Performance

Performance-wise, depending on the benchmark and environment, JavaScript can compete with most programming languages. In addition to that, the answer to JavaScript performance lies in the engines. In addition to precompilation abilities, there are optimizations such as just-in-time compilation that allow the engines to do less work. On top of that, each browser has its own engine developed by different tech companies; this creates an interesting competition environment. Therefore companies are trying to best one another at making their engine better than the other, which translates to better performance over a shorter period of time. 

Here are some benchmarks that ran with some simple computations, and we see that the JavaScript V8 engine is, in fact, able to compute faster than most. 

Future

With a bright future ahead, JavaScript is currently one of the most-used programming languages and a high-demand computer software industry skill. Some of the biggest tech companies are developing and maintaining JavaScript libraries, engines, and frameworks.:

  • Google
    • V8 Engine
    • AngularJS 
    • Chromium
  • Facebook
    • React.js
    • ReactNative
  • Microsoft
    • Chakra Engine
    • Typescript
  • Mozilla
    • SpiderMonkey Engine

JavaScript is baked into these companies’ core products, so we can say with certainty that while they’re around, JavaScript will also be there..

What is a JavaScript library?

By

JavaScript is one of the most widely used programming languages in the world. It’s a scripting language used by developers to create interactive user interfaces that display dynamic content. It is s referred to as The Language of the Web Browser because it is the most commonly used language to build web applications and works well across all web browsers

As the popularity of JavaScript increased and more people were using it to build websites and applications, the JavaScript community recognized that certain patterns in the code were being used repeatedly to accomplish the same tasks.

This re-writing of code and recognizing that certain JS functions need to be implemented multiple times led to the development of JavaScript libraries and frameworks. For instance, reoccurring animations and interactive forms that appear in different places on a website or app were repetitive tasks that could be automated by using a code snippet as needed without writing code every time.

Generally speaking, JavaScript libraries are collections of prewritten code snippets that can be used and reused to perform common JavaScript functions. A particular JavaScript library code can be plugged into the rest of your project’s code on an as-needed basis. This led to faster development and fewer vulnerabilities to have errors.

jQuery 

There are many libraries and frameworks available to JavaScript developers today, but the concept of a JavaScript library was initiated with the creation of jQuery. jQuery is a JavaScript library designed to simplify HTML, DOM (Document Object Model) manipulation, and event handling, CSS animations, and Ajax. At the time, the jQuery library shortened the syntax and simplified the code, making it easy to understand and increased web developer productivity. 

All a web developer had to do was install jQuery and use prewritten code snippets to manipulate the virtual DOM. For example, if a developer wants to add an autocomplete feature in a search bar on their site, they would insert the appropriate jQuery code snippet into the project’s code. When a user enters text into the search bar, the jQuery code snippet retrieves the feature from the jQuery library and displays it in the user’s modern browser. 

React JS

In 2011, Facebook created a JavaScript library called React, which specializes in helping developers build user interfaces or UI’s. React

 JS is a web component-based library and an open source JavaSscript framework that helps developers design simple views for each state of the JavaScript application. React is also extremely smart in that it does a lot of heavy lifting in terms of efficiently updating and rendering the right components when there is a change in data or the state of the JavaScript application.

Today, React is the most popular JavaScript library, and companies use it all over the world like Uber, Airbnb, Facebook, Netflix, Instagram, Amazon, Twitter, and much more. 

The web component-based library allows developers to avoid the pitfalls of rewriting code and dealing with complicated debugging. With React, you can reuse and recycle different components across the web application or other products.

Components such as navigation bars, buttons, cards, forms, sections, and the like can all be reused like little building blocks that make the web application. A library like React dramatically increases the development speed with fewer bugs and makes extremely performant applications. 

Library vs. Framework 

Perhaps one of the most common topics of discussion in the software community is the difference between a library and a framework. As we see above, jQuery and React are libraries with prewritten code snippets that we can use and reuse to build applications.

So while JavaScript libraries are a specialized tool for on-demand use, JavaScript frameworks are a full toolset that helps shape and organize your website or application. In other words, libraries are about using what is needed for the task, while frameworks provide you with all the tools you could need even if you don’t particularly need all of them. 

Think of it like cooking some pasta. When using a JavaScript library, you simply grab the pot, pan, ingredients to make the pasta, and plates to serve. You only require only the things you need to make pasta. When thinking about a JavaScript framework, imagine an entire fully loaded kitchen. Another way to think about it can be that JavaScript libraries are like pieces of furniture that add style and function to an already constructed house. At the same time, frameworks are templates you can use to build the house itself. 

Examples of an open source JavaScript framework includes Angular, Ember JS, and Vue JS. These are some of the most popular frameworks with large communities and support systems. Frameworks provide a structure to base your entire application around, and developers can safely work within the structure’s rules.

The advantage of frameworks is the overall efficiency and organization. The disadvantage is that a developer has less freedom to work around the rules and conventions specific to a particular JS framework. Libraries, on the other hand, give developers more freedom to use different code and snippets but do not provide the type of structure and convention that comes with a framework.

What is a JavaScript framework?

By

A JavaScript framework is a collection of JavaScript code libraries that provide a web developer with pre-written code for routine programming tasks. Frameworks are structures with a particular context and help you create web applications within that context. 

It is completely possible to build strong web applications without JavaScript frameworks, but frameworks provide a template that handles common programming patterns. Each time you have to build an application, you don’t need to write code for every single feature from scratch. Instead, you can build upon an existing feature set. 

JavaScript frameworks, like most other frameworks, provide some rules and guidelines. Using these rules and guidelines, any developer can make complex applications faster and more efficiently than if they decided to build from scratch. The rules and guidelines help shape and organize your website or web application too!

For example, think about a potter’s wheel where you can build pots. The potter’s wheel is your framework; it has certain consistencies that you have to work with. The wheel rotates, and you can use that rotation to build pots of different shapes and sizes.

You can build pots, plates, cups, bowls, or even cylindrical sculptures. But you can’t build a house with it; you need to find a different framework for that. 

Framework vs. Library 

A common topic of discussion in the software community is the difference between a framework and a library. In truth, experts have suggested that the line between them can be blurry, but it is useful to make the distinction.

While a JS framework is a full toolset that helps shape and organize your website or application, a JS library, on the other hand, is a collection of pre-written code snippets that are less about shaping your application and more about providing a use-as-needed library of features. 

Model View Controller (MVC) 

Modern JavaScript frameworks use a software design pattern called Model–View–Controller. It is commonly used for developing user interfaces that divide related programming logic into three interconnected elements.

The model is the central web component of the pattern as it is the application’s dynamic data structure. It manages the data of the application.

The view consists of all the code that has to do with representing the application’s data — the code for the user interface.

The controller is the interpreter. It accepts inputs and converts them into commands for the model or view.

Frameworks are built around the MVC design pattern to provide structure and adaptability in software development. 

JavaScript is one of the most popular and widely used programming languages globally and has more frameworks than any other language. Since JavaScript is used for both client-side and server-side code, there are many frameworks to work with. Some of the most popular frameworks include: 

Front-End Frameworks

React

React.js is an efficient and flexible JavaScript library for building user interfaces created by Facebook. Technically, React is a JS library, but it is often discussed as a web framework and is compared to any other open source JavaScript framework.

React makes it easy to create interactive user interfaces because it has predictable JavaScript code that is easy to debug. Furthermore, it provides a REACT component system where blocks of JavaScript code can be written once and reused repeatedly in different parts of the application or even other applications. 

Angular

AngularJS is a popular enterprise-level JavaScript framework used for developing large and complex business applications. It is an open-source web framework created by Google and supported by both Google and Microsoft. 

Vue 

Vue.js is a progressive framework for building user interfaces. It is an up-and-coming framework that helps developers in integrating with other libraries and existing projects. It has an ecosystem of libraries that allow developers to create complex and solid single-page applications. 

Back-End Frameworks

Express 

Express.js is a flexible, minimalistic, lightweight, and well-supported framework for Node.js applications. It is likely the most popular framework for server-side Node.js applications. Express provides a wide range of HTTP utilities, as well as high-performance speed. It is great for developing a simple, single-page application that can handle multiple requests at the same time. 

Next.js

Next.js is a minimalistic framework that allows a a JavaScript developer to create a server-side rendering and static web applications using React.js. It is one of the newest and hottest frameworks that takes pride in its ease of use. Many of the problems developers experience while building applications using React.js are solved using Next.js. It has many important features included “out of the box,” and makes development a JavaScript breeze. 

In the current job market, the most popular JavaScript framework/library is React.js. Since JavaScript has so many frameworks, it can sometimes be hard to decide which one to start learning. You could start with any framework, but if your goal is to get a job, you will have better odds if you learn React first. The same can be said for Express.js as a back-end framework as it is the most widely used and sought-after framework. 

JavaScript frameworks are more adaptable for designing web applications and make working with JavaScript easier and smoother. This is why they are so popular among developers. A variety of frameworks exist because they can be applied to solve different problems. When choosing a framework, carefully consider your project requirements before deciding to implement any particular JavaScript framework. In addition to all the unique technical features of JavaScript frameworks, each framework comes with its own learning curve, community engagement/support, documentation, and compatibility. 

Portfolio Project Spotlight: Software Engineering Immersive

By

Every graduate of our Software Engineering Immersive programs gets the opportunity to work on a portfolio-grade final project. The experience gives students a chance to apply their newfound skills in programming languages and problem-solving to real-world issues and scenarios, as well as gaining invaluable insights and impactful results that they can use to stand out in their job searches.

Here are a few of our instructors’ favorites.


Save the ocean

Jiha Hwang, a visual interaction designer at Lopelos Project Group, created an app to raise ocean pollution awareness, allowing users to share tips for reducing plastic use. She used Rails, React, and PostgreSQL to build the app and deployed it with Heroku.


FRIDGIFY

Sathya Ram and Marichka Tsiuriak, now both front-end developers, created this eater-friendly organizational tool using MongoDB, Express, React, and Node. The animated web app allows you to categorize the contents of your fridge and track their expiration dates.


SETTLERS OF CATTAN

Bryant Cabrera, now a software engineer at Amazon, built a web-based adaptation of this popular board game. Powered by HTML, CSS, JavaScript, and jQuery, the app allows players to test their logic and negotiation skills just as they would in person.


15 Data Science Projects to get you Started

By

When it comes to getting a job in data science, data scientists need to think like Creatives. Yes, that’s correct. Those looking to enter this field need to have a data science portfolio of previously completed data science projects, similar to those in Creative professions. What better way to prove to your future data science team that you’re capable of being a data scientist than proving you can do the work?

A common problem for data science entrants is that employers want candidates with experience, but how do you get experience without having access to experience? Suppose you’re looking to get that first foot in the door. It will behoove you to undertake a couple of data science projects to show future employers you’ve got what it takes to use big data to identify opportunities and succeed in the field.

The good news is that we live in a time of open and abundant data. Websites like Kaggle offer a treasure trove of free data for deep learning on everything from crime statistics to Pokemon to Bitcoin and more. However, the wealth of easily accessible data can be overwhelming, which is why we’ve taken it upon ourselves to present 15 data science projects you can execute in Python to showcase and improve your skills in data analytics. Our data science project ideas cover various topics, from Spotify songs to fake news to fraud detection and techniques such as clustering, regression, and natural language processing.

Before you dive in, be sure to adhere to these four guidelines no matter which data science project idea you choose:

1. Articulate the Problem and/or Scenario

It’s not enough to do a project where you use “X” to predict “Y”; you need to add some context to your work because data science does not occur in a vacuum. Tell us what you’re trying to solve and how data science can address that. Employers want to know if you can turn a problem into a question and a question into a solution. A good place to start is to depict a real-world scenario in which your data project would be useful.

2. Publish & Explain Your Work

Create a GitHub repository where you can upload your Jupyter Notebooks and data. Write a blog post in which you narrate your project from start to finish. Talk about the problem or question at the heart of the project, and explain your decision to clean the data in a certain way or why you decided to use a certain algorithm. Why all this? Potential employers need to understand your methodology.

3. Use Domain Expertise

If you’re trying to break into a specific field such as finance, health, or sports, use your knowledge of this area to enhance your project. This could mean deriving a useful question to a pressing problem or articulating a well-thought-out interpretation of your project’s results. For example, if you’re looking to become a data scientist in the finance sector, it would be worthwhile to show how your methods can generate a return on investment.

4. Be Creative & Different

Anyone can copy and paste code that trains a machine learning algorithm. If you want to stand out, review existing data science projects that use the same data and fill in the gaps left by them. If you’re working on a prediction project, try coming up with an unexpected variable that you think would be beneficial.

Data Science Projects

1. Titanic Data

Working on the Titanic dataset is a rite of passage in data science. It’s a useful dataset that beginners can work with to improve their feature engineering and classification skills. Try using a decision tree to visualize the relationships between the features and the probability of surviving the Titanic.

2. Spotify Data

Spotify has an amazing API that provides access to rich data on their entire catalog of songs. You can grab cool attributes such as a song’s acoustics, danceability, and energy. The great thing about this data source is that the project possibilities are almost endless. You can use these features to try to predict genre or popularity. One fun idea would be to better understand your music by training a machine learning classifier on two sets of songs; songs you like and songs you do not.

3. Personality Data Clustering

You’ve probably heard the phrase, “There are X types of people.” Well, now you can actually find out how many types of people there really are. Using this dataset of almost 20k responses to the Big Five Personality Test, you can actually answer this question. Throw this data into a clustering algorithm such as KMeans and sort this into K number of groups. Once you decide on the optimal number of clusters, it’s incumbent on you to define each cluster. Come up with labels that add meaning to each group, and don’t be afraid to use plenty of charts and graphs to support your interpretation.

4. Fake News

If you are interested in natural language processing, building a classifier to differentiate between fake and real news is a great way to demonstrate that. Fake news is a problem that social media platforms have been struggling with for the past several years and a project that tackles this problem is a great way to show you care about solving real-world problems. Use your classifier to identify interesting insights about the patterns in fake versus real news; for example, tell us which words or phrases are most associated with fake news articles.

5. COVID-19 Dataset

There probably isn’t a more relevant use of data science than a project analyzing COVID-19. This dataset provides a wealth of information related to the pandemic. It provides a great opportunity to show off your exploratory data analysis chops. Take a deep dive into this data, and through data visualization unearth patterns about the rate of COVID infection by county, state, and country.

6. Telco Customer Churn

If you’re looking for a straightforward project that is extremely applicable to the business world, then this one’s for you. Use this dataset to train a classifier that predicts customer churn. If you can show employers you know how to prevent customers from leaving their business, you’ll most definitely grab their attention. Pro tip: this is a great projection to show your understanding of classification metrics besides accuracies, such as precision and recall.

7. Lending Club Loans

Like the Telco project, the Lending Club loan dataset is extremely relevant to the business world. Here you can train a classifier that predicts whether or not a Lending Club loanee will pay back a loan using a wealth of information such as credit score, loan amount, and loan purpose. There are a lot of variables at your disposal, so I’d recommend starting with a handful of features and working your way up from there. See how far you can get with just the basics.

Also, this is a fairly untidy dataset that will require extensive cleaning and feature engineering, which is a good thing because that is often the case with real-world data. Be sure to explain your methodology behind preparing your dataset for the machine learning algorithm — this informs the audience of your domain expertise.

8. Breast Cancer Detection

This dataset provides a simpler classification scenario in which you can use health-related variables to predict instances of breast cancer. If you’re looking to apply your data science skills to the medical field, this is certainly worth a shot.

9. Housing Regression

If classification isn’t your thing, then might I recommend this ready-made regression project in which you can predict home prices using variables like square footage, number of bedrooms, and year built. A project such as this can help you understand the factors driving home sales and let you get creative in your feature engineering. Try to involve outside data that can serve as proxies for quality of life, education, and other things that might influence home prices. And if you want to show off your scraping skills, you can always create your dataset by scraping Zillow.

10. Seeds Clustering

The seeds dataset from UCI provides a simple opportunity to use clustering. Use the seven attributes to sort the 210 seeds into K number of groups. If you’re looking to go beyond KMeans, try using hierarchical clustering, which can be useful for this dataset because the low number of samples can be easily visualized with a dendrogram.

11. Credit Card Fraud Detection

Another project idea for those of you intent on using business world data is to train a classifier to predict instances of credit card fraud. The value of this project to you comes from the fact that it’s an imbalanced dataset, meaning that one class vastly outweighs the other (in this case, non-fraudulent transactions versus fraudulent). Training a model that is 99% accurate is essentially useless, so it’s up to you to use non-accuracy metrics to demonstrate the success of your model.

12. AutoMPG

This is a great beginner regression project in which you can use car features to predict their fuel efficiency. Given that this data is from the past, an interesting idea you can use is to see how well this model does on data from recent cars to show how car fuel efficiency has evolved over the years.

13. World Happiness

Using data science to unlock what’s behind happiness? Maybe you can with this dataset on world happiness rankings. You can go a number of ways with this project; you can use regression to predict happiness scores, cluster countries based on socio-economic characteristics, or visualize the change in happiness throughout the world from 2015 to 2019.

14. Political Identity

The Nationscape Data Set is an absolute goldmine of data on the demographics and political identities of Americans. If you’re a politics junkie, it’ll be sure to satisfy your fix. Their most recent round of data features over 300,000 instances of data collected from extensive surveys of Americans. If you’re interested in using demographic information for political ideology or party identification this is the dataset for you. This is an especially great project to flex your domain expertise in study design, research, and conclusion. Political analysis is replete with shoddy interpretations that lack empirical data analysis, and you could use this dataset to either confirm or dispel them. But be warned that this data will require plenty of cleaning, which you’ll need to get used to, given that’s the majority of the job.

15. Box Office Prediction

If you’re a movie buff, then we’ve got you covered with the TMDB dataset. See if you can build a workable box office revenue prediction model trained on 5000 movies worth of data. Does genre actually correlate with box office success? Can we use runtime and language to help explain the variation in the revenue? Find out the answers to those questions and more with this project.

Computer Science vs. Data Science: What is the Difference?

By

Maybe you want to learn more about data science since you’ve heard it’s “the sexiest job of the 21st century.” Or maybe your software engineer friend is trying to talk you into learning computer science. Either way, both data science and computer science skills are in demand. In this article, we will cover the major differences between data science and computer science to clarify the distinction between these two fields.

Before we dive into the differences, let’s define these two sciences:

Data Science vs. Computer Science

Data science is an interdisciplinary field that uses data to extract insights and inform decisions. It’s often referred to as a combination of statistics, business acumen, and computer science. Data scientists clean, explore, analyze, and model with data using programming languages such as Python and R along with techniques such as statistical models, machine learning, and deep learning.

While it’s one part of data science, computer science is its own broader field of study involving a range of both theoretical and practical topics like data structures and algorithms, hardware and software, and information processing. It has many applications in fields like machine learning, software engineering, and mathematics.

History

While many of the topics used in data science have been around for a while, data science as a field is in its infancy. In 1974, Peter Naur defined the term “data science” in his work, Concise Survey of Computer Methods. However, even Naur couldn’t have predicted the vast amount of data that our modern world would generate on a daily basis only a few decades later. It wasn’t until the early 2000s that data science was recognized as its own field. It gained popularity in the early 2010s, leading to the field as we know it today — a blend of statistics and computer science to drive insights and make data-driven business decisions. “Data science,” “big data,” “artificial intelligence,” “machine learning,” and “deep learning” have all become buzzwords in today’s world. These are all components of data science and while trendy, they can provide practical benefits to companies. Historically, we did not have the storage capacity to hold the amount of data that we are able to collect and store today. This is one reason that data science has become a popular field only recently. The emergence of big data and the advancements in technology have paved the way for individuals and businesses to harness the power of data. While many of the tools that data scientists use have been around for many years, we have not had the software or hardware requirements to make use of these tools until recently.

Computer science, on the other hand, has been a field of study for centuries. This is one of the main differences between it and data science. Ada Lovelace is known for pioneering the field of computer science as the person who wrote the first computer algorithm in the 1840s. However, computing devices such as the abacus date back thousands of years. Computer science is a topic that has been formally researched for much longer than data science, and companies have been using computer science tools for decades. It’s an umbrella field that has numerous subdomains and applications. 

Applications

The applications of each of these fields in the industry differs as well. Computer science skills are used in many different jobs including that of a data scientist. However, common roles involving computer science skills include software engineers, computer engineers, software developers, and web developers. Two roles that use computer science, front end engineer and Java developer, ranked first and second respectively on Glassdoor’s 50 Best Jobs in America for 2020 list. While these roles do not formally require degrees, many people in these jobs hold a degree or come from a background in computer science. 

Common computer science job tasks include writing, testing, and debugging code, developing software, and designing applications. Individuals that use computer science in their roles often create new software and web applications. They need to have excellent problem solving skills and be able to write code in programming languages such as Python, Ruby, JavaScript, Java, or C#. They also need to have a fundamental understanding of how these languages work, and be well-versed in object oriented programming.

Data science is applied in job titles such as data scientist, data analyst, machine learning engineer, and data engineer. Data scientist and data engineer ranked third and sixth respectively on Glassdoor’s 50 Best Jobs in America for 2020. Individuals in these roles come from a variety of backgrounds including computer science, statistics, and mathematics. 

Common data science job tasks include cleaning and exploring data, extracting insights from data, and building and optimizing models. Data scientists analyze and reach conclusions based on data. They need to be well versed in statistics and mathematics topics including linear algebra and calculus as well as programming languages such as Python, R, and SQL. They also need to have excellent communication skills as they are often presenting insights, data visualizations, and recommendations to stakeholders.

Since computer science is one component of data science, there is often crossover in these roles and responsibilities. For example, computer science tasks like programming and debugging are used in both computer science jobs and data science jobs. Both of these fields are highly technical and require knowledge of data structures and algorithms. However, the depth of this knowledge required for computer science vs. data science varies. It’s often said that data scientists know more about statistics than a computer scientist but more about computer science than a statistician. This reinforces the interdisciplinary nature of data science.

The Use of Data

Data, or information such as numbers, text, and images, has applications in both computer science and data science. The study and use of data structures is a topic in computer science. Data structures are ways to organize, manage, and store data in ways that it can be used efficiently; a sub-domain of computer science, it allows us to store and access data in our computer’s memory. Data science benefits from data structures to access data, but the main goal of data science is to analyze and make decisions based on the data, often using statistics and machine learning.

The Future of Computer Science and Data Science

Today, all companies and industries can benefit from both of these fields. Computer scientists drive business value by developing software and tools while data scientists drive business value by answering questions and making decisions based on data. As software continues to integrate with our lives and daily routines, computer science skills will continue to be critical and in demand. As we continue to create and store vast amounts of data on a daily basis, data science skills will also continue to be critical and in demand. Both fields are constantly evolving as technology advances and both computer scientists and data scientists need to stay current with the latest tools, methods, and technologies.

The field of data science would not exist without computer science. Today, the two fields complement each other to further applications of artificial intelligence, machine learning, and personalized recommendations. Many of the luxuries that we have today — a favorite streaming service that recommends new movies, the ability to unlock our phones with facial recognition technology, or virtual home assistants that let us play our favorite music just by speaking — are made possible by computer science and made better by data science. As long as bright, motivated individuals continue to learn data science and computer science, these two fields will continue to advance technology and improve the quality of our lives.

Explore Data Workshops


How is Python Used in Data Science?

By

Python is a popular programming language used by both developers and data scientists. But what makes it so popular and why are so many data scientists choosing Python over other programming languages? In this article, we’ll explore the advantages of Python programming and why it’s useful for data science.

What is Python?

No, we’re not talking about the giant, tropical snake. Python is a general-purpose, high-level programming language. It supports object oriented, structured, and functional programming paradigms.

Python was created in the late 1980s by the Dutch programmer Guido van Rossum who wanted a project to fill his time over the holiday break. His goal was to create a programming language that was a descendant of the ABC programming language but would appeal to Unix/C hackers. Van Rossum writes that he chose the name Python for this language, “being in a slightly irreverent mood (and a big fan of Monty Python’s Flying Circus).”

Python went through many updates and iterations and by the year 2008, Python 3.0 was released. This was designed to fix many of the design flaws in the language, with an emphasis on removing redundant features. While this update had some growing pains as it was not backwards compatible, the new updates made way for Python as we know it today. It continues to be well-maintained and supported as a popular, open source programming language.

In “The Zen of Python,” developer Tim Peters summarizes van Rossum’s guiding principles for writing code in Python:

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren’t special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one– and preferably only one –obvious way to do it.
Although that way may not be obvious at first unless you’re Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it’s a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea — let’s do more of those!

These principles touch on some of the advantages of Python in data science. Python is designed to be readable, simple, explicit, and explainable. Even the first principle states that Python code should be beautiful. In general, Python is a great programming language for many tasks and is becoming increasingly popular for developers. But now you may be wondering, why learn Python for data science?

Why Python for Data Science?

The first of many benefits of Python in data science is its simplicity. While some data scientists come from a computer science background or know other programming languages, many come from backgrounds in statistics, mathematics, or other technical fields and may not have as much coding experience when they enter the field of data science. Python syntax is easy to follow and write, which makes it a simple programming language to get started with and learn quickly. 

In addition, there are plenty of free resources available online to learn Python and get help if you get stuck. Python is an open source language, meaning the language is open to the public and freely available. This is beneficial for data scientists looking to learn a new language because there is no up-front cost to start learning Python. This also means that there are a lot of data scientists already using Python, so there is a strong community of both developers and data scientists who use and love Python.

The Python community is large, thriving, and welcoming. Python is the fourth most popular language among all developers based on a 2020 Stack Overflow survey of nearly 65,000 developers. Python is especially popular among data scientists. According to SlashData, there are 8.2 million active Python users with “a whopping 69% of machine learning developers and data scientists now us[ing] Python (compared to 24% of them using R).”4 A large community brings a wealth of available resources to Python users. Not only are there numerous books and tutorials available, there are also conferences such as PyCon where Python users across the world can come together to share knowledge and connect. Python has created a supportive and welcoming community of data scientists willing to share new ideas and help one another. 

If the sheer number of people using Python doesn’t convince you of the importance of Python for data science, maybe the libraries available to make your data science coding easier will. A library in Python is a collection of modules with pre-built code to help with common tasks. They essentially allow us to benefit from and build on top of the work of others. In other languages, some data science tasks would be cumbersome and time consuming to code from scratch. There are countless libraries like NumPy, Pandas, and Matplotlib available in Python to make data cleaning, data analysis, data visualization, and machine learning tasks easier. Some of the most popular libraries include:

  • NumPy: NumPy is a Python library that provides support for many mathematical tasks on large, multidimensional arrays and matrices.
  • Pandas: The Pandas library is one of the most popular and easy-to-use libraries available. It allows for easy manipulation of tabular data for data cleaning and data analysis.
  • Matplotlib: This library provides simple ways to create static or interactive boxplots, scatterplots, line graphs, and bar charts. It’s useful for simplifying your data visualization tasks.
  • Seaborn: Seaborn is another data visualization library built on top of Matplotlib that allows for visually appealing statistical graphs. It allows you to easily visualize beautiful confidence intervals, distributions, and other graphs.
  • Statsmodels: This statistical modeling library builds all of your statistical models and statistical tests including linear regression, generalized linear models, and time series analysis models.
  • Scipy: Scipy is a library used for scientific computing that helps with linear algebra, optimization, and statistical tasks.
  • Requests: This is a useful library for scraping data from websites. It provides a user-friendly and responsive way to configure HTTP requests.

In addition to all of the general data manipulation libraries available in Python, a major advantage of Python in data science is the availability of powerful machine learning libraries. These machine learning libraries make data scientists’ lives easier by providing robust, open source libraries for any machine learning algorithm desired. These libraries offer simplicity without sacrificing performance. You can easily build a powerful and accurate neural network using these frameworks. Some of the most popular machine learning and deep learning libraries in Python include:

  • Scikit-learn: This popular machine learning library is a one-stop-shop for all of your machine learning needs with support for both supervised and unsupervised tasks. Some of the machine learning algorithms available are logistic regression, k-nearest neighbors, support vector machine, random forest, gradient boosting, k-means, DBSCAN, and principal component analysis.
  • Tensorflow: Tensorflow is a high-level library for building neural networks. Since it was mostly written in C++, this library provides us with the simplicity of Python without sacrificing power and performance. However, working with raw Tensorflow is not suited for beginners.
  • Keras: Keras is a popular high-level API that acts as an interface for the Tensorflow library. It’s a tool for building neural networks using a Tensorflow backend that’s extremely user friendly and easy to get started with.
  • Pytorch: Pytorch is another framework for deep learning created by Facebook’s AI research group. It provides more flexibility and speed than Keras, but since it has a low-level API, it is more complex and may be a little bit less beginner friendly than Keras. 

What Other Programming Languages are Used for Data Science?

Python is the most popular programming language for data science. If you’re looking for a new job as a data scientist, you’ll find that Python is also required in most job postings for data science roles. Jeff Hale, a General Assembly data science instructor, scraped job postings from popular job posting sites to see what was required for jobs with the title of “Data Scientist.” Hale found that Python appears in nearly 75% of all job postings. Python libraries including Tensorflow, Scikit-learn, Pandas, Keras, Pytorch, and Numpy also appear in many data science job postings.

Image source: The Most In-Demand Tech Skills for Data Scientists by Jeff Hale

R, another popular programming language for data science, appeared in roughly 55% of the job postings. While R is a useful tool for data science and has many benefits including data cleaning, data visualization, and statistical analysis, Python continues to become more popular and preferred among data scientists for a majority of tasks. In fact, the average percentage of job postings requiring R dropped by about 7% between 2018 and 2019, while Python increased in the percentage of job postings requiring the language. This isn’t to say that learning R is a waste of time; data scientists that know both of these languages can benefit from the strengths of both languages for different purposes. However, since Python is becoming increasingly popular, there’s a high chance that your team uses Python, and it’s important to use the language that your team is comfortable with and prefers.

What is the Future of Python for Data Science?

As Python continues to grow in popularity and as the number of data scientists continues to increase, the use of Python for data science will inevitably continue to grow. As we advance machine learning, deep learning, and other data science tasks, we’ll likely see these advancements available for our use as libraries in Python. Python has been well-maintained and continuously growing in popularity for years, and many of the top companies use Python today. With its continued popularity and growing support, Python will be used in the industry for years to come.

Whether you’ve been a data scientist for years or you are just beginning your data science journey, you can benefit from learning Python for data science. The simplicity, readability, support, community, and popularity of the language — as well as the libraries available for data cleaning, visualization, and machine learning — all set Python apart from other programming languages. If you aren’t already using Python for your work, give it a try and see how it can simplify your data science workflow.