4 ms·
You could make the same argument about Unix, but I still say that with great power comes great responsibility. If you can't handle the responsibility maybe you
by sjs 15y ago
You could make the same argument about Unix, but I still say that with great power comes great responsibility. If you can't handle the responsibility maybe you should use watered down tools. That's somewhat bleak though and following that logic you end up with Java. Java is not the worst language on Earth but I doubt it's your favourite and no one writes it w/o a code generating and refactoring IDE.
- arkitaip 15y agoThis is your selection bias speaking. Tons of people LOVE to code in Java or the similar C# for that matter because that's the most suitable tool they have.
- RodgerTheGreat 15y agoThis 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.
- chimeracoder 15y ago> 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!
- hmottestad 15y agoOne 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"); } }
- noblethrasher 15y agoC# 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 https://github.com/noblethrasher/Prelude
- sjs 15y agoThere'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.
- wr1472 15y agoI 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.
- palish 15y agoHey, 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 http://pastebin.com/R47bwDZx and save it into a new file called "test.xml" 3) copy and paste http://pastebin.com/Ut5dKBkn 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.
- amcintyre 15y agoYou 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.)
- Kliment 15y agopyInstaller is a pretty good multiplatform alternative, but I still use py2exe on Windows because it's incredibly robust.
- Xurinos 15y agoYet 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.