Slashdot Mirror


Thoughts On The Pike Programming Language?

bilboyablan asks: "Ive stumbled upon the Roxen Web server , mostly implemented in the Pike programming language. I got curious about Roxen, but even more about Pike, and it seems to me like a quite solid scripting OO language, with a C-like syntax, and with a quite good documentation (user manual) to boot. So it seems intriguing to me why Pike hasnt gotten a wider acceptance. So, if some of you fellow Slashdotters have had any experience with Pike (outside of Roxen), could you maybe drop a few lines on it? "

9 of 235 comments (clear)

  1. Pike with Gtk bindings by moibus · · Score: 4

    Pike has Gtk bindings too and my (limited) experience with them has been good. Seems like a pretty cool language. There's a good Pike resource site at http://www.pike-community.org/.

    --
    -moibus http://moibus.jfm.net/
  2. Pike by roman_mir · · Score: 4

    When C was introduced it quickly won the hearts of computer programmers as a high level language that still feels like a low level one (close to Assembler memory management.) It was not like Fortran, Ada or Basic, it allowed something that was never there before C. We have C++ that can do all that C does, we have Python and Perl that can do somethings in more convenient ways, there is Java and VB etc.
    How easy is it to introduce a new language that will catch up with the masses? Java and Python are good examples of such languages. Java allowed many programmers do what C++ does in the sence of OO but easier to learn, Python has the power of Perl plus it allows use of other language libraries. These are clearly improvements (no I am not saying Java is better than C++, I am saying there was (is) a market for this language for those who want some (not all) power of C++ and they want it fast and easy to learn).

    Maybe in order for a language to become widely accepted it must present something new from marketing point of view not only from functional point of view.
    Still it is not impossible that pike will find its own audience. How many of you use ML, Prolog, Lisp or Scheme in your everyday life? But these languages have their own purpose, their own market niche, mainly AI R&D.
    If Pike has something new to offer, it'll be used.

  3. A good example of Pike in action by IronGorilla · · Score: 4

    The world's largest amateur fantasy and sci fi art/writing site is powered by it. Every page is automatically generated by pike whenever one of the thousands of artists on board update their page. The URL is http://elfwood.lysator.liu.se and yes, I'm a member (though my gallery shall remain anonymous as my intention here is not to plug myself though I will say I joined when there was less than 100 people involved) and a voulentier staff member on the webpage.

    I'm not sure, but I THINK that Roxen and Pike were created at the Lysator computer club at Linkopeg university in Sweeden, who as you can see in the above link, are hosting Elfwood. The URL for the Lysator computer club is http://www.lysator.liu.se Of course, there's a high probability of me being wrong about that being where Roxen and pike came from.. but I seem to remember that's what someone told me.

  4. Re:Scriptlanguages are bad by roman_mir · · Score: 5

    well that is a strange statement. Most script languages are hard to use for those who do not know how to use them.
    Here is another one: Unix IS user-friendly, it just chooses its friends very carefully.

    Why are scripting languages hard to use? I use sh, csh, ksh, awk, sed, Perl, Python, jsp, asp and even Dos batch files in primitive basic. What is so hard about 'em?

    Translated languages under Unix/Linux have the same precedence level as compiled binaries (under DOS bat files are secondary). Translated languages don't even have to be compiled! It is true that I have not seing a good IDE for awk or csh but it does not mean the language is bad.

  5. Re:That's not a haiku. by 575 · · Score: 4

    There once was an impatient poster
    He cried out "That haiku's not kosher!"
    The rest of us pounced
    His poor ego was trounced
    Maybe next time he'll look a bit closer

  6. About Pike. by Cedric+Adjih · · Score: 4
    I've just downloaded and played a bit with the language. Basically, if I understood properly:
    • It is in fact quite close to Java.
    • It has garbage collection (or is it reference counting ? I created some circular dependencies and it didn't seem to collect).
    • It has high level types: string, array, mapping, multiset. It has simple syntax for defining constants with those objects, and basic operation on them (like lists, dictionnaries, hashes in Perl or Python).
    • It has OO, looks less hackish than Perl, but just doesn't look as clean as Java. Is class-shared data possible ?
    • The variables have to be declared. It is not statically typed though, and it has a "mixed" type which is a placeholder for any type (something like Delphi's "Variant").
    • It tries hard to be like C. Exactly the same declaration syntax, operators, control flow structures. Worrying point: it also has the preprocessor.
    • It is probably less dynamic than Perl or Python (I couldn't set the method of one object to be another, at runtime).

    Basically it is closer to Java than to scripting languages because of the declarations. It might be simpler to use than Java if, for instance, you used the "mixed" type (can hold any object) everywhere, because you don't need casts ; it still looks heavier than Tcl, Perl or Python.

  7. Re:Yeah, but what does it have to offer? by davidhedbor · · Score: 4
    To mention a few things:
    • C-like syntax. Not a very important point, but when it comes to learning the language it's much easier than say Perl if you come from a C/C++ background. It's basically a highly evolved LPC (of LPMUD fame).
    • A very powerful Image package. Can load tons of formats natively including Photoshop (psd) and Gimp (xcf). Used by Roxen to do all kinds of graphics generation on-the-fly.
    • Powerful datatypes - mappings, multisets, shared strings. Nothing unique, but Pike's are very scalable. Also string handling is rather powerful.
    • Integrated bignum support. Pike 7 can handle arbritrary size integers without any special effort from the programmers point of view.
    • Very good and easy to use socket handling. Not strange since the main app written in Pike is a webserver.
    • Good object orientation, easy-to-use abstracted database handling, very nice GTK bindings and lots of more things I have forgotten about etc.

    Now to some drawbacks - we all know that everything isn't all good.

    • Shared strings, and datatypes in general, does have a memory overhead. Usually not noticable but if you deal with LOTS of short strings for example, you'll notice it. Nothing really unique to Pike though, but it's worth mentioning.
    • Not very wide spread usage and historically not very well documented. There are no Pike books, but there is a good tutorial now (check out http://docs.roxen.com).
    • Slower than C - can't be avoided. Slower and faster than Java (depending on what you do), sometimes slower than perl. Unfortunately I have forgotten the URL to the site that had benchmarks.
    • Less mature than some other languages. Syntax still changes, although backwards compatibility usually isn't major problem.
    • More things I'm sure. I just can't think of anything right now.

    I hope this is helpful.

  8. too many scripting languages by jetson123 · · Score: 4
    Pike, Python, Perl, Tcl, JavaScript, Ruby, etc. are all very similar: dynamically typed, byte code interpreted, procedural/OO languages.

    In addition, there is a plethora of interesting, powerful interpreters for languages that go beyond traditional scripting: EiC (ANSI C interpreter), CINT (C++ interpreter), Hugs/Haskell, CAML-Light, Scheme, Icon, CLisp/CommonLisp, Squeak/Smalltalk-80, etc.

    Next time you feel the urge to invent a new scripting language, think about doing something genuinely new, rather than coming up with a language that is merely an incompatible, incremental improvement of something existing.

    If you can't formulate some new idea that your language implements that isn't easily added to Python or Perl, I'd say, don't bother and work on one of the existing languages instead. Many of the existing languages need more libraries and better foreign function interfaces, and several of the existing languages would benefit from new implementations in C++ and/or Java, etc.

  9. Re:About Pike. (long) by kinkie · · Score: 5

    Pike is close to java in that they are both follow C syntax somewhat, extending it to OO concepts.

    It is unlike java in that while Java is strongly typed and you have to use typecast, Pike is as strongly-typed as you wish. You can use the mixed type to completely defeat any typechecking, or you can use classes and call them by name to be as strongly-typed as you wish.
    Also notice that pike's concept of "class compatibility" is somewhat different from all other strongly typed OO languages, as it doesn't call into play inheritance. If two classes have similar signatures (names and types of public methods and variables), they are compatible.

    Another novel approach Pike has is to function and operator overloading.
    With C++ (and Java, if I remember correctly), overloading is defined by having different functions take different numbers and types of arguments: i.e.
    void foo (int arg);
    void foo (char* arg);
    They are distinguishable at compile-time because the function signature is extended to its arguments' types, usually via name mangling.

    Pike insteads allows arguments to be of different types. The above example would translate to:
    void foo (int|string arg).
    The programmer can then use runtime type information to discriminate.

    Pike has both refcounting and garbage collection. It is quite uncommon to see the gc in action, as it will kick in when some percentage (I think half) of the object references are deemed garbage (it uses some adaptive algorithm to determine when to run). Or when explicitly invoked.

    About static typing, see above. It can be as strict (or as lax) as the programmer wishes. It is refreshing to have some "mixed tmp" variable in a function and use it for loops etc.

    About control flow structures, it has some more than C (i.e. foreach()).
    The preprocessor if used wisely can be a nice weapon. For instance, you can detect the interpreter's version and use threads when possible. Of course, this also means that it allows people to write messy code. But they'd do it anyways...

    It can be as dynamic as you wish. For instance, setting a method of another object can be done using a "function"-type variable:

    class foo {
    private int foo_bar() {
    werror "foo";
    }
    function bar=_bar;
    }
    class gazonk {
    private int gazonk_bar() {
    werror "gazonk";
    }
    object foo_object=foo();
    void create() { /* constructor */
    foo_object->bar=gazonk_bar;
    }
    }

    I could have also used anonymous functions (lambda) here.
    i.e.
    function foo_bar=lambda() {werror "foo";}

    A nice thing about the language is that it doesn't try to hide details from the user. It is known what is handled by reference (every composite type, classes, objects, functions) and what is by value (basic types). It allows runtime inspection (via the indices, and typeof operators), remote objects, etc.

    Since functions are primary objects, the whole runtime library follows a very consistent callbacks-based approach. This comes very handy when doing asynchronous I/O (one of Pike's strong points) or GTK programming.

    About its "product placement" in terms of heavy-ness. It has some at-large programming helpers (more than TCL), and its syntax is less shell-ish than TCL's. Perl is IMO simpler for very simple tasks, but heavier for more complex ones (especially when need to go further than the string-array-hash types, and references come into play. Pike is much easier in this respect).
    Python, I don't know really.I've never used it. I suspect that Pike and Python play roughly in the same league, neither clearly besting the other. I find Pike very convenient in I/O-related task, X programming (although here TCL/TK is better), and some simple text-manipulation tasks, requiring little text manipulation and a bit of variables-juggling.

    About the runtime environment, Pike offers a two-pass compiler (no forward declarations), a mixed static+dynamic names binding model (intra-object references are static, inter-object they are dynamic), and a nice (but not comparable to CPAN) runtime library, including some nice DB-connectivity options.

    --
    /kinkie