Google
 
Site navigation: [ Home | Theory | Java | Moodle courses | Resource wiki | About ]

Language Translators

Languages, architecture, systems. networks, data representation, errors and utility programs

 

Key fact: Everything inside the computer hardware is expressed in binary machine code, everything.

 

 

 

 

 

 

 

 

Semantic and logical errors are the same thing.

 

 

 

 

 

 

 

 

 

 

 

As an SL candidate this is more than you really need to know.

It's hard to discuss the function of an HLL translator without this context, however.

 

 

 

 

 

 



 

 

 

 

 

 

 

 

 

 

 

 



 

On this page: [ Syntax and Semantics | HLL Translators | Software development tools ]

Syntax and Semantics

High-level language features are only important to the programmer , the user doesn't care which language is used as long as the product is user-friendly.

Programmers usually write programs which are not commercially available, many users can get by with the common applications packages like word processors, databases, spreadsheets, etc.

We should be able to distinguish syntax (the rules which govern the construction of a language) from semantics (the meaning of a language - which is not always literal). Thus

             "You are so right!"

could be a political message as well as an expression of agreement depending upon the context.

When we talk about the semantics of an HLL we refer to the meaning which we attach to program statements (ie what do they do ).

The syntax of a high level language program has to be correct, otherwise the program which is supposed to translate it into binary machine code (compiler or interpreter) will refuse to do so (you'll soon discover this for yourself).

Sometimes programmers get confused about what exactly they are trying to achieve and use a ( logically ) incorrect statement that is syntactically correct . This program can be executed by the computer but results in a logic or semantic error.

A programming language, eg Java , is used to construct programs or applications. Internally, as we shall see, the language is translated into binary machine code that the computer works with.

Languages like Java are designed for the convenience of programmers .

Back to top

What are computer languages?

The hardware refers to the electronic circuitry and other physical components that carry out instructions . This process is automated by the CPU - a complex piece of hardware that is nevertheless just a machine.

Software refers to the programs and data that it operates on. These are supplied by humans. There are two main types of computer language for writing computer programs:

  • Low-level language
  • High-level language

The hardware runs only in machine code , usually represented (by us) as the 1's and 0's of binary code. The electrical circuits and magnetic storage devices which make up the computer can only recognise two states. Inside the hardware a computer program may look like this:

        0001010011100110
         0001001100001111
         1010001110101100
         1001010000111011

Binary machine code is tedious for humans to work with and they tend to make lots of mistakes when trying to do so.

The first step for computer engineers was to make codes (or mnemonics)which could stand for binary instructions thus ADD might correspond to the code for adding two numbers together, LDA might correspond to the for code fetching a number from memory (LoaDing the Accumulator). Thus a low level language might express the above as:

        LDA 2309
         ADD 2310
         MLT #002
         STO 2325

This language is also known as Assembly Language and there is a one-to-one correspondence with machine code. Of course, this is still not very easy to handle so the next step was the development of High Level Languages (HLL's).

Back to top

Nature and Function of HLL's

One HLL statement usually translates into many machine code statements, you might see something like:

        FOR X = 1 to 23 DO
           Y = X * 2
           PRINT (X, Y)
        NEXT

Which, believe it or not, is easier to understand when you are trying to develop computer software (programs). Some features of HLL's are:

. They are portable, ie can be run on different machines rather than machine-specific like assembly language.
. They are English-like, more easy to understand.
. Different languages have been developed for different tasks.

Examples of HLL's

There are said to be 2000 different high level computer languages so these are just a few examples from the mainstream:

Early HLL's were FORTRAN (FORmula TRANslation language) which was intended for mathematical and scientific programming and COBOL (COmmon Business-Oriented Language) for developing business and data-processing applications.

ALGOL (ALGOrithmic Language) was an early (1950's) attempt to introduce the concept of structured programming and eventually led to the development of C and so on to Pascal which are highly-structured block languages. The structure is (supposed to be) used by programmers to make the workings of the program clear to other programmers who may have to work in the same team or do maintenance.

BASIC (Beginners All-purpose Symbolic Instruction Code) was introduced for microcomputers and, although poorly structured and often misused, gave many, many people an easy initial introduction to computer programming.

Some other notable languages are: FORTH , LISP and Prolog . All of these languages are available (or have been at some time) in versions for microcomputers.

More recently Object Orientated Languages , notably SMALLTALK , C++ and Java have taken the concepts of structured programming one stage further (but you'll learn about this in another part of the course).

Only Higher Level students need to know the concepts associated with Object Oriented programming.

The next wave may well be scripting languages such as PHP , Python and Javascript.

Back to top

Comparison of Compilers and Interpreters

Compilers and interpreters are two types of program that translate High Level languages into binary machine code . Different programs operate in different ways - many compilers produce an assembly language stage.

With the advent of Java as a cross-platform language the following distinctions become a little blurred. Your Java source code files are compiled (by the javac program) not to machine code for a specific platform but to an intermediate stage known as bytecodes .

These bytecodes are then fed to an interpreter (the Java Virtual Machine) of which there are different versions for different types of computer.

In the simpler world, Compilers and Interpreters take High Level language source codes and produce binary machine code for a specific platform.

Compiler

Interpreter

1

Produces a complete machine code program which can be stored on disc, loaded and run. Translates an HLL line by line without saving any object code

2

Needs a complete HLL program Starts at the beginning and continues to end or first error

3

Gives an error listing of all errors in the program Stops at the first error.

4

More complex program Simpler, needs less memory, frequently used in older microcomputers.

5

Machine code product can be run on any machine without a compiler. Interpreter needs to be in memory when the program is run

Back to top

Software Development Tools

In this section: [ DBMS | macros | CASE | HTML/Web page editors ]
                  
[ code specification editor | visual IDE ]

DBMS
In a typical high-level language application, the programmer defines files to hold data such as personnel or medical records. As a company expands, new requirements and new data on employees may be required and the original files modified. It can easily happen that the same data is kept in different files and in different formats .

A DBMS ( Database Management System ) provides an interface which makes data access simple for both users and system developers. It provides the following key functions:

. "Hiding" the internal structure of the data from the users
. Managing a data dictionary (contains detailed information about database structure, access rights and relationships between data items)
. Managing database safety and security (scheduling backups, controlling access rights and sharing violations)

top of section

MACROS
Many integrated applications packages (Office Software like Office 2000, Corel Office or Star Office) also offer ways to automate common tasks. These usually use some form of high level language (such as MS VBA - Visual Basic for Applications or ObjectPAL in Corel Paradox). Typically these work via a "macro recorder" which allows you to record sequences of keystrokes for later playback .

As an example consider a paragraph in MS Word that contains several sentences which you want to split into a list. You could record the following keystrokes using Tools|Macro |Record New Macro...

      Use Edit|Find to locate the first full stop (period)
       Hit the return key
       Select Stop recording

You can then assign the macro to a shortcut key (Alt-Ctrl-S, say) and quickly separate the required lines.

top of section

CASE
Computer Aided Software Engineering . Software Engineering covers all of the activities in the Systems Life Cycle from initial problem analysis to final testing . There are a number of standard techniques which can be applied at each stage (eg data flow diagrams, condition-action tables, state transition diagrams) some of which you will learn about in other parts of the course.

Because these are standard techniques they can be implemented in a software package.

top of section

HTML Editors and Web page editors
In order to develop successful computer applications (software) it is not always necessary (or desirable) to use High Level languages such as those described above. Many information systems can be built with software development tools .

HTML (HyperText Markup Language) was developed as a way of exchanging documents between different computer systems. Commands or <tags> inserted into the original (source) documents are used to show special features.

For example the a heading can have a tag <H3> at the beginning and another <\H3> at the end to show that it is a level 3 heading. Other tags determine font styles , colours , sizes:

    Other tags determine font <strong>styles</strong>,
     <font color="#FE072D"> <strong>colours</strong></font>, <font size="+1">      sizes:</font>

The computer program that interprets these tags is called a browser - you are probably using Internet Explorer, Mozilla Firefox or Safari if you are a Mac user.

However, there are other browsers for other systems and the way the tags are interpreted will vary from browser to browser. Some systems can only show text or limited graphics so the common language HTML can only "suggest" what the browser/hardware should do. The people who compose HTML documents do not have total control over their appearance.

For those interested a pretty substantial list is given on this site.

Here is an excellent page for html and JavaScript tutorials .

Some HTML tools are editors - these work directly with the code; a good free example is FirstPage from Evrsoft. [screenshot, opens in new window].

Other tools like FrontPage or Dreamweaver are webpage editors which use high level tools to set things like font size and colour - using these tools you may never need to see the html tags at all. [FrontPage screenshot, opens in new window].

Some allow both like DreamWeaver. [screenshot of Dreamweaver, opens in new window]

Search engines
There are just as many search engines as browsers. The job of a search engine is to retrieve hyperlinks to pages that you want. The problem, as ever, is specifying what you want. There is an excellent page on this subject at:

http://webquest.sdsu.edu/searching/fournets.htm

which features the Google search engine - one of the most popular, of course. For a full list of search engines and their features try:

http://www.searchengineshowdown.com/features/

New search engines on the market have special requirements but can be useful for generic searches. The best of these at the time of writing is probably kartoo which requires Flash.

http://www.kartoo.com/

Back to top of page                      Back to top of section

Code Editors
Code editors are designed to make the writing of program code easier. They often feature:

syntax highlighting - to help you spot syntax errors . Keywords are in a different colour for example. Also quoted strings are also coloured differently which makes it easier to spot when they haven't been terminated properly. Many of the screenshots above illustrate this feature (see, FirstPage for example).

automatic indenting - this helps you get a smart layout and keep it after you have edited bits in or out. It's a pain to keep typing spaces by hand.

auto-completion - common keywords or groups of them can be completed automatically by some code editors. If it's a library method , the editor may be able to remind you of the required parameters .

This is in addition to the normal features you would expect of any editor - cut, copy, paste, find, replace etc.

top of section

Visual IDE's

An IDE is an Integrated Development Environment which usually includes all the tools you need to develop applications such as:

  • A code editor (with syntax highlighting)
  • A compiler for the target platform
  • A debugger
  • A set of library routines
  • A GUI editor (for some languages)

An excellent example of such an editor for java is the NetBeans IDE (http://www.netbeans.org ) which is free. However, it is very demanding of resources (needs a lot of memory and disc space) and pretty hard for beginning programmers.

[ screenshots of NetBeans, opens in new window ]

An IDE helps the programmer by helping them to organise their code and to spot syntax errors quickly (using the syntax highlighting ).

The debugger can be used to step through the code line by line and watch various identifier values change.

Programmers can add their own specialist routines to the library which speeds up development of projects.

BlueJ from http://www.bluej.org includes most of these features (not the GUI editor) and is also free but considerably easier to use and much less resource-hungry.

You can see brief screenshots on the getting started with Java page.

Back to top top of section

related: [ Common core home | next: data represenation ]

Topic 3.1





 
The site is partly financed by advertising revenue, partly by online teaching activities and partly by donations. If you or your organisation feel these resouces have been useful to you, please consider a donation, $9.95 is suggested. Please report any issues with the site, such as broken links, via the feedback page, thanks.

Questions or problems related to this web site should be addressed to Richard Jones who asserts his right to be identified as the author and owner of these materials - unless otherwise indicated. Please feel free to use the material presented here and to create links to it for non-commercial purposes; an acknowledgement of the source is required by the Creative Commons licence. Use of materials from this site is conditional upon your having read the additional terms of use on the about page and the Creative Commons Licence. View privacy policy.

Creative Commons License


This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License. © 2001 - 2009 Richard Jones, PO BOX 246, Cambridge, New Zealand;
This page was last modified: May 31, 2009