ArticleslgStudy

science

Comparison of programming languages (syntax)

Comparison of programming languages (syntax) is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Comparison of programming languages (syntax) rather than just read about it. In short: This article compares the syntax of many notable programming languages. Expressions Programming language expressions can be broadly classified into four syntax structures: prefix notation Lisp (* (+ 2 3) (expt 4 5)) infix notation Fortran (2 + 3) * (4 ** 5) suffix, postfix, or Reverse Polish notation Forth 2 3 + 4 5 ** * math-like notation TUTOR (2 + 3)(45) $$ note implicit multiply operator Statement delimitation A…

Key takeaways

  • Comparison of programming languages (syntax) belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Comparison of programming languages (syntax) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Comparison of programming languages (syntax) from memory before moving on to harder problems.

Reference excerpt

This article compares the syntax of many notable programming languages.

Expressions Programming language expressions can be broadly classified into four syntax structures:

prefix notation Lisp (* (+ 2 3) (expt 4 5)) infix notation Fortran (2 + 3) * (4 ** 5) suffix, postfix, or Reverse Polish notation Forth 2 3 + 4 5 ** * math-like notation TUTOR (2 + 3)(45) $$ note implicit multiply operator

Statement delimitation A language that supports the statement construct typically has rules for one or more of the following aspects:

Statement terminator – marks the end of a statement Statement separator – demarcates the boundary between two statements; not needed for the last statement Line continuation – escapes a newline to continue a statement on the next line Some languages define a special character as a terminator while some, called line-oriented, rely on the newline. Typically, a line-oriented language includes a line continuation feature whereas other languages have no need for line continuation since newline is treated like other whitespace. Some line-oriented languages provide a separator for use between statements on one line.

Line continuation Listed below are notable line-oriented languages that provide for line continuation. Unless otherwise noted, the continuation marker must be the last text of the line.

Ampersand Fortran 90, Fortran 95, Fortran 2003, Fortran 2008 Backslash bash and other Unix shells C preprocessor macros; used in conjunction with C, C++ and many other programming contexts Crystal Mathematica, Wolfram Language Python Ruby JavaScript – only within single- or double-quoted strings Vimscript as first character of continued line Backtick PowerShell Hyphen SQL*Plus Underscore AutoIt Cobra Visual Basic Xojo Ellipsis (three dots) MATLAB: The ellipsis need not end the line, but text following it is ignored. It begins a comment that extends through (including) the first subsequent newline. Contrast this with a line comment which extends until the next newline. Comma delimiter Ruby: comment may follow delimiter Left bracket delimiter Batch file: starting a parenthetical block can allow line continuation Ruby: left parenthesis, left square bracket, or left curly bracket Operator symbol Ruby: as last object of line; comment may follow operator AutoHotkey: As the first character of continued line; any expression operators except ++ and --, and a comma or a period Some form of line comment serves as line continuation Turbo Assembler: \ m4: dnl TeX: % Character position Fortran 77: A non-comment line is a continuation of the prior non-comment line if any non-space character appears in column 6. Comment lines cannot be continued. COBOL: String constants may be continued by not ending the original string in a PICTURE clause with ', then inserting a - in column 7 (same position as the * for comment is used.) TUTOR: Lines starting with a tab (after any indentation required by the context) continue the prior command. The C compiler concatenates adjacent string literals even if on separate lines, but this is not line continuation syntax as it works the same regardless of the kind of whitespace between the literals.

Consuming external software

Languages support a variety of ways to reference and consume other software in the syntax of the language. In some cases this is importing the exported functionality of a library, package or module but some mechanisms are simpler text file include operations. Import can be classified by level (module, package, class, procedure,...) and by syntax (directive name, attributes,...).

File include #include <filename> or #include "filename" – C preprocessor used in conjunction with C and C++ and other development tools

File import addpath(directory) – MATLAB COPY filename. – COBOL import <filename>; or import "filename"; – C++ :-include("filename"). – Prolog #include file="filename" – ASP #include <filename> or #include "filename" – AutoHotkey, AutoIt #import "filename" or #import <filename> – Objective-C Import["filename"] – Mathematica, Wolfram Language include 'filename' – Fortran include "filename"; – PHP include [filename] program or #include [filename] program – Pick Basic include!("filename"); – Rust load "filename" – Ruby load %filename – Red require('filename') – Lua require "filename"; – Perl, PHP require "filename" – Ruby, Crystal source(""filename"") – R @import("filename"); – Zig

Package import #include filename – C import module; – C++ #[path = "filename"] mod altname; – Rust @import module; – Objective-C <<name – Mathematica, Wolfram Language :-use_module(module). – Prolog: from module import * – Python extern crate libname; – or extern crate libname as altname; or mod modname; – Rust library("package") – R: IMPORT module – Oberon import altname "package/name" – Go: import package.module; or import altname = package.module; – D import Module or import qualified Module as M – Haskell import package.* – Java, MATLAB, Kotlin import "modname"; – JavaScript import altname from "modname"; –JavaScript import package or import package._ – Scala import module – Swift import module – V (Vlang) import module – Python require('modname') – Lua require "shard" – Crystal require "gem" – Ruby use module – Fortran 90+ use module, only : identifier – Fortran 90+ use Module; – Perl use Module qw(import options); – Perl use Package.Name – Cobra uses unit – Pascal with package – Ada @import("pkgname"); – Zig

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Comparison of programming languages (syntax)

Start with the simplest possible case. Write down what Comparison of programming languages (syntax) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Comparison of programming languages (syntax) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Comparison of programming languages (syntax) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Comparison of programming languages (syntax)

In research
Comparison of programming languages (syntax) appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Comparison of programming languages (syntax) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Comparison of programming languages (syntax) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Programming language comparisons, so understanding it makes those chapters shorter.
In everyday life
Look for Comparison of programming languages (syntax) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Comparison of programming languages (syntax) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Comparison of programming languages (syntax) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Comparison of programming languages (syntax) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Comparison of programming languages (syntax) in simple terms?

This article compares the syntax of many notable programming languages. Expressions Programming language expressions can be broadly classified into four syntax structures: prefix notation Lisp (* (+ 2 3) (expt 4 5)) infix notation Fortran (2 + 3) * (4 ** 5) suffix, postfix, or Reverse Polish notati…

Why does Comparison of programming languages (syntax) matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Comparison of programming languages (syntax)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Comparison of programming languages (syntax).

Tags

  • Programming language comparisons

Keep exploring