Watch on Instagram

Code Bytes · "Start Here: What Is Coding?" · Episode 3 · The big picture

Apps, websites and programs

Apps, websites and games are all programs, saved instructions ready to run. Every tap runs code, a website is code in three parts (content, looks and actions) that your browser downloads and runs, and many apps ask servers for data.

Posted · About a 1 minute watch, 3 minute read · Take the quiz

Programs and apps

A program is a set of instructions saved on a computer so it can run them whenever you ask. An app is a program with screens and buttons, so people can use it with a tap instead of typing commands.

Real apps are more than one file: they bundle many files of code together with images, sounds and settings. But the heart of every app is the same thing: instructions.

Every tap runs code

When you tap a button, the app doesn't "just know" what to do. Somewhere in its code there is an instruction that says, in effect: when this is tapped, do this. Play a sound. Save a photo. Open a new screen.

Programmers call this kind of code an event handler: a tap, a click or a key press is an event, and the handler is the code that runs when it happens.

A website is code your browser runs

When you open a website, your browser downloads the site's files from a computer called a web server, then reads them and puts the page on your screen. A web page has three parts:

  • HTML holds the content: the headings, text, pictures and buttons.
  • CSS sets the looks: colours, fonts, sizes and layout.
  • JavaScript adds the actions: it makes things happen when you click, type or scroll.

Here is a tiny piece of HTML. It puts a heading and a button on a page:

``html <h1>Hello!</h1> <button>Click me</button> ``

Strictly speaking, HTML and CSS are not programming languages (HTML is a markup language and CSS a style-sheet language), which is why we call them "parts" of a website. JavaScript is the programming language that adds behaviour.

Apps talk to servers

Many apps also talk to programs running on other computers, called servers. A weather app doesn't know tomorrow's forecast by itself: it sends a request to a server, the server sends back data such as "18°", and then the app's own code decides what to draw on your screen, like a sunshine icon.

Not every app needs a server. A calculator or a clock can work completely offline.

Try it yourself

  1. On a computer, open any web page and press Ctrl+U (on a Mac, Option+Cmd+U), or right-click the page and choose "View page source". The wall of text you see is the page's HTML, the code your browser downloaded. Look for tags like <h1>, <p> and <button>.
  2. On your phone, turn on airplane mode, then open the calculator and then a weather app. The calculator still works because all its instructions are on your phone. The weather app can't get a fresh forecast, because it needs to ask a server.

Good to know

  • "A set of saved instructions" simplifies a program: real apps are many files plus images, sounds and settings.
  • HTML is a markup language and CSS a style-sheet language, not programming languages in the strict sense; JavaScript is the programming language that adds behaviour.
  • Browsers download a site's HTML, CSS and JavaScript from a web server and then display or run them. Network Bytes Season 1 goes deeper into how that download works.
  • Not every app needs a server (a calculator works offline), hence "many apps".
  • The weather example's "18°" is a generic Celsius temperature. The sunshine icon may be a stored image that the app's code chooses and displays rather than draws line by line.
  • No code is run in this episode; the code lines in the video's editor are drawings, not real code.

Answer to the comment question

Which of the three web parts sets how a page looks? CSS. HTML holds the content, CSS sets the looks (colours, fonts, sizes and layout), and JavaScript makes things happen when you click. Change a site's CSS and the same content can look completely different.

Test your knowledge

Quick quiz: Apps, websites and programs

4 multiple-choice questions. Pick one answer for each, then check how you did.

1What is a program?
2You tap a button in an app and it plays a sound. What made that happen?
3Which part of a website makes things happen when you click?
4Why does a weather app need a server?

Sources

  • MDN Web Docs, "How the web works": browsers download a site's files from servers
  • MDN Web Docs, "Learn web development": HTML for content, CSS for styling, JavaScript for behaviour
  • MDN Web Docs, "CSS reference": the style-sheet language for how pages look
  • Britannica Dictionary, "program": a set of instructions that tell a computer what to do

Video transcript

Is every app on your phone really just code?

Yes. A program is a set of saved instructions, ready to run. An app is a program with screens and buttons.

Every tap runs code that says: when this is tapped, do this. Play a sound, save a photo.

A website is code your browser downloads and runs. It has three parts. HTML holds the content, CSS sets the looks, and JavaScript makes things happen when you click.

Many apps also talk to programs on other computers, called servers. A weather app asks a server for the forecast, then its own code draws the sunshine.

Apps, websites, games: same thing underneath. Instructions.

Which of those three web parts sets how a page looks? Comment your answer below!

That's your byte.

More from "Start Here: What Is Coding?"

All "Start Here: What Is Coding?" lessons