0% found this document useful (0 votes)
41 views3 pages

Act05 Bsme33 Ca23

The document discusses various programming paradigms like imperative, functional, and object-oriented programming and provides examples of languages that fall under each paradigm such as C, Java, and Lisp. It also explains the tradeoffs between compiled and interpreted programs in terms of speed, portability, and development cycles as well as how virtual machine languages aim to achieve the benefits of both compiled and interpreted languages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views3 pages

Act05 Bsme33 Ca23

The document discusses various programming paradigms like imperative, functional, and object-oriented programming and provides examples of languages that fall under each paradigm such as C, Java, and Lisp. It also explains the tradeoffs between compiled and interpreted programs in terms of speed, portability, and development cycles as well as how virtual machine languages aim to achieve the benefits of both compiled and interpreted languages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Polytechnic University of the Philippines

College of Engineering
Sta. Mesa Manila

Computer Applications for ME – Activity 05

12/09/2
Name Lagajino, Rolando Jr. A. Signature Date
020
Student 2018-01664-
Section BSME 3-3 Score
Number MN-0

Instruction: Answer the following questions. Write your answer on the space
below each question.
1. What are the three ways of thinking about programming, often called
programming paradigms?

A programming paradigm is all about the methodology of a programming


language. Paradigms are significant because they define a programming
language and explain how it works. A great way to think of a paradigm is as a
set of ideas that a programming language can use to execute tasks at a much
higher level in terms of machine code. Here are the three different programming
paradigms:

a. Imperative

Imperative programming paradigms function by modifying the program


state through assignment statements. It performs the task step by step by
changing the state. The primary focus is on how to achieve the goal.

b. Functional

Functional programming paradigms deal as much as possible with the


state by avoiding it. Solutions are also defined as a series of functions that
pass values to one another which leads to a series of transformations. Parts of
the program dealing with the state, if any, appear to be isolated.

c. Object-Oriented

In the object-oriented programming paradigm, the program is written as


a set of classes and objects that are intended for communication. The smallest
and basic entity is the object and all kinds of computation are performed on the
objects only. More focus is on data rather than procedure. It can cope with
almost all sorts of real-life issues that are today in the scenario.
2. Name at least one language for each of the three methods of programming
described in the previous question.

Here are the sample programming languages in each respective


programming paradigms:

a. Imperative

● C ● Assembly
● FORTRAN

b. Functional

● Common Lisp ● R
● Scheme ● Julia
● Haskell ● Nimrod

c. Object-oriented

● C++
● Java
● JavaScript
● Python
● Scala

3. Why is compiling a program preferred over interpreting a program?


Compiled languages are directly translated into machine code which can
be executed by the processor. As a consequence, they prefer to execute quicker
and more effectively than interpreted languages. They also offer more control
over hardware aspects, such as memory management and CPU use to the
developer. Compiled languages need a "build" step; first, they need to be
compiled manually. Every time you need to make a change, you need to
"rebuild" the program. The entire translation is written in our hummus
example.

Programs compiled into native machine code prove to be faster than code
that has been interpreted. This is because the process of translating code adds
to the overhead at run time, which can cause the overall program to be slower.
A compiled program has a faster performance by directly using the native code
of the target machine while the execution speed of the interpreted program is
slower. The compiled program also has an opportunity to apply quite powerful
optimizations during the compile stage.

4. Why is interpreting a program preferred over compiling a program?


The interpreted languages tend to be more versatile and also have
features such as dynamic typing and smaller program size. Often, since the
source program code itself is executed by interpreters, the code itself is
platform-independent. The computed program needs additional time to
complete the entire compilation step before the testing and it is platform
dependent on the generated binary code. Interpreted programs are easier to
implement. It does not need to run a compilation stage and can execute code
directly "on the fly". Also, it can be more convenient for dynamic languages

Interpreters run line by line through a program and execute each


command. Here, if the author decides what he wants, he can change it
immediately and replace a new one. That change can then be conveyed to you
by the translator. Interpreted languages were considerably slower than
compiled ones. But the gap is shrinking with the development of just-in-time
compilation.

5. What benefits do virtual machine languages have over interpreted languages?


Virtual machine languages (VML) were created to link compiled and
interpreted languages together. Under ideal conditions, running a program in
virtual machine language is also as fast as compiled language programs but has
the platform independence of interpreted language programs. The way that
virtual machine languages gain their portability because of the platform
independence is by having a different interpreter for each supported operating
system. This interpreter makes itself tied to correct runtime libraries for each
different operating system. VML is more efficient than interpreted languages as
well as being a high productivity language. It is also known to be highly
compatible; "write once, run anywhere". On the other hand, interpreted
languages tend to be more powerful and flexible but are slower and consume
more resources. Interpreted languages allow the use of a variable without a
defined type, which is usually seen as an increase in power and productivity,
but can have great cost producing errors difficult to detect.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy