Please enable JavaScript to use CodeHS

CS Practice

Guess the Language

Can you spot which programming language a snippet is written in? Test your eye for syntax across JavaScript, Python, Java, C++, HTML, CSS, PHP, and Ruby.

Languages ~8 min Middle / High school
The Big Idea

What is syntax?

Every programming language has its own syntax: the rules for how code must be written. Some languages use braces and semicolons, others use indentation, and others use tags or selectors.

Learning to recognize syntax clues helps you read code in languages you have never studied. It also deepens your understanding of the languages you already know.


Interactive

Try it: Guess the Language

Read the snippet, then click the language you think it is.


How It Works

Syntax clues to look for

Here are a few quick signals that can help you identify each language.

  • Python: def, print(), and indentation instead of braces.
  • JavaScript: function, console.log, and const/let.
  • Java: public class, public static void main, and System.out.println.
  • C++: #include <iostream>, std::cout, and semicolons.
  • HTML: Angle-bracket tags like <h1> and <p>.
  • CSS: Selectors, curly braces, and properties like color and background-color.
  • PHP: $name variables and echo.
  • Ruby: puts and string interpolation with #{...}.

Real World

Why this matters

Professional developers read code in many languages: documentation, examples, libraries, and teammates' code. Being able to quickly identify the language makes it easier to borrow ideas and debug problems.

Recognizing syntax also helps when you move from one class or project to another. The ideas stay the same; only the notation changes.


Check Yourself

Quick quiz

1. Which language uses def to define a function?

2. Which language uses tags like <h1>?

3. Which language uses #include <iostream>?


Keep exploring

Keep practicing with more CS skill tutorials.

Part of the CS Practice tutorial series.