Preface
This book was written with the intention of making anybody with a little programming experience able to use Pike. It should also be possible to gain a deep understanding of how Pike works and to some extent why it works the way it does from this book. It will teach you how to write your own extensions to Pike. I have been trying for years to get someone else to write this book, but since it seems impossible without paying a fortune for it I will have to do it myself. A big thanks goes to Ian Carr-de Avelon and Henrik Wallin for helping me iron out some of the rough spots. The book assumes that you have programmed some other programming language before and that you have some experience of UNIX.Introduction
This introduction will give you some background about Pike and this book and also compare Pike with other languages. If you want to start learning Pike immediately you can skip this chapter.Overview
This book is designed for people who want to learn Pike fast. Since Pike is a simple language to learn, especially if you have some prior programming experience, this should benefit most people.The history of Pike
In the beginning, there was Zork. Then a bunch of people decided to make multi-player adventure games. One of those people was Lars Pensjö at the Chalmers university in Gothenburg, Sweden. For his game he needed a simple, memory-efficient language, and thus LPC (Lars Pensjö C) was born. About a year later I started playing one of these games and found that the language was the most easy-to-use language I had ever encountered. I liked the language so much that I started improving it and before long I had made my own LPC dialect called LPC4. LPC4 was still geared towards writing adventure games, but was quite useful for writing other things with as well. A major problem with LPC4 was the copyright. Since it was based on Lars Pensjö's code, it came with a license that did not allow it to be used for commercial gain. So, in 1994 I started writing µLPC, which was a new but similar LPC interpreter. I got financial backing from Signum Support AB for writing µLPC. Signum is a company dedicated to supporting GNU and GPL software and they wanted to create more GPL software.A comparison with other languages
Python Python is probably the language that is most like Pike. Pike is faster and has better object orientation. It also has a syntax similar to C++, which makes it more familiar for people who know C++. Python on the other hand, has a lot more libraries available. C++ Pike's syntax is almost the same as for C++. A huge difference is that Pike is interpreted. This makes the code slower, but reduces compile times to almost nothing. For those few applications which require the speed of C or C++, it is often easier to write a Pike extension than to write the whole thing in C or C++. Lisp and Scheme Internally Pike has a lot in common with simple interpreted Lisp and Scheme implementations. They are all stack based, byte-compiled, interpreted languages. Pike is also a 'one-cell' language, just like Scheme. Pascal Pike has nothing in common with Pascal. Tcl/Tk Pike is similar to Tcl/Tk in intent and they both have good string handling. Pike has better data types and is much faster however. On the other hand Tcl/Tk has X windows system support.What is Pike
Pike is: A programming language Object oriented Interpreted Fast Dynamic High-level similar to C++ easy to extend (a fish) Pike has: Garbage collection Advanced string functions 6 years of development behind it Advanced data types such as associative arrays Support for bignums Builtin socket supportHow to read this manual
This manual uses a couple of different typefaces to describe different things: italics Italics is used as a placeholder for other things. If it says a word in the text it means that you should put your own word there. bold Bold is just used to emphasize that this word is not merely what it sounds like. It is actually a term. fixed size Fixed size is used to for examples and text directly from the computer.Also, please beware that the word program is also a builtin Pike data type.
1.你要學這個語言,應該有其他一些程序語言的基礎,和UNIX平臺下編程的基礎.
2.本章只是介紹一些關於Pike語言的背景,可以跳過這一章.
3.這個語言的前身是MUD的LPC語言,後來得到一些研究機構資助?寫了一個強大的web-server
相比之下,Python和Pike最爲相象.但是Pike is faster and has better object orientation
Pike語法和C++最爲相象,但他是解釋執行的,但是效率方面幾乎不比C++差,相對
用C 或者 C++實現一些功能或者模塊而言.他很容易編寫和實現,
........................等俺接着看下一章