Comment by bheadmaster

2 years ago

In my experience, Java is a nightmare the moment you try to do anything beyond what C++ can (easily) do.

Which would be?

  • Ok, here are two examples on the top of my head, of fairly trivial programs that are a pain to do right in Java.

    1) A program that copies all data from standard input to the standard output. Try to write this without Googling. Simple enough, eh?

    2) A program that serves as a middleware between servers and clients, both of which are behind NATs so they connect to your middleware, using gRPC methods. Servers use gRPC streams to maintain a connection, send their ID as the first message, receive request messages, and send reply messages. Clients send ID and request in a message, and receive reply message.

    I hope you're willing to show me how wrong I am by writing the code :)

    • 1 is really trivial and took me like 5 seconds to write:

          public class Test {
              public static void main(String[] args) {
                  System.in.transferTo(System.out);
              }
          }
      

      2 is anything but trivial in any language, unless it is some kind of a language specifically designed to build gRPC programs.

      Never versions of Java are quite pleasant to work with. There are a lots of quality-of-life improvements (switch expression, multi-line string literals, string templates (currently in preview), lots of useful stdlib APIs), as well as quite fundamental additions like Loom.

      edit: formatting, explanations

      6 replies →