[HN Gopher] Java in the Small
       ___________________________________________________________________
        
       Java in the Small
        
       Author : crummy
       Score  : 128 points
       Date   : 2024-12-18 20:42 UTC (2 hours ago)
        
 (HTM) web link (horstmann.com)
 (TXT) w3m dump (horstmann.com)
        
       | wing-_-nuts wrote:
       | I remember reading horstmann's books in college and it doesn't
       | surprise me at all that java is the hammer he reaches for given a
       | particular nail.
       | 
       | I have to say I find it an odd choice for small replacements for
       | bash scripts. I think python or golang are probably better
       | choices for that purpose. Java is one of those 'enterprise'
       | backend languages which lend itself to making a _team_ productive
       | over making the individual productive, and I say this as a java
       | / go dev who's most comfortable with java for most backend work.
        
         | ggerules wrote:
         | Dr. Horstmann was my advisor in college, San Jose State.
         | 
         | I just loved his lectures, very dry sense of humor, and
         | extremely funny.
         | 
         | He was just getting started writing books in the early 90s. He
         | has this awesome way of thinking about programming, that I
         | imparted to my own students when it came my turn to teach
         | programming. I wish there some videos of his classes that I
         | could go back to and share with people.
         | 
         | Good website also, https://horstmann.com/
         | 
         | The picture on the website with him in the row boat has a funny
         | story with it. When asked why he is in a row boat, he would
         | reply, "Students are in the row boat with me, learning to
         | program. At some point I push them out of the boat into the eel
         | infested lake. The ones who are clever enough to make it back
         | to the shore will be good programmers." All of this said with a
         | faint hint of a German accent and a sly smile.
         | 
         | If you happen to read this, Dr. Horstman. I made it to shore.
         | Thanks! It has been an awesome journey!
        
         | anitil wrote:
         | > lend itself to making a team productive over making the
         | individual productive
         | 
         | That's a really insightful way of presenting this. I think if
         | that's how I'd been introduced to Java I might even have
         | tolerated it.
        
       | PaulHoule wrote:
       | I learned to code "single file Java" when I was working through
       | Hacker Rank before they added features to the JDK to make it
       | easier. Certainly if you want to do whiteboard coding sorts of
       | problems it is good to know.
        
       | losvedir wrote:
       | I've been using Java 21 for Advent of Code this year, and I've
       | been surprised at how much less clunky it is than I remember.
       | `var` and `record`'s are especially nice for how I like to code.
       | It's still not perfect, but it's not something that I hate
       | programming in now.
       | 
       | These were some neat tricks. I've been using the `java
       | myfile.java` approach for running the AoC problems. I didn't
       | realize the "implicit class" thing where you could have top level
       | statements and methods, though, with the automatic import of
       | java.base. That's pretty slick for this.
        
         | papercrane wrote:
         | Records being allowed in methods has been great for me when
         | doing things like path finding. Makes it easy to write
         | something like:                   record Node(int cost, int
         | row, int col){}         var pq = new
         | PriorityQueue<Node>(Comparator.comparingInt(Node::cost));
        
       | Nijikokun wrote:
       | Java is still great, same for PHP and they have only been getting
       | better.
        
         | lxgr wrote:
         | Great is pretty domain-specific!
         | 
         | Java has been great for larger projects for a while, but I
         | think smaller things like one-off scripts have been firmly out
         | of reach so far.
         | 
         | It's good to see that change, as being able to use it in the
         | small has obvious synergies.
        
       | HaroldCindy wrote:
       | I wasn't aware that single-file Java without a top-level static
       | class was possible now, that + JBang seems quite useful for small
       | tasks.
       | 
       | One nit:
       | 
       | > Python programmers often use ad-hoc dictionaries (i.e. maps) to
       | aggregate related information. In Java, we have records:
       | 
       | In modern Python it's much more idiomatic to use a
       | `typing.NamedTuple` subclass or `@dataclasses.dataclass` than a
       | dictionary. The Python equivalent of the Java example:
       | @dataclasses.dataclass         class Window:             id: int
       | desktop: int             x: int             y: int
       | width: int             height: int             title: str
       | @property             def xmax(self) -> int: return self.x +
       | self.width                  @property             def ymax(self)
       | -> int: return self.y + self.height                   w =
       | Window(id=1, desktop=1, x=10, y=10, width=100, height=100,
       | title="foo")
        
         | qsort wrote:
         | This is obviously valid, but it's definitely more common in a
         | language like Python to just dump data inside a dict. In a
         | dynamic language it's a far more flexible structure, it's the
         | equivalent of HashMap<? extends CanBeHashed,
         | LiterallyWhatever>, which is obviously a double edged sword
         | when it comes to consuming the API. Luckily more rigid
         | structures are becoming more popular at the API boundary.
        
         | bcoates wrote:
         | That's deranged, just use a namedtuple and some functions. Even
         | decorators for something this simple are a code smell.
         | 
         | What do you do when another module needs ymin, inheritance?
         | 
         | OO is dead, leave it buried umourned.
        
       | lxgr wrote:
       | It's of course always a good idea to read the article before
       | posting, but doubly so here - I was getting ready to yell about
       | all of the annoyances making this infeasible to anyone with a
       | less-than-extreme pain tolerance, but it turns out Java has
       | changed a lot since I last used it around six years ago :)
        
       | Shakahs wrote:
       | After years of Python and TypeScript, I've started using Java as
       | my default for everything. It's just so much more productive. The
       | ancient developer memes that Java is slow and clunky don't apply
       | anymore.
       | 
       | Postgres also had a long-held reputation for being slow and
       | difficult, but it made incremental improvements for decades and
       | now it's the default choice for databases.
       | 
       | I see Java in the exact same position, as the Postgres of
       | languages.
        
         | agumonkey wrote:
         | what parts do you enjoy now ?
         | 
         | I do agree that new ecosystems (js for instance) makes you miss
         | some of the old big languages development feel. less churn
        
         | sdf4j wrote:
         | First time I hear those claims about Postgres. Was that the
         | sentiment 30 years ago?
        
           | dannyobrien wrote:
           | It was definitely initially seen as big and cumbersome
           | compared to MySQL, but sentiment shifted.
        
           | Tostino wrote:
           | If say it was only about 15 years ago that the Postgres is
           | slow stuff started dying off. Right around 2010.
        
           | bcoates wrote:
           | 14 years or less. Any version of Postgres before 9.0 was a
           | nightmare to administer as a real production transactional
           | dbms, at least the off the shelf version without a whole lot
           | of tweaking without a (then very rare) pg expert.
        
         | cflewis wrote:
         | The problem with Java since Java 8 has never been Java. It's
         | been about the appalling ecosystem that infected it with
         | reflection frameworks. It was bonkers that "POJO" was ever a
         | thing that had to be defined.
         | 
         | It feels like these frameworks are now just falling away, which
         | is great. I'm not even hearing about Spring anymore, and if
         | there is any reason to not use it, it would be this cringe "how
         | do you do fellow kids?" blurb I just saw on their front page:
         | 
         | > Level up your Java(tm) code
         | 
         | > With Spring Boot in your app, just a few lines of code is all
         | you need to start building services like a boss.
         | 
         | I personally would reach for Go by default, but I have no ill-
         | will to Java.
        
           | MattPalmer1086 wrote:
           | Ahhhhh, yes. Java itself isn't bad and has been getting
           | better. The frameworks made me want to scream.
        
             | arez wrote:
             | which ones specifically? I like Spring Boot tbh
        
               | MattPalmer1086 wrote:
               | Hibernate mostly. Spring too, but it has been a while.
               | Mostly I just find the abstraction isn't worth it .
        
           | qsort wrote:
           | > The problem with Java since Java 8
           | 
           | I agree with the sentiment, but I'd move up to a version with
           | type inference at least. I have nothing against static types
           | and in fact in a vacuum I prefer them, but the particular
           | brand of OO and "weak" generics that Java and C# have feels
           | like filling forms in triplicate. "var" alleviates that
           | significantly.
        
             | neonsunset wrote:
             | Generics in Java and C# are _vastly_ different.
             | 
             | .NET has true generics with full type information and
             | struct type parameter monomorphization which works the same
             | way generics do in Rust.
        
               | qsort wrote:
               | yes, this is true. I was talking more about the UX of how
               | to use them, which in both cases is quite painful without
               | type inference.
        
             | layer8 wrote:
             | Any competent Java IDE automatically generates you a
             | variable declaration from the expression you want to assign
             | to it. It's actually less keystrokes than having to type
             | "var". Unless you only use a simple editor that doesn't
             | perform static analysis, less typing is not a good excuse
             | for using "var".
             | 
             | Conversely, in Java you often use the diamond operator like
             | in:                   List<String> items = new
             | ArrayList<>();
             | 
             | (Half of which, again, is code completion in your IDE.)
             | 
             | That doesn't work with "var". You'd have to write:
             | var items = new ArrayList<String>();
             | 
             | while losing the ability to constrain your variable to a
             | narrower type.
             | 
             | The loss of directly seeing the type information in
             | statements of the form                   var foo = bar(x,
             | y);
             | 
             | should meet a very high bar, IMO.
        
           | gf000 wrote:
           | Spring boot is itself also very different than Spring, so
           | depending on what was your last experience with these
           | frameworks, you might be surprised.
           | 
           | Given, they are still quite reflection-heavy and full of
           | POJOs and annotations, it supports compile-time resolution
           | for many things now.
           | 
           | Also, you would be hard-pressed to find a more productive
           | developer than a well-versed Spring boot guru for typical
           | backend jobs. You might dislike the framework, but credit
           | where it's due, it is a workhorse and the amount of time
           | someone makes a POC, you can make it with spring properly, in
           | a way that you can build your prod app on top. Like, it's
           | easily as productive as RoR and similar.
        
             | p2detar wrote:
             | Serious question - what could Spring Boot give me for
             | POC/prototyping that Javalin or Micronaut couldn't? I
             | really struggle to understand why most of Java shops out
             | there have set themselves on the Boot path. Is it
             | technology-based decision or politics?
        
       | simonw wrote:
       | Wow:                 void main(String[] args) {
       | println("Hello world");       }
       | 
       | I just saved that as "hello.java" and ran it (using OpenJDK
       | Runtime Environment Homebrew (build 23.0.1) which I happened to
       | have on my Mac already) like this:                 java --enable-
       | preview hello.java
       | 
       | This is SO MUCH less crufty than the old "public static void
       | main(String[] args)" thing. I always felt that was a terrible
       | introduction to programming, when Hello World included a whole
       | chunk of boilerplate and a class that didn't need to exist.
        
         | jimbob45 wrote:
         | I disagree. Working through each keyword until you understand
         | the full signature felt great when learning.
         | 
         | It's the Python if __name__ == __main__ trash that was the
         | worst. You'll never understand it and it doesn't fit in the
         | language.
        
           | Comma2976 wrote:
           | In my humble and correct (trumping anyone else's) opinion,
           | they are both garbage.
        
           | exe34 wrote:
           | you don't need it until you get to importing modules.
           | 
           | hello world in python is literally just print("hello world!")
        
             | dvdkon wrote:
             | You don't even need it afterward, unless you want a file to
             | be both an importable module and an executable script.
             | 
             | Arguably you could be a happy Python programmer without
             | this capability.
        
               | jraph wrote:
               | I never understood why people bother with this when
               | writing their python main file, which is never going to
               | be imported because it doesn't make sense in the first
               | place.
        
           | dajtxx wrote:
           | Python seems to have started with 'why do those other
           | languages have all this trash' and then spent the time since
           | then learning why and coming up with worse versions.
           | 
           | I use python a lot these days, and like it, but it's pretty
           | funny seeing stuff like the above and type hints.
           | 
           | I hate not knowing what types a function takes and returns.
        
             | nayuki wrote:
             | > Python seems to have started with 'why do those other
             | languages have all this trash' and then spent the time
             | since then learning why and coming up with worse versions.
             | 
             | This seems true to me too. Examples:
             | 
             | * if __name__ == "__main__": main()
             | 
             | * Private members being marked by convention with leading
             | underscore (e.g. def _foo()) instead of being a language
             | feature
             | 
             | * @staticmethod as a decorator instead of being a language
             | feature
             | 
             | * Duck typing vs. abstract base classes
             | 
             | * Static type hints
             | 
             | * Reference-counted garbage collection seems to be more
             | deterministic than tracing garbage collection and ensures
             | that unreachable resources have their finalizers run as
             | soon as possible... except it's not true.
             | 
             | * Having a GIL instead of being truly multi-threaded from
             | day one
             | 
             | * Various OOP concepts that are much better explained in
             | Java than Python: __eq__(), __hash__(), monitor wait() and
             | notify(), object finalizers, thread safety, weak
             | references.
             | 
             | * Distinction between str and bytes. This is the biggest
             | change from Python 2 to 3 and caused a lot of
             | incompatibilities. Java separated String and byte[] from
             | the start (though the use of UTF-16 is unfortunate).
        
         | p1necone wrote:
         | Really Java has always been kinda okay - the really horrible
         | part of Java was always the "enterprise OOP" programming
         | patterns that were basically a given in any commercial codebase
         | - little things like pointing out the verbosity of a basic
         | single file project are just shorthand for "look at all this
         | shit people have written".
         | 
         | As the adage goes - Java programmers can write Java in any
         | language.
        
         | jjice wrote:
         | Anecdotal, but I had an intro to programming class in high
         | school and the teacher was a wonderful woman, but not a
         | programmer. She didn't know that this was a function
         | declaration or its meaning, so she would just have us repeat
         | out loud "public static void main string box args". I get a
         | laugh whenever I think of that. I hope she's doing well.
        
         | riku_iki wrote:
         | > than the old "public static void main(String[] args)" thing
         | 
         | you forgot surrounding class definition.
        
         | geokon wrote:
         | I haven't written Java in a million years.. so I'm trying to
         | understand better.
         | 
         | But what does this code even mean..? Isn't Java's whole
         | simplifying model that everything lives in "Objects"? This
         | seems to break that fundamental paradigm and makes the language
         | more complicated. If you needed something like global functions
         | then in vanilla Java as I remember you'd stick it into static
         | final Objects that acts as a namespace of sorts. So you don't
         | need to worry about functions floating around in a global
         | namespace soup.
         | 
         | If you're gunna just have free floating functions in your
         | file.. then why not just cut to the chase and have a
         | println("Hello world");
         | 
         | floating in your file..? (I mean... you don't have REPL so
         | maybe that wouldn't be too meaningful...)
        
           | int_19h wrote:
           | It's implicitly still a class, you just don't need to write
           | all the scaffolding to indicate that. The functions are still
           | methods of that class etc.
           | 
           | But, yes, with static imports, you can just write "println"
           | like that and have it work.
        
           | semiquaver wrote:
           | > you don't have REPL
           | 
           | (ahem) https://docs.oracle.com/en/java/javase/23/jshell/intro
           | ductio...
        
         | foobarian wrote:
         | Song version: https://www.youtube.com/watch?v=yup8gIXxWDU
        
       | forty wrote:
       | You might also want to look at scala and ammonite [1]
       | 
       | [1] https://ammonite.io/#ScalaScripts
        
       | brundolf wrote:
       | Very cool to see all these quality of life improvements. I
       | haven't kept up with Java for several years. Still, the
       | dependencies thing seems like an issue (as it is in Python)
       | 
       | Deno has been my go-to scripting tool lately. Similar benefits to
       | Java as used by the OP, but it also allows you to import
       | dependencies directly by URL, which means you can have your
       | script self-define dependencies without a separate manifest file
        
         | qsort wrote:
         | Python packaging continues to be a pain, but you can specify
         | dependencies for single-file scripts with inline script
         | metadata, see:
         | https://packaging.python.org/en/latest/specifications/inline...
        
       | nesk_ wrote:
       | Remembers me the "Java for Everything" blog post:
       | https://www.teamten.com/lawrence/writings/java-for-everythin...
       | 
       | Also, thank you for sharing! I do appreciate Java and I'm glad to
       | see it can be used for scripting nowadays.
        
       | neonsunset wrote:
       | Still long way to go before it reaches .NET levels of
       | productivity (especially so if you use F# for scripting, but C#
       | is no slouch either) :P
        
         | pjmlp wrote:
         | Depends on the platform, some don't have any .NET productivity
         | available. :)
        
           | neonsunset wrote:
           | These platforms are not being considered here nor have much
           | relevance anymore. You cannot seriously claim this unless you
           | don't use the tooling side by side at all.
           | 
           | The difference is so stark it's no longer amusing. Performing
           | setup for complex Java projects has me go through similar
           | steps as if they were written in C++. Performing setup for C#
           | projects of comparable complexity usually requires just
           | cloning and hitting 'dotnet run', much like it usually
           | happens with Rust or to a surprisingly somewhat lesser extent
           | with Go.
        
             | pjmlp wrote:
             | Like my phone, or those used by US military?
             | 
             | I love your identity with .NET ecosystem, to the point of
             | nothing else being in the way.
             | 
             | See latest JetBrains Developer Surrey about platforms.
             | 
             | .NET is a great ecosystem, but lets be real where it stands
             | outside Microsoft shops, across everything that has a CPU
             | on them, and the various ecosystem where sadly it doesn't
             | even get a tier 1 support.
             | 
             | Programming languages are tools, a toolbox has space for
             | plenty of them.
        
             | mike_hearn wrote:
             | Are you comparing "complex Java projects" against just
             | ordinary "C# projects"? Because ordinary Java projects will
             | also be "./gradlew run" or the Maven equivalent, that's
             | nothing special.
        
               | neonsunset wrote:
               | And in many other situations "./gradlew run" just doesn't
               | work. Hell, Gradle does not even let you quickly scaffold
               | it without pre-existing knowledge and community advice!
               | (if you want to avoid pitfalls and have the best
               | "streamlined" experience) Something that is not an issue
               | in Rust or Go. Maven is even worse.
               | 
               | Meanwhile I can 'git clone https://github.com/ryujinx-
               | mirror/ryujinx && cd ryujinx/src/Ryujinx && dotnet run -c
               | Release' and it works on the first attempt (though takes
               | a moment to pull nuget packages, it's a big project).
               | 
               | The Java ecosystem has incredible projects from the
               | technical point of view (GC implementations, OpenJDK's
               | JIT compiler), but the tooling and application packaging
               | and distribution seem like the painful parts.
        
         | gibspaulding wrote:
         | I'd be curious to hear more about how you're using F#? I've
         | previously used Python for scripting, but just started
         | developing for a company pretty deeply entrenched in .NET.
         | Currently they're migrating a lot from VB to C#, but I've
         | missed having a handy scripting language like Python for small
         | tools or test applications. Do you think F# could fill that
         | roll?
        
           | stackskipton wrote:
           | Powershell is probably best fit for that role. You have to
           | learn a new scripting language but since it runs on .Net you
           | can actually bring in .Net Classes if you need a little more
           | power.
           | 
           | https://learn.microsoft.com/en-
           | us/powershell/module/microsof...
        
           | neonsunset wrote:
           | It should be able to! F# has "gradual typing" and full type
           | inference which means you often do not need to specify the
           | types at all, and it also happens to be whitespace-sensitive
           | language much like Python is. Both of these aspects should
           | make it feel quite familiar while also giving you full
           | advantages of static typing.
           | 
           | One thing to note is I find `dotnet fsi {some script
           | name}.fsx` taking more time to start than ideal - up to 800ms
           | is just too much, normal .NET applications usually start in a
           | fraction of this.
           | 
           | I recently posted a submission here for "FSharpPacker"
           | written by my friend that lets you compile F# _scripts_ to
           | standalone applications (either runtime-dependent, self-
           | contained or fully native binaries, much like Go), it also
           | has some comments on getting the best mileage out of it:
           | https://news.ycombinator.com/item?id=42304835
           | 
           | Probably the best feature that also comes with scripting
           | (both C# and F#) is "inline" nuget references e.g. #r "nuget:
           | FSharp.Control.TaskSeq" which will automatically pull the
           | dependency from nuget without ever dealing with manually
           | installing it or tinkering with build system in any other
           | way.
           | 
           | Some additional links:
           | 
           | https://learn.microsoft.com/en-
           | us/dotnet/fsharp/tools/fsharp...
           | 
           | https://github.com/dotnet-script/dotnet-script (C# is _also_
           | a quite productive language for scripting and small programs
           | because of top-level statements, record types, pattern
           | matching and many other functional features though perhaps
           | not as strongly represented as in F#, it 's just very
           | unfortunately abused in enterprise world, with teams often
           | going out of their way to make the code far more bloated than
           | necessary, against the language design intentions)
           | 
           | https://github.com/waf/CSharpRepl
        
           | taberiand wrote:
           | F# is a leap if it's your first functional / ML style
           | language (but worthwhile). Modern C# is good for small tools
           | and scripting, there is the dotnet-script tool for running
           | single .csx files
        
       | singpolyma3 wrote:
       | > Java has many features that make it well suited for large,
       | long-lasting projects
       | 
       | Already disagree, haha
        
         | whtsthmttrmn wrote:
         | I'll bite. Explain, please.
        
       | mongol wrote:
       | I don't think Java is fit for "the small". And there is nothing
       | wrong with that. My go-to language for "the small" is Go. Java is
       | good for enterprise heavy-lifting, not for quick and nimble
       | tools.
        
         | Pet_Ant wrote:
         | For the small I like Groovy. Especially as Grapes is like Maven
         | but in annotations that you include in the script file. Being
         | Java-based means that if it goes from "in the small" into
         | something larger you are already on a stable foundation.
        
         | jknoepfler wrote:
         | and you get a nice little portable binary that doesn't force
         | someone to install a compatible version of an
         | interpreter/virtual machine to run.
        
           | mongol wrote:
           | Exactly
        
         | tmiku wrote:
         | Can you tell us about how you use Go in the small? I like Go,
         | but it doesn't strike me as particularly nimble for scripty use
         | cases like this - error handling is part of it, but I know
         | that's fixable with the Must() pattern.
        
           | mongol wrote:
           | I just write a small Go program. I agree that error handling
           | is a weak point, but the tooling is well integrated. The
           | article mentions that Java does not know about Maven. The go
           | tool is much more versatile in that sense.
           | 
           | Also, go run is almost like running a script.
        
       | dajtxx wrote:
       | I started with Java 1.0 and thought it was great. I still do,
       | although I haven't used it since 2020.
       | 
       | The only thing I don't like is how there is no built-in JSON
       | package which seems like a necessity these days.
       | 
       | Removing the public static void main(String[] args) business
       | seems like pandering to a non-existent audience, or at least a
       | miniscule and insignificant one. Anyone who is going to use Java
       | for a real project is not going to be worried about that, and
       | anyone who thinks that's too difficult to deal with is never
       | going to be a good programmer anyway.
        
         | Zu_ wrote:
         | The last part seems like a very 'gate keepy' point of view.
         | 
         | If you want to introduce someone to programming, you probably
         | don't want them to worry about what all those 'magic words' do.
         | 
         | At least for their first steps, they won't need to know what a
         | class is or what `public` and `static` mean.
        
           | znpy wrote:
           | > If you want to introduce someone to programming, you
           | probably don't want them to worry about what all those 'magic
           | words' do.
           | 
           | I learned Java when i was 15 or 16, reading some random book
           | first and then I stole 35 euros from my mother's purse and
           | bought a copy of "Java how to program" by deitel and
           | deitel[1]. The recommended version at the time was Java 5,
           | and the SJCP certification was still issued by Sun
           | Microsystems.
           | 
           | I can tell you, "public static void main" is not going to be
           | the problem.
           | 
           | [1]: looking back (i'm in my 30ies now) sometimes I wonder if
           | i would have been better off buying weed or alcohol (or both)
        
             | acbart wrote:
             | So you believe that your experience is a universal one for
             | all learners? Cognitive load is a real consideration in
             | teaching, and having to ignore and filter text is
             | challenging for some folks.
        
           | jknoepfler wrote:
           | Yeah, you want to start with basic imperative programming
           | with as little cargo-cult nonsense in the way as possible.
           | 
           | Your csci 101 kids will not benefit from unpacking what it
           | means to compile an object-oriented language down to bytecode
           | to run on a virtual machine. It's not that it's not valuable
           | knowledge, they just won't have the context to make
           | meaningful heads or tails of it.
           | 
           | related: I still puke a little remembering the requirement
           | that students work on assignments in emacs on terminal
           | machines rather than their text processor of choice(which was
           | fine for me, but why on god's green earth would you put
           | usability warcrimes like 'hjkl' in the way of someone just
           | starting to learn? No wonder nobody in the early naughts
           | wanted to learn to program...).
        
             | dustyventure wrote:
             | A lot of people learn to program from declarative languages
             | like spread sheets. We should all be happy we have access
             | to defective versions of assembly at too high a level but
             | be angry that we had to use too low level an editor?
        
           | smaudet wrote:
           | Agreed.
           | 
           | I still feel like the author is missing the forest for the
           | trees. Bash is not great to write e.g. a red black tree in or
           | do complex image processing, but you don't have to maintain a
           | Java install, download libraries, or setup an editor with an
           | LSP (and really, calling java script.java 10 asdf? Why do I
           | need to invoke Java at all? At that point, I'm probably going
           | to wrap it in a script anyways...)
           | 
           | Python has its own issues but it's a small, embedded install
           | that you don't have to accept 5 different licenses for and
           | worry about it being able to get the same version...
           | 
           | And bash? That's what pacman -S jq is for - anything I can't
           | easily do in bash or batch I just offload to a small utility
           | written in python or rust.
           | 
           | Java is, at it's core, just too heavy, IMO.
        
           | jraph wrote:
           | I think gp is right, and I don't think it's gatekeeping. I
           | thought this about Java, it was easy to criticize its
           | verbosity, but I realized how insignificant this is when
           | actually practicing it. There's probably way more interesting
           | and deeper criticism to make about Java.
           | 
           | About the first steps of a newcomer, there's always going to
           | be some level of "don't worry about this now, we'll see what
           | this means later" for any language. I remember this to be the
           | case for every tutorial I read to learn a language. And it's
           | fine, as long as you can try stuff and it doesn't get in the
           | way.
        
         | cbsmith wrote:
         | [delayed]
        
       | scotty79 wrote:
       | For error handling they could add error propagation operator `?`
       | from Rust. In Java it could propagate "throws" from the
       | expression it's applied to the signature of a method that
       | contains it. In Rust it's a bit awkward becuse you need to adjust
       | return type. Since Java tracks exceptions separately it would be
       | completely unobtrusive and ultraconvenient.
       | 
       | As a cherry on top they could add treatment of :\n<INDENT> and
       | <OUTDENT> as { }
        
       | deergomoo wrote:
       | It's not a popular choice for it, but PHP is also fantastic for
       | the sort of things described in this article. A relatively recent
       | version is pre-installed on many *nixes, it has a decent enough
       | (and gradual) type system, and standard library absolutely chock
       | full of functionality (albeit very self-inconsistent in naming
       | and structure) for dealing with files, JSON, making network
       | requests, etc.
       | 
       | And because it's not compiled, you can just whack a hashbang at
       | the top of the file and chmod it to be executable.
        
       | AtlasBarfed wrote:
       | Groovy is still far far far better at cli scripting in javaland.
       | 
       | You don't even need main methods and class wrappers, can import
       | libraries with annotations with Grape, etc.
       | 
       | The real failing of cli and scripting in jaba and groovy is
       | running cli commands with access to stdin stdout stderr streams.
       | I have figured out the dark art for groovy but it takes quite a
       | few stack overflows to get there.
        
       ___________________________________________________________________
       (page generated 2024-12-18 23:00 UTC)