1 / 15

Compilers, Interpreters, and Programming Languages

Learn about the fundamentals of programming languages, including the difference between natural and artificial languages, the use of compilers and interpreters, and the importance of platform considerations in client-server computing. Explore examples of Java applets and applications, as well as the distinctions between Java and JavaScript.

nancyyoung
Download Presentation

Compilers, Interpreters, and Programming Languages

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming FundamentalsAnne Marchant, Ph.D.Instructor, CS DepartmentGeorge Mason Universityamarchan@gmu.edu

  2. Lecture 2 Compilers, Interpreters and Programming Languages (Or: How to speak “Computer”)

  3. Natural vs Artificial Languages • We speak natural languages • (such as: Arabic, Chinese, English, German, Spanish, etc). • The computer “speaks” binary (on/off switches that we represent as 0 (off) or 1 (on) called bits-binary digits).

  4. So How do we Communicate? • We don’t want to have to communicate in binary. • Teaching the computer to understand Natural • Language is very difficult and works well only • in constrained applications where vocabulary • and context is restricted.

  5. So How Do We Communicate? • We use intermediary Languages called programming languages that humans can learn and computers can translate. Some Languages: • Assembly • Basic • C/C++ • Java

  6. Translation Tools • Compilers-translates the code into machine instructions (an “executable file”). • Interpreter-no separate executable is created. You must use the interpreter to execute the code.

  7. Platform Considerations • Compilers generally create executables for a specific computer. In other words, you can’t take a program that was compiled under Windows and expect it to work on the Mac or under Unix.

  8. Client-Server Computing Internet Applications need to be platform independent. Two approaches: • Scripts that are interpreted by the browser (such as Javascript) • Compiling the program into an intermediary form (byte code) that is then interpreted by the browser for a specific client.

  9. JavaScript • Code is placed directly into the HTML file between <script> </script> tags.

  10. Java Applets Java applets are compiled into byte code. • The source code will have the extension : .java • The compiled code will have the extension: .class

  11. Java Applets • The applet is invoked by from the web page • (the .html file) with the <applet> tag. • Example: • <applet code="MyWindow.class" width=“300” • height=“300”></applet>

  12. Java Applications • Java applications are used to solve general purpose problems and are run from the operating system with a Java interpreter instead of being run from a web page. • Java applications can be used for all sorts of things: to program devices, create business applications, games, etc.

  13. Java and Javascript Are Different! • While the two languages are related and share some fundamental concepts, Java and Javascript are different languages. • Java is much richer and broader in scope than Javascript.

  14. Java and Javascript Are Different! Which you choose will depend on the application: • To check an HTML form, you might use a simple Javascript. • To write a program to allow users to vote online, you might want to use Java with its built-in security and ability to encrypt information.

  15. Summary Be sure you know these terms: • Compiler • Interpreter • Byte code Understand the difference between: • Javascript • Java Applet • Java Application

More Related