Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Java Recommendations for a Perl developer

by talexb (Chancellor)
on Jun 17, 2020 at 02:12 UTC ( [id://11118156]=perlmeditation: print w/replies, xml ) Need Help??

I'm currently doing Perl development, but there's a fair bit of Java code at work .. so I'm wondering if any monks can recommend a book, website or approach they found useful when getting up to speed.

My background in Perl started in about '98, after about 15 years of developing C (with a few years of Pascal thrown in for good measure). Before that, I did development in a variety of assemblers (x86, 68000, 6809). I never did any C++, so any OO nomenclature I've picked up has been via Perl's take on OO.

What I've seen of Java is that it's very hierarchical, and is also exception based -- Try::Tiny seems to neatly encapsulate the try / catch of Java.

Alex / talexb / Toronto

Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Replies are listed 'Best First'.
Re: Java Recommendations for a Perl developer
by jo37 (Deacon) on Jun 17, 2020 at 22:04 UTC

    Being payed as a Java developer, I'd like to point to some circumstances beyond the language, which is embedded in some kind of ecosphere in real life. In my case this consists of Maven and Spring. There are others, but these might be representative.

    In such a world, dependency and complexity are separated into these two. Solving a specific task may end up in finding a suitable maven artifact for that task and then configuring it within Spring. I may end up with maybe some tens of lines consisting of Java code and configuration after a few days of work. (I'm sometimes joking about my own performance being measured in "lines per week", which may be less than 10.) The Java skills required for this kind of job are minimal. Handling Maven and Spring are the real challenges.

    Greetings,
    -jo

    $gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$
Re: Java Recommendations for a Perl developer
by Arunbear (Prior) on Jun 17, 2020 at 16:51 UTC
    Some book recomendations: An article on some productivity enhancing frameworks.

    Re the OO mechanisms, if you can drive a manual (Perl), then driving an automatic (Java) shouldn't present too much of a challenge. I learnt Java before learning Perl, so this was reversed for me :)

Re: Java Recommendations for a Perl developer
by davido (Cardinal) on Jun 17, 2020 at 18:37 UTC

      TL;DR: “I like it because it’s braindead and that’s a nice change of pace sometimes.” :P

Re: Java Recommendations for a Perl developer
by bliako (Monsignor) on Jun 17, 2020 at 11:38 UTC

    I love Perl OO because it is bare-bones and does not push you to do things. I think the other end of the spectrum is Java which probably should have been invented in 1933. (In fact this Jawa_Moto was invented in 1929.)

    Exceptions in Java and Perl are similar semantically. But exception objects are thrown in Java. For which the Perl equivalent is explained here : https://www.perl.com/pub/2002/11/14/exception.html . And that's a good idea. Of course Java's beauraucracy has an Exception class for each and every conceivable failure in machine activity both on Planet earth and extra-terrestial territories (I am sure somewhere the idea is or has been hatched: HALCantDoThatException). But don't let that scare you because you can do away with using the parent Exception class for everything (though it could be frowned upon).

    The other thing is Java Generics (sort of equivalent idea is C++ templates). I mention this because Java is strictly typed and that can hit a Perl programmer. Each variable must have a type. And each method accepts and returns strictly typed objects/scalars. Where this paradigm fails is when trying to implement general methods for, for example, sorting. And that's where the Generics come in. And that's where the "pollution" of Java with new semantics starts and never ends... latest addition the lambda expressions which lead to code like this: IntStream.iterate(1, i -> i < 100, i -> i + 1).forEach(System.out::println); which is the Marquee's De Sade way of printing in a loop. Personally, it reminds me of assembly.

    Java has excellent, IMO, documentation framework, javadoc. Similar to pod. And it's worth getting to know that before anything else.

    One other good thing in Java is the Interface notion. Which allows completely unrelated classes to be treated as similar wrt just one aspect of their operation. For example you can have a "stringable" interface to make sure that all classes which implement it have a stringify() method. And so you can say class1 A; class2 B; print(A); print(B) without using Generics, because both class1 and class2 implement the interface and print() is assured that it will find a stringify() method to call in both A and B. This is a great feature which avoids the mess of multiple inheritance (not supported in Java) with all the benefits, including avoiding situations like A.stringify(); ... no such method exists . There is also the Comparable interface (requiring the existence of method compare(A,B)) which allows to compare unrelated objects.

    Java recognised the importance of regular expressions (just like Perl) and supports them well. However, unlike Perl, there is boilerplate. So, this is another field I would investigate to be comfortable and make the most use of, just like in Perl. Also, Java recognised early the importance of some basic "geeky" data structures like Hashtable, (Tree), etc. (which Perl also did and it was one of its great contributions to the world and a revolution really whereas C++ didn't dare to do that when it did matter.) and are supported really really well.

    Finally, Java comes with its own Graphical toolkit. Which allows you to write multiplatform GUIs. Java will also open a door into the Android apps world.

    bw, bliako

Re: Java Recommendations for a Perl developer
by Anonymous Monk on Jun 24, 2020 at 15:49 UTC
    One strategy which consistently helps me when faced with an unfamiliar language or dialect is ... GitHub. On that site you can very quickly find debugged(?) source code in almost any language. Find things which do things that you already know how to do in Perl, check them out and compare them. While the languages are not directly comparable – not at all, in this case – the tasks being performed by each, are. And this can give you a handle on the new language, as well as the different ways that different programmers do the same things.
      This also gives you an easy way to exercise the new SDK because here you have a program that is supposed to be error-free and which may also be accompanied by instructions as to how to build and run it. So, all you have to do is build and run it!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-03-29 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found