http://qs321.pair.com?node_id=11147450

Dr. Subtilis has asked for the wisdom of the Perl Monks concerning the following question:

Dear Perl Monks,

I seek your advice with the following conundrum: My 9-year old got completely hooked into Perl, and I feel only slightly guilty about it. Now it would be desirable if he could go into graphics and user interfaces, which is not one of Perl's strongest suits. The only ways that I can find for the latter are the very dated Perl/TK and bindings for Qt4. Now I am wondering: should I really let him go deeper into outdated technology or do I finally have to tell him: "Yea, maybe you should go for Python after all. Or Rust."?

I was not too unhappy about him learning Perl, as he was learning concepts that are applicable in any programming language (+ Perl is just the loveliest language out there). But this seems to be another matter, but at the same time it is quite a road block for the ambitions of a 9-year-old. Would you have any advice? Is there any way of doing graphical things in perl that actually teaches stuff that can also be used in more up to date contexts?

Replies are listed 'Best First'.
Re: Advice on learning Perl and graphics
by eyepopslikeamosquito (Archbishop) on Oct 16, 2022 at 09:04 UTC

      Thank you eyepopslikeamosquito...
      I didn't realise there were so many Perl GUI's - next time I want to write anything for the desktop in Perl I shall try an alternative to Tk

Re: Advice on learning Perl and graphics
by haj (Vicar) on Oct 16, 2022 at 15:31 UTC
    I see several aspects here:
    • Perl and graphics: Is this about creating graphical user interfaces (GUI) - or about creating pictures and animations? For GUI, the choice is, well, difficult. For a somewhat narrower scope, SDL Perl comes with a book Writing Games in Perl (a bit stale, though). If it's about creating beautiful images, you could start with an app like harmonograph (based on Wx) and work from there (but see the third item below).
    • to be used in more up to date contexts: That would make it difficult for Tk. While the widget demo provided with the library is very helpful, it shows a style which is very idiomatic to Perl - and to a somehow old-fashioned Perl style in particular. Also, Perl/Tk apps look a bit "old". On the plus side, to my knowledge it is the only toolkit which allows to define events on individual canvas items.
    • An important aspect of is to get it running in the environment which your son wants to use, and unfortunately this isn't always trivial. So, I would be tempted to recommend WxPerl, but unfortunately it doesn't install cleanly from CPAN these days. For example, for Windows and Strawberry Perl there's the open Bug #129768; applying the patch suggested by Kai-Uwe Eckhardt in that bug report makes installation work and tests pass.
Re: Advice on learning Perl and graphics
by NERDVANA (Deacon) on Oct 16, 2022 at 18:41 UTC
    If you want to guide him into a career of computer programming with forward-looking skills, javascript would be the logical next step, not python (or perl or Rust or anything like that). Javascript has canvases and SVG and WebGL and anything he creates, he can show it to his friends on a wide variety of devices without them installing anything. Showing off creations can be a strong motivator. It's also getting to the point where you can use ES6 directly in modules loaded into the page without needing all the webpack hassle and still be compatible with most devices.

    I'm not really recommending this for a 9 year old, but since we're on the topic of graphics in Perl, I'll go ahead and promote my OpenGL::Sandbox module, combined with the fact that it can run shader demos from www.ShaderToy.com. (but of course, so can javascript) Teaching a kid to think in terms of transformed coordinate spaces will go a LONG way in geometry and trigonometry later in high school and college. I'm doubting a 9 year old can grasp that yet, but who knows, everyone has different strengths. And sometimes early exposure can lead to later understanding.

    Edit: Also, there is CmdlineGL if you want to teach him how to do 3D graphics in bash.

      I'd add Kotlin to your post: to be able to program for mobiles seems to be our destiny.. or doom :)

      L*

      There are no rules, there are no thumbs..
      Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Re: Advice on learning Perl and graphics
by LanX (Saint) on Oct 16, 2022 at 10:55 UTC
    > should I really let him go deeper into outdated technology or do I finally have to tell him: "Yea, maybe you should go for Python after all. Or Rust."?

    Well, he's 9 year old, when do you expect him to enter the job market and how can you know which technology will be on-date then? :)

    I would let him play and experiment, I think Perl is a very good starting point for the concepts of most dynamic languages out there (mostly because they borrowed heavily from Perl or Perl did from them)

    He could chose his path then, if he really continues to be interested in programming at all.

    After all, the top-quality of a programmer is to be able to adapt to a new language.

    It's true you can find a lot of teaching material out there for Python, but my experience is that quantity is not quality.

    This "Python is easy" mantra is encouraging a lot of "easy" minds to write half-baked summaries.

    Cheers Rolf
    (addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
    Wikisyntax for the Monastery

Re: Advice on learning Perl and graphics
by Discipulus (Canon) on Oct 16, 2022 at 16:55 UTC
    Hello Dr.Subtilis and welcome to the monastery and welcome to your son to the wonderful world of Perl!

    > My 9-year old got completely hooked into Perl

    Firts I should say: lucky you and him :)

    > Now it would be desirable if he could go into graphics and user interfaces

    In this situation for GUI I would opt for Prima: I never used it it but I have look at it several times with a growing interest. It is modern and under active developping but a mature project.

    Tk is old and has many quirks but still works well: can I prodly point you to my Tartaglia-s-triangle, picwoodpecker, Stone-Jam and Discipulus-15-puzzle?

    Stone-Jam is a simple game and maybe my code ( the core is under 200 lines ) is not that bad to understand.

    For graphics I used GD in the above picwoodpeaker and in tk-jepg-custom-rotator

    GD is not that easy to learn ad use but he can start under your guidance.

    My best wishes to your son (..and you)!

    L*

    PS I have also a fun project where graphic is rendered in terminal: the demo of the project is usable but the overall design is flawed and I have no more will to correct it: Game-Term

    git clone https://github.com/LorenzoTa/Game-Term cd Game-Term perl -I ./lib ./demo/00-start.pl

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Re: Advice on learning Perl and graphics
by karlgoethebier (Abbot) on Oct 16, 2022 at 08:50 UTC
    "My 9-year old…"

    OT: Programming For Kids might be helpful for further inspiration. Assumed that I understood your question right.

    «The Crux of the Biscuit is the Apostrophe»

Re: Advice on learning Perl and graphics
by davies (Prior) on Oct 16, 2022 at 11:36 UTC

    One area that is transferrable is SVG. Perl has some decent modules for this such as SVG, and it can be fun to compare carefully written SVG to the output of inkscape doing the same thing, which I have found hideous.

    Regards,

    John Davies

Re: Advice on learning Perl and graphics
by eyepopslikeamosquito (Archbishop) on Oct 17, 2022 at 01:39 UTC
      all the above languages have ... superior performance to scripting languages.

      If you have one (and I'm sure that if anyone has it will be you :-) I would be interested to see a reference for this as it pertains to Java. My experience has been quite the opposite.


      🦛

      I'll stick by my recommendation of javascript, because the last thing a kid would want to do is have to write their program twice so that their iPhone friends and android friends can both see it. And don't forget the hassle of tooling and publishing on the app store.

      I recently came across an IRC client called The Lounge which is the single best written JavaScript GUI I've ever used. I haven't had time to pick apart the source code yet, but they built that thing with the best that web technologies have to offer. You can browse to it from any common web browser, and on mobile devices there is a button in the UI to save a link to it onto the phone's desktop as if it were a native app. It's indistinguishable from a native app and functions better than half the apps on my phone. And best of all, it's free and allows me to cross off my TODO list item for that web-based multi-platform IRC bouncer I always intended to write, and without regrets, because this is way better than what I would have created.

        And don't forget the hassle of tooling and publishing on the app store

        Ha ha, not to mention the cost. Every hobbyist Apple developer I met at work actually lost money! Admittedly, they were Apple die-hard fans and novice iPhone developers with a full-time day job ... but the annual Apple Developer Program fee turned out to be greater than what they earned from their App! :)

Re: Advice on learning Perl and graphics
by Bod (Parson) on Oct 16, 2022 at 14:04 UTC
    should I really let him go deeper into outdated technology

    Perl does not fall under the "outdated technology" banner in my opinion. Sure, it might not be the latest sexy, shiny language but that does not make it outdated.

    Having written code in a number of languages with varying degrees of success, I feel Perl is the easiest and most versatile among them. Hence it is very much my language of choice.

    There is a rather intetesting article that addresses this issue of Perl being outdated. It points out just how different Perl is now to when Perl 5 first appeared despite the name implying they are similar.

    I wish I had discovered Perl in my early days of programming. I learnt BASIC from a textbook and wrote lots of code by hand with a pen and paper before I ever got the opportunity to test that code on an actual computer! I was about 12 at the time...

Re: Advice on learning Perl and graphics
by eyepopslikeamosquito (Archbishop) on Oct 19, 2022 at 08:49 UTC

    LanX's post just now -- mentioning domm's bicycle routes from Vienna to Frankfurt -- brought back happy memories of domm here at Perl Monks. He was quite a character at the monastery back in the early 2000s. Feeling nostalgic, I checked out some of his old nodes and noticed his two highest rated posts:

    might assist you in your quest of introducing programming to your nine year old son!

    Is obfu of interest to a nine year old? I have no idea, so I'd be interested to learn of your son's reaction to domm's Space Invaders ... and which obfus appeal to him from The Top Ten Perl Obfus. :)

      Interestingly, one of his sons has become a game developer :-)

      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re: Advice on learning Perl and graphics
by cavac (Parson) on Oct 18, 2022 at 09:36 UTC

    Another "more-or-less graphical" user interface that is quite useful is ncurses, which gives you quite good interfaces in the terminal. Curses::UI is a good start for this.

    You can make nice user interfaces, and as a bonus, this also works over SSH. Which is quite a useful feature when you are working remotely on a system that had no monitor, keyboard and mouse. Like, for example, a Raspberry Pi stuffed into some other project like an autonomous RC car.

    PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP
Re: Advice on learning Perl and graphics
by xiaoyafeng (Deacon) on Oct 20, 2022 at 04:22 UTC

    Interesting Topic! ;)

    maybe it's a little bit off topic, but I feel sad to see many guys recommend Java ,C++ etc(in perlmonks!).

    yes, C++ Java, python etc are all good languages and many many guys use them. but if let me say, Perl is absolutely best language for kids learning. It has at least 2 advantages:
  • it's still in most 20 pop languages. that means it's still evolved, many many ppl use it and you can find what you need in CPAN
  • second, but the more importantly, Perl is the most like human language which I've seen. Other languages, for compromising engineering and semiconductor, they have been add many things but not for pure language. like python's tab, C's pointer etc. that's maybe good for worker and engineer, but for kid, they are all useless.
  • In short, computer language is another language for human. So the most importance are can-evolve, the ability of expression (especially new thing), easy use for communication(Making Easy Things Easy and Hard Things Possible) and free style for expression(TIMTOWTDI, ). I think perl perfectly meet these requirements. that's my 2c.





    I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

        Dear All,

        thank you a lot - these were superb answers and I have now a lot of homework to do.

        It seems that half of you are suggesting jumping to a different language. I have considered that often (the most serious contenders would be Rust, JavaScript, and Kotlin), but I do concur with xiaoyafeng and others - Perl is not at all bad for him, versatile and playful, and also just beautiful, I find. And he can learn the concepts here as well as anywhere else.

        His case is however a bit untypical - I am not looking for beginners' stuff. He made his way through "Learning Perl" and "Intermediate Perl" very swiftly, and now I can hardly separate him from "Programming Perl". But he usually writes very self-referential stuff that doesn't do much - he plays with the concepts, builds modules, objects, regexes, complicated data structures with references, that sort of thing. But that is also partly because he does not know to do anything but text-output on the console. So I am in the weird situation trying to interest him in maybe writing a game or so. As for the rest of the tech stack: It's all Linux only, and he has little acquaintance with or interest in phones, and he does have some sense of HTML and CSS.

        I do feel glad he took so well to a language that I like and that we could explore it together (he is already way better than me), but I also do feel bad seeing him a bit stuck or confined (although he does not experience it as such). Anyway, I think with all the new options you gave me, for now we will stick with Perl and see what these various suggestions can do.

        One note about "outdated technology": Yes, I get it's not quite yet so. I guess I am more worried about the trajectory. Perl and Python (which really never did it for me) are pretty much the same age. However, Python has been going places (partly for the very reasons I dislike it) while Perl, even though it keeps hanging in there, has very few new users and uses. Even more importantly it seems unclear whether the community can productively unify behind a consistent development of the language. This is why I fear it may be on its way out. I really hope I am wrong.
Re: Advice on learning Perl and graphics
by tybalt89 (Monsignor) on Oct 21, 2022 at 21:16 UTC

    My vote is for Perl/Tk (mainly because I still use it a lot). It uses the basic widget callback paradigm which applies to many other systems, and for that reason it's reasonable to learn.

    And since one of my philosophies is "always show code", here's a very simple drawing program in Perl/Tk:

    #!/usr/bin/perl use strict; use warnings; use Tk; my @lines; my $mw = MainWindow->new; my $c = $mw->Canvas(-width => 900, -height => 900,)->pack(-side => 'bo +ttom'); $mw->Button(-text => $_->[0], -command => $_->[1])->pack(-side => 'rig +ht') for [ Exit => sub { $mw->destroy } ], [ 'Clear Last' => sub { pop @lines; draw() } ], [ 'Clear All' => sub { @lines = (); draw() } ]; $c->Tk::bind('<1>' => sub { push @lines, [ &xy ]; $c->Tk::bind('<Motion>' => sub { push @{ $lines[-1] }, &xy; draw() } + ); } ); $c->Tk::bind('<ButtonRelease-1>' => sub { $c->Tk::bind('<Motion>' => ' +') } ); MainLoop; sub xy { $_[0]->XEvent->x, $_[0]->XEvent->y } sub draw { $c->delete('pen'); @$_ >= 4 and $c->createLine(@$_, -smooth => 1, -width => 5, -tag => +'pen') for @lines; }

    Maybe others can post a comparable program in other GUIs for comparison purposes.

Re: Advice on learning Perl and graphics
by Anonymous Monk on Oct 16, 2022 at 16:18 UTC
    Is there any way of doing graphical things in perl that actually teaches stuff that can also be used in more up to date contexts?

    Mojolicious::Lite and Imager are a powerful combination for writing graphical applications with Perl.

Re: Advice on learning Perl and graphics
by harangzsolt33 (Chaplain) on Oct 17, 2022 at 05:38 UTC
    I think, each programming language has its strengths and weaknesses. Or I should say some programming languages make solving certain tasks easier. So, if your son wants to learn graphics, you should probably introduce him to HTML / JavaScript! That is the easiest way to go. I think, you didn't mention what OS you use. Windows makes it super easy to create GUI programs written in HTML and JavaScript. Add .HTA extension to it, and you have a GUI application in a matter of minutes. Seriously, you want to make sure you don't complicate it too much lest he lose interest. Make it simple for him. And JavaScript is very simple! It's also very similar to Perl. In JavaScript, you can start variable names with a '$' sign just like in Perl. It has regex and substr() and there are a bunch of other very familiar things in JavaScript. So, it's not a big step in the opposite direction, I think. In Windows, you can write a GUI application that launches Perl scripts, which is pretty cool... (For similarities and differences between JavaScript and Perl, see this page I wrote: http://wzsn.net/perl/jsandperl.html)

    Also, check out PureBasic. It's a paid software, yes, and it's expensive (about $70-80 to purchase), but it makes GUI programming very easy (not as simple as HTML & JavaScript, but still on the easy side), and it can compile to Windows, Linux and MacOS. It comes with an extensive Help file and lots of example programs to learn. And it's easy to learn. Okay, it's totally different from Perl, but it's not hard to learn at all. By the way, there is a Freeware version too. It's called XBasic. It also runs on Windows and Linux and makes graphics programming fun and easy!

Re: Advice on learning Perl and graphics
by bliako (Monsignor) on Oct 24, 2022 at 12:55 UTC

    Now that I know a bit more about the use-case after your second post I can give my 2 drachmas. 1.5 of which has already been given by fellow monks here.

    I usually don't bother with GUI (in the usual context). I put all my effort in building the logic as a non-GUI Perl application and then combine it with Mojolicious to react to user requests locally or remotely and totally compatible with all the OS which support browsers which support standard HTML and javascript. I add extra functionality to the "endpoints", e.g. "login", to communicate (read input params and send out a response) with the user in 2 different ways: HTML and JSON. If the user uses the browser then HTML rendered on their browser can do as much as a modern GUI can do. JSON is intended for allowing an "app" to interact with your back-end. For this last scenario and if you don't want to bother too much with "apps", Android (and I guess IOS) provide a Webview widget which renders HTML and executes JS. Which makes this prospect a click more powerful than a browser because Webview can inject HTML+JS and execute code in the "app" space. So, Javascript, as mentioned already by NERDVANA and Mojolicious by anonymonk. The drawback here is that there can be need for advance JS skills like XHR and the reactive-programming challenges therein. Otherwise JS is cute and easy.

    Secondly, I love to scrape! Scraping should be given the "hero of the internets" award. There's data everywhere and scraping it, legally, combining, storing etc. can give you a playground to do super-powerful things. Perl is in par with any other language here with its reliable LWP::UserAgent and CPAN modules to parse received data. Plus Perl's seamless use of regexes (whereas Java needs some boilerplate to do basic regex, yikes).

    Thirdly, in some cases I need very fast network response and number crunching. Then I resort to trusty C and C++. There are C-native, open source (a very important criterion in whatever you decide to use) libraries which offer access for, say, curl and OpenCV from C and C++. Perl is perfect for calling C executables. No fancy XS is required, just a simple system() suffices. You want some face recognition? Easy peasy with above setting and OpenCV.

    Fourthly, there are languages dedicated for doing certain things. One of which is R. A totally head-hitting-the-wall language with steep learning curves but with an amazing gamut of open-source packages for doing virtually anything in the statistics, bionformatics, data-processing fields. All with easy multi-threading or GPU support. Again, you do not need to write a huge R script and, ouch!, a GUI. All you need is to follow the basic Unix mantra: do one thing and do it well and create a small script which you can call from Perl. You want some sentiment analysis? Easy peasy with above setting and R. There's also LaTeX, a language dedicated to typesetting of the highest standard. You want to render some PDF? Easy peasy with LaTeX (which has a Perl driver so you don't need to shell-out).

    Finally, you can't go wrong when you are backed by an OS like Linux*, which is my Fifth and last point. So, for me, nah pop has no style, I strictly roots and I am enjoying every single keystroke of it.

    bw, bliako

    *) Don't make the mistake to think Linux and OSX are the same thing. Big mistake, keep away from OSX as it has become worse than M$ in the well-known aspects plus a few more perversions that the apple people invented all by themselves. (a good post must contain a rant).

Re: Advice on learning Perl and graphics
by salva (Canon) on Oct 25, 2022 at 19:52 UTC