You are on page 1of 4

Kingdom of Saudi Arabia

Ministry of Higher Education


‫المملكة العربية السعودية‬
Prince Sattam Bin Abdulaziz ‫وزارة التعليم العالي‬
University ‫جامعة األمير سطّام بن عبدالعزيز‬
College of Computer Engineering and ‫كلية هندسة وعلوم الحاسب‬
sciences ‫قسم علوم الحاسب‬
Computer Science Department

Course Title:Programming Languages & Compiler- Lab Abdulrab Ali Bin Taleb :‫اسم الطالب‬
Homework #1
Instructor Name: Abdul Haseeb 435050452 :‫الرقم الجامعي‬
Date:03/05/2018 :‫الشعبة‬
Deadline: 14/03/2018 1438-1439 (II) :‫المجموع‬

1. What, exactly, is a programming language?

is a formal language that specifies a set of instructions that can be used to produce various kinds of
output. Programming languages generally consist of instructions for a computer.

2. How do compilers and interpreters differ?

Compilers

Compilers were the first sort of translator program to be written. The idea is simple: You write the program,
then hand it to the compiler which translates it. Then you run the result.

Interpreters

An interpreter is also a program that translates a high-level language into a low-level one, but it does it at the
moment the program is run. You write the program using a text editor or something similar, and then
instruct the interpreter to run the program. It takes the program, one line at a time, and translates each line
before running it: It translates the first line and runs it, then translates the second line and runs it etc.

3. Why do we call C a “Third Generation Language”?

much more machine independent and more programmer-friendly. This includes features like improved
support for aggregate data types, and expressing concepts in a way that favors the programmer, not the
computer. A third generation language improves over a second generation language by having the computer
take care of non-essential details such as C .

4. What is a “Fourth Generation Language”?

CS4321 – Homework #1 Page: 1 of 4


is any computer programming language that belongs to a class of languages envisioned as an
advancement upon third-generation programming languages (3GL). Each of the programming
language generations aims to provide a higher level of abstraction of the internal computer hardware
details, making the language more programmer-friendly, powerful and versatile.

5. What are the main Paradigm of Programming Languages?

are a way to classify programming languages based on their features. Languages can be classified
into multiple paradigms.Some paradigms are concerned mainly with implications for the execution
model of the language, such as allowing side effects, or whether the sequence of operations is
defined by the execution model.

6. Name 20 Programming Languages

1. JavaScript
2. Java
3. Python
4. Ruby
5. CSS
6. PHP
7. C++
8. C
9. Shell
10. C#
11. Objective-C
12. R
13. VimL
14. Go
15. Perl
16. CoffeeScript
17. TeX
18. Scala
19. Haskell
20. Emacs Lisp

7. What arguments can you make for the idea of a single language for all programming
domains?
It’s a great idea to have a generalised programming language for any type of programming. It would make
both developer and users understand about the language deeper since there are no longer any additional
hustle in understanding another language for each cases. It would also make programs made under the
same language compatible one another and so there are no ports needed on different platform.

CS4321 – Homework #1 Page: 2 of 4


8. What arguments can you make against the idea of a single language for all programming
domains?
A single language helps better understanding for each party of devs and users. However, this is also a
problem. A great thing about various language for programming is that devs are able to express their ideas
much more secure since other devs may not know the algorithm and process that happens in the
background. therefore, a large varieties of programming language also helps the developments be better
than one another.

9. In a program reading user input using a Scanner, if the user types the following line of input:

Hello there. 3+4 is 7 and 2.5 squared is 5!

How many tokens are in the preceding line? What types can the Scanner legally read each
token as?

10 Tokens:
Token1: Hello
Tokens2: There.
Tokens3: 3+4
Tokens4: Is
Tokens5: 7
Tokens6: and
Tokens7: 2.5
Tokens8: squared
Tokens9: Is
Tokens10: 5!

10. What are the three most fundamental models in compiler design and how they are used?

1. finite state machine:


is a mathematical model of computation. It is an abstract machine that can be in
exactly one of a finite number of states at any given time. The FSM can change from
one state to another in response to some external inputs the change from one state to
another is called a transition. An FSM is defined by a list of its states, its initial state,
and the conditions for each transition.

2. regular expression:
regular expression are patterns used to match character combinations in strings.

3. context-free grammar:
A context-free grammar is a grammar which satisfies certain properties. In computer
science, grammar describe languages; specifically, they describe formal languages.
CS4321 – Homework #1 Page: 3 of 4
CS4321 – Homework #1 Page: 4 of 4

You might also like