Logo (programming language): Difference between revisions

Content deleted Content added
m adjust heading
No edit summary
 
Line 1:
{{Short description|Computer programming language}}
[[fr:Logo]][[pl:J%EAzyk programowania Logo]] [[zh:Logo程序设计语言]]
{{Infobox programming language
| name = Logo
| logo =
| logo caption =
| screenshot = KochTurtleAnim.gif
| screenshot caption = [[L-system#Example 4: Koch curve|L-system (Koch curve)]] turtle graphic
| paradigms = [[Multi-paradigm programming language|Multi-paradigm]]: [[Functional programming|functional]], [[Educational programming language|educational]], [[Procedural programming|procedural]], [[Reflective programming|reflective]]
| family = [[Lisp (programming language)|Lisp]]
| designers = [[Wally Feurzeig]], [[Seymour Papert]], [[Cynthia Solomon]]
| developer = [[BBN Technologies|Bolt, Beranek and Newman]]
| released = {{Start date and age|1967}}
| typing = [[Dynamic typing|dynamic]]
| implementations = [[UCBLogo]], many others
| dialects = [[StarLogo]], [[NetLogo]] and [[AppleLogo]]
| influenced = [[AgentSheets]], [[NetLogo]], [[Smalltalk]], [[Etoys (programming language)|Etoys]], [[Scratch (programming language)|Scratch]], [[Microsoft Small Basic]], KTurtle, [[REBOL]], [[Boxer (programming environment)|Boxer]]
| influenced by = [[Lisp (programming language)|Lisp]]
}}
[[File:Remi_turtlegrafik.png|thumb|Symmetry around a point can be obtained using only a few instructions, allowing users to draw [[hypotrochoid]]s like the one shown here.]]
'''Logo''' is an [[list of educational programming languages|educational programming language]], designed in 1967 by [[Wally Feurzeig]], [[Seymour Papert]], and [[Cynthia Solomon]].<ref>{{Cite journal |url=https://dspace.mit.edu/handle/1721.1/6226 |title=Logo Manual |last1=Abelson |first1=Hal |last2=Goodman |first2=Nat |date=December 1974 |website=Artificial Intelligence Lab, Massachusetts Institute of Technology |access-date=August 28, 2016 |last3=Rudolph |first3=Lee |hdl=1721.1/6226 |url-status=live |archive-url=https://web.archive.org/web/20160911020834/https://dspace.mit.edu/handle/1721.1/6226 |archive-date=September 11, 2016 }}</ref> The name was coined by Feurzeig while he was at [[Raytheon BBN|Bolt, Beranek and Newman]],<ref name="goldenberg198208">{{cite news |url=https://archive.org/stream/byte-magazine-1982-08/1982_08_BYTE_07-08_Logo#page/n209/mode/2up |title=Logo – A Cultural Glossary |last=Goldenberg |first= E. Paul |date=August 1982 |work=Byte |access-date=19 October 2013|pages=218}}</ref> and derives from the Greek ''logos'', meaning 'word' or 'thought'.
 
A general-purpose language, Logo is widely known for its use of [[turtle graphics]], in which commands for movement and drawing produced line or [[vector graphics]], either on screen or with a small robot termed a [[Turtle (robot)|turtle]]. The language was conceived to teach concepts of programming related to [[Lisp (programming language)|Lisp]] and only later to enable what Papert called "[[Proprioception|body-syntonic]] reasoning", where students could understand, predict, and reason about the turtle's motion by imagining what they would do if they were the turtle. There are substantial differences among the many dialects of Logo, and the situation is confused by the regular appearance of turtle graphics programs that are named Logo.
'''Logo''' is a computer [[programming language]] first developed in the late [[1960s]], by a team at BBN led by [[Seymour Papert]], Wallace Feurzeig, and Daniel Bobrow. Logo was originally about manipulating words and sentences, hence its name, derived from the Greek word "logos" meaning "word".
Papert, a professor at [[MIT]] and the author of ''Mindstorms: Children, Computers, and Powerful Ideas'', later added the turtle graphics for which Logo is now most famous.
 
Logo is a [[Comparison of multi-paradigm programming languages|multi-paradigm]] adaptation and dialect of Lisp, a [[functional programming]] language.<ref name=cslsPreface >CSLS Vol 1, Preface .pxvi, Harvey 1997</ref> There is no standard Logo, but [[UCBLogo]] has the facilities for handling lists, files, I/O, and [[Recursion (computer science)|recursion]] in scripts, and can be used to teach all computer science concepts, as [[University of California, Berkeley|UC Berkeley]] lecturer [[Brian Harvey (lecturer)|Brian Harvey]] did in his ''Computer Science Logo Style'' trilogy.<ref name=csls>''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 [http://www.cs.berkeley.edu/~bh/ online] {{webarchive |url=https://web.archive.org/web/20130704014342/http://www.cs.berkeley.edu/~bh/ |date=2013-07-04 }}</ref>
Papert used [[Lisp programming language|LISP]] but changed the [[syntax]] so it is much easier to read. One could say that Logo is Lisp without the parentheses. Today, it is known principally for its "Turtle Graphics" but it has significant list handling facilities, file handling and I/O facilities and can be used to teach most computer science concepts, as Brian Harvey does in his "Computer Science Logo Style" trilogy. Equally it can be used to prepare [[microworlds]] for students to investigate,
 
Logo is usually an [[Interpreter (computing)|interpreted language]], although compiled Logo dialects (such as Lhogho and Liogo) have been developed. Logo is not case-sensitive but retains the case used for formatting purposes.
There are over 130 implementations of Logo, each of which has its own strengths. A popular Linux implementation is UCBLogo. MSWLogo, its freeware Windows derivative, is commonly used in schools in the [[United Kingdom]]. Comenius Logo is available in Dutch, German, Czech etc. and is worth considering.
 
==History==
==Logo Programming==
Logo was created in 1967 at [[Bolt, Beranek and Newman]] (BBN), a [[Cambridge, Massachusetts]], research firm, by [[Wally Feurzeig]], [[Cynthia Solomon]], and [[Seymour Papert]].<ref name="mit.edu">{{cite web |url=http://el.media.mit.edu/logo-foundation/index.html |title=Logo Foundation |website=el.media.mit.edu |url-status=dead |archive-url=https://web.archive.org/web/20110721122057/http://el.media.mit.edu/logo-foundation/index.html |archive-date=2011-07-21 |access-date=2011-04-07 }}</ref> Its intellectual roots are in [[artificial intelligence]], [[mathematical logic]] and [[developmental psychology]]. For 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 a [[PDP-1]]. The goal was to create a mathematical land where children could play with words and sentences.<ref>{{cite web |url=https://logothings.wikispaces.com/ |title=logothings |website=logothings.wikispaces.com |url-status=live |archive-url=https://web.archive.org/web/20111207111525/http://logothings.wikispaces.com/ |archive-date=2011-12-07 }}</ref> Modeled on LISP, the design goals of Logo included accessible power{{Clarify |date=March 2008}} <!-- what kinda of power? --> and informative error messages. The use of virtual [[Turtle (robot)|Turtles]] allowed for immediate visual feedback and debugging of graphic programming.
The idea is that a turtle with a pen strapped to it can be instructed to do simple things like move forward 100 spaces or turn around. From these building blocks you can build more complex shapes like squares, triangles, circles--using these to draw houses or sail boats.
 
The first working Logo turtle robot was created in 1969. A display turtle preceded the physical floor turtle. Modern Logo has not changed very much from the basic concepts predating the first turtle. The first turtle was a tethered floor roamer, not [[radio-control]]led or [[wireless]]. At BBN Paul Wexelblat 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 in [[Lexington, Massachusetts]]. The virtual and physical turtles were first used by fifth-graders at the Bridge School in the same city in 1970–71.
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 she would do if she were the turtle. Papert called this "body syntonic" reasoning.
 
==Turtle and graphics==
The idea of turtle graphics is also useful for
{{see also|Turtle graphics}}
example in [[Lindenmayer system]] for generating fractals.
[[File:Tartapelago Bicicardio 01.gif|thumb|upright=1| Animated gif with turtle in [[MSWLogo]] ([[Cardioid]])<ref>{{cite web|url=https://www.maecla.it/tartapelago.htm |title=Tartapelago|first=Giorgio|last=Pietrocola |date=2005 |website=Maecla }}</ref>]]
Logo's most-known feature is the turtle (derived originally from [[Turtle (robot)|a robot of the same name]]),<ref name="mit.edu"/> an on-screen "[[Pointer (graphical user interfaces)|cursor]]" that shows output from commands for movement and small retractable pen, together producing line graphics. It has traditionally been displayed 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. The turtle moves with commands that are relative to its own position, ''LEFT 90'' means spin left by 90 degrees. 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 [[Sprite (computer graphics)|sprites]].
===Turtle Programming===
 
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 [[fractal]]s.
The following are examples of Turtle code. While seemingly very simple, titles can be given to groups of instructions, essentially creating libraries of more complex commands. In practice short forms are used "LEFT 90" is written "LT 90" <br>
Key words are usual written in UPPER CASE for beginners, but more advanced texts use lower case.
 
== Implementations ==
====Example 1: A Square====
{{anchor|DrLogo}} <!--The page Dr. Logo redirects here-->
<code>FORWARD 100
{{Redirect|Apple Logo|the logo of Apple Inc.|Apple logo}}
LEFT 90
[[File:IBM LCSI Logo Welcome Screen.png|thumb|IBM LCSI logo welcome screen]]
FORWARD 100
[[File:IBM LCSI Logo Circles.png|thumb|Source code and output in IBM LCSI Logo]]
LEFT 90
FORWARD 100
LEFT 90
FORWARD 100</code>
 
Some modern derivatives of Logo allow thousands of independently moving turtles. There are two popular implementations: [[Massachusetts Institute of Technology]]'s [[StarLogo]] and [[Northwestern University]] Center for Connected Learning's (CCL) [[NetLogo]]. They allow exploring [[emergence|emergent phenomena]] and come with many experiments in social studies, biology, physics, and other areas. NetLogo is widely used in agent-based simulation in the biological and social sciences.
This would draw a square with sides 100 units long ( but the turtle still has to turn LT 90 to be in the starting position).
 
Although there is no agreed-upon standard, there is a broad consensus on core aspects of the language. In March 2020, there were counted 308 implementations and dialects of Logo, each with its own strengths.<ref>{{cite web |url=https://pavel.it.fmi.uni-sofia.bg/logotree/pdf/LogoTree.pdf |title=The Logo Tree Project |website=elica.net |url-status=dead |archive-url=https://web.archive.org/web/20090306084150/http://elica.net/download/papers/LogoTreeProject.pdf |archive-date=2009-03-06 |access-date=2020-03-25 }}</ref> Most of those 308 are no longer in wide use, but many are still under development. Commercial implementations widely used in schools include ''[[MicroWorlds]] Logo'' and ''Imagine Logo''.
 
Legacy and current implementations include:
====Example 2: A Triangle====
The commands may be written on one line, or more
<code>FORWARD 100 RIGHT 120
FORWARD 100 RIGHT 120 FORWARD 100</code>
 
; First released in 1980s:
Would draw a triangle.
* Apple Logo for the [[Apple II Plus]] and Apple Logo Writer for the [[Apple IIe]], developed by Logo Computer Systems, Inc. (LCSI), were the most broadly used and prevalent early implementations of Logo that peaked in the early to mid-1980s.
* Aquarius LOGO was released in 1982 on cartridge by [[Mattel]] for the [[Mattel Aquarius|Aquarius]] home computer.
* [[Atari Logo]], developed by LCSI, was released on cartridge by [[Atari Inc|Atari, Inc.]] in 1983 for the [[Atari 8-bit computers]].
* Color Logo was released in 1983 on cartridge (26–2722) and disk (26–2721) by [[Tandy Corporation|Tandy]] for the [[TRS-80 Color Computer]].
* Commodore Logo was released, with the subtitle "A Language for Learning", by [[Commodore International]]. It was based on MIT Logo and enhanced by Terrapin, Inc. The [[Commodore 64]] version (C64105) was released on diskette in 1983; the [[Commodore Plus/4|Plus/4]] version (T263001) was released on cartridge in 1984.<ref>{{cite web |url=http://www.zimmers.net/commie/docs/cbm-products.txt |title=Canonical List of Commodore Products |date=2017-10-30 |access-date=2017-12-03 |last1=Brain |first1=Jim |last2=Zimmerman |first2=Bo |url-status=live |archive-url=https://web.archive.org/web/20171220005631/http://www.zimmers.net/commie/docs/cbm-products.txt |archive-date=2017-12-20 }}</ref><ref>{{cite web |url=http://plus4world.powweb.com/software/Logo |title=Logo – Software Details |website=Plus/4 World |access-date=2017-12-03 |url-status=live |archive-url=https://web.archive.org/web/20171204171250/http://plus4world.powweb.com/software/Logo |archive-date=2017-12-04 }}</ref>
* SmartLOGO was released on cassette by [[Coleco]] for the [[Coleco ADAM|ADAM]] home computer in 1984. It was developed by LCSI and included a primer, ''Turtle Talk'', by Seymour Papert.
* ExperLogo was released in 1985 on diskette by Expertelligence Inc. for the [[Macintosh 128K]].
* Hot-Logo was released in the mid-1980s by EPCOM for the [[MSX]] 8-bit computers with its own set of commands in Brazilian Portuguese.
* TI Logo (for the [[TI-99/4A]] computer) was used in primary schools, emphasizing Logo's usefulness in teaching computing fundamentals to novice programmers.
* Sprite Logo, also developed by Logo Computer Systems Inc., had ten turtles that could run as independent processes. It ran on Apple II computers, with the aid of a Sprite Card inserted in one of the computer's slots.
* IBM marketed their own version of Logo (P/N 6024076), developed jointly by Logo Computer Systems, Inc. (LCSI), for their then-new IBM PC.
* [[ObjectLOGO]] is a variant of Logo with [[object-oriented programming]] extensions and lexical scoping. Version 2.7 was sold by Digitool, Inc.<ref>[http://www.digitool.com/ol-specs.html Object Logo] {{webarchive|url=https://web.archive.org/web/20080430083030/http://www.digitool.com/ol-specs.html |date=2008-04-30 }} page on the Digitool website (accessed 4 March 2008)</ref> It is no longer being developed or supported, and does not run on versions of the Mac operating system later than 7.5.<ref>[http://www.digitool.com/ol-purchase.html Object Logo ordering page] on the Digitool website (accessed 4 March 2008)</ref>
* Dr. Logo was developed by [[Digital Research]] and distributed with computers including the [[IBM PCjr]],<ref name="DRI_1984_MicroNotes2"/> Atari ST and the [[Amstrad CPC]].<ref>{{Cite web|url=https://www.computerhistory.org/collections/search/|title=Catalog Search &#124; Computer History Museum|website=www.computerhistory.org}}</ref><ref>{{Cite web|url=https://www.computinghistory.org.uk/det/2666/Amstrad-CPC-6128/|title=Amstrad CPC 6128 - Computer - Computing History|website=www.computinghistory.org.uk}}</ref><ref>{{Cite web|url=https://www.habisoft.com/pcwwiki/doku.php?id=es:manual_del_amstrad_pcw_8256_8512_ingl%C3%A9s|title=es:manual_del_amstrad_pcw_8256_8512_ingles [PcwWiki]|website=www.habisoft.com}}</ref>{{anchor|DrLogo}}<!--The page Dr. Logo redirects here-->
* [[Acornsoft Logo]] was released in 1985. It is a commercial implementation of Logo for the 8-bit [[BBC Micro]] and [[Acorn Electron]] computers.<ref name="field">{{cite book | title=LOGO on the BBC computer and Acorn Electron | publisher=[[Macmillan Publishers|Macmillan]] | author=Field, Graham | year=1985 | isbn=0-333-39566-2}}</ref> It was developed for [[Acorn Computers]] as a full implementation of Logo. It features multiple screen [[turtle (robot)|turtle]]s and four-channel sound. It was provided on two 16kB [[Read-only memory|ROMs]], with utilities and [[device driver|driver]]s as accompanying software.<ref name="tmu four logos">{{cite news | url=http://www.nostalgia8.nl/logo/docs/mudeel1.jpg | title=Four Logos for the BBC Micro | publisher=[[The Micro User]] | work=The Micro User Education Special | access-date=February 20, 2012 | author=Radburn, Derek}}</ref>
*Lego Logo is a version of Logo that can manipulate robotic [[Lego]] bricks attached to a computer.<ref>{{cite journal|journal=[[Communications of the ACM]]|volume=36|number=7|date=July 1993|first=Mitchel|last=Resnick|title=Behavior Construction Kits|pages=64–71|doi=10.1145/159544.159593|s2cid=9263998|url=https://web.media.mit.edu/~mres/papers/BCK/BCK.html|accessdate=5 January 2022|doi-access=free}}</ref> It was implemented on the [[Apple II]] and used in American and other grade schools in the late 1980s and early 1990s.<ref>{{cite web|url=http://www.ucls.uchicago.edu/students/projects/1994-95/Lego-Logo/ProjectDescription.html|archiveurl=https://web.archive.org/web/20110720072907/http://www.ucls.uchicago.edu/students/projects/1994-95/Lego-Logo/ProjectDescription.html |archivedate=20 July 2011|title=The Laboratory Schools LEGO-LOGO Project|website=[[University of Chicago Laboratory Schools]]}}</ref> Lego Logo is a precursor to [[Scratch (programming language)|Scratch]].<ref>{{citation|last1=Bull|first1=G.|last2=Garofalo|first2=J.|last3=Hguyen|first3=N.|year=2020|title=Thinking about computational thinking: Origins of computational thinking in educational computing|journal=Journal of Digital Learning in Teacher Education|volume=36|number=1|pages=6–18|doi=10.1080/21532974.2019.1694381|s2cid=214563715}}</ref>
 
; First released in 1990s:
====Example 3: Dotted Line====
* In February 1990, ''Electron User'' published Timothy Grantham's simple implementation of Logo for the [[Acorn Electron]] under the article "Talking Turtle".<ref>{{cite web|url=http://www.acornelectron.co.uk/mags/eu/ills/7_05/s-p20.jpg|title=Talking Turtle|date=February 1990|pages=20–21|archiveurl=https://web.archive.org/web/20170328011620/http://www.acornelectron.co.uk/mags/eu/ills/7_05/s-p20.jpg |archivedate=28 March 2017}}</ref>
* Comenius Logo is an implementation of Logo developed by [[Comenius University Faculty of Mathematics, Physics and Informatics|Comenius University Faculty of Mathematics and Physics]]. It started development in December 1991, and is also known in other countries as SuperLogo, MultiLogo and MegaLogo.<ref>{{Cite web |date=2002-12-09 |title=History of Comenius Logo |url=http://www.input.sk/slogo/history.htm |access-date=2022-10-12 |archive-url=https://web.archive.org/web/20021209200055/http://www.input.sk/slogo/history.htm |archive-date=2002-12-09 }}</ref>
* [[UCBLogo]], also known as Berkeley Logo, is a free, cross-platform implementation of standard Logo last released in 2009. George Mills at MIT used UCBLogo as the basis for [[MSWLogo]] which is more refined and also free. Jim Muller wrote a book, ''The Great Logo Adventure'', which was a complete Logo manual and which used MSWLogo as the demonstration language.<ref>{{cite web|url=https://softronix.com/logo.html|accessdate=5 January 2022|title=MSWLogo, An Educational programming language|first=Jim|last=Muller|date=November 2001}}</ref> MSWLogo has evolved into [[FMSLogo]].
 
; First released from 2000 onwards:
The turtle's pen could be lifted and lowered; drawing a dotted line was rudimentary. In this example we'll use the short form for <code>FORWARD</code>, which is <code>FD</code>. When teaching this say "FD space 10" is saves alot of frustration. Anything written after the ; (semicolon) is ignored so can be used as a comment.
* aUCBLogo is a rewrite and enhancement of [[UCBLogo]].
* Imagine Logo is a successor of Comenius Logo, implemented in 2000.<ref>{{Cite book |last=Andrej |first=Kalas |url=https://worldcat.org/oclc/854959806 |title=Imagine... a new generation of Logo : programmable pictures |last2=Blaho |first2=Ivan |year=2000 |oclc=854959806}}</ref> The English version was released by Logotron Ltd. in 2001.<ref>{{Cite web |date=2001-04-17 |title=Imagine {{!}} Press Release |url=http://logo.com/press_releases/imagine/index.html |access-date=2022-10-12 |archive-url=https://web.archive.org/web/20010417020957/http://logo.com/press_releases/imagine/index.html |archive-date=2001-04-17 }}</ref>
* [[LibreLogo]] is an extension to some versions of LibreOffice. Released in 2012, it is written in [[Python (programming language)|Python]]. It allows vector graphics to be written in Writer.
* Logo3D is a tridimensional version of Logo.
* POOL is a dialect of Logo with object-oriented extensions, implemented in 2014. POOL programs are compiled and run in the graphical IDE on [[Microsoft Windows]]. A simplified, cross-platform environment is available for systems supporting [[.NET Framework]].
* QLogo is an open-source and cross-platform rewrite of [[UCBLogo]] with nearly full UCB compatibility that uses hardware-accelerated graphics.
* Lynx is an online version of Logo developed by Logo Computer Systems Inc. It can run a large number of turtles, supports animation, parallel processes, colour and collision detection.
* LogoMor is an open-source online 3D Logo interpreter based on JavaScript and p5.js. It supports 3D drawings, animations, multimedia, 3D models and various tools. It also includes a fully-featured code editor based on [[CodeMirror]]
* LbyM is an open-source online Logo interpreter based on JavaScript, created and actively developed (as of 2021) for [[Sonoma State University]]'s ''Learning by Making'' program.<ref>{{cite web|url=https://make.sonoma.edu/learning-making|title=Learning by Making ¦ Make@SSU|date=14 August 2017|accessdate=8 January 2022}}</ref> It features traditional Logo programming, connectivity with a customized microcontroller and integration with a modern code editor.
 
== Influence ==
FD 10 ;(drawing a line and moving)
PENUP ;(now we've lifted the pen so it won't draw anything even if we do move)
FD 10 ;(not drawing but moving)
PENDOWN ;(now we've lowered the pen so it draws a line wherever the turtle moves)
FD 10 ;(drawing a line and moving)
PENUP
FD 10 ;(etc...)
PENDOWN
FD 10
 
Logo was a primary influence on the [[Smalltalk]] programming language. It is also the main influence on the [[Etoys (programming language)|Etoys]] educational programming environment and language, which is essentially a Logo variant written in [[Squeak]] (itself a variant of Smalltalk). Logo influenced the procedure/method model in [[AgentSheets]] and [[AgentCubes]] to program agents similar to the notion of a turtle in Logo. Logo provided the underlying language for Boxer. Boxer was developed at [[University of California, Berkeley]] and MIT and is based on a ''literacy model'', making it easier to use for nontechnical people.<ref>{{Cite web |title=Boxer - EduTech Wiki |url=https://edutechwiki.unige.ch/en/Boxer |access-date=2024-04-10 |website=edutechwiki.unige.ch}}</ref>
====Example 4: Loops====
 
KTurtle is a variation of Logo implemented at [[Qt (software)|Qt]] for the [[KDE]] environment loosely based on Logo.<ref>{{cite web |url=http://edu.kde.org/kturtle/ |title=The KDE Education Project – KTurtle |website=edu.kde.org |url-status=live |archive-url=https://web.archive.org/web/20060827165231/http://edu.kde.org/kturtle/ |archive-date=2006-08-27 }}</ref>
You could also use loop (repeat) commands. This would draw the exact same box in the first example:
 
Two more results of Logo's influence are [[Kojo (programming language)|Kojo]], a variant of Scala, and [[Scratch (programming language)|Scratch]], a visual, drag-and-drop language which runs in a web browser.
<code>
REPEAT 4 [FD 100 RIGHT 90]
</code>
 
==References==
Which would execute the command "<code>FD 100 RIGHT 90</code>" four times.
{{Reflist|refs=
A simplistic circle consists of 360 individual rotations with a step forward, so "<tt>REPEAT 360 [FD 1 RIGHT 1]</tt>" would have the expected result.
<ref name="DRI_1984_MicroNotes2">{{cite news |title=DRI ships 128K version of Dr. Logo |newspaper=[[Micro Notes (Digital Research)|Micro Notes]] - Technical information on Digital Research products |volume=2 |number=2 |date=May 1984 |publisher=[[Digital Research, Inc.]] |___location=Pacific Grove, CA, USA |id=NWS-106-002 |page=4 |url=https://www.z80cpu.eu/mirrors/oldcomputers.dyndns.org/public/pub/manuals/DRI_Micronotes_Vol2_1,2,3_full.pdf |access-date=2020-02-11 |url-status=live |archive-url=https://web.archive.org/web/20200211005618/https://www.z80cpu.eu/mirrors/oldcomputers.dyndns.org/public/pub/manuals/DRI_Micronotes_Vol2_1,2,3_full.pdf |archive-date=2020-02-11 |quote=[…] [[Dr. Logo]] first appeared on the retail market in fall of 1983 for the [[IBM PC]] and climbed to the top of the [[Softsel Hot List]]. The retail release included [[SpeedStart CP/M]], an abridged version of [[CP/M-86|CP/M]] that boots automatically when the system is turned on. […]}} [https://web.archive.org/web/20200211102248/https://www.z80cpu.eu/mirrors/oldcomputers.dyndns.org/public/pub/manuals/DRI_Micronotes_Vol2_1,2,3_bw_full.pdf<!-- https://www.z80cpu.eu/mirrors/oldcomputers.dyndns.org/public/pub/manuals/DRI_Micronotes_Vol2_1,2,3_bw_full.pdf -->]</ref>
}}
 
==Further reading==
{{refbegin}}
* {{Cite journal |last=Solomon |first=Cynthia |last2=Harvey |first2=Brian |last3=Kahn |first3=Ken |last4=Lieberman |first4=Henry |last5=Miller |first5=Mark L. |last6=Minsky |first6=Margaret |last7=Papert |first7=Artemis |last8=Silverman |first8=Brian |date=2020-06-12 |title=History of Logo |url=https://dl.acm.org/doi/10.1145/3386329 |journal=Proc. ACM Program. Lang. |volume=4 |issue=HOPL |pages=79:1–79:66 |doi=10.1145/3386329|hdl=1721.1/133952 |hdl-access=free }}
* [https://history.dcs.ed.ac.uk/archive/docs/ArtificialIntelligence/art0084.html ''To Artificial Intelligence'' (1976)] Early AI textbook where Logo is used extensively. (Using the [[Edinburgh University]] dialect, AI2LOGO)
* [https://www.amazon.com/gp/product/0262510375 Turtle Geometry] Abelson and diSessa
* ''Children Designers'', Idit Harel Caperton, Ablex Publishing Corporation {{ISBN|0893917885}}. Available [https://www.amazon.com/Children-Designers-Interdisciplinary-Constructions-Computer-Rich/dp/0893917885/ online]
* ''Learning With Logo'', Daniel Watt, McGraw Hill, {{ISBN|0-07-068570-3}}. Available Through Amazon
* Teaching With Logo: Building Blocks For Learning, Molly Watt and Daniel Watt, Addison Wesley (now Pearson) 1986, {{ISBN|0-201-08112-1}} Available through Amazon
* {{cite magazine|magazine=Byte|year=1982|volume=7|issue=8|publisher=McGraw-Hill|title=Logo|url=https://ia600605.us.archive.org/14/items/byte-magazine-1982-08/1982_08_BYTE_07-08_Logo.pdf}} (''Byte'' magazine special 1982 issue featuring multiple Logo articles).
{{refend}}
 
==External links==
====Example 5: New words====
* {{commons category-inline}}
You can teach the turtle new words, i.e. groups of instructions,or procedures. These can to be done from Logo prompt or an Editor, that is invoked by <cite>EDALL</cite> in many logo dialects. <br> 'TO CHAIR' must be on a separate line. 'END' must be on a separate line. Anything written after a ';' is ignored- so can be used as a comment.
* {{Wikibooks inline|Logo Programming}}
 
{{Logo programming}}
{{Lisp programming language}}
{{Authority control}}
 
[[Category:1967 in robotics]]
<code>EDALL</code>
[[Category:Apple II software]]
<code>
[[Category:Dynamically typed programming languages]]
[[Category:Domain-specific programming languages]]
TO CHAIR
[[Category:Educational programming languages]]
REPEAT 4 [FD 100 RT 90] FD 200
[[Category:Free educational software]]
END
[[Category:Functional languages]]
</code>
[[Category:Lisp programming language family]]
 
[[Category:Logo programming language family]]
If you are using the editor you must exit from it, and the new word is saved into the availabe vocabulary, but will be lost when LOGO is exited.
[[Category:Programming languages]]
Now any time <code>CHAIR</code> is entered, "<code>REPEAT 4 [FD 100 LEFT 90] FD 30</code>" will be executed. You could compound these by <code>REPEAT 4 [CHAIR] if you wanted.</code>
[[Category:Programming languages created in 1967]]
 
[[Category:Robot programming languages]]
====Example 6: Erasing (In the UCBLogo dialect)====
The turtle can erase a line. <code>PENERASE PE</code>. You must then replace the 'pen' with the command <code>PENPAINT PPT</code>.
 
<code>EDALL</code> ;(to enter the editor mode, then the actual procedure)
<code>
TO ERASECHAIR
PE
REPEAT 4 [FD 100 RT 90] FD 200
PPT
END
</code>
 
 
====Example 7: Parameters- giving the word changeable information ====
Logo can pass extra information to its words, and return information. We must tell the word to expect something and give it a name. Notice the use of the colon. We are passing 'by value' and the colon is pronounced as 'the value of'. When the procedure is run with a command like <code>CHAIR 200</code>, the size takes the value 200 so we go 'FD the value of 200'.
 
<code>EDALL</code> (to enter the editor mode, then the actual procedure)
TO CHAIR :thesize
REPEAT 4 [FD :thesize RT 90] FD :thesize FD :thesize
END
Try
REPEAT 50 [HOME CHAIR 200 HOME CHAIR 100 WAIT 200 HOME ERASECHAIR ]
 
There were two new instructions- which are easier to use than explain. Thats the spirit of LOGO. <br>
If you do need help. Type <code>HELP</code>, or <code>HELP "HOME</code> ( note the single quote mark.)
 
==The Language==
 
Logo is an interpreted language. It is not case dependant , but retains the case used for formatting. It is written in lines . 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 remarkable useful for producing useful scripts.
 
===Functions/Procedures===
 
Each line is made up of 'function calls'. 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 or readlist.
 
A command is similar to a Pascal procedure, and a operation is similar to a Pascal function.
 
A special subset of operations called predicates, that just output the word <code>"true</code> or <code>"false</code>, these are conventionally written with a final ‘p’- like <code>emptyp, wordp, listp</code>.
 
* 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: <code>sum :x :y, product :x :y, difference :x :y, quotient :x :y<code>. Infix is also available.
 
help "keyword ;(will bring up a full description of the expression) .
 
A command can call itself, this is called [[recursion]]
 
====Example 8: A spiral drawn using recursion====
to spiral :size
if :size > 30 [stop] ; a condition stop
fd :size rt 15 ; many lines of action
spiral :size *1.02 ; the tailend recursive call
end
 
spiral 10
 
===Data===
 
There are three datatypes in UCBLogo,
 
* the word,
* the list,
* the array.
 
A number is a special case of word.
 
There is no strong typing. The interpreter detects the datatype by context.
 
There are two important symbols
 
* The colon <code>:</code>- 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'''
 
Assignment in Pascal <code>x:= y +3</code> becomes in Logo
make "x sum :y 3
or
make "x sum :y "3
<code>make</code> takes 2 parameters, the second of which here is <code>sum :y "3</code>. Now <code>sum</code> takes two 'parameters' and is a 'operation', thus the calculation is possible. <code>"3</code> evaluates to <code>3</code>, and <code>:y</code> takes the contents of the thing called <code>y</code>, these are summed giving a number. The effect of <code>make</code> is to place the result into the first parameter.
 
An alternative way of looking at this, maybe, is that the second parameter is 'passed by value' while the first is 'passed by address.'
 
Indirection (within a procedure) is possible with the form <code>make :x :x + 1</code>.
 
====Scoping====
Variables don’t have to be declared before use. Their scope is then global.
A variable may be declared <code>local</code>, thenits scope is limited to that procedure and its subprocedures. This is dynamic scoping. Calling a 'procedure' with 'inputs', creates 'local variables' which hold the contents of the parameters.
 
===Lists===
 
Discussing lists comes as a surprise to a Pascal programmer, who has managed quite well without them, however this opens many new possibilities. Arrays are also provided for the timid.
 
* Operators exist to convert words into lists, and lists into arrays and back again.
* This data type has the advantage over array in that it is infinitely expandable Data is extracted using the the operations first, butfirst, last, butlast, member and item. Data is 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.
 
====Example 9: Using List primitives to extract the first 5 members of a list====
a: One way would be to use iteration.
to firstfive :alist
ifelse lessp count :alist 5 [ op :alist ][
make "olist []
repeat 5 [ make "olist lput first :alist :olist make "alist bf :alist ] output :olist ]
end
 
show firstfive [1 2 3 4 5 6 7 8 9 ]
[1 2 3 4 5]
foreach firstfive [1 2 3 4 5 6 7 8 9 ] show 10 - ?
[9 8 7 6 5]
 
b: Another, more elegant way would be
 
to firstn :num :list
if :num = 0 [output []]
output fput (first :list) (firstn :num-1 butfirst :list)
end
 
to firstfive :list
output firstn 5 :list
end
This method uses recursion, and is an example of a 'functional' rather than a 'sequential' programming approach.
 
===Control Structure Commands===
 
The standard Pascal controls are available, there is selection
 
* 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 prefered processing paradigm.
 
===Template iteration ===
 
The Pascal programmer will be surprised by a series of list based control structures. The basic idea is that you have 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 <CODE>MAP, APPLY, FILTER, FOREACH, REDUCEand CASCADE.</CODE> They repesent four flavours of template iteration, known as explicit-slot, named-procedure, named-slot (or Lambda) and procedure-text.
 
show map [? * ? ] [ 5 6 7 ]
[25 36 49 ]
show filter [ (count ? ) > 4 ] [ the quick brown fox jumps over the lazy dog ]
[quick brown jumps]
show foreach [1 2 3 4 5] [ ? * 10 ]
[10 20 30 40 50]
 
RUN [ list of commands ] ;run a list of commands ( or programs ) from in a program.
 
===Property Lists===
A property list is a special list where the odd number items are property name, 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
 
===I/O Commands===
Text may be written to the command window (output stream) using <code>print, show</code> and to the graphics window using <code>label </code>
 
The standard commands are <code>readlist readword readchar</code> 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. The technique will be familiar to Pascal Programmers- using a sequence
 
openread [filename]
setread[filename]
setreadpos nn
readchar
setread[]
close [filename].
 
There are equivalent commands to change the output stream, <code>openwrite, openappend, setwrite, setwritepos nn. <code>
 
dribble [filename]
Creates a transcript of everything that is typed in or outputted to the command window.
nodribble
This turns it off.
 
===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)
 
====Example 10: Calculating and drawing a [[sundial]] for a given latitude====
This is a typical garden dial. The graphic can be printed and transfered to wood or brass to make an accurate garden timepiece.
to dial
cs show [Type in your latitude as a whole number]
make "latitude readword ;uses keyboad input
for [i 0 6 1][
make "ang arctan product sin :latitude tan product :i 15 ;the calculation
rt :ang fd 200 bk 200 lt :ang ;draw the morning line
lt :ang fd 200 bk 200 rt :ang ;use symmetry to draw the afternoon line
]
pu setx -300 sety -300 seth 90 pd ;send the turtle to the bottom
fd 300 seth 270 rt 90 - :latitude fd 300 ;draw the [[style]] or [[gnomon]]
pu home pd ;tidy it up
end
A sundial plate must be calculated for its latitude using the formula
x= arctan( sin(latitude)*tan(HourDiff * 15 ) )
The Gnomon Angle = 90 - latitude.
 
===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.
 
==Logo instead of [[Pascal_programming_language|Pascal]]?==
 
Logo is slow, it is not suitable for processsing vast amount of data- it is a learning language. If speed is not an issue anymore it is educationally more useful to watch a program cranking through a problem. The visual output allows this. It assists students understanding how the computer is working sequentially through the instructions.
 
Logo scores on graphics, and MSWLogo allows the use the Windows dll.. A crucial point for learning Pascal is that students must master 'pointers' before they can do any useful data structure theory. This excludes all except the most committed. In Logo, Lists, stacks and queues are trivial. Trees are more fun. All are recursive in nature.
 
UCBLogo and MSWLogo include a rudimentary Pascal intrepreter written in Logo as one of the examples.
 
==External Link==
* [http://www.cs.berkeley.edu/~bh/logo.html Berkeley Logo] (UCBLogo, GNU)
* [http://www.softronix.com MSWLogo]: To down load MSWLogo.
* [http://www.input.sk/slogo/usage.htm Comenius Logo] A popular European Logo.
* [http://www.embry.com/rLogo/ rLogo]: Play with Logo online (you will need a [[Java programming language|Java]]-enabled [[Web browser|browser]]).
* [http://education.mit.edu/starlogo/ MIT StarLogo]
* [http://ibiblio.org/obp/thinkCS/ How to Think Like a Computer Scientist] How to Think Like a Computer Scientist, Logo version
 
==External Sources==
Computer Science Logo Style, Brian Harvey, MIT Press (3 volumes) 0-262-58148-5, 0-262-58149-3,0-262-58150-7.<br>
The Great Logo Adventure, Jim Muller, Doone Publications 0-9651934-6-2