Rabu, 15 Oktober 2014

ASSIGNMENT III

Lecture:Tri Djoko Wahjono,Ir.,M.Sc.(D0206)

Class:LM01

ASSIGNMENT III


REVIEW QUESTION CHAPTER III

11.Q: How is the order of evaluation of attributes determined for the trees of a
given attribute grammar?

A:Semantik statis bahasa hanya secara tidak langsung terkait dengan makna program selama eksekusi; melainkan harus dilakukan dengan bentuk hukum dari program
(sintaks bukan semantik). Banyak aturan semantik statis bahasa menyatakan kendala jenisnya. Semantik statis dinamakan demikian karena analisis yang dibutuhkan untuk
memeriksa spesifikasi ini dapat dilakukan pada waktu kompilasi.
      Semantik dinamis adalah makna ekspresi, pernyataan, dan unit program bahasa pemrograman.

12. Q:What is the primary use of attribute grammars?

A:Atribut tata bahasa utama yang digunakan untuk memberikan deskripsi lengkap sintaks dan semantik statis bahasa pemrograman.

13.Q: Explain the primary uses of a methodology and notation for describing
the semantics of programming languages.

A:Jika pemutusan lingkaran dapat ditampilkan, deskripsi aksiomatik loop disebut total kebenaran. Jika kondisi lain dapat dipenuhi tetapi terminasi tidak
dijamin, hal itu disebut correctnes parsial.

14.Q: Why can machine languages not be used to define statements in operational
semantics?

A:Bahasa mesin tidak dapat digunakan untuk mendefinisikan pernyataan dalam semantik operasional karena beberapa masalah. Pertama, langkah-langkah individu dalam pelaksanaan mesin
bahasa dan perubahan yang dihasilkan pada keadaan mesin terlalu kecil dan terlalu banyak. Kedua, penyimpanan komputer yang nyata terlalu besar dan kompleks.

15. Q:Describe the two levels of uses of operational semantics.

A:Pada tingkat tertinggi, yang menarik adalah di hasil akhir dari pelaksanaan program yang lengkap. Hal ini kadang-kadang disebut semantik operasional alami.
Pada tingkat terendah, semantik operasional dapat digunakan untuk menentukan makna yang tepat dari sebuah program melalui pemeriksaan urutan lengkap negara
perubahan yang terjadi ketika program dijalankan. Penggunaan ini kadang-kadang disebut semantik operasional struktural.

PROBLEM SET CHAPTER III

11. Consider the following grammar:
<S> → <A> a <B> b
<A> → <A> b | b
<B> → a <B> | a

Which of the following sentences are in the language generated by this
grammar?
a. baab
b. bbbab
c. bbaaaaa
d. bbaab

=<S> → <A> <B> <C>
<A> → a <A> | a
<B> → b <B> | b
<C> → c <C> | c

12. Consider the following grammar:
<S> → a <S> c <B> | <A> | b
<A> → c <A> | c
<B> → d | <A>

Which of the following sentences are in the language generated by this
grammar?
a. abcd
b. acccbd
c. acccbcc
d. acd
e. accc

LHS non-terminal S didefinisikan sebagai non-terminal A, terminal, non-terminal B dan terminal b, di mana non-terminal A dapat nol atau lebih b atau satu b, dan di mana non-terminal B dapat menjadi salah satu atau lebih adalah satu atau a;

Menghasilkan satu atau lebih b atau satu b, satu, satu atau lebih atau satu, dan satu b.
Jawaban a (Baab) dan d (bbaab) mematuhi produksi ini.

13. Write a grammar for the language consisting of strings that have n
copies of the letter a followed by the same number of copies of the
letter b, where n > 0. For example, the strings ab, aaaabbbb, and

=<S> -> <A>
<A> -> a <A> b <B>
aaaaaaaabbbbbbbb are in the language but a, abb, ba, and aaabb are not.

14. Draw parse trees for the sentences aabb and aaaabbbb, as derived from
the grammar of Problem 13.

=<stmt> -> <A>
<A> -> A <A> b | ab
pohon untuk aabb
pohon untuk aaaabbbb

15. Convert the BNF of Example 3.1 to EBNF

=<program> -> begin <stmt_list> end

<stmt_list> -> <stmt>

| <stmt> ; <stmt_list>

<stmt> -> <var> = <expression>

<var> -> A | B | C

<expression> -> <var> {(+|-) <var>}

ASSIGNMENT II

Lecture:Tri Djoko Wahjono,Ir.,M.Sc.(D0206)

Class:LM01

REVIEW QUESTION CHAPTER II

11.Q: What control flow statements were added to Fortran IV to get Fortran 77?

A:logical loop statements and IF with an optional ELSE

12.Q: Which version of Fortran was the first to have any sort of dynamic variables?

A:fortran 90

13.Q: Which version of Fortran was the first to have character string handling?

A:fortran 77

14.Q:Why were linguists interested in artificial intelligence in the late 1950s?

A: Linguists were concerned with natural language processing.

15.Q: Where was LISP developed ? By whom?

A:it was developed at MIT by john McCarthy


PROBLEM SET CHAPTER II


11.Q: Was IBM’s assumption, on which it based its decision to develop PL/I, correct, given the history of computers and language developments since 1964?

A:The assumption is correct,because on 70s, PL/I used worldwide for bussiness and science application althought have many failure past years and after years.

12.Q: Describe, in your own words, the concept of orthogonality in programming language design.

A: concept of orthogonality in programming languange to create a new program that teaches the language to be independent of other capabilities and can be combined with a variety of programming language features so that each combination has a meaning and can be used as widely as possible.

13.Q:What is the primary reason why PL/I became more widely used than ALGOL 68?

A:PL/I achieved far greater acceptance than ALGOL 68, due largely to IBM’s promotional efforts and the problems of understanding and implementing ALGO 68.Implementation was a difficult problem for both, but PL/I had the resources of IBM to apply to building a compiler. ALGOL 68 enjoyed no such benefactor.

14.Q:What are the arguments both for and against the idea of a typeless language?

A:In a typeless language, a variable can contain any kind of value (numeric, string, boolean), so it’s more flexible. In the other side it is more prone to make mistakes for the programmer and may resulted ambiguity.

15.Q: Are there any logic programming languages other than Prolog?

A:FORTRAN, LISP and ALGO 60

Minggu, 28 September 2014

ASSIGNMENT I

Lecture:Tri Djoko Wahjono,Ir.,M.Sc.(D0206)

Class:LM01

ASSIGNMENT I

REVIEW QUESTION I


11. Q: What primitive control statement is used to build more complicated control statements in languages that lack them?


A: The selection statement plus GOTO is used to build more complicated control statements such as FOR loop.


12. Q: What construct of programing language provides process abstraction?


A:Subprograms

13. Q: What does it mean for a program to be reliable?


A: program is said to be reliable if it performs to its specifications under all conditions.


14. Q: Why is type checking the parameters of a subprogram important?


A: It can lead to lots of hard to debug errors. One example of how failure to type check, at either compile time or runtime, has led to countless program errors is the use of subprogram parameters in the original C language


15. Q: What is aliasing?

A : aliasing describes a situation in which a data location in memory can be accessed through different symbolic names in the program


PROBLEM SET I


11. Q: Describe some design trade-offs between efficiency and safety in some language you know


A: C today is what assembly language was 10 or 15 years ago. It's the language used when efficiency or low level access to hardware really matters. We can, of course, still use assembly language today. But optimizing C/C++ compilers are so good today, that they can often trump hand coded assembly language.

So, C is very fast, and very good for low level, hardware level access. Java (and other modern, safe languages like C#) are slower than C.

12 Q: In your opinion, what major features would a perfect programming language include?

A:
  • Maintainability
You are either writing code, or you are fixing it. That’s (roughly) the life of a programmer. Now this encompasses several bits. One is simply the ease of writing new code. If your language provides an easy way to write good, solid code the first time then you hopefully minimize the amount of time spent maintaining it. This is typically a balance of verbosity; type systems requiring more code and effort for the tradeoff of maintainability of having the compiler do some low-level sanity checks for you.

  • Performance
But no matter how easy a programming language makes it to write new code and later debug it, none of it is worth anything if the language is too slow. This is when flexibility is sacrificed, which can often mean sacrificing maintainability in terms of how much extra work is required to accomplish the same thing in a slower language. You can statically declare everything in your language as much as you want, but if all you can do is integer math and array usage (e.g. a Turing machine), you are not exactly going to be productive.


13 Q: Was the first high-level programming language you learned implemented with a pure interpreter, a hybrid implementation system, or a compiler? (You may have to research this.)


A:C languange

14 Q:Describe the advantages and disadvantages of some programming environment you have used.

A:

Advantages of C language
  • Speed of the resulting application. C source code can be optimized much more than higher level languages because the language set is relatively small and very efficient.
  • That leads to a second advantage that C has which is its application in Firmware programming (hardware). That is due to its ability to use/work with assembly and communicate directly with controllers, processors and other devices.
  • C programming language is very easier to learn. The main advantages of C language is that there is not much vocabulary to learn, and that the programmer can arrange for the program is very fast.

Disadvantages of C Language:
  • C does not have OOPS feature that's why C++ is developed. If you know any other modern programming language then you already know its disadvantages.
  • There is no runtime checking in C language.
  • There is no strict type checking (for example: we can pass an integer value for the floating data type). 
  • C doesn't have the concept of namespace.
  • C doesn't have the concept of constructors and destructors.

15.Q: How do type declaration statements for simple variables affect the readability of a language, considering that some languages do not require them?

A:
  • for structural languange such as C, variable will be easy to read when recode or when fixing the program,because variable listed on the top of the codes.
  • otherwise for modern programming languange such as php declaration not needed,you can use variable anywhere you need it