Thursday, September 18, 2014


Information Processing Language


Information Processing Language (IPL) is a programming language created by Allen Newell, Cliff Shaw, and Herbert A. Simon at RAND Corporation and the Carnegie Institute of Technology at about 1956. Newell had the job of language specifier-application programmer, Shaw was the system programmer, and Simon took the job of application programmer-user.

The language includes features intended to help with programs that perform simple problem solving actions such as lists, dynamic memory allocation, data types, recursion, functions as arguments, generators, and cooperative multitasking. IPL invented the concept of list processing, albeit in an assembly-language style.

An IPL computer has:
  1. a set of symbols. All symbols are addresses, and name cells. Unlike symbols in later languages, symbols consist of a character followed by a number, and are written H1, A29, 9-7, 9-100.
    1. Cell names beginning with a letter are regional, and are absolute addresses.
    2. Cell names beginning with "9-" are local, and are meaningful within the context of a single list. One list's 9-1 is independent of another list's 9-1.
    3. Other symbols (e.g., pure numbers) are internal.
  2. a set of cells. Lists are built from several cells holding mutual references. Cells have several fields:
    1. P, a 3-bit field used for an operation code when the cell is used as an instruction, and unused when the cell is data.
    2. Q, a 3-valued field used for indirect reference when the cell is used as an instruction, and unused when the cell is data.
    3. SYMB, a symbol used as the value in the cell.
  3. a set of primitive processes, which would be termed primitive functions in modern languages.
The data structure of IPL is the list, but lists are more intricate structures than in many languages. A list consists of a singly linked sequence of symbols, as might be expected -- plus some description lists, which are subsidiary singly linked lists interpreted as alternating attribute names and values. IPL provides primitives to access and mutate attribute value by name. The description lists are given local names (of the form 9-1). So, a list called L1 holding the symbols S4 and S5, and described by associating value V1 to attribute A1 and V2 to A2, would be stored as follows. 0 indicates the end of a list; the cell names 100, 101, etc. are automatically generated internal symbols whose values are irrelevant. These cells can be scattered throughout memory; only L1, which uses a regional name that must be globally known, needs to reside in a specific place.


Whenever I’m TA for a introductory CS class where students learn some programming language, I have trouble coming up with good exercises. Problems from Project Euler and the like are usually much too difficult for beginners, especially if they don’t have a strong background in mathematics.

This page is a collection of progressively more difficult exercises that are suitable for people who just started learning. It will be extended as I come up with new exercises. Except for the GUI questions, exercises are generally algorithmic and should be solvable without learning any libraries. The difficulty of the exercises of course somewhat depends on the programming language you use. The List exercises for example are more complicated in languages like C that don’t have build-in support for lists.
I suppose they are also useful, although much easier, whenever an experienced person wants to learn a new language.

Click the link below for more samples
http://cs.boisestate.edu/~amit/prog-contest/sample-problems.html


C language elements

Elements of the C Language - Identifiers, Keywords, Data types and Data objects

The C Character Set

C uses the uppercase English alphabets A to Z, the lowercase letters a to z, the digits 0 to 9, and certain special characters as building blocks to form basic program elements viz. constants, variables, operators, expressions and statements.

Identifiers and Keywords

Identifiers are names given to various items in the program, such as variables, functions and arrays. An identifier consists of letters and digits, in any order, except that the first character must be a letter. Both upper and lowercase letters are permitted. Upper and lowercase letters are however not interchangeable (i.e., an uppercase letter is not equivalent to the corresponding lowercase letter). The underscore character (_) can also be included, and it is treated as a letter. Keywords like if, else, int, float, etc., have special meaning and they cannot be used as identifier names.

The following are examples of valid identifier names: A, ab123, velocity, stud_name, circumference, Average, TOTAL

Constants

The constants in C can be classified into four categories namely integer constants, floating point constants, character constants and string constants.

A character constant is written as for example - 'A' (always enclosed in single quotes).

Examples of string constants are - "Jamshedpur", "A", etc. Note that a string constant is always enclosed within double quotes.

A normal integer constant is written as 1234.

A long int is recognized by the presence of L (uppercase or lowercase) at the end of the constant, e.g. 2748723L.

The suffix u or U signifies the int to be an unsigned one.

The UL or ul at the end indicates the int quantity is of unsigned long type

Floating point constants contain a decimal point (167.903) or an exponent (1e-2) or both. Their type is double unless suffixed. The suffix of f or F indicates float; 1 or L indicates long double.

C also supports octal and hexadecimal data. The value of an integer data can be specified in either octal or hexadecimal form. A hexadecimal constant must begin with 0x or 0X, a leading 0 indicates the octal representation. Octal and hexadecimal constants may also be followed by U to indicate unsigned or L to determine long.

click this link for more resources
http://www.how2lab.com/programming/c/data-types.php#.VBudlqFR65c


Posted on Thursday, September 18, 2014 by Unknown

No comments


Perspective of programming languages

Almost thirty years ago, a noted computer scientist (1) remarked that it was unfortunate that real computers had to be us ed in teaching computer science. Although many in the audience may have viewed this as a rather radical position at the time, it has proven to be an insightful commentary on many of our efforts to design and deliver courses in the discipline. In fact, the premise probably should be broadened to include software as well as hardware. Actual computing systems, hardware as well as software, often swamp the learner in a sea of minutia in which basic concepts are at least obscured if not completely lost.

While there are difficulties in using real system s in courses at all levels, it appears that some of the greatest problems ma y be found at the introductory level. In particular, achieving consensus in the choice of a programming language (or none at all!) for CS1 has proven to be elusive. With Curriculum 2001 now in the works, it is particularly timely that experience with this course be reviewed.

Language Processor

By a language processor, we mean a program that processes programs written in a programming language (source language). All or part of a language processor is a language translator, which translates the program from the source language into machine code, assembly language, or some other language. The machine code can be for an actual computer or for a virtual (hypothetical) computer. If it is for a virtual computer, then a simulator for the virtual computer is needed in order to execute the translated program.
If a language processor is a translator that produces machine or assembly code as output (in object code or executable code) then it is called a compiler. If the language processor executes the translated program (output from the translator) then it is called an interpreter.

In a typical programming language implementation, source program components (files or modules) are first translated into machine language to produce components called object modules or object files. Following the translation step, a linkage editor (or linker) combines multiple object components for a program with components from libraries to produce an executable program. This can occur either as an intermediate step, or in some cases it may occur as the program executes, loading each component as it is needed. The execution of a program may be done by an actual computer or by a simulator for a virtual computer.

Program components in languages such as C are normally compiled into object files, which are combined into an executable file by a linkage editor or linking loader. The linkage editor adjusts addresses as needed when it combines the object modules, and it also puts in the addresses where a module references a location in another module (such as for a function call). If an executable file is produced, then there will also be a loader program that loads an executable file into memory so that it can execute. The loader may also do some final adjustments on addresses to correspond to the actual locations in memory where the executing program will reside.

Data-Level Structure

In computer science, a data structure is a particular way of organizing data in a computer so that it can be used efficiently.


Different kinds of data structures are suited to different kinds of applications, and some are highly specialized to specific tasks. For example, B-trees are particularly well-suited for implementation of databases, while compiler implementations usually use hash tables to look up identifiers.

Data structures provide a means to manage large amounts of data efficiently, such as large databases and internet indexing services. Usually, efficient data structures are a key in designing efficient algorithms. Some formal design methods and programming languages emphasize data structures, rather than algorithms, as the key organizing factor in software design. Storing and retrieving can be carried out on data stored in both main memory and in secondary memory.

Program-level Structure

Structured programming is a programming paradigm aimed at improving the clarity, quality, and development time of a computer program by making extensive use of subroutines, block structures and for and while loops—in contrast to using simple tests and jumps such as the goto statement which could lead to "spaghetti code" which is difficult both to follow and to maintain.

It is possible to do structured programming in any programming language, though it is preferable to use something like a procedural programming language. Some of the languages initially used for structured programming languages include: ALGOL, Pascal, PL/I and Ada – but most new procedural programming languages since that time have included features to encourage structured programming, and sometimes deliberately left out features – notably GOTO – in an effort to make unstructured programming more difficult.

Control-level Structure

Programs written in procedural languages, the most common kind, are like recipes, having lists of ingredients and step-by-step instructions for using them. The three basic control structures in virtually every procedural language are:
  • 1. Sequence—combine the liquid ingredients, and next add the dry ones.
  • 2. Conditional—if the tomatoes are fresh then simmer them, but if canned, skip this step.
  • 3. Iterative—beat the egg whites until they form soft peaks.

Following the structured program theorem, all programs are seen as composed of three control structures:
  • "Sequence"; ordered statements or subroutines executed in sequence.
  • "Selection"; one or a number of statements is executed depending on the state of the program. This is usually expressed with keywords such as if..then..else..endif.
  • "Iteration"; a statement or block is executed until the program reaches a certain state, or operations have been applied to every element of a collection. This is usually expressed with keywords such as while, repeat, for or do..until. Often it is recommended that each loop should only have one entry point (and in the original structural programming, also only one exit point, and a few languages enforce this).

Subroutines

Subroutines; callable units such as procedures, functions, methods, or subprograms are used to allow a sequence to be referred to by a single statement.

Blocks

Blocks are used to enable groups of statements to be treated as if they were one statement. Block-structured languages have a syntax for enclosing structures in some formal way, such as an if-statement bracketed by if..fi as in ALGOL 68, or a code section bracketed by BEGIN..END, as in PL/I, whitespace indentation as in Python - or the curly braces {...} of C and many later languages.

Posted on Thursday, September 18, 2014 by Unknown

1 comment