Computer Language
Lecture 1

Introduction to Computer Programming

Josue Obregon

Seoul National University of Science and Technology
Information Technology Management
Lecture slides index

March 24, 2025

Agenda

  • Lecturer and students
  • Course logistics
    • Objectives
    • Methodology
    • Class contents
    • Evaluation
    • Resources
  • Introduction to Computer Programming

Lecturer Presentation

  • BSC in Computer Engineering
    • Universidad de San Carlos de Guatemala

  • MSc in Industrial & Management Systems Engineering
    • Business Process Management Laboratory
    • Process mining applied to SNS

  • PhD in Industrial & Management Systems Engineering
    • Industrial Artificial Intelligence Laboratory
    • Interpretable Machine Learning for tree ensembles

Prof. Josue Obregon

Tel: 02-970-7291
Office: Changhak Hall (3), Room 334-1
Office Hours: Monday 14:00 – 17:00 (but come anytime!)
Home-page: https://eis.seoultech.ac.kr/
Email: jobregon@seoultech.ac.kr
Publications: Google Scholar Profile

Students

  • Question for students:
    • What programming languages do you have experience with?
    • Can you name one difference between Python and Java?
    • If you become a good programmer, what kind of application would you like to develop?


Learning to write programs stretches your mind, and helps you think better, creates a way of thinking about things that I think is helpful in all domains.

— Bill Gates, Microsoft co-founder

Course objectives

  1. Understanding Programming Constructs: Develop a deep understanding of Java programming constructs, including syntax, semantics, control structures, and object-oriented principles.
  2. Problem-Solving Skills: Enhance problem-solving abilities by applying programming knowledge to design and implement software solutions.
  3. Critical Thinking in Code Analysis: Cultivate the ability to trace, analyze, and evaluate code for correctness, efficiency, and maintainability.
  4. Software Design and Development: Learn to create modular, reusable, and maintainable software using object-oriented programming (OOP) principles.
  5. Practical Application: Apply learned concepts in a complex project that mimics real-world programming tasks.

Methodology

  • Flipped Clasroom style
  • (1 ~ 1.5 hours) Watch online lectures and complete readings before class.
  • (2 hours) Offline activities (10:00 am)
    • Initial Quiz: Formative assesement of basic concepts and syntax.
    • Interactive Q&A: discussions and to clarify doubts.
    • Programming Quizzes: Take regular quizzes to reinforce concepts.
    • Hands-On Practice: Engage in coding exercises to apply what you’ve learned.

Class contents

  1. Introduction to Computer Programming and Java
  2. Input and Output
  3. Variables and calculation with numbers
  4. Conditional statements
  5. Repeating functionality
  6. Methods & Debugging
  7. Lists, Arrays and Strings
  8. Midterm
  1. Introduction to Object Oriented Programming
  2. Deeper look into Object Oriented Programming
  3. Inheritance and Interfaces I
  4. Inheritance and Interfaces II
  5. Class diagrams, packages and exceptions
  6. Project Live Code Review and Evaluation
  7. Final examination

Evaluation

Point Distribution
Assesment Points
Assignments 15%
Term project 15%
Midterm 30%
Final exam 40%
Total 100%
Grading guideliens
SeoulTech Grades Marks (100) NU Grades
A+ (4.5)
A0 (4.0)
above 70 First
B+ (3.5)
B0 (3.0)
above 60 Upper Second
C+ (2.5)
C0 (2.0)
above 50 Lower Second
D+ (1.5)
D0 (1.0)
above 40 Third
F (0.0) under 40 Fail

Resources

Development tools

  • Text editor: a text editor to write source code. If the text editor has syntax highlighting capabilities it would help you a lot. Recommendations:
  • Command Line: to manually compile and run Java applications.
  • What about IDE?
    • During the first weeks of our course, we are going to work only with text editor, to learn well the structure of Java applications and how to successfully run our projects.
    • What specific IDE we are going to use, will be announced later.

Introduction to Computer Programming

public class HolaMundo{
    public static void main(String[] args){
        System.out.println("Hola mundo");
    }
}

Objectives

  • Learn what is programming language, program and computer programming
  • Distinguish between low-level and high-level programming languages
  • Explain the difference between compiled and interpreted languages, and classify Java as a compiled language.
  • Become familiar with executing programs
    • Write and execute several programs in Java, following the steps to compile and run the program using a text editor and the command line.
  • Learn to write programs that print text.
  • Know what the term “parameter” means.

Problem-solving for computer scientists

  • It involves the ability to formulate problems, think creatively about solutions, and express solutions clearly and accurately.

  • Broad goals of this module:

    • Learn to read Java programs
    • Learn to write Java programs
    • Design and write Java programs to solve problems

What is a programming language?

A programming language is a formal system used to communicate with computers, allowing humans to write instructions that a computer can understand and execute (i.e., to write, compile, and execute programs).

  • A programming language is described by its syntax (form) and semantics (meaning)
    • Syntax: the rules that define the combinations of symbols that are considered to be correctly structured statements or expressions in that language
    • Semantics: the meaning of programming languages. Semantics assigns computational meaning to valid strings in a programming language syntax.

Programms and programming?

A program is a sequence of instructions that specifies how to perform a computation on computer hardware.

  • input: Get data from the keyboard, a file, a sensor, or some other device.
  • output: Display data on the screen or send data to a file or other device.
  • math: Perform basic mathematical operations like addition and division.
  • decision: Check for certain conditions and execute the appropriate code.
  • repetition: Perform an action repeatedly, usually with some variation.

Programming can be seen as the process of breaking down a large, complex task into smaller and smaller subtasks.

Types of computer languages

Low-level languages

  • Machine languages: any computer can directly understand
    • Defined by hardware design
    • Machine dependent
  • Assembly languages
    • English-like abbreviations to represent elementary operations
    • Assemblers – translators to a machine language

High-level languages

  • Write instructions that look almost like everyday English
  • Compilers – convert a high-level language into a machine language
  • Interpreters – execute high-level language programs directly

Interpreted vs compiled programming languages

How interpreted languages are executed

The process of compiling and running a Java program

Integrated Development Environment

Modern programming is practically always done in an IDE (integrated development environment).

An IDE contains a set of useful tools for the programmer.

It does not create the program by itself, but it can give hints about common mistakes in the code, and help the programmer understand the structure of the program.

But, for the first weeks, we are going to use a much simpler approach.

Our first minimalist development environment

In order to understand better how Java programs are written, compiled and executed, we are going to do it manually.

The following steps must be followed:

  1. Get and install Java Development Kit (JDK).
  2. Configure our system to run Java applications.
  3. Run our first Java program.

What is the JDK?

  • JDK stands for Java Development Kit.
  • It provides the tools necessary to develop, compile, and run Java applications.
  • It Includes the Java Runtime Environment (JRE), compiler, and various utilities.
  • Key components include:
    • The compiler (javac)
    • The Java Virtual Machine (java)
    • Essential libraries and tools

Downloading Java JDK 17

Installing Java JDK 17

  1. Download the installer for your OS.
  2. Run the installer and follow the on-screen instructions.
  3. Verify your installation:
    • Open a terminal or command prompt.
    • Run java -version to check the installed Java version.
    • Run javac -version to ensure the compiler is installed.

Running your first Java application

  1. Create a folder structure that you are going to use for our course, for example comlang/week1/01_helloworld/.

  2. Inside that folder, create a file named HelloWorld.java with the following code:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, Computer Language ITM!");
    }
}
  1. Compile the program:
javac HelloWorld.java
  1. Run the program:
java HelloWorld

Programmers Write Source Code

  1. Source Code is the written code composed of statements and expressions read sequentially.

  2. Java offers many built-in commands to simplify development.

    • You will learn this by doing a lot of programming exercises.
  3. Example:

    System.out.println("Hello World");
  4. This command instructs the computer to print the provided string.

  5. Note the semicolon ; at the end, which marks the end of a statement.

These basics form the foundation for all Java programming.

What does this program print?

public class Example {
    public static void main(String[] args) {
        // The statements used by the program are placed here
        System.out.println("Welcome to the course - you will learn to program!");
    }
}
  • Welcome to the course - you will learn to program!
  • Welcome to the course - you will learn to program
  • you will learn to program!
  • Welcome to the course
  • The program prints nothing since it cannot do anything about the substraction

The print command

The print command System.out.println("Hello world"); prints the text “Hello world”.

System.out.println("Hello world!");

Output

Hello world!

You can print any text you want with the command, as long as the command System.out.println("arbitrary text"); — i.e., System dot out dot println open parenthesis ( “the text” close parenthesis ) and semicolon ; remains unchanged.

Program boilerplate

In Java, our programs have to include some boilerplate code1 to work.

This boilerplate, an example of which is shown below, for example tells the computer what your program is called.

Below, the name of the program is Example. This name has to correspond to the name of the file that contains the source code (e.g. Example.java).

public class Example {
    public static void main(String[] args) {
        System.out.println("Text to be printed");
    }
}

Executing code

  • Execution of the program starts from the line that follows public static void main(string[] args) {, and ends at the closing curly bracket }.

    • Commands are executed one line at a time.
  • We’ll learn what the terms public class and public static void mean later on.

  • In this example, System.out.println("Text to be printed") is the only command to be executed.

    • Its output is: Text to be printed
public class Example {
    public static void main(String[] args) {
        System.out.println("Text to be printed");
    }
}

Code templates

  • The examples in our slides will not always show the template, but you can assume that your program file always needs one.

  • As such, the examples might be as short as a single line, such as the example below that illustrates the print command.

System.out.println("Hello world");
  • In reality, the above example, when written as a full Java program, looks like so:
public class Example {
    public static void main(String[] args) {
        // Here goes the statements used by the program
        System.out.println("Hello world!");
    }
}

Exercise 2

Here’s the second programming exercise of this course.The exercise template has the following boilerplate code:

public class AdaLovelace {
    public static void main(String[] args) {
        // Write your program here

    }
}

The line “// Write your program here” is a line comment, and the computer will ignore it when executing the program.

Add a new line below the line comment that prints the string “Ada Lovelace” and run the program. The output of the program should be:

Ada Lovelace

Running Java programs

  • Running the program is straightforward, but a lot is happenings behind the scenes. Can you explain it step by step?

    1. When a program is run, the source code is first compiled into Java bytecode by the java compiler. What command do we use for this?
    1. Following that, the program gets executed, meaning the commands are executed one-by-one by a Java-interpreter that is able to read Java bytecode. What is the name of the Java interpreter?
  • This compile process affects how and when errors occur. When a program is compiled before execution, the compiler can search for errors in it.

Printing multiple lines

  • Programs are constructed command-by-command, where each command is placed on a new line.

  • In the example below, the command System.out.println appears twice, which means that two print commands are being executed in the program.

public class HelloWorldMultiLine {
    public static void main(String[] args) {
        System.out.println("Hello world!");
        System.out.println("... and the universe!");
    }
}
  • The program above will print:
Hello world!
... and the universe!

Precision Matters in Programming

  • The guidelines in the assignments regarding the print format are very precise. If the assignment expects you to print a parenthesis, you must print the parenthesis.
  • Missing a single character may cause an error. Novice programmers often:
    • Enter a comma instead of a dot
    • Write printin instead of println
    • Leave out apostrophes, or forget the semicolon after a command.
  • Any error of these would cause an error and cause the program execution to fail.
  • Learning programming is, a path full of mistakes — and every error message is a chance to learn.

Exercise 3

The exercise comes with the following template:

public class OnceUponATime {
    public static void main(String[] args) {
        // Write your program here

    }
}

Modify the program so that it will print the following text. Use three System.out.println-commands for printing.

Once upon a time
there was
a program

Terminology and Code Comments

Command parameters

  • The information to be printed by the print command, i.e. its parameters, are passed to it by placing them inside the parentheses () that follow the command.
    • For example, passing Hi as a parameter to the System.out.println command is done like this: System.out.println("Hi").

Semicolon Separates Commands

  • Commands are separated with a semicolon ;.
  • We could, if we wanted to, write almost everything on a single line.
System.out.println("Hello "); System.out.println("world"); System.out.println("!\n");

Output

Hello
world
!

Comments (I)

Source code can be commented to clarify it or to add notes. There are two ways to do this.

  • Single-line comments are marked with two slashes //. Everything following them on the same line is interpreted as a comment.

  • Multi-line comments are marked with a slash and an asterisk /*, and closed with an asterisk followed by a slash */. Everything between them is interpreted as a comment.

Comments (II)

Below is an example of a program where both are used.

public class Comments {
    public static void main(String[] args) {
        // Printing
        System.out.println("Text to print");
        System.out.println("More text to print!");
        /* Next:
        - more on printing
        - more practice
        - variables
        - ...
        */
        System.out.println("Some other text to print");
        // System.out.println("Trying stuff out")
    }
}

The last line of the example shows a particularly handy use-case for comments. Code that has been written does not need to be deleted to try out something else.

Exercise 4

The exercise comes with the following template:

public class Dinosaur {
    public static void main(String[] args) {
        // Write your program here
    }
}

Edit the program so that it will print the following text:

Once upon a time
there was
a dinosaur

Checking our learning objectives

  • Learn what is programming language, program and computer programming
  • Distinguish between low-level and high-level programming languages
  • Explain the difference between compiled and interpreted languages, and classify Java as a compiled language.
  • Become familiar with executing programs
    • Write and execute several programs in Java, following the steps to compile and run the program using a text editor and the command line.
  • Learn to write programs that print text.
  • Know what the term “parameter” means.

Next week

  • Output and variables

Acknowledgements


Back to title slide Back to lecture slides index