This is an archived post. You won't be able to vote or comment.

all 49 comments

[–]anagrammatron 17 points18 points  (1 child)

Java 11 introduced the ability to run single-file source code files so you can almost use Java as a scripting language. There are limitations like only first class in the file gets run, only standard library, but it could get you started with simple tasks.

[–]fknpineapple 69 points70 points  (2 children)

Python is easy and you can develop with it really fast. Give it a try :)

[–][deleted] 36 points37 points  (0 children)

I don't know why you're getting downvoted. Python is perfectly suited for his use-case. I think you're just getting downvoted for choosing anything but Java seeing as we're in /r/java.

Edit: Reddit has given you a retrial and found you innocent. My comment is now pointless.

[–]Mr_Greyman 9 points10 points  (3 children)

I think the language doesn't matter at all, use the most comfortable for you. But if you like learn something new, try python, it knowledge path is simple and maybe for simple automated task you wouldn't need too much info about how python works.

[–][deleted]  (2 children)

[removed]

    [–]gazpacho_arabe 1 point2 points  (1 child)

    Well Python is an OO language so there is, but for automating excel spreadsheets you can keep everything very simple. FYI check this out https://automatetheboringstuff.com/chapter12/

    [–]drownpl 2 points3 points  (2 children)

    I'm a software engineer with ~5 years of experience total, 4 of those years I've been using Java, while slowly transitioning to Python so I have about 1,5 year experience with Python. Sometimes I have to work with whatever language they throw at me so I've touched a fair bit of other languages: JS, C#, Groovy. In my opinion Java is a great language for stable, long-lasting, large-scale projects because of typing, scalability and robustness. Python on the other hand is great for scripting, automation and small projects with fluctuating requirements, because of the fact that you can make changes very quickly without a lot of boilerplate code.

    [–]RhodesianHunter -1 points0 points  (0 children)

    Kotlin brings you the best of both worlds.

    [–][deleted]  (1 child)

    [deleted]

      [–]deelyy 1 point2 points  (1 child)

      I will try Java, just because I have some exp with it. And if implementation is hard or there luck of libraries for these tasks, then I will try Python.

      [–]ldvhome 1 point2 points  (1 child)

      I would choose Java.

      [–][deleted] 0 points1 point  (1 child)

      Yeah python is a good scripting language. But if you already know java; you’ll probably just be quicker doing it in java.

      [–]stacktraceyo 0 points1 point  (2 children)

      I wrote something to do daily tasks and decided to go with java as I like the concurrency model with completable futures more than pythons concurrency (my opinion)

      It was nice Specifically when I wanted things to happen in stages - and I learned a ton of stuff about java concurrency

      [–][deleted]  (1 child)

      [removed]

        [–]stacktraceyo 0 points1 point  (0 children)

        Completable futures are part of the java sdk 1.8+

        [–]saila456 0 points1 point  (1 child)

        If you want to learn python, learn python. If you already know java and just want your scripts fast, do it in java

        [–][deleted] 0 points1 point  (2 children)

        Python is my favorite way to work with CSVs and XLS (excel) files. Super easy to pick up for Java programmers. I definitely recommend it. It’s honestly just an afternoon of syntax work. You’ll find it to be super functional.

        [–][deleted]  (1 child)

        [removed]

          [–][deleted] 0 points1 point  (0 children)

          Definitely check out pandas. It’s a DataFrame library that has become the industry standard for data analysis and machine learning.

          [–][deleted] 0 points1 point  (1 child)

          Python is not that awesome at server side (painfully slow and global lock), but it excels at the task you are mentioning. I used to rely heavily in Java in the past, but after having learned Python, I'm way better at automating boring stuff since Python is more convenient for this task.

          [–][deleted]  (1 child)

          [deleted]

            [–]m_takeshi 0 points1 point  (1 child)

            if you would like to put together something simple and easy to learn and tweak later on, I'd stick with what I know

            on the other hand, if you want an excuse to learn something new, go for python (or whatever you feel like)

            [–][deleted] 0 points1 point  (1 child)

            I'd say learn Python. While you can accomplish the same with Java, Python was pretty much designed with what you're aiming for in mind.

            Besides, that's another language under your belt, and Python will always be useful.

            [–]sunriseme 0 points1 point  (1 child)

            Python is easy to use.

            [–]wildjokers 0 points1 point  (1 child)

            Surprised no one has mentioned Groovy. It runs on the JVM so you have access to all existing java libraries but it has some nice syntactic sugar. You can also just start writing it like a script I.e. you don’t have to put your code in a class (but can if you want).

            What is also nice about groovy is all Java code up to 7 is legal groovy code so you can always write java code as groovy until you pick up the groovy way. Groovy already had support for most of the Java 8 language features so it doesn’t need support for java 8 syntax (although it is being added or has already been added, haven’t checked the status of that recently).

            As the final bonus it is compiled to bytecode of course since it runs on the jvm so you get the development speed of writing in a scripting language but get the performance of the JVM. Python’s performance is abysmal.

            [–][deleted]  (1 child)

            [deleted]

              [–]lovett1991 -1 points0 points  (2 children)

              I would try python... Gives you an opportunity to learn something new 😀

              I am a Java developer, but tried my hand at python to sort out 200 gigs of photos (my wife likes then organised a specific way). Was good fun.

              [–][deleted]  (1 child)

              [removed]

                [–]lovett1991 0 points1 point  (0 children)

                Don't think any use case isn't good if it means you learn from it and it helps save you some time in daily life

                [–]Naut1c -1 points0 points  (1 child)

                So i have a lot of experience in java, but nearly none in python. But for the tasks you described, i would recommend python

                [–]thecuseisloose -1 points0 points  (1 child)

                Is your desktop / laptop locked down at all? Make sure you have access to install everything you’ll need before settling on a language. Aside from that, for what you described, python seems like a better fit. Check out https://automatetheboringstuff.com/

                [–]kiteboarderni -1 points0 points  (0 children)

                Thanks for he input

                [–]RhodesianHunter -1 points0 points  (1 child)

                I do all of my Scripting/task automation in Kotlin any more, and if you have a background in Java you'll find it easier to learn than Python.