Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
×
Perl Programming

Developing Games with Perl and SDL 248

segphault writes "Andy Bakun has written an excellent 20 page guide to game development with SDL_Perl for Ars Technica. The tutorial, which includes extensive code examples and plenty of screenshots, walks readers through the process of building a clone of the original Atari Kaboom! game." From the article: "One of the biggest benefits of using SDL is that it allows portable media applications to be written without having to be concerned with specific implementations of media libraries for each target platform. Bringing Perl into the picture takes the portability one step further, allowing media-rich applications to be written in a high-level language that can be targeted to a number of platforms. While programming using SDL requires knowledge of C and access to a C compiler, using SDL_perl does not. This greatly decreases the amount of time it takes to get something up on the screen and working."
This discussion has been archived. No new comments can be posted.

Developing Games with Perl and SDL

Comments Filter:
  • Well, duh! (Score:3, Insightful)

    by GreatBunzinni ( 642500 ) on Wednesday February 15, 2006 @07:40AM (#14723337)
    While programming using SDL requires knowledge of C and access to a C compiler, using SDL_perl does not. This greatly decreases the amount of time it takes to get something up on the screen and working.

    Yet, it does need knowledge of Perl, another programming language, and access to a Perl interpreter. So, indeed, in the end it needs the exact same thing that is needed to write a game in C or C++. A person needs knowledge of a programming language, knowledge of an API and access to software which will make the program happen. So, having this in mind, wtf is that intended to mean? Sheesh....

  • Hmm (Score:2, Insightful)

    by darkmonkeh ( 953919 ) on Wednesday February 15, 2006 @07:43AM (#14723347)
    While this may give a backbone for new programmers to get out their first game, the complexity of game making cannot be "simplified" more than it already is. Perl itself is slow, and not directly suited for making games. One would have to think carefully about what they wish to achieve before committing to making a game using SDL_Perl.
  • by cheekyboy ( 598084 ) on Wednesday February 15, 2006 @08:04AM (#14723387) Homepage Journal
    Think C64 games, but with true 24bit graphics at 640.

    SDL+PERL can be thought of a 'flash killer' hack.... with enough specific libraries for sdl in perl, they
    could do extra tricky bits animated mpeg1 in a sprite with one command.

  • Re:Hmm (Score:1, Insightful)

    by 91degrees ( 207121 ) on Wednesday February 15, 2006 @08:05AM (#14723393) Journal
    Perl may be slow, but this doesn't always matter. If you use a fast high level API to deal with physics and graphics, and keep AI fairly simple, then the time spent executing perl code will be very small, and the effect on overall speed will be negligible.
  • by Vo0k ( 760020 ) on Wednesday February 15, 2006 @08:35AM (#14723468) Journal
    Moreover, writting in Perl is fast and easy. You can test your ideas, check if the game would be playable at all, create a working mockup in Perl and finding "not enough raw horsepower" move to C with the "final product". Sure it will take longer than writing everything in C from scratch, but shorter than writing everything in C and then deciding it sucks and abandonning it.
  • by master_p ( 608214 ) on Wednesday February 15, 2006 @09:01AM (#14723548)
    SDL is "a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer" (quote taken from the SDL web site). What about:

    1) drawing functions
    2) fonts
    3) openGL
    4) file formats
    5) game GUI
    6) sound formats
    7) networking
    8) configuration

    etc?

    there are various SDL-derived libraries that implement, more or less, the above, but they are C/C++ libraries, and the quality varies. Does Perl make it easy to use those libraries?
  • Finally! (Score:4, Insightful)

    by jalefkowit ( 101585 ) <jason@jaso3.14nlefkowitz.com minus pi> on Wednesday February 15, 2006 @09:04AM (#14723555) Homepage
    At last we can have Tetris with regular expressions.
  • Re:Well, duh! (Score:2, Insightful)

    by Jedi Alec ( 258881 ) on Wednesday February 15, 2006 @09:11AM (#14723577)

            While programming using SDL requires knowledge of C and access to a C compiler, using SDL_perl does not. This greatly decreases the amount of time it takes to get something up on the screen and working.

    Yet, it does need knowledge of Perl, another programming language, and access to a Perl interpreter. So, indeed, in the end it needs the exact same thing that is needed to write a game in C or C++. A person needs knowledge of a programming language, knowledge of an API and access to software which will make the program happen. So, having this in mind, wtf is that intended to mean? Sheesh....


    Because, well, C and Perl are the same level of complexity. All this superficial nonsense like garbage collection, not having to worry about memory allocation etc. won't save any time whatsoever.
  • Easy (Score:5, Insightful)

    by Andy Dodd ( 701 ) <atd7NO@SPAMcornell.edu> on Wednesday February 15, 2006 @09:35AM (#14723663) Homepage
    All that highly optimized C is part of a prewritten library (as is the case here).

    For the remaining non-performance-critical stuff, Perl is often MUCH easier to develop with.

    And in many cases, keep in mind the 80/20 rule of thumb. 80% of the time is spent in 20% of the code. This does vary, but in many cases the amount of highly optimized code needed for good performance is very little.

    Many years ago, I was writing a program in Perl. I knew that there was a good chance I'd have to rewrite some of it in C eventually for decent performance, and this turned out to be true. In the end, I obtained 20-40 times the performance (and most likely 95%+ of the performance I would have obtained using C only) by rewriting approximately five lines out of 100-200 lines of Perl in C. The time it took me to figure out how to interface C and Perl (doing so was not documented very well then, it took me 2 weeks to find SWIG) was still far less than the time it would've taken me to write the entire program in scratch using straight C.
  • what really gets me is when you wan't to make some changes to open source software (particularlly windows stuff) and sure you can download the source but you have to spend hours messing arround trying to get the build environment right.

    how the hell are users supposed to fix bugs that annoy them if they can't get the build environment right for the existing code?!
  • Re:Hmmmm.... (Score:4, Insightful)

    by Mr_Silver ( 213637 ) on Wednesday February 15, 2006 @10:03AM (#14723826)
    However, it's in Perl. And I really have to ask myself; Do I want to play games coded by people who started programming games in perl?

    I would ask yourself, "why do you care what it is written in?". The whole point of playing a game is that its supposed to be enjoyable. The fact that it is written in Perl, C, BASIC, Java or Cobol is immaterial if you enjoy the game.

    Would you suddenly consider Half-life 2, GTA or any other game "rubbish" just because you found out that it was written in a programming language that you didn't like or didn't think would be suited to the task?

    I see a similar thing with people who snub Visual Basic applications. Yes we all know how good or bad VB is at development but if someone has produced a tool using it which does what you want, quickly, easily and at the right price, why does it matter what it was written in?

  • by ajs ( 35943 ) <{ajs} {at} {ajs.com}> on Wednesday February 15, 2006 @10:04AM (#14723832) Homepage Journal
    Yes, yes, python is not less perfect than perl. We get it. I think the point to TFA was that high-level languages + SDL make a nice game development combination, not that [insert high level language] is special.
  • Re:Well, duh! (Score:2, Insightful)

    by Shaper_pmp ( 825142 ) on Wednesday February 15, 2006 @10:05AM (#14723834)
    Yeah, this means nothing at all, right? I mean, everyone knows Perl's just as hard to learn as C/C++, right? And it takes you exactly the same amount of time to jump through all the hoops coding something in strictly-typed, anally-retentive, compiled C/C++ than hacking it together quickly in a loosely-typed Perl script.

    Oh, and scripted languages' memory management saves exactly zero development and testing time over non-memory-managed languages, too, while simultaneously not helping you at all to avoid memory leaks and other nasty hard-to-debug errors. And CPAN stores phenomenally huge amounts of pre-written plug-in-and-go code for both Perl and C/C++, right? And...

    Either we haven't ever written a line of code in C/C++ or Perl, or we didn't think before we posted...

    Disclaimer: I first learned to code in C/C++, so I harbour it no ill-will at all. Nevertheless, anyone seriously suggesting that Perl won't save you time over C/C++ in the short-term is insane. Of course, a non-trivial project where C/C++'s strict typing and formal style produces big wins is another matter, but when the context's "getting something up on the screen and working" it's simply no contest.
  • by ajs ( 35943 ) <{ajs} {at} {ajs.com}> on Wednesday February 15, 2006 @10:48AM (#14724143) Homepage Journal
    Anyone who has learned both languages does not agree, in my particular case. They're both powerful, highly flexible languages that have powerful constructs for managing high-level structures. Perl tends to have more varied facilities while Python tends to have fewer, but often more robust facilities (twisted comes to mind).

    They are both excellent languages, and if you're of the ill-informed opinion that one or the other does not serve well for large, highly strucutred projects, then I suppose our experiences simply differ.
  • Re:Hmm (Score:3, Insightful)

    by mysticgoat ( 582871 ) * on Wednesday February 15, 2006 @11:08AM (#14724325) Homepage Journal

    Perl itself is slow....

    I keep seeing statements like this, and I wonder what they mean.

    I have used Perl fairly extensively in data mining and format conversion work, sometimes using the Tk extension to provide a GUI front end, but I don't do real time applications or games. However I expect Perl would be adequate for many games, because I think that a lot of people are not recognizing the difference between a scripted language and an interpreted language.

    Perl is a script language that is compiled on the fly, before processing starts: there is no Perl interpreter. My understanding is that the resulting code runs at the same speed as an executable from a C compiler: that it is in fact an executable from a specialized C compiler. My experience is that large, complex Perl scripts will exhibit a noticeable delay on start-up (during the compilation phase), but are indistinguishable in performance from any other executable once data crunching begins.

    IME, any noticeably slow performance in Perl scripts can be traced to inefficient uses of regular expressions or string evals (both of which see heavy usage in the kind of work I've been doing). But these are program design issues, not inherent in the Perl implementation itself, and I doubt that either of these techniques would be used much in games. Obviously Perl isn't a good choice for 3D games with Shrek level animations, but I don't think you could do that kind of thing with any of the common C or C++ packages.

    So am I missing something here? Is Perl really too slow for game development, or are people thinking that since it is scripted, it must be implemented like a Basic interpreter? Or are people overly concerned about the start-up delay of the compilation phase (which can be gotten around for Windoze/Wine by using something like perl2exe to precompile an executable for distribution).

  • by mr_mophead ( 886977 ) on Wednesday February 15, 2006 @01:13PM (#14725385)
    Oh yeah, "Practical Extraction and Report Language." Sounds like a real game friendly language choice. Come on, I know this is Slashdot, and most of us spend our free time installing Linux in our pillows and spoons, but this is just a bad idea.

Always draw your curves, then plot your reading.

Working...