PLC – Names,Binding and Scope

A. Naming 
There are various things that have to be paid attention to when giving name for a variable, class, and such in C++, such as the following:

– Naming should be unique and a variable should not have the same name with other variables in the same scope.
– Reserved words and keywords may not be used for a variable name.
– Naming can only consist of alphabets (A-Z, a-z), numbers (-0-9), dollar symbol ($), and underscore (_).
– The first character of the name should be either an alphabet or an underscore.
– Names in C++ are case-sensitive, so, for example, the variable index and Index are different from each other. This may cause a problem in both readibility and writability as it considers similar names as different.
– While there are no limit in character length, during execution the program will only recognize the first 32 characters of the name.
– It is advised to use relevant, short, and clear names for variables, classes, etc., so when the coder or other people read the codes again, they would not be confused of what are the use of several variables and the variables would be easier to use.

Pay attention to the following snippet of codes:

int main() {

int 2nama, nim, _alamat, for;
cin>> 2nama >> NIM >> _alamat >> for;

}
Mistakes of naming that can be seen from the codes above:

– During the declaration (line 1), the variable 2nama violated the rule that a name can only be started with alphabets or underscore, not numbers. The variable for can’t be used too, as for is already a keyword used for looping function.
– During the value input of the variables (line 2), same as line 1, variables 2nama and for violate the rule. In addition, athe variable NIM would cause an error too as the compiler does not recognize that name, because C++ is a case-sensitive language, so it considers the variable nim declared on the first line different from the variable NIM used on the second line.


B. Binding
Binding is the association between an entity and an attribute, such as the association of a variable and its attributes like name, address, data type, value, lifetime, and scope. Binding time is the time at which binding takes place.
The examples of binding time:

o Language design time
o Language implementation time
o Program translation / compile time
o Link edit time
o Load time
o Run time

For a variable to be able to be referenced in a program, first it need to be bound to a type, which is called type binding. It can be differentiated into two kinds of type binding:

1. Static type binding, binding that took place during compile time. The data type that the variable is bound to is decided either by directly specifying a data type to the variable name (explicit) or by default associating a variable with a type during compile time (implicit). In C++, Explicit static type binding is usually used.

2. Dynamic type binding, where a variable is bound to a type when it is assigned a value in an assignment statement (at run time, take the type of the value on the right-hand side). By using dynamic type binding, it’s more flexible compared to static type binding, but error detection is harder and prone to typing errors. In C++, dynamic type binding can be used with the help of template by using generics.


C. Scope
The scope of a variable is the range of statements over which it is visible. The scope rules of a language determine how references to names are associated with variables. In C++, the scope of a variable depends on the block where the variable is declared or called. There are two kinds of scope, static and dynamic scope. Depending on the scope it is in, a variable can be divided into two kinds:

o Local Variable is variable declared in a block of program and can only be called in said block.
o Global Variable is variable declared outside of all block of programs and can be called from anywhere after its declaration. In the case when a global variable and a local variable share a name, the local variable will be prioritized if the variable name is called inside the same block of that local variable.

1.  Static Scope
Static scope is based on program text and connect a name reference to a variable by finding the declaration. The search process of the declaration starts locally, then in increasingly larger enclosing scopes, until one is found for given name.
2. Dynamic Scope
Dynamic scope is based on calling sequences of program units, not their textual layout. References to variables are connected to declarations by searching back through the chain of subprogram calls that forced execution to this point.

PLC – Syntax and Symantics

A. Definition

The word syntax comes from Ancient Greek: σύνταξις “coordination”, which consists of σύν syn, “together,” and τάξις táxis, “an ordering”.
In computer science, the syntax of a computer language is the set of grammatical rules that defines the combinations of words and symbols that are considered to be a correctly structured document or fragment in that language.
Semantic focuses on the relationship between signifiers— like words, phrases, signs, and symbols—and what they stand for, their denotation. In computer science, semantics is the meaning of the expressions, statements, and program units.


B. C++ Syntax

The syntax of textual programming languages is usually defined using a combination of regular expressions (for lexical structure) and Backus–Naur Form (for grammatical structure) to inductively specify syntactic categories (nonterminals) and terminal symbols. Syntactic categories are defined by rules called productions, which specify the values that belong to a particular syntactic category. Terminal symbols are the concrete characters or strings of characters (for example keywords such as define, if, main, or void) from which syntactically valid programs are constructed.

The following are the examples of basic C++ keywords syntax:

  1. #include, which is used to insert the library of functions we are going to use in our program. For example, #include , which includes the standard input and output codes.
  2. Int main(), which is called first by the program after the initialization. A statement return 0; should be written at the end of the codes inside int main().
  3. Cout, which is used to print output on the screen.
  4. Cin, which is used to input data by user and store it as a variable.
  5. int, char, etc., which are used to declare a variable, according to the data types. (int for integer, char for a character, string for string of characters, etc.)
  6. if, which is used in selection and will execute the codes if the condition is true.

There are also various points that should be paid attention to:

  1. The semicolon (;) is used to separate each statements.
  2. The curly brackets ({ }) must be used on several functions such as if, for, and while if there are more than one statements that will be executed in the function.
  3. C++ is a case-sensitive programming language, so if you use capitalization incorrectly, the compiler will give an error message.
  4. To set the value of char and string data types or to print text on a program, double quotation mark (“ “) is necessary.
  5. For comments, we use double slash (//) to mark the following text in a line as comment or type them between /* and */ to mark several lines of code or text as comments.

Here are an example of a program with correct syntax in C++:

#include
using namespace std;

int main() {

int x,y,z;
cout<<“Masukkan nilai x dan y : “; cin>> x >> y;
fflush(stdin);
z=x+y;
if (z>50) cout<<“Jumlah dari x dan y lebih dari 50”;
else cout<<“Jumlah dari x dan y kurang dari 50”;
getchar();
return 0;

}


 

C. Semantics
The requirements for a methodology and notation for semantics are as follows:
– Programmers need to know what statements mean
– Compiler writers must know exactly what language constructs do
– Correctness proofs would be possible
– Compiler generators would be possible
– Designers could detect ambiguities and inconsistencies

There are some kinds of semantics:
1. Operational semantics, which describes the meaning of a program directly by executing its statements on a machine, either simulated or actual. The change in the state of the machine (memory, registers, etc.) defines the meaning of the statement.
2. Denotational semantics, where each phrase in the language is interpreted as a denotation, i.e. a conceptual meaning that can be thought of abstractly.
3. Axiomatic semantics, where axioms or inference rules are defined for each statement type in the language (to allow transformations of logic expressions into more formal logic expressions).

Introduction Programming Language

A. Reasons for Studying Concepts of Programming Languages

➢ Increased ability to express ideas.

  • It is believed that the depth at which we think is influenced by the expressive power of the language in which we communicate our thoughts. It is difficult for people to conceptualize structures they can’t describe, verbally or in writing.
  • Language in which they develop software places limits on the kinds of control structures, data structures, and abstractions they can use.

➢ Improved background for choosing appropriate languages.

  • Many programmers, when given a choice of languages for a new project, continue to use the language with which they are most familiar, even if it is poorly suited to new projects.
  • If these programmers were familiar with other languages available, they would be in a better position to make informed language choices.

➢ Greater ability to learn new languages.

  • Programming languages are still in a state of continuous evolution, which means continuous learning is essential.
  • Programmers who understand the concept of OO programming will have easier time learning Java.
  • Once a thorough understanding of the fundamental concepts of languages is acquired, it becomes easier to see how concepts are incorporated into the design of the language being learned.

➢ Understand significance of implementation.

  • Understanding of implementation issues leads to an understanding of why languages are designed the way they are. • This in turn leads to the ability to use a language more intelligently, as it was designed to be used.

➢ Ability to design new languages.

  • The more languages you gain knowledge of, the better understanding of programming languages concepts you understand.

➢ Overall advancement of computing.

  • Many believe that ALGOL 60 was a better language than Fortran; however, Fortran was most widely used. It is attributed to the fact that the programmers and managers didn’t understand the conceptual design of ALGOL 60.

B. Programming Domains

➢ Scientific applications

  • In the early 40s computers were invented for scientific applications.
  • The applications require large number of floating point computations.
  • Fortran was the first language developed scientific applications.
  • ALGOL 60 was intended for the same use.

➢ Business applications

  • The first successful language for business was COBOL.
  • Produce reports, use decimal arithmetic numbers and characters.
  • The arrival of PCs started new ways for businesses to use computers.
  • Spreadsheets and database systems were developed for business.

➢ Artificial intelligence

  • Symbolic rather than numeric computations are manipulated.
  • Symbolic computation is more suitably done with linked lists than arrays.
  • LISP was the first widely used AI programming language.

➢ Systems programming

  • The operation system and all the programming supports tools are collectively known as its system software.
  • Need efficiency because of continuous use.

➢ Scripting languages

  • Put a list of commands, called a script, in a file to be executed.
  • PHP is a scripting language used on Web server systems. Its code is embedded in HTML documents. The code is interpreted on the server before the document is sent to a requesting browser.

C. Language Evaluation Criteria

1.  Readability

  • Language constructs were designed more from the point of view of the
    computer than the users.
  • Because ease of maintenance is determined in large part by the readability of
    programs, readability became an important measure of the quality of programs
    and programming languages. The result is a crossover from focus on machine orientation to focus on human orientation.
  • The most important criteria “ease of use”
  • Orthogonality

✓ Makes the language easy to learn and read.
✓ Meaning is context independent. Pointers should be able to point to
any type of variable or data structure. The lack of orthogonality leads
to exceptions to the rules of the language.
✓ A relatively small set of primitive constructs can be combined in a
relatively small number of ways to build the control and data structures
of the language.
✓ Every possible combination is legal and meaningful.
✓ The more orthogonal the design of a language, the fewer exceptions
the language rules require.
✓ The most orthogonal programming language is ALGOL 68. Every
language construct has a type, and there are no restrictions on those
types.
✓ This form of orthogonality leads to unnecessary complexity.

2. Writability

  • It is a measure of how easily a language can be used to create programs for a
    chosen problem domain.
  • Most of the language characteristics that affect readability also affect
    writability.

Simplicity and orthogonality

  • A smaller number of primitive constructs and a consistent set of rules
    for combining them is much better than simply having a large number
    of primitives.

Support for abstraction

  • Abstraction means the ability to define and then use complicated
    structures or operations in ways that allow many of the details to be
    ignored.
  • A process abstraction is the use of a subprogram to implement a sort
    algorithm that is required several times in a program instead of
    replicating it in all places where it is needed.

Expressivity

  • It means that a language has relatively convenient, rather than
    cumbersome, ways of specifying computations.

3. Reliability

  • A program is said to be reliable if it performs to its specifications under all
    conditions.
  • Type checking: is simply testing for type errors in a given program, either by
    the compiler or during program execution.
  • The earlier errors are detected, the less expensive it is to make the
    required repairs. Java requires type checking of nearly all variables
    and expressions at compile time.
  • Exception handling: the ability to intercept run-time errors, take corrective
    measures, and then continue is a great aid to reliability.
  • Aliasing: it is having two or more distinct referencing methods, or names, for
    the same memory cell.
  • It is now widely accepted that aliasing is a dangerous feature in a
    language.
  • Readability and writablity: Both readability and writability influence
    reliability.

4. Cost

✓ Training programmers to use language
✓ Writing programs “Writability”
✓ Compiling programs
✓ Executing programs
✓ Language implementation system “Free compilers is the key, success
of Java”
✓ Maintaining programs: Maintenance costs can be as high as two to
four times as much as development costs.
✓ Portability “standardization of the language”
✓ Generality (the applicability to a wide range of applications)


D. Influences on Language Design

➢ Computer architecture: Von Neumann
➢ We use imperative languages, at least in part, because we use von Neumann machines

• Data and programs stored in same memory
• Memory is separate from CPU
• Instructions and data are piped from memory to CPU
• Results of operations in the CPU must be moved back to memory
• Basis for imperative languages

✓ Variables model memory cells
✓ Assignment statements model piping
✓ Iteration is efficient

plc1
➢ Program Design Methodologies

• New software development methodologies (e.g., object-oriented software
development) led to new programming paradigms and by extension, new
programming languages

➢ Programming methodologies

• 1950s and early 1960s: Simple applications; worry about machine efficiency
• Late 1960s: People efficiency became important; readability, better control
structures

✓ Structured programming
✓ Top-down design and step-wise refinement

• Late 1970s: Process-oriented to data-oriented

✓ data abstraction

• Middle 1980s: Object-oriented programming

✓ Data abstraction + inheritance + polymorphism


E. Language Categories

➢ Imperative

• Central features are variables, assignment statements, and iteration
• C, Pascal

➢ Functional

• Main means of making computations is by applying functions to given
parameters
• LISP, Scheme

➢ Logic

• Rule-based
• Rules are specified in no special order
• Prolog

➢ Object-oriented

• Encapsulate data objects with processing
• Inheritance and dynamic type binding
• Grew out of imperative languages
• C++, Java


F. Implementation Methods

➢ Compilation

• Programs are translated into machine language; includes JIT systems
• Use: Large commercial applications
• Translate high-level program (source language) into machine code (machine
language)
• Slow translation, fast execution

plc2

➢ Pure Interpretation

• Programs are interpreted by another program known as an interpreter
• Use: Small programs or when efficiency is not an issue
• No translation
• Easier implementation of programs (run-time errors can easily and immediately be
displayed)
• Slower execution (10 to 100 times slower than compiled programs)
• Often requires more space
• Now rare for traditional high-level languages
• Significant comeback with some Web scripting languages (e.g., JavaScript, PHP)

plc3

➢ Hybrid Implementation Systems

• A compromise between compilers and pure interpreters
• Use: Small and medium systems when efficiency is not the first concern
• A compromise between compilers and pure interpreters
• A high-level language program is translated to an intermediate language that
allows easy interpretation
• Faster than pure interpretation

plc4

HTTP 2016

HTTP adalah event yang diselenggarakan oleh HIMTI (Himpunan Mahasiswa Teknik Informatika). Acara sambutan ini selalu diadakan setiap tahun untuk menyambut mahasiswa baru dalam School Of Computer Science dengan tema yang berbeda-beda. HTTP 2016 ini bertemakan Passion,Innovation, And Togetherness. Dalam acara ini, para mahasiswa harus membayar seharga Rp.150.000 sebagai tiket. Dalam Rp.150.000 yang kita bayar kita mendapat:

  • PBC
  • HIMTI Exclusive PIN
  • Transportation
  • Merchandise
  • HIMTI KIT
  • Poin SAT

S__30187594

Acara ini diselenggarakan di Gedung BPPT II pada hari Sabtu, 10 September 2016 dari pukul 09.00 sampai selesai.S__30187590

Dalam HTTP dilaksanakan acara sebagai berikut:

  1. Hiburan dari Peanut Butter Band
  2. Sambutan dari MC
  3. Sambutan dari Ketua HIMTI Kemanggisan Jonathan Gozali dan Alam Sutra Rionaldo Aureri Linggautama
  4. Dekan Fredy Purnomo, S.Kom., M.Kom dan Dosen IT Binus University
  5. Wakil Rektor Dr. Andres Chang
  6. Acara hiburan Penyanyi Adam Sidqon
  7. Games 1 : Menyambung kata. Game yang menyambung kata yang diucapkan dari kata kata sebelumnya yang membentuk frasa yang logis yang melatih konsentrasi dan ingatan. Game ini memerlukan 6 orang untuk memainkannya.
  8. Break (Makan dan minum)
  9. Talkshow. Dalam talkshow ini, HTTP mengundang alumni Binus Christian Tarunajaya, Reinhard Lazuardi Kuwandy dan Natanael Febrianto. Para alumni share mengenai produk yang dibuat oleh mereka dan proses pembuatan produknya. Produk diantara mereka berupa program penunjuk kepribadian user dalam Twitter dan Robot pengenal wajah.
  10. Games 2: Melempar bola ping-pong ke kepala pemain lain. Bola dilempar oleh pemain ke dalam keranjang kertas yang diletakkan dalam kepala pemain lain. Pemenang dihitung jumlah bola yang masuk ke dalam keranjang. Ada 3 Tim dengan anggota 2 orang setiap tim.
  11. Visualisasi HTTP :Visualisasi itu seperti drama yang membahas tentang binusian 2020 dari hari pertama FEP sampai masuk HIMTI dan pengalaman menjadi bagian dari HIMTI.
  12. Hiburan Dance By Revolution
  13. Guest Star : Vibing High yang membawa 5 lagu
  14. Selesai hiburan, kita diminta untuk memakai almamater Binus untuk dilantik menjadi Anggota HIMTI.
  15. Music house yang dibawakan oleh DJ Angelo.
  16. Pemberian Baju dan HIMTI KIT

S__30187595

Begitu saja susunan acara dari HTTP. Semoga dapat menikmati artikel saya. Terima Kasih.

HTTP,One Family,One Goal!