0% found this document useful (0 votes)
29 views

Comp Lang Intro

Uploaded by

Sudipta Roy Rimo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Comp Lang Intro

Uploaded by

Sudipta Roy Rimo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Computer Languages:

Introduction

OCN-3205
(Computer Programming for Oceanographers)
Lecture 06 (updated_new)

Sujit Kumar Debsarma


Visiting Professor, BSMRMU & DU
Former Scientist, SMRC
Former Pr. Meteorologist & System Manager, BMD
E-mail: [email protected], [email protected]
Cell: +88 01911 025955, +88 01818 383404
Computer languages: Brief
introduction
BASIC (Beginners All purpose Symbolic Instruction
Code) was developed by John G. Kemeny and Thomas
E. Kurtz at Dartmouth College in 1960s. It is an easy to
learn programming language for computers. Because of its
simplicity having interpreter/ compiler and programmers can
give instant feedback, it became the most popular
programming language when microcomputers made their
debut. It has a large number of followers even today.
Following BASIC program is for printing “Hello, World!”.
File name: hello.bas

PRINT “Hello, World!” OUTPUT:


END Hello, World!
Run BASIC Link:
http://www.runbasic.com/seaside/go/runbasic?_s=MEomDwCuCKQuGLUE&_k=fdCZUnze

Simple code in Run BASIC, File name: substring.bas


REM variable names followed by '$' sign character strings.


input "Please type your full name"; fullName$
firstName$ = word$(fullName$, 1)
middleName$=word$(fullName$, 2)
lastName$ = word$(fullName$, 3)
print "First name is "; firstName$
print "Middle name is "; middleName$
print "Last name is "; lastName$: END

OUTPUT:
Please type your full name? Sujit Kumar Debsarma
First name is Sujit
Middle name is Kumar
Last name is Debsarma
Fortran Language
FORTRAN was developed by a team of programmers at IBM led
by John Backus, and was first published in 1957. The name
FORTRAN is an acronym for FORmula TRANslation.
According to someone, BASIC is the child of FORTRAN.
Mathematical expressions and some structures are very much
similar. Oldest versions still in use are Fortran IV, and Fortran 66.
Most commonly used versions today are : Fortran77, Fortran90,
and Fortran95. It supports −
● Numerical analysis and scientific computation
● Structured programming
● Array programming
● Modular programming
● Generic programming
● High performance computing on supercomputers
● Object Oriented Programming (OOP)
● Concurrent programming
● Reasonable degree of portability between computer systems
First Fortran Program
Compiler Link:
https://www.tutorialspoint.com/compile_fortran_online.php
File name: hello.f95
NB: Fortran file name extension may be *.f or *.for in Fortran77,
*.f90, and *.f95 in Fortran90 and 95 respectively. Here '*' may be
any file name.
program hello
implicit none ! Implicit typing is a good practice in Fortran
! Some compiler takes both single and double quote strings.
print *, 'Hello, World!' ! print string ''Hello, World!'
end program hello

OUTPUT:
Hello, World!
C Language
❖ C is a general-purpose, high-level language that was
originally developed by Dennis M. Ritchie to develop the
UNIX operating system at Bell Labs, USA. C was
originally first implemented on the DEC PDP-11 computer
in 1972.

❖ In 1978, Brian Kernighan and Dennis Ritchie produced


the first publicly available description of C Language with
29 keywords only, now known as the K&R standard.

❖ The language was formalized in 1988 by the American


National Standard Institute (ANSI).
C Language
❑ The UNIX operating system, the C compiler, and
essentially all UNIX application programs have been
written in C.
❑ C has now become a widely used professional language
for various reasons −

✔ Easy to learn
✔ Structured language
✔ It produces efficient programs
✔ It can handle low-level activities
✔ It can be compiled on a variety of computer platforms
First C Program
Compiler Link: https://www.tutorialspoint.com/compile_c_online.php

C program consists of the following parts −


● Preprocessor Commands
● Functions
● Variables
● Statements & Expressions
● Comments
Let us look at a simple code that would print the string of words
"Hello World!" −
File name: hello.c
#include <stdio.h>
int main() {
/* my first program in C */
printf("Hello, World! \n"); OUTPUT:
return 0; Hello, World!
}
Java Language
➢ James Gosling initiated Java language project in
June 1991 for use in one of his many set-top box
projects. The language, initially called ‘Oak’ after
an oak tree that stood outside Gosling's office,
also went by the name ‘Green’ and ended up
later being renamed as Java, from a list of random
words.

➢ Sun Microsystems, Inc. (Sun for short) an


American company released the first public
implementation as Java 1.0 in 1995. It promised
Write Once, Run Anywhere (WORA), providing no-
cost run-times on popular platforms.
Java Language
➢ On 13 November, 2006, Sun released much of
Java as free and open source software under
the terms of the GNU General Public License
(GPL).

➢ On 8 May, 2007, Sun finished the process,


making all of Java's core code free and open-
source, aside from a small portion of code to
which Sun did not hold the copyright.
First Java Program
Compiler Link: https://www.tutorialspoint.com/compile_java_online.php

File name: hello.java


public class FirstJavaProgram {
/* This is my first java program.
* This will print 'Hello, World!' as the output */

public static void main(String []args) {


System.out.println("Hello, World!");
// prints 'Hello, World!' string.
}
}
OUTPUT:
Hello, World!
Python Language
❖ Python is a general-purpose interpreted, interactive,
object-oriented, and high-level programming language.
❖ It was created by Guido van Rossum during 1985-
1990.
❖ Like Perl, Python source code is also available under
the GNU General Public License (GPL).
❖ It has fewer syntactical constructions than other
languages.
❖ Python language has many similarities to Perl, C, and
Java.
❖ However, there are some definite differences between
the languages.
First Python Program
Python Compiler Link:
www.programiz.com/python-programming/online-compiler/
File name: hello.py

#! /usr/bin/python # PATH of python language


# This program prints "Hello world!"
print ("Hello, World!")

OUTPUT:
Hello, World!
Python Program
#! /usr/bin/python # PATH of python language
# Variable declaration
var1 = 'Hello World!'
# var1[:6] equals 'Hello '
print ("Updated String :- ", var1[:6] + 'Python')

When the above code is executed, it produces the


following result −

OUTPUT:
●Updated String :- Hello Python
Last Words About Computer
Languages
➢ There are many other computer languages like Perl,
Pascal, etc., etc.
➢ But Fortran is the most suitable language for
mathematical/ numerical calculations and modeling.
➢ Hence, we will discuss and practice Fortran77,
Fortran90 and Fortran95.
➢ Fortran77 codes can run well with Fortran90/95
compiler (upward compatibility).
➢ Fortran90/95 is a very powerful high level language.
➢ If you learn one language well, you can learn other
languages yourself easily.
Conventional File name Extensions
File names may be Upper case, Lower case or mixed
cases with underscore (_) like HELLO.F, My_Prog.c
string.bas etc.
Sl. No. Computer languages File name Extensions
1 BASIC *.bas
2 Fortran 77 *.f or *.for
3 Fotran 90 *.f90
4 Fortran 95 *.f95
5 C / C++ *.c / *.cpp
6 Java *.java
7 Python *.py

You might also like