Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Can Perl do anything Java can do?

by shmem (Chancellor)
on Jul 19, 2017 at 12:03 UTC ( [id://1195442]=note: print w/replies, xml ) Need Help??


in reply to Can Perl do anything Java can do?

Short answer: Yes to all 4 points.

Long answer:

Of course perl can be used to do all of that, since it is a complete language. To the points:

  1. It depends. In theory, there's no difference between theory and pratice; in pratice, there is. There are many areas in which perl would be just as suitable as java, but they have been neglected by the perl community. Take smartphones and smartphone applications. While it is possible to nail perl onto an device running a linux kernel (e.g. Android phones), little code has yet been written to provide interfaces to their hardware components and libraries.
  2. Of course, many web-applications have been written using perl. The website you are visiting is all done in perl, as is slashdot afaik.
  3. The Perl Comprehensive Archive Network a.k.a CPAN contains bindings to many GUI toolkits (WxWidgets, Tk, gtk,...). WxWidgets and PerlTk run on Windows and X11 platforms.
  4. Yes, definitely. CPAN provides many modules to this end.

That said, the decision between using Perl or Java hinges more on the environment in which your code is running, and on the expertise of the coders in either language.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Replies are listed 'Best First'.
Re^2: Can Perl do anything Java can do?
by MikeBraga (Initiate) on Jul 19, 2017 at 12:28 UTC
    "That said, the decision between using Perl or Java hinges more on the environment in which your code is running, and on the expertise of the coders in either language." ------------------------------------ Hi, thanks for the answers. Why do you say this?? Won't the Perl code run in Unix (our code will be running in Linux machines) and Windows both?? Are you saying that Perl will run only in Unix OSs??
      Won't the Perl code run in Unix (our code will be running in Linux machines) and Windows both??

      Perl and many modules will run just fine in both environments, and there is lots of Perl code that is entirely portable to many platforms. But in some cases, care has to be taken to ensure portability. For example, you'll often see code that is hard-coded to use the forward slash as a directory separator, which works in many cases on Windows, but not all. If instead one uses the core module File::Spec or one of the more user-friendly modules from CPAN like Path::Class, they'll do filename handling in a more native way, and you should have much less portability issues. When picking modules, you can look at their documentation as well as the CPAN Testers Matrix for compatibility (e.g. this is the one for IPC-Run3).

        You should be aware that if you specify a path with forward slashes to a Windows instance of perl, the interpreter will usually auto-convert the forward slashes to backslashes for file access. This is a particularly helpful feature when wrapping a Windows path in interpolating delimiters, e.g. double quotes. Obviously, File::Spec et al. represent the most transferable approach.

        #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

      Won't the Perl code run in Unix (our code will be running in Linux machines) and Windows both??

      Definitely on Linux, and surely on Windows, too. But I don't have enough expertise on Windows to assert that all perl code portably written on Linux/UNIX runs on Windows without (trivial) changes. Others should step in here.

      perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

        As with any 'portable' language, not all programs can be just copied between *nix and Windows. Many can, some can with effort, and others can't.

        It is particularly difficult if the program has implemented functionality that relies on platform specific libraries for instance, or attempts to do things on an OS where the capabilities don't exist or work reliably ($SIG{ALRM} comes to mind).

        Again though, the vast majority of the time, if a Perl script can't be migrated from one platform to another, neither can a similarly-written program written in another language.

        Here's an example Makefile.PL of a Perl distribution that is specifically designed to work cross-platform. That file, and the entire codebase of the dist checks to see what OS its on, and sets itself up accordingly. In this case, the code had to be written in this fashion as it requires a lot of OS-specifics. Most of my other distributions are cross platform without any need to do any specific checking at all.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1195442]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2024-04-19 07:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found