Homework 1

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

CSC 212 Homework1

Programming Language1

Instructor: Dima Almani


2

Please check the following book to answer the questions:

Programming Language Pragmatics, Third Edition by Michael L. Scott, Morgan Kaufmann


Publishers, 2009

1. PLP, p.66: (27)

What is the difference between static and dynamic semantics?

The basic idea of dynamic semantics is that the meanings of sentences are not propositions but

rather functions that alter the context. They also must be checked at the run time.

Static Semantics: Whether syntactically valid statements have any meaning, and not all semantic

rules can be checked at compile time.

2. PLP, p. 68: (1.8)

(a) What was the first programming language you learned? If you chose it, why did you do so? If it

was chosen for you by others, why do you think they chose it? What parts of the language did you

find the most difficult to learn?

The first programming language I learned is Python, but it’s not my best programming language so

I won’t choose it as my favorite one. I think my favorite programming language is Java. I like it

because it’s easy to work with, and the error detecting is helping me so much when I face an error

in my code. Java was chosen by my university to be learned, and I think they chose it for it’s ease,

flexibility and security. I think the most difficult parts in Java are how to memorize the code with

no errors, and the no experience that I have with the programming in general.

(b) For the language with which you are most familiar (this may or may not be the first one you

learned), list three things you wish had been differently designed. Why do you think they were

designed the way they were? How would you fix them if you had the chance to do it over? Would
3

there be any negative consequences, for example in terms of compiler complexity or program

execution speed?

I don’t have any thing in particular that I wish it had been designed differently, I feel like

everything is on its place and everything looks perfect.

3. PLP, p. 70: (1.13)

Using an Internet search engine or magazine indexing service, read up on the history of Java and

C#, including the conflict between Sun and Microsoft over Java standardization. Some have

claimed that C# is, at least in part, Microsoft’s attempt to kill Java. Defend or refute this claim.

Sun Microsystems and Microsoft have settled their long-running lawsuit over Microsoft's use of

Sun's Java software. Sun scored a victory in this case when the judge ruled that Sun was likely to

win its case based on the merits and issued a preliminary injunction in Sun's favor. The injunction

forced Microsoft to modify the Java technology it had distributed in its operating system, Web

browser, and development tools so that it passed Sun's tests. In my opinion, Microsoft had what

they deserved because they breached the contract between them and Sun Microsystems by trying to

extend Java so it would work differently, and Sun On the other hand did all what they have to do to

defend themselves.

4. PLP, p. 152: (10-11)

10. What is garbage collection?

Garbage collection is a type of memory management. It automatically cleans up unused objects and

pointers in memory, allowing the resources to be used again.

11. What is a dangling reference?

When memory is deallocated, but not all pointers to it are removed, the pointers are called dangling
references -- they point to memory that is no longer valid and which will be reallocated when there
is a new memory request, but the pointers will be used as tho they still pointed to the original
memory.
4

5. Explain the distinction between interpretation and compilation. What are the comparative
advantages and disadvantages of the two approaches?
The difference between an interpreted and a compiled language lies in the result of the process of
interpreting or compiling. An interpreter produces a result from a program, while a compiler
produces a program written in assembly language. ... If the program is complex, pieces of it may be
spread across several files.

6. Is Java compiled or interpreted (or both)? How do you know


Java is a compiled programming language, but rather than compile straight to executable machine
code, it compiles to an intermediate binary form called JVM byte code. The byte code is
then compiled and/or interpreted to run the program.

You might also like