TCP Lec01

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 32

Introduction to Integrative

Programming
Lecture 1

Compiler and Interpreter video: https://www.youtube.com/watch?v=I1f45REi3k4


Wear A Mask Properly
 You are encouraged to wear a mask during the lecture
class and lab session.
Learning Outcome
 Comprehend the integration method and technique used
for data transformation and application execution
 Perform the programming practices and transformation
rule to solve the problems
 Propose solution to problems related to data
transformation and application execution through a group
work
Mark Distribution
Coursework (100%)
1. Continuous Assessment (60%)
 Midterm Test (30%)
 Assignment (15%)
 Quizzes (15%)
2. Final Assessment (40%)
 Project (40%)
Programming Process
 Computer program (source code) is human-readable text
file.
 The program must be translated into machine language
so that the computer can execute the program.
 The way that this translation occurs depends on whether
it is implemented with an interpreter or compiler.
 Hence, compilation and interpretation are
implementation techniques, not property of language.
Compiler
 Compiler is a language processor that reads the source
program (written in high level language) as a whole and
translates it into machine language module (object file).
 Compiler specifies the errors at the end of compilation with
line numbers when errors are found.
 The errors must be removed before the compiler can
successfully recompile the source code again.
Compiler

Source
Compiler
program

Target Output
Input
program

If the target program is an executable machine-language program, it can then be


called by the user to process input and produce output
Native Compiler
 Native compiler is a compiler that works on compilation for
the same platform on which it runs.
 Native compiler runs on the same platform X as the target
code
debug on X
Source Native Compiler Target
program program
compile on X
CPU-executable
binary target code

Target Output
Input
program
run on X
Cross Compiler
 Cross compiler is a compiler which generates code for a
platform different than the platform on which the compiler
itself runs.
 The computer the compiler runs on is called the host, and
the computer the new programs run on is called
the target.
 Cross compiling means that the host and target platform
are not the same.
 Example:
 Windows software is built on a Linux computer.
 64-bit executables is compiled under a 32-bit system
Cross Compiler
 Cross-compiler runs on platform X, target code runs on platform Y

debug on X
Source Cross Compiler Target
program program
compile on X

copy to Y

Target Output
Input
program
run on Y
Interpreter
 An interpreter translates program code into machine code,
instructed by instruction.
 The CPU executes each instruction before the interpreter
moves on to translate the next instruction.
 The instruction is executed directly without converting
them to an object code or machine code.
 If there is an error in the statement, the interpreter
terminates its translating process at that statement and
displays an error message.
 The interpreter moves on to the next line for execution
only after removal of the error.
Interpreter

Source program
Interpreter Output
Input
Difference between Interpreter and
Compiler
Difference between Interpreter and
Compiler
Interpreter Compiler
Translates program one statement at a time Scans the entire program and translates it as a
whole into machine code
It takes less amount of time to analyze the It takes large amount of time to analyze the
source code but the overall execution time is source code but the overall execution time is
slower comparatively faster
No intermediate object code is generated, hence Generate intermediate object code which
are memory efficient further requires linking, hence requires more
memory
Continue translating the program until the first It generates the error message only after
error is met, in which case it stops. Hence scanning the whole program. Hence debugging
debugging is easy is comparatively hard

Programming language like PHP, JavaScript Programming language like C, C++ use
use interpreters compilers

Source: http://www.programiz.com/article/difference-compiler-interpreter
Programming Language
 Programming language is a set of commands and
instructions that a computer can understand and execute.
 Programming language refers to high-level languages, such
as C, C++, C#, Java, and others.
 Each language has a unique set of keywords and special
syntax for organizing program instructions.
Jav
C C#
a
High-Level Language

Assembly Language

Machine Language

Hardware
Scripting language
 A scripting language is a form of programming language
that is usually interpreted rather than compiled.
 A "script" is code that acts upon some system in an
external or independent manner. It can be removed
without disabling the system itself.
 Scripting language is generally less strict about syntax,
and often produce code that works with another
application (e.g. a web browser or a web server).
Scripting language
 Advantage:
 easy to learn and use
 minimum programming knowledge or experience required
 allow complex tasks to be performed in relatively few steps
 allow simple creation and editing in a variety of text editors
 allow the addition of dynamic and interactive activities to web
pages
 Disadvantage:
 Not all scripting languages are supported by all systems.
Programming Language vs Scripting Language
Programming Language Scripting Language
Type Compiler based language Interpreter based language
Usage Developing something from Used to combine existing
scratch components
Design Designed to get full usage of a Designed to make coding fast and
language simple
Creation Creates a .exe file Does not create a .exe file
Coding Programming is making a full code Scripts are just a piece of code
of program
Temperament Harder to code. Needs numerous Easier to code. Needs only a few
lines of code for each function short lines of code for each function
Complexity Complex Easy to use and easy to write
Development Takes longer to develop as more Takes less time to code as it needs
Time code needs to be written. less coding.
Examples C, C++, C#, Java, VC++, VB, JavaScript, VB Script, Shell, Perl,
Basic, COBOL, Pascal, etc. Python, Ruby, PHP, etc.
Mobile Programming Language
 Mobile programming language is used to develop a
mobile apps for mobile devices (smartphone, tablet,
smartwatch)
 Mobile apps can be grouped into three categories:
 Web
 Native
 Hybrid
Mobile Programming Language
 Web apps
 Web apps are hosted on web browsers, and are
essentially websites that look like native apps.
 Web apps are written in HTML5, CSS3, JavaScript and
server-side languages or web application frameworks
(such as PHP, Python, etc)
 Web apps are not native to any system, and do not need
to be downloaded or installed.
 Web apps support multiplatform, easier to maintain
and low development cost.
Mobile Programming Language
 Native apps
 Native apps are built using platform-specific software development tool provided by
the mobile OS.
 Native mobile app stores the app resources in the device memory and ensures
maximum utilization of OS features
 Native apps can access all the built-in features of smartphones (such as camera,
GPS, compass, list of contacts).
 Hence, mobile app offers the fastest and best in class user experience and app
functionality.
 However, code written for one mobile platform cannot be used on another, making
the development and maintenance of native apps for multiple Oss very long and
expensive undertaking.
Mobile Platform Programming Tool Package
Language format
Android Java (some C, C++) Android SDK .apk
Apple iOS Objective-C, C, C++ Xcode .app
Windows Phone C#, VB.NET Visual Studio .xap
Mobile Programming Language
Native apps

Source: https://medium.com/applantic/mobile-applications-in-2018-part-i-comparison-native-vs-hybrid-be16a4067a9b
Mobile Programming Language
 Hybrid apps
 The hybrid approach combines native development with web
app technology.
 The HTML, CSS and JavaScript code base runs in WebView
(an internal browser) within a native wrapper/container.
 The native wrapper (such as Apache Cordova) allows hybrid
app to be installed on devices, deploy via app stores and
access native device APIs via JavaScript.
 When a hybrid apps run, the native application wrapper hosts
a full-screen web container in which the HTML, JavaScript
and CSS are loaded and run.
Mobile Programming Language
Hybrid apps

Source: https://medium.com/applantic/mobile-applications-in-2018-part-i-comparison-native-vs-hybrid-be16a4067a9b
Mobile Programming Language
Mobile Programming Language

Source: https://santoshshinde2012.blogspot.my/2016/02/picking-mobile-technology-stack.html
Mobile Programming Language

Native apps Hybrid apps


Platform dependent Platform independent
Respective development tools Commonly used development tools
Time consuming Quick development
Expensive development Cheap development
More platform more code Single code for multiple platform
Best performance Limited performance

Easy access to mobile native features Limited access to mobile native features

Source: http://www.dotnet-tricks.com
Mobile Programming Language
Web Native Hybrid
Distribution Hosted on a web server and Downloaded to device from Downloaded to device
accessed on a web browser. App Store. from App Store.
Development One app is developed to work One app is built for each One all is built and then
on all platforms because logic platform. Application logic is wrapped to fit specific
can be reused. App looks reconstructed for each app on native platforms using a
nearly identical on all devices each platform. Difficult to tool such as PhoneGap.
but requires testing across all replicate app precisely across
devices. all platforms.
Release App updates can be handled App updates must be App updates must be
remotely and are downloaded and installed each downloaded and installed
instantaneous. time. each time.
Performance Noticeable performance lag, Fast response. Faster than web app but
especially with poor web slower than native app.
connectivity.
Design User interface geared more Richly appealing user interface Mix between native app
towards functionality then look design. and web app visual
and feel. More images leads to appeal, but not as rich as
loading constraints. native app.
Integrative Programming Language
 Integrative programming language manages two type of
languages to perform the task.
 Example, code written in Java are interacting with code
written in C++.

Java C++
Integrative Programming Language
 Java provides a framework called the Java Native
Interface (JNI), with which it is possible to write native
methods.
 A native method is a method that is mapped to a function
in a library of native code, such as a DLL under Windows.
 It is used solely to interact with "native" code -- code
written in a system-level language like C.
Integrative Programming Language
Advantages:
 The existing library that was previously written in another
languages (C or C++) can be used by other language
(Java)
 API functions from server product that is developed in C
or C++ is invoked from a Java client.
 Some hardware features using other languages like C or
C++ can be accessed by Java
Integrative Programming Language
JNI in mobile application development:
 Java is slow in handling the hardware resources.
 In the Android NDK (Native Development Kit), Android
application developers can reuse legacy codes which are
written C/C++ and assembly language through the JNI.
 Hence, Android application developers can manage
hardware resources in detail and the application
performance is improved.

You might also like