POP-2 facts for kids
POP-2 was an early programming language created around 1970. It was developed by Robin Popplestone and Rod Burstall at the University of Edinburgh in Scotland. POP-2 grew from an earlier language called POP-1 (originally named COWSEL). It took ideas from other languages like LISP and ALGOL 60.
One cool thing about POP-2 was its "incremental compiler." This made it very flexible, almost like an interpreted language. It meant you could create new functions or change existing ones while your program was already running! This was a special feature for its time.
How POP-2 Worked
Using the Stack
POP-2 had a unique way of handling information, using something called an operand stack. Think of a stack like a pile of plates. You can only add a plate to the top, and you can only take a plate from the top.
In most programming languages, you might write: `a := 3;` (meaning "put the number 3 into the variable 'a'")
But in POP-2, you wrote it differently: `3 -> a;`
This was because of the stack. First, you'd put the number 3 onto the stack. Then, `-> a;` would take that number from the top of the stack and put it into the variable 'a'.
You could also call functions using the stack. For example, if you wanted to call a function `f` with values `x`, `y`, and `z`, you could write: `x, y, z; f();` This would put `x`, `y`, and `z` onto the stack, and then the function `f` would use those values.
Functions in POP-2
In POP-2, functions were very important. You could store functions in variables, just like you store numbers or text! This made the language very powerful and flexible.
Here's how you could create a function called `max` that finds the larger of two numbers: `function max x y; if x > y then x else y close end;`
Another interesting feature was "partial application," also known as "currying." This allowed you to "freeze" some of a function's inputs to create a new, simpler function.
Imagine you have a function that calculates `a * x * x + b * x + c`. `function poly2 x a b c; a * x * x + b * x + c end;`
You could then create a new function, say `less1squared`, by freezing some of the inputs for `poly2`: `vars less1squared;` `poly2(% 1, -2, 1%) -> less1squared;`
Now, if you used `less1squared(3)`, it would be like calling `poly2(3, 1, -2, 1)`. This would calculate `1*3*3 + (-2)*3 + 1`, which is 4. It's a clever way to make new functions from existing ones!
A Look at POP-2's History
POP-2 was first created on an Elliott 4130 computer at the University of Edinburgh. This computer had only 64KB of RAM (memory), which was very little compared to today's computers!
Over the years, POP-2 was adapted to work on many different computers. These included the ICT 1900 series, BESM-6, PDP-10, and CTL Modular One.
One important version was called POP-10, created by Julian Davies in Edinburgh. This version allowed for longer names for things in the code and used lowercase letters for many system names.
Later, a new version called WPOP (short for WonderPop) was developed. It added new features like special ways to handle different types of data.
Around 1976, Steve Hardy at Sussex University created a smaller version of POP-2 called POP-11. It was first used for teaching on a DEC PDP-11/40 computer. POP-11 changed some of the original POP-2 commands to make them easier to learn. It also added a "pattern matcher," which made it much simpler to teach artificial intelligence (AI) programming.
In the 1980s, POP-11 was improved to create machine code directly, making it faster. This led to the creation of Poplog, a system that combined POP-11 with other programming languages like Prolog, Common Lisp, and Standard ML. Pop-11 became the most popular version of POP-2 and is still available today in the Poplog system.
Around 1986, a company worked with Sussex University to create AlphaPop. This version ran on Apple Mac computers and included graphics. It was used for both commercial projects and teaching AI.