Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Can Perl do anything Java can do?

by MikeBraga (Initiate)
on Jul 19, 2017 at 11:01 UTC ( #1195433=perlquestion: print w/replies, xml ) Need Help??

MikeBraga has asked for the wisdom of the Perl Monks concerning the following question:

We want to create some applications and want to know the feasibility of using Perl.

The other option is Java.

We have these questions:
(1.) Can Perl do anything Java can do?
(2.) Can Perl be used to create web-applications like Amazon or Ebay? What is the HTTP and Application servers we can use then?
(3.) Can Perl be used to create desktop applications, like can using Java swing?
(4.) Can Perl be used to create a message broker applications, a FTP file transfer application, an e-mail sending and receiving application, or an ESB application?

Replies are listed 'Best First'.
Re: Can Perl do anything Java can do?
by cavac (Curate) on Jul 19, 2017 at 11:34 UTC

    In simple words: Yes, Perl is Turing complete, therefore it can, given enough resources, do what every other Turing complete language or computer can do.

    But you may find it a bit hard to write programs in Perl that are as clunky, memory hungry and slow as your typical Java program.(*)

    (*) Sorry, couldn't resist that one...

    "For me, programming in Perl is like my cooking. The result may not always taste nice, but it's quick, painless and it get's food on the table."
      Did anyone ever tried writing a JVM using Perl? That would be fun, for various values of "fun". :-P

        I don't think anyone did the full on thing. But i found a few interesting dists on CPAN:

        So it turns out, you actually can do in Perl everything you can do in Java, because you can just load the Java code into the perl interpreter.

        "For me, programming in Perl is like my cooking. The result may not always taste nice, but it's quick, painless and it get's food on the table."

      What is so slow about the modern JVM?

      Three thousand years of beautiful tradition, from Moses to Sandy Koufax, you're god damn right I'm living in the fucking past

        What is so slow about the modern JVM?

        Erm... its slowness? - Back in the 90s of the past century, at a customers site we replaced two blue closet-sized boxes proudly carrying three letters with a small pizza box running HP-UX which did all the work and cycles to spare. My workstation at that time was a SPARCstation ELC with 50MHz CPU clock and 48MB RAM. I had perl 4 patchlevel 36 on it, and later the first instance of perl5.

        Today I am carrying a so-called SmartPhone with me which in terms of CPU speed and memory could replace 14 of those pizza boxes. Alas, although it runs a Linux kernel and sports a (presumably) modern JVM, opening my phone rolodex (its Java) sometimes takes about 10 times the time to be responsive compared to the rolodex application I developed on my ancient ELC with perl. That's incredibly slow. Java is, more than anything else, bloat.

        perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
Re: Can Perl do anything Java can do?
by shmem (Chancellor) on Jul 19, 2017 at 12:03 UTC

    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'
      "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).

        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'
Re: Can Perl do anything Java can do?
by haukex (Chancellor) on Jul 19, 2017 at 11:23 UTC

    Having worked with both Perl and Java, I can answer "yes, absolutely, Perl can" to all of those questions. The Comprehensive Perl Archive Network has plenty of modules to help.

    However, since it sounds like you're asking about taking your software and team in two fundamentally different directions, I suspect you'll also have to take into account other questions like, what languages do the programmers on your team know? And if these are long-term projects, you should definitely investigate the two options further, i.e. try writing a program or two in each language to get a feel for the differences.

    There are several Perl GUI APIs, see e.g. Perl GUI (2013). As for HTTP/app servers, many modern Perl web frameworks come with their own servers, but can also be integrated into powerful existing web servers like Apache. See e.g. UP-TO-DATE Comparison of CGI Alternatives.

      Another thing I have been reading in some sites is that Perl is "slow" compared to Java??

      About 10 years ago, in order to fulfill the requirements for a for a final contract to be signed with a big company, the Java Witnesses coded a web interface to the ticket system living inside SAP (CATB). They coded for about two years trying to make everything generic, which led to a compressed source tarball of about 20MB. Signing day drew nigh, and a new requirement dropped in: they had to retrieve yet another datum from the vast SAP data table desert. Two weeks left, and they admitted, that they couldn't do it: too vast the sources and entanglements had grown, and they would have needed far more than two weeks to accomplish the task. I heard about that informally (i.e. gossip), and whipped up the whole crap on a sunday in merely 4 hours using SAP::Rfc (superseded by SAPNW::Rfc) in perl. On monday I presented my solution, which ran in no time compared to the Java solution, with just a fraction of memory footprint, was easily extendable and already did more than the Java bulk. Some bits of CSS fumbling, corrections here and there, and the stuff was up and running.

      So, faster in execution, in development, much easier to maintain and extend. Not that I earned much reward with that - see the parable of the two programmers. The task turned out to be quite easy.

      This again is anecdotal, I know, but also first class witness, and I know I am biased - heavily towards perl, by experience. Java folks tend to overcomplicate things (which leads to bloat, again ;-).


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

        I don't know if your reply was meant for me because you seem to be quoting this node? But I'll reply anyway:

        I dunno, my experiences with Java were not as bad. Whenever I hear "Java is slow and bloated", I wonder how much of that is hard evidence (if I had the time right now I'd run a benchmark or two), and how much of that is a stereotype originating from the days Java was first introduced and it was slow and bloated. Nowadays, with JIT and Java having many of its library functions implemented in native code (kind of like Perl's XS), I really do wonder how true that still is. Java isn't the fastest language of course, but sometimes I feel that the "Java is slow because it runs on a VM" complaint is roughly on the same level as "Perl is slow because it's interpreted". Adding that it's possible to write bad programs in any language, and that Java is in more widespread use than Perl, then there will unfortunately be a larger number of bad programs written in Java ;-)

        I don't mean to rip on your post in particular, I'm just giving my two cents because I'm seeing the "Java is slow" meme in several posts in this thread.

      Back story: Our previous project in Java failed. We have 2 Perl developers who know Perl. I am the Software Manager. We are not fond of Java since it has dozens of frameworks and is too bulky.

      I am doing my research on Perl. The 2 Perl developers CAN teach Perl to our Java devs. But I need some independent information. That is what I am doing here.

      Some more questions I have:

      (a.) Another thing I have been reading in some sites is that Perl is "slow" compared to Java?? What is the truth behind this?

      (b.) Can you create web-services in Perl?

      (c.) Can Perl communicate with an Oracle DB? We use Oracle 11g and 12c as our DB.

      (d.) Can Perl create a daemon that runs on the background, monitors a directory and FTP files that are dropped to the directory? We need to create an app like this.

      (e.) Is it possible to create a Windows or Web applications that can have an icon in the Windows System Tray. We click the icon and the application will open.

      (f.) Is Perl free and Open source?

      (g.) How many "frameworks" does Perl have?

        Another thing I have been reading in some sites is that Perl is "slow" compared to Java??

        Which sites? How did they determine this? It certainly doesn't reflect my anecdotal experience which is the complete opposite.

        Can you create web-services in Perl?

        Yes

        Can Perl communicate with an Oracle DB?

        Yes

        Can Perl create a daemon that runs on the background, monitors a directory and FTP files that are dropped to the directory?

        And a lot more besides.

        Is it possible to create a Windows or Web applications that can have an icon in the Windows System Tray.

        No idea. I wouldn't use that OS if you paid me.

        Is Perl free and Open source?

        I think you would benefit from reading the FAQ. eg: Who supports Perl? Who develops it? Why is it free? and How does Perl compare with other languages like Java, Python, REXX, Scheme, or Tcl?.

        How many "frameworks" does Perl have?

        Plenty. The number changes all the time.

        • a. Have your perl & java guys solve the same problem. benchmark the results, performance and consider the time it took to code it.
        • b. Yes. Mojolicious docuemntation has some nice examples.
        • c. Yes, DBI/DBD::Oracle.
        • d. Yes.
        • e. Web applications don't have system tray icons, they run behind web servers. Win32::SysTray.

        • f. Seriously? You can't look up https://perl.org or wikipedia?. Yes. Your research skills need some work.
        • g. what sort of frameworks?
Re: Can Perl do anything Java can do?
by zentara (Archbishop) on Jul 19, 2017 at 12:05 UTC
    Can Perl be used to create a message broker applications,

    Yes, you can make anykind of socket connections you desire. See IO::Socket::SSL GTk2 server and multiple clients for example

    a FTP file transfer application
    Yes, see commandline ftpssl client with Perl which was quickly written in Perl, when there
    was no available working ftpssl client, which wasn't a binary. Perl
    did the job.

    You should check out what modules are available to you in whatever language you choose. Perl does not do as good of a job with the graphical user interface stuff, or Android development. Perl5 has some excellent but less-known Web interfaces

    What I suggest is prototype your system quickly using Perl, then convert it to whatever you want.


    I'm not really a human, but I play one on earth. ..... an animated JAPH
Re: Can Perl do anything Java can do?
by hippo (Canon) on Jul 19, 2017 at 12:47 UTC
    Can Perl be used to create web-applications like Amazon or Ebay?

    Yes. Both Amazon and Ebay were originally written predominantly in Perl. Over time their language base has broadened and while I have no idea what Ebay uses now, Amazon still relies on Perl for a fair chunk of their operations.

Re: Can Perl do anything Java can do?
by thanos1983 (Parson) on Jul 19, 2017 at 13:23 UTC

    Hello MikeBraga,

    Just to include something that fellow monk hippo point out here Re: Can Perl do anything Java can do?.

    Can Perl be used to create web-applications like Amazon or Ebay?

    Company booking.com is all running on Perl.

    Seeking for Perl wisdom...on the process of learning...not there...yet!
Re: Can Perl do anything Java can do?
by jdporter (Canon) on Jul 19, 2017 at 16:14 UTC

    See BuiltInPerl.com, a showcase of Perl success stories.

    I reckon we are the only monastery ever to have a dungeon stuffed with 16,000 zombies.
Re: Can Perl do anything Java can do?
by cavac (Curate) on Jul 19, 2017 at 12:17 UTC

    As for a message broker, yes. Depends on what you need/want, this can be relatively easy.

    For example, i use my DIY "Clacks" opt-in notifier service to talk in near-real-time between a few hundred processes.

    You can find the relevant source code at the maplat_helpers and maplat_framework mercurial repositories.

    (It's not on CPAN yet. The code is used in production, but doesn't have good documentation yet. Sorry about that)

    "For me, programming in Perl is like my cooking. The result may not always taste nice, but it's quick, painless and it get's food on the table."
Re: Can Perl do anything Java can do?
by eyepopslikeamosquito (Chancellor) on Jul 19, 2017 at 20:36 UTC

    We want to create some applications and want to know the feasibility of using Perl. The other option is Java.
    Why are these the only two options? I mean there are many, many languages/tools that can do what you ask.

    I'm interested to learn the back story/politics behind this question. If you provide more context, we may be able to advise you better.

Re: Can Perl do anything Java can do?
by Anonymous Monk on Jul 19, 2017 at 12:14 UTC
Re: Can Perl do anything Java can do?
by karlgoethebier (Monsignor) on Jul 19, 2017 at 16:21 UTC

    2.: nginx with starman. See also for the proxy setup. Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

    perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

        "...it's worth pointing out that ... This server does not support Win32."

        Yes. You are right. Thank you very much davies. Best regards, Karl

        «The Crux of the Biscuit is the Apostrophe»

        perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Re: Can Perl do anything Java can do?
by BrowserUk (Pope) on Jul 19, 2017 at 21:13 UTC

    No. Java can run in the user's browser. (If any are still fool enough to have that insecure crap enabled.)


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
    In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit
      No. Java can run in the user's browser.

      Perl can do that, too.

      (If any are still fool enough to have that insecure crap enabled.)

      Well, enabling ActiveX controls (required for that) fall into the same category, if not in a worse one.


      Update: Link broken less then 12 hours after my post. See Re^4: Can Perl do anything Java can do?.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
        Perl can do that, too.

        Let's see what's required:

        1. Run your commercial website on IIS.

          Uh huh!

          (Not even MS will do that.)

        2. Persuade *all* your users to install ActiveState Perl; and ActiveState PerlScript.

          Right!

          (Wanna buy our bagles? Okay just find, download and learn how to install this 5GB of sofware. (And then install a C compiler and learn how to use it once AS take the repository for whichever version you installed off-line.))

        3. Persuade *all* your customers that it is safe to enable ActiveX controls.

          You mean that ancient, long deprecated, technology that has has 330 vulnerabilities in the last 10 years (and 2 in this month alone; and probably 1000s if you still find the infor mation for the preceeding 10 years.)

          Mmmmmmmmmm.

        4. Find an insurance company willing to insure your business.

          Maybe you could get funding for the premium from that new kickstarter style site run by philanthopic law firms: FIFFLE. (Funding Idiots For Future Lawyer Employement).

        Riiiight. DCUW(N)CU.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
        In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit
    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1195433]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2019-08-21 16:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?