The Syntax of Object-Oriented Programming Languages

Comparative Programming Languages with Kristoffer Hebert

Kristoffer Hebert
2 min readOct 20, 2018



Every language mentioned in this article uses the class keyword. C++, Java, and Node.js have similar syntax for extending Classes. The same is true for instancing new classes. Python does not use extends syntax but uses the parent class as the first argument.

Extending Classes

Java and Node both use the extends keyword, when extending classes. Python passes the class as the first argument, since the first argument of a function is always self. C++ uses the colon syntax as it’s extension keyword.

// C++
class TodoApp : public Todo {…}
// Java
public class TodoApp extends Todo {…}
// Node.js
class TodoApp extends Todo {…}
// Python
class TodoApp(Todo):

Instancing new classes

All the languages described use the class = new Class(args) syntax. C++ has multiple ways to instantiate a class, but the two most common have been provided. Python does not use the new keyword.

// C++
TodoApp todoapp(args);
TodoApp todoapp = new TodoApp(args);
// Java
TodoApp todoApp = new TodoApp(args);
// Node.js
let todoApp = new TodoApp(args);
// Python
todo_app = TodoApp(args)

Protecting methods and variables

Java and C++ both have public and private declaration modifiers. Python and Node.js are not strict about public and private attributes, but have work language specific ways of achieving it.

// C++
class TodoApp {
int privateValue
void privateFunction(){...}
void publicFunction(){...}
}// Java
public class TodoApp extends Todo {
public static function {...}
private function {...}
// Node.js
// Declare a function that is not a method of a Class
// Then call that function from the Class method
function __privateFunction(){...}class TodoApp {
// Python
Class Todo():


Provided is the same application coded in multiple languages.




Example Object Oriented Applications

The following is a interactive Node.js Todo application, written for your terminal.