Hacker News new | past | comments | ask | show | jobs | submit login

This is both glib and anecdotal, but Java is one of my favorites and I never write Java with an IDE. It has an extensive standard library that I can count on having available without requiring users to install optional packages, it's easy to write portable code and I can write software for everything from a cheap feature-phone to a high-end server.

There's a lot of horrible Java code on the internet, mostly because there are tons of people writing Java. Nevertheless, in good hands, Java can be quite elegant and succinct.




> Nevertheless, in good hands, Java can be quite elegant and succinct.

Could you elaborate, perhaps with an example? Not trying to start a flamewar or anything - but I honestly can't imagine a case where Java is succinct relative to other languages. And as far as elegance goes, Java is so overly verbose and fixated on classes ('too many classes? there's a class for that!') that I have a hard time thinking of it as elegant.

But then again, maybe I'm just used to reading bad Java code everywhere, and you've been lucky enough to find the good stuff!


There's no way to reduce something like:

    runOnUiThread(new Runnable() {
        @Optional
        public void run() {
            // ...
        }
    });
It's just the nature of the language. I honestly don't mind recent versions of Java all that much but without an IDE I would lose my mind in about 3 seconds.

And once you start writing something significant or that needs to work cross platform say hello to design patterns to work around the straight jacket.

I'll take Lisp, JavaScript, Ruby, or Python any day of the week. All languages have warts but to me it seems that Java has warts by design.


One of my favorite things to do in java. Save anything to XML, it even handles all the objects your objects are pointing to. All you need to do is make your objects serializable. Then java handles everything else using reflection.

  public void saveAll(Object[] objects) {

	File file = new File(filename + ".xml");

	try {
		BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
		XMLEncoder xenc = new XMLEncoder(bos);

		for (Object o : objects) {
			xenc.writeObject(o);
		}

		xenc.close();

	} catch (FileNotFoundException e) {
		System.err.println("File not found");
	} catch (IOException e) {
		System.err.println("Some other error");
	}
  }


C# also gets knocked for verbosity (though it's a bit better than Java). But with manifest typing (which is optional since C# 3.0), judicious use implicit cast, and `dynamic` the language can be made concise and elegant.

An example from my library[1]:

    SqlCommandEx sql = "select * from person";

    foreach (dynamic p in sql)
    {
        var full_name = p.first_name + " " + p.last_name;
        var age = ((DateTime)p.dob).YearsAgo();

        //etc
    }
    //automatically disposes the connection

[1]: https://github.com/noblethrasher/Prelude


I don't know Java, but it's often worth trying this sort of exercise out. I'm open to the idea it might be perfectly possible.

I once took one of Peter Norvig's Python programs (a spelling corrector) and converted it into VB.NET, just to see whether VB was as succinct as Python. Turns out it is:

http://www.stevecooper.org/index.php/2010/11/10/vb-net-and-p...

Or finding out that C# anonymous functions are more concise than Haskell. Thing is, sometimes these things surprise you. Languages do get reputations that are hard to shake.


I would suggest reading Effective Java by Josh Bloch, it has some great tips on how to write code and design APIs as well as nicely structured sample code. I'm a much better developer (not just in Java) for it.

Also browse some of the core Java source code to see really elegant implementations by him.


Hey, that is pretty awesome. I had zero Java experience, but I felt inspired by your post, so I searched "java without ide" and got an XML parser up and running in approximately 20 minutes.

For the curious reader, here's how to do Java entirely from the command line:

1) install the JDK and add its "bin" directory to your PATH. For me this was "jdk1.7.0_02/bin"

2) copy and paste http://pastebin.com/R47bwDZx and save it into a new file called "test.xml"

3) copy and paste http://pastebin.com/Ut5dKBkn and save it into a new file called "ReadXMLFile.java"

- note, this is not my code. It's just a snippet I found from the 'net. Feel free to clean it up. =) My goal was "to get up and running as quickly as possible". Production code would be cleaner than this.

4) run these commands:

  javac ReadXMLFile.java
  java ReadXMLFile test.xml
And the XML file is parsed!

So why go through all this trouble, when you could just write it in Python?

Deployment comes to mind as one reason to go with this approach; fewer systems have Python installed than Java runtime.

So therefore when you deploy your app, you'd have to either 1) make customers install Python, or 2) (more likely) ship the contents of the "Python27" folder along with your Python app, and invoke your app via a shell script, or something. I'm not sure.


Deployment comes to mind as one reason to go with this approach; fewer systems have Python installed than Java runtime.

I would like to see proof of this. Perhaps Windows has fewer Python installs, but I would find it hard to believe that there are more Linux systems out there with Java (which most distros don't install by default) than python (which more systems do install by default).


You can bundle a Python program up into an executable with things like py2exe and cx_Freeze, and it will do most of the grunt work of bundling up any necessary dependencies (scripts, stdlib stuff, DLL's, etc.) into the .exe.

(It's been a while since I used either of those tools, so there may very well be other alternatives around now.)


pyInstaller is a pretty good multiplatform alternative, but I still use py2exe on Windows because it's incredibly robust.


At uni we first learned to program java using just the command line and emacs.

Though working on a big project or just simply wanting to get up and running fast a good text editor or an IDE is so nice to have. I hate having write my own getters and setters, or just simple the psvm method.


Yet I have had trouble with having the "right version of Java runtime" installed in order to run programs, especially on Mac OS X where you sometimes cannot upgrade Java without upgrading the OS. I think there is still an installation/compatibility issue to consider. No free lunch.


Is that more a deficiency of MacOS than of the JRE?


I see it as a reminder that one still needs to worry about deployment because of OS version limitations, lack of upgrades, etc.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: