Karel (programming language)
Karel is an educational programming language for beginners, created by Richard E. Pattis in his book Karel The Robot: A Gentle Introduction to the Art of Programming. Pattis used the language in his courses at Stanford University, California. The language is named after Karel Čapek, a Czech writer who introduced the word robot in his play R.U.R.[1][2] PrinciplesA program in Karel is used to control a simple robot named Karel that lives in an environment consisting of a grid of streets (left-right) and avenues (up-down). Karel understands five basic instructions: ExampleThe following is a simple example of Karel syntax: BEGINNING-OF-PROGRAM DEFINE turnRight AS BEGIN turnLeft; turnLeft; turnLeft; END BEGINNING-OF-EXECUTION ITERATE 3 TIMES BEGIN turnRight; move END turnoff END-OF-EXECUTION END-OF-PROGRAM SpecificationThe following implementation is Karel in the Python programming language.[3] Other implementations are available. Primitive functionsThe following are the primitive functions.
Program StructuresKarel programs are structured in the following way:
Conditions in KarelKarel can respond to certain conditions in its world:
And their inverses:
It can also check the current block's color by Conditions and LoopsThere are two control structures:
Variants and descendantsThe language has inspired the development of various clones and similar educational languages. As the language is intended for beginners, localized variants exist in some languages, notably Czech (the programming language was quite popular in Czechoslovakia). The principles of Karel were updated to the object-oriented programming paradigm in a new programming language called Karel++. Karel++ is conceptually based on Karel, but uses a completely new syntax, similar to Java. A REALbasic implementation, rbKarel,[4] provides the basic Karel commands within an RBScript environment with BASIC syntax being used for loops and conditionals. This teaching project provides a cross-platform GUI for Karel experiments including single-stepping and spoken output. A Karel-inspired language and environment called Robot Emil[5] uses a 3D view of the robot's world. Robot Emil offers a large palette of objects that can be placed to depict walls, windows (transparency), water and grass. The camera may be moved freely throughout the 3D environment. The robot may be controlled interactively with buttons in the GUI, or by programs written in Emil's Karel-like programming language. The author states that the program is free for use by schools, students and children. Versions are available in English, Czech and Slovak. A proprietary language which is also called Karel is used to program the robots of FANUC Robotics. However, FANUC Karel is derived from Pascal. The language has also been implemented as Karel the Dog in JavaScript by CodeHS. Similar to the original language, this implementation features Karel in a grid world. Programmers use and build upon Karel's simple vocabulary of commands to accomplish programming tasks. Instead of putting and picking beepers, Karel the Dog puts and takes tennis balls. A German version of Karel is named "Robot Karol".[6] See also
Further reading
References
External links
|
Portal di Ensiklopedia Dunia