- 浏览: 53862 次
- 性别:
- 来自: 上海
最新评论
-
iseesea:
如果有图片就好了·
我只有自己google
~一下了
进入Linux桌面时代! -
jamesqiu:
vala:C#的语法,c和glib的效率和跨平台性
对.NET,Java,D,Lua语言的一点评价 -
RyanPoy:
不知道开源否?
最近正在重写我自己的数据库框架 -
ddandyy:
如果真的是工作用的 就要勇于花钱
连这点钱都舍不得花 还做 ...
Freeware List -
danielking:
不管怎么说Visual Studio还是相当好用的, 我现在基 ...
Freeware List
Logo (programming language)
From Wikipedia, the free encyclopedia
functional , educational |
1967 |
Wally Feurzeig & Seymour Papert |
Wally Feurzeig & Seymour Papert |
Dynamic |
UCBLogo , many others |
Lisp |
Smalltalk , Etoys , Scratch |
Logo is a computer programming language used for functional programming . It is an easier-to-read adaptation and dialect of the Lisp language; some have called it Lisp without the parentheses . Today, it is known mainly for its turtle graphics , but it also has significant facilities for handling lists, files, I/O, and recursion .
Logo was created for educational use, more so for constructivist teaching , by Daniel G. Bobrow , Wally Feurzeig and Seymour Papert . It can be used to teach most computer science concepts, as UC Berkeley Lecturer Brian Harvey does in his Computer Science Logo Style trilogy.
Contents[hide ] |
<script type="text/javascript"><!----></script>
[edit ] History
Logo was created in 1967 at Bolt, Beranek and Newman (BBN), a Cambridge, Massachusetts research firm, by Wally Feurzeig and Seymour Papert [1] . Its intellectual roots are in artificial intelligence , mathematical logic and developmental psychology . The first four years of Logo research, development and teaching work was done at BBN. The first implementation of Logo, called Ghost, was written in LISP on an SDS 950 . The goal was to create a math land where kids could play with words and sentences. Modeled on LISP, the design goals of Logo included accessible power[clarify ] and informative error messages. The use of virtual Turtles allowed for immediate visual feedback and debugging.
The first working turtle robot was created at MIT in 1969. A display turtle preceded the physical floor turtle. Modern Logo has not changed too much from the basic concepts before the first turtle. The first turtle was a tethered floor roamer, not radio-controlled or wireless . Later, BBN developed a turtle named Irving that had touch sensors and could move forwards, backwards, rotate, and ding its bell. The earliest year-long school users of Logo were in 1968-69 at Muzzey Jr High, Lexington MA . The virtual and physical turtles were first used by fifth graders at the Bridge School in Lexington, MA in 1970-71.
[edit ] Implementations
As of July 2008 there were 187 implementations and dialects of Logo , each with its own strengths. Most of those 187 are no longer in wide use, but many are still under active development.
As yet there is no single agreed-upon Logo language definition or standard, though there is a broad consensus on core aspects of the language. There are substantial differences between the many dialects of Logo. The situation is confused by the regular appearance of turtle graphics programs that mistakenly call themselves Logo.
The most broadly used and prevalent early implementation of Logo was Apple Logo, which was developed by LCSI for the Apple II computer and popular during the 1980s.
The closest thing to a de facto Logo standard today is UCBLogo , also known as Berkeley Logo. It is free and cross-platform. UCBLogo has only a rudimentary graphical user interface, so several projects exist that provide a better interface. MSWLogo, and its successor FMSLogo , for Windows, are commonly used in schools in the United Kingdom and Australia . Commercial Logos that are still widely used in schools include MicroWorlds Logo and Imagine Logo .
Some modern derivatives of Logo allow thousands of independently moving turtles. There are two popular implementations: MIT 's StarLogo and CCL 's NetLogo . They allow for the exploration of emergent phenomena and come with many experiments in social studies, biology, physics, and other areas.
Most Logos are 2D, but the Elica interpreter is notable for supporting 3D graphics. Most Logo implementations are interpreted, but some compilers have been built, including the Lhogho compiler, by the same author as Elica. Although most often used for graphics, Logo can also control robots. It was interfaced with Lego bricks , although Lego decided later to use another language in the commercial Lego Mindstorms products. The Mindstorms GUI interface is based on LabVIEW by National Instruments . An interface also exists for Cricket robots .
ObjectLOGO is a variant with object-oriented extensions.
[edit ] Influence
Logo was a primary influence on the Smalltalk programming language. It is also the main influence on the Etoys educational programming environment and language, which is essentially a Logo written in Squeak (a variant of Smalltalk ).
[edit ] Programming
Logo's best-known feature is the turtle, which is an on-screen cursor (derived originally from a robot of the same name), which can be given movement and drawing instructions, and is used to programmatically produce line graphics. It is traditionally and most often represented pictorially either as a triangle or a turtle icon (though it can be represented by any icon). Turtle graphics were added to the Logo language by Seymour Papert in the late 1960s to support Papert's version of the turtle robot , a simple robot controlled from the user's workstation that is designed to carry out the drawing functions assigned to it using a small retractable pen set into or attached to the robot's body.
As a practical matter, the use of turtle geometry instead of a more traditional model mimics the actual movement logic of the turtle robot. Turtle geometry works somewhat differently from (x,y) addressed Cartesian geometry , rather operating in a Euclidean space (i.e., relative measures and angles without an origin, unlike coordinate-addressed systems such as PostScript ). The turtle moves with commands that are relative to its own position, LEFT 90 meant rotate left by 90 degrees. A student could understand (and predict and reason about) the turtle's motion by imagining what they would do if they were the turtle. Papert called this body-syntonic reasoning. Some Logo implementations, particularly those that allow the use of concurrency and multiple turtles, support collision detection and allow the user to redefine the appearance of the turtle cursor, essentially allowing the Logo turtles to function as sprites .
Turtle geometry is also sometimes used in environments other than Logo as an alternative to a strictly coordinate-addressed graphics system. For instance, the idea of turtle graphics is also useful in Lindenmayer system for generating fractals .
[edit ] Syntax
Commands may be written on one line, or more. Many commands have mnemonic short forms; for example FORWARD
and RIGHT
are coded FD
and RT
respectively. This makes the input less onerous. Anything written after
the ; (semicolon) is ignored, allowing the coder to insert comments.
FORWARD 100 ; draws a square with sides 100 units long LEFT 90 FORWARD 100 LEFT 90 FORWARD 100 LEFT 90 FORWARD 100 LEFT 90
FD 100 RT 120 FD 100 RT 120 ; draws a triangle FD 100 RT 120
The Hello World program in Logo looks like this:
print [Hello World]
Loading a file will include all its defined procedures into the currently open file. If the file being opened has commands that are not in a defined procedure they will be run on startup and will be removed from the workspace (except for variable assignments), so if the file is then saved it becomes blank. For example, one could have a helloworld.lgo which prints Hello World and becomes blank when EDALL is called:
print [Hello World]
Alternatively, one could put the command in a procedure that is run when the program is loaded.
to main print [Hello World!] end make "startup [main]
[edit ] The pen
The analogy of a turtle with a pen attached to its tail is often used. The turtle's pen can be lifted and lowered, thus drawing a rudimentary dotted line.
FD 20 ; drawing a line and moving PENUP ; lifting the pen so it won't draw anything FD 20 ; not drawing but moving PENDOWN ; lowering the pen so it draws again FD 20 ; drawing a line and moving PENUP ;lifting the pen so it won't draw anything FD 40 ; not drawing but moving PENDOWN ;lowering the pen so it draws again RT 20 ;drawing a line and moving
[edit ] Loops
There are three loop (repeat) commands; REPEAT is one. This draws the a box.
REPEAT 4 [FD 100 LEFT 90]
The command FD 100 LEFT 90
is executed four times. An approximation of a circle can be constructed easily with 360 small rotations and a step forward: REPEAT 360 [FD 1 RIGHT 1]
. Loops may be embedded, giving spectacular results with little effort.
REPEAT 36[ RT 10 REPEAT 360 [FD 1 RT 1]] FD 25 RT 90
[edit ] Defining procedures, the need for an editor
Procedures can be defined on the command line, using the TO END pair:
TO CHAIR REPEAT 4 [FD 100 RT 90] FD 200 END
However, in some early Logos the procedure is limited to the physical line length of the input device.
All Logos can invoke an Editor, usually by EDALL . In the editor, procedures may be written over many lines, as nothing is interpreted until the edit is complete.
EDALL TO CHAIR REPEAT 4 [FD 100 RT 90] FD 200 END
The new word is saved into the available vocabulary, but the
definition will be lost once the Logo session is over. Internally
procedures are words and in this case, any time CHAIR
is entered, the sequence REPEAT 4 [FD 100 LEFT 90] FD 200
will be executed. The word CHAIR
can be used as a command; for example, REPEAT 4 [CHAIR]
would repeat the CHAIR
operation four times.
[edit ] Animation
Logo was designed in spirit of low threshold and no ceiling, which enables easy entry by novices and yet meet the needs of high-powered users. Animations require both the ability to draw shapes and to erase shapes. The process is the same, except that in the former a line is deposited on the display device and in the latter a line is removed. Using the turtle analogy, the turtle's pen must paint, and the turtle's pen must erase.
In UCBLogo, the turtle can be set to erase using the command PENERASE
(PE
). Now any future FD movements will erase anything beneath them. The pen can be restored with the command PENPAINT
(PPT
).
EDALL
;(to enter the editor mode, then the actual procedure)TO ERASECHAIR PE BK 200 REPEAT 4 [FD 100 RT 90] PPT END
CS CHAIR WAIT 200 ERASECHAIR
A WAIT delay between the drawing and the erasing introduces the illusion of motion.
CS REPEAT 20 [CHAIR WAIT 200 ERASECHAIR FD 20]
Logo can pass extra information to its words, and return
information. The procedure, (word) is instructed to expect something
and give that something a name. The colon is used for this purpose. It
passes the information by value
and the colon is pronounced as the value of
. When the procedure is run with a command such as CHAIR 200
, the word :thesize
takes the value 200 so when FD :thesize
is executed, the interpreter understands FD, the value of 200
.
EDALL
;(to enter the editor mode, then the actual procedure)
TO CHAIR :thesize
REPEAT 4 [FD :thesize RT 90] FD :thesize FD :thesize
END
CS REPEAT 9 [CHAIR 50 RT 20 CHAIR 100 WAIT 50 RT 20]
[edit ] The language
Logo is generally known as an interpreted language, although recently there have been developed compiled Logo dialects—such as Lhogho or Liogo. Logo is not case-sensitive but retains the case used for formatting. It is a compromise between a sequential programming language with block structures, and a functional programming language. There is no standard LOGO, but UCBLogo is highly regarded. It is a teaching language but its list handling facilities make it remarkably useful for producing useful scripts.
[edit ] Functions and procedures
Each line is made up of function calls, or subroutines in programming terminology, of which there are two types:
- commands (which do something—effects—but don't return a value) like
print
. - operations (which just return a value, its output) like
sum
,first
orreadlist
.
A command is similar to a Pascal
procedure, and an operation is similar to a Pascal function. (See also: command-query separation
, where a query is an operation in Logo). A special subset of operations, called predicates
, which just output the word true
or false
, are conventionally written with a final p
. Examples include emptyp
, wordp
, and listp
.
- Expressions can be primitives, or can be defined by the user.
- Expressions can take zero, one or more parameters.
Mathematics in Logo uses prefix notation, like: sum :x :y, product :x :y, difference :x :y, quotient :x :y
. Infix is also available.
help "keyword ;(will bring up a full description of the expression).
Logo allows for recursion , the process where a procedure calls itself.
to spiral :size if :size > 30 [stop] ; an exit condition fd :size rt 15 ; many lines of action spiral :size *1.02 ; the tailend recursive call end
spiral 10
[edit ] Data
There are three datatypes in UCBLogo,
- the word,
- the list,
- the array.
A number is a special case of word.
There is no static typing. The interpreter detects the datatype by context.
There are two important symbols
- The colon
:
- this means the contents of .
This is an extremely useful symbol that keeps reminding students that a variable is really some 'place' in memory.
- The quote- this means '"the word is evaluated as itself"', or '"its value after evaluation is the same as it was before"'. This is important.
A number is a special case of self evaluation—it really could be written with a quote 2 is really "2
Variable assignment
(eg. x := y + 3
) is handled in Logo with the make
command:
make "x sum :y 3
or
make "x sum :y "3
make
takes 2 parameters, the second of which here is sum :y "3
. sum
takes two 'parameters' and is an 'operation', thus the calculation is possible. "3
evaluates to 3
, and :y
takes the contents of the thing called y
, these are summed giving a number.
The effect of make
is to place the result into the first parameter. From a programmatical perspective, the first argument to make
is passed by reference, while the second is passed by value.
[edit ] Scoping
Variables don't have to be declared before use; their scope is then global. A variable may be declared local
, then its scope is limited to that procedure and any procedures that it calls (a.k.a. dynamic scope
).
Calling a procedure with inputs (the name usually used for arguments in
the Logo literature) also creates local variables that hold the
argument values.
[edit ] Lists
Logo inherits lists from Lisp , and they are its primary method of storing vectors. Arrays are also provided.
- Operators exist to convert words into lists, and lists into arrays and back again.
- This data type has the advantage over arrays that it is infinitely expandable. Data are extracted using the operations first, butfirst, last, butlast, butmember, member and item. Data elements are added using sentence fput and lput.
- A list can be considered to be a queue with the operators queue and dequeue, or a stack with the operations push and pop.
- Recursion rather than iteration is the natural method to process lists.
[edit ] Control structure commands
Logo provides several common control structures.
- ifelse test [ do_if_true list ] [do_if_false list]
There are iteration commands
- while condition [instruction list]
- until condition [instruction list ]
- repeat number [instruction list]
Recursion is Logo's preferred processing paradigm.
[edit ] Template iteration
Logo also provides list-based control structures. The basic idea is of two lists:
OPERATION [ a list of commands ] [ many data items ]
each of the commands is applied in turn to each of the data items. There are several of these template commands with names like MAP, APPLY, FILTER, FOREACH, REDUCE and CASCADE. They represent four flavours of template iteration, known as explicit-slot, named-procedure, named-slot (or Lambda), and procedure-text.
[edit ] Property lists
A property list is a special list where the odd number items are property names, and the even are property values. There are three commands to process property list.
pprop :listname :name :value ;to add a new pair to the list remprop :listname :name :value ;to remove a pair to the list show gprop :listname :name ;to get the matching value from the list
[edit ] I/O Commands
Text may be written to the command window (output stream) using print, show
and to the graphics window using label
The standard commands are readlist readword readchar
with the normal input stream being the keyboard. In Unix tradition the
input stream can be changed, so input can come from a disk file.
Similarly, output can be redirected.
[edit ] Graphics
Turtle graphics is a powerful method of introducing thinking but LOGO also has a few useful Cartesian commands
home ;returns the turtle to (0,0) setx xx sety yy ; sends the turtle, still drawing to (xx,yy) seth nn ; sets the turtle on a heading or compass bearing of (nn)
[edit ] MSWLogo extensions
MSWLogo supports multiple turtles, and 3D Graphics. MSWLogo allows input from COM ports and LPT ports and also hardware ports. MSWLogo also supports a windows interface thus I/O is available through this GUI- and keyboard and mouse events can trigger interrupts.
Simple GIF animations may also be produced on MSWlogo version 6.5 with the gifsave command.
[edit ] See also
- Lego Logo , which uses Logo to control Lego bricks
[edit ] Further reading
- Computer Science Logo Style , Brian Harvey, MIT Press (3 volumes) ISBN 0-262-58148-5 , ISBN 0-262-58149-3 , ISBN 0-262-58150-7 . Available online
- Practical logo for the Atari ST (Paperback) , Martin Sims, Glentop ISBN 1851810307 ,ISBN 978-1851810307 . Available online
- How to Think Like a Computer Scientist: Logo Version (Paperback) , Allen Downey & Guido Gay, Lulu .
- The Great Logo Adventure , Jim Muller, Doone Publications ISBN 0-9651934-6-2 (Now out of print but downloadable free of charge in pdf form from The MSWLogo website - from where you can also download the freeware MSWLogo program)
- To Artifical Intelligence (1976) Early AI textbook where Logo is used extensively. (Using the Edinburgh University dialect, AI2LOGO)
- Turtle Geometry Abelson and diSessa
- Children Designers , Idit Harel Caperton, Ablex Publishing Corporation ISBN 0-89391-8788 -5. Available online
[edit ] External links
- papert , an online implementation of Logo using HTML canvas and Javascript
- ACSLogo for Mac OS X
- Berkeley Logo (UCBLogo)
- Elica a 3D Logo
- FMSLogo
- Gary Stager's Logo Resources
- Lhogho a Logo compiler for Linux and Windows
- Logo Computer Systems, Inc. maker of Microworlds, a commercial Logo
- Logo (programming language) at the Open Directory Project
- MSWLogo
- Wiki history of Logo covering the very early days
- XLogo a Logo programming interpreter under GPL Licence. (Support Linux , Windows , Mac ...)
相关推荐
《LOGO语言竞赛教程》是针对学生群体,特别是青少年计算机爱好者编写的教学材料。教程旨在培养学生的计算机程序设计能力和逻辑思维,同时也介绍LOGO语言的基础知识和编程实例。 首先,教程强调计算机技术在当代社会...
LOGO语言教程全集是一份全面介绍LOGO编程语言的学习资料,特别适合初学者,尤其是儿童和学生群体。LOGO语言,全称为“Logo”,是由Wally Feurzig和Seymour Papert在1960年代开发的一种简单易学的编程语言。它的设计...
LOGO语言,全称为“Logo”,是一种以图形绘制和编程教育为主的编程语言,最初由Wally Feurzig和 Seymour Papert在20世纪60年代为儿童设计。它以其简单的命令集和图形化输出而闻名,是计算机科学教育领域的重要工具,...
Logo语言是一种早期的编程语言,特别适合初学者和儿童学习编程思维。它的设计目标是简单易用,通过图形化的方式让编程变得直观和有趣。"Flash版Logo语言997"是一个基于Flash平台的Logo语言实现,允许在Windows 64位...
LOGO语言,全称为“Logo”,是一种以图形编程为主的教育性编程语言,旨在帮助初学者理解计算机编程的基本概念。它的设计目标是使儿童能够通过简单的命令控制计算机,从而实现图形化编程,绘制出各种复杂的几何图形。...
《Flash版LOGO语言 v9.0:启蒙编程教育的新里程》 LOGO语言,源自1960年代,是一种为了教育目的而设计的简单编程语言。它以其易学性和图形化输出闻名,尤其适合初学者,特别是小学生,用于学习编程基础。Flash版...
LOGO语言,全称为“Logo”,是一种以图形化编程为主的教育编程语言,旨在帮助初学者,尤其是儿童,理解和掌握计算机编程的基本概念。LOGO的设计理念是通过简单的指令控制虚拟turtle(海龟)在画布上移动,绘制出复杂...
LOGO语言又称作海龟语言,由操作者通过一行命令来控制一个三角形的海龟移动,海龟的移动轨迹可以形成各种图案。 用一行语句操纵海龟完成下边显示的图形。最外围一个实心圆,圆里面有一个实心正五角星,五角星的最...
LOGO语言Flash版具备Pc-Logo语言的常用操作命令、画图命令、数学函数/字表运算等命令、文件加载保存命令、结构化语言特点等,添加了logo模块窗口,让学生能够喜欢上logo语言,快来下载体验吧。 软件功能 Flash版Logo...
【Logo语言教学设计】 Logo语言是一种简单易学的编程语言,特别适合初学者,特别是儿童,用来学习编程基础。在教学Logo语言时,首先要确保学生能够熟悉并掌握进入和退出Logo语言窗口的操作,这是基本的环境操作。...
【LOGO语言基础】 LOGO语言是一种简单易学的编程语言,主要面向初学者,特别是小学生,用于教育目的。它通过指令控制一个虚拟的“海龟”在屏幕上移动和绘图,帮助学习者理解基本的编程概念。厦门市小学生计算机LOGO...
【LOGO语言培训讲义概览】 本讲义主要针对LOGO语言的教育与培训,旨在教授初学者如何使用这种编程语言。LOGO语言是一种专为儿童和初学者设计的程序设计语言,它通过简单的命令和图形化的方式,帮助用户理解编程的...
中小学生喜爱的编程语言 flash版的Logo语言
第三十届厦门市小学生计算机LOGO语言竞赛初赛试卷
【LOGO语言教学的核心概念与方法】 LOGO语言是一种简易而直观的编程语言,特别适合初学者,尤其是小学生。它的核心在于通过简单的命令控制“小海龟”进行绘图,以此激发学生对计算机编程的兴趣,同时锻炼他们的逻辑...
LOGO语言的教学,在普及小学生计算机知识,激发小学生学习计算机的兴趣,培养和训练他们的思维能力,发展他们的智力及创造力等方面都起了积极的作用。 用Flash程序进行LOGO语言的模拟,可以完全模拟小学阶段大多数...
LOGO语言教程旨在引导初学者理解编程的基本概念,特别是针对儿童设计,以培养他们的创造性思维和逻辑推理能力。LOGO源自古希腊语,意为“思想”,由心理学家佩伯特设计,他在人工智能研究中受到启发,创造了一个类似...
小学LOGO语言是一种面向初学者的编程语言,它通过简单的指令让学习者能够轻松地进行图形绘制和逻辑运算。在2002年北京市西城区的小学LOGO语言程序设计竞赛中,学生们需要掌握以下几个核心知识点: 1. **图形绘制**...
LOGO语言,全称为“Logo”,是一种以图形绘制和简单编程为主的教育编程语言。它的设计初衷是为了帮助孩子们理解和学习计算机编程的基本概念,如顺序、循环和条件语句,同时通过控制一个虚拟的“海龟”在屏幕上移动和...
很好的logo语言辅导资料,归纳、总结了logo的编程思维。