Oct
08
2017
0

Session II : Names, Binding, Scope

Session II : Names, Binding, Scope

In this Session II : Names, Binding, and Scope, there are 4 sub topics :

  • Introduction
  • Names
  • Variables
  • The Concept of Binding
  • Scope

Introduction

Imperative programming languages are, to varying degrees, abstractions of
the underlying von Neumann computer architecture. The architecture’s two
primary components are its memory, which stores both instructions and data,
and its processor, which provides operations for modifying the contents of the
memory.

A variable can be characterized by a collection of properties, or attributes,
the most important of which is type, a fundamental concept in programming
languages. Designing the data types of a language requires that a variety of
issues be considered. Among the most important of these issues are the scope and lifetime of variables.

Names

A name is a string of characters used to identify some entity in a program. For every programming language, they have maximum length for the names. Fortran 95, in their programming language, can only contain names with maximum length of 31. C99: no limit but only the first 63 are significant. And for C#, Java, C++ have no limit for their name’s length.

And for some other programs, they need special character for the names. For example : PHP, all variable names must begin with dollar signs($) ; Perl,all variable names begin with special characters, which specify the variable’s type; and Ruby, for variable names that begin with @ are instance variables and for those that begin with @@ are class variables. And also there are some programs that are case sensitive such as C, C#, and Java

For notes : if the names are too short, they cannot be connotative by others. So it’s recommended to have longer length for the names ( or as clear as possible for the names so it can be read by others )

Variables

Variable is an abstraction of a computer memory cell or collection of cells.

The move from machine languages to assembly languages was largely one
of replacing absolute numeric memory addresses for data with names, making
programs far more readable and therefore easier to write and maintain. That
step also provided an escape from the problem of manual absolute addressing,
because the translator that converted the names to actual addresses also chose
those addresses.
A variable can be characterized as a sextuple of attributes: name, address,
value, type, lifetime, and scope.

The Concept of Binding

A binding is an association between an attribute and an entity, such as
between a variable and its type or value, or between an operation and a symbol.
The time at which a binding takes place is called binding time.

Binding can be divided into two : Static and Dynamic. A binding is static if it first occurs before run time begins and remains unchanged throughout program execution. If the binding first occurs during run time or can change in the course of program execution, it is called dynamic. However, this processes are maintained by computer hardware, and the changes are invisible to the program and the user. Static and Dynamic type of binding have their own advantage and disadvantage. For the static type of binding, it’s efficient but lacks of flexibility. And for the dynamic type of binding, it’s really flexible but hard to be checked if there’s something wrong or missing and has high cost.

Back to the variable sub-topic, variables’ attributes : storage bindings and lifetime. Storage bindings of the variables can be divided into two : allocation and deallocation. Allocation is a process that the memory cell to which a variable is bound somehow must be taken from a pool of available memory. And deallocation is the process of placing a memory cell that has been unbound from a variable back into the pool of available memory. The lifetime of a variable is the time during which the variable is bound to a specific memory location. So, the lifetime of a variable begins when it is bound to a specific cell and ends when it is unbound from that cell.

The lifetime of variables itself has 4 categories :

  • Static  : bound to memory cells before execution begins and remains bound to the same memory cell throughout execution
  • Stack-dynamic  : Storage bindings are created for variables when their declaration statements are elaborated.
  • Explicit heap-dynamic  : Allocated and deallocated by explicit directives, specified by the programmer, which take effect during execution
  • Implicit heap-dynamic  : Allocation and deallocation caused by assignment statements

Scope

Scope is also one of the variables’ attributes. The scope of a variable is the range of statements in which the variable is visible. The scope of a variable can also be divided into 3 categories : Local variables, those that are declared in that unit;  The nonlocal variables, those that are visible in the unit but not declared there; and global variables, that are a special category of nonlocal variables. Scope itself can be divided into Static and Dynamic Scope. Static scope refers to scope of a variable is defined at compile time itself that is when the code is compiled a variable to bounded to some block scope if it is local, can be bounded to entire Main block if it is global. Dynamic scope refers to scope of a variable is defined at run time rather than at compile time.

 

End of the Session II : Names, Binding, and Scope

Read more
Oct
06
2017
0

Session I : Introduction

Sesi I : Introduction

Pada Sesi I : “Pengenalan pada Konsep Bahasa Pemrograman” ini, terbagi menjadi 6 sub topik yaitu :

  • Alasan mempelajari Konsep Bahasa Pemrograman secara umum
  • Domain dari Programming
  • Kriteria dari bahasa pemrograman
  • Pengaruhnya pada desain pemrograman
  • Kategori bahasa pemrograman
  • Metode Implementasi

Alasan Mempelajari Konsep Bahasa Pemrograman

Ada banyak sekali benefit dari mempelajari konsep programming,

berikut adalah beberapa alasan utama dari pentingnya mempelajari Konsep  Bahasa Pemrograman :

Mengasah kemampuan mengekspresikan ide

Dengan mempelajari semakin banyak bahasa pemrograman, seorang programmer akan terasah cara berfikir agar dapat mengekspersikan idenya ke dalam bahasa pemrograman

Dapat memilih bahasa pemrograman yang efektif

Agar mendapatkan hasil dari pemrograman yang tepat dan efisien, haruslah memilih bahasa pemrograman yang efektif. Contohnya : untuk membuat mobile app untuk iOS, dapat menggunakan aplikasi Swift. Untuk membuat website, dapat menggunakan aplikasi Pascal

Lebih mudah untuk mempelajari bahasa pemrograman baru

Dengan mempelajari konsep dari programming, seseorang akan dengan mudah dapat mempelajari bahasa pemrograman baru. Hal itu dikarenakan semua bahasa pemrograman memiliki konsep yang sama ( hanya bahasanya saja yang berbeda )

Kemampuan Implementasi 

Kemampuan untuk membuat aplikasi dengan efektif

Advancement

Kemampuan untuk meneliti dan membuat suatu program yang lebih efektif dan efisien dari sebelumnya

 

Domain dari Programming

Terbagi menjadi :

  • Scientific App

Bahasa Pemrograman Scientific App yang pertama kali dibuat adalah Fortran pada tahun 1940-an lalu pada tahun 1960-an dibentuk ALGOL 60. Scientific App pada saat itu hanya berbatas pada data yang relatif sederhana. Struktur yang paling umum digunakan pada saat itu adalah matriks dan deret.

  • Business App

Bahasa Pemrograman Business App yang pertama kali sukses dan terkenal adalah COBOL. Business App digunakan umumnya untuk membuat laporan, menyimpan angka dan karakter dengan tepat hingga operasi deret aritmetika

  • Artificial intelligence

Bahasa Pemrograman Artificial Intelligence umumnya digunakan untuk memprediksi kemungkinan-kemungkinan sehingga membuat komputer melakukan hal-hal yang dapat dilakukan oleh manusia

  • Software Programming

Bahasa Pemrograman Software Programming haruslah efisien karna software programming tersebut akan digunakan hampir secara terus menerus. Kebanyakan software zaman sekarang menggunakan bahasa pemrograman C

  • Web Programming

Bahasa Pemrograman Web Programming digunakan dalam pembuatan website

 

Kriteria Dari Bahasa Pemrograman

  • Readability : Bahasa Pemrograman dapat dibaca dan mudah dimengerti termasuk oleh orang lain
  • Writability : Bahasa Pemrograman yang digunakan mudah untuk membuat program
  • Reliablity : Dapat bekerja dengan optimal
  • Cost : Mengetahui total cost / expense dari program yang dibuat

 

Pengaruh Pada Desain Pemrograman

  • Comp Architecture

Arsitektur dasar komputer memberikan efek pada bahasa desain pemrograman. Sebagian besar bahasa populer tersebut telah dirancang ke dalam arsitektur komputer yang lazim, yang disebut arsitektur von Neumann

  • Programming Design Methodologies

Metode pengembangan software baru yang menyebabkan paradigma pemrograman baru dan perluasan, bahasa pemrograman baru

Kategori Bahasa Pemrograman

  • Logic
  • OOP (object oriented program)
  • Imperative
  • Scripting Language

Metode Implementasi

  • Compilation

Mentranslate dari high-level program menjadi machine code

  • Pure Interpretation

Tidak ada proses translation, umumnya membutuhkan lebih banyak space, slower execution , sudah jarang digunakan untuk traditional high-level languages

  • Hybrid Implementation Systems

Gabungan antara compilation + hybrid system. Lebih cepat dibandingkan dengan pure interpretation

 

Read more

Powered by WordPress. Kredit, Streaming Audio | Theme by TheBuckmaker.