Java for Python programmers
interactivepython.org
interactivepython.org
Sounds like they hated Java rather than specifically Apache Groovy, which is really a scripting language for systems already built with Java code.
The free IntelliJ edition is somewhat limited but perfectly usable for core Java.
I personally prefer Netbeans but then again I choose Linux or even Windows over Mac so there goes my credibility ;-/
You might know all this but for the benefit of thise who don't:
I guess you think in another way in an IDE: often you don't replace text (unless you are specifically updating comments or strings) - you rename variables.
Example: the IDE knows about scoping rules etc so even if someone adds a local variable that shadows a field (BAD) the IDE will understand and only rename one of them when I do a rename.
For me I find the IDE is more than worth it. Keybindings are a bit different but can be adjusted so I rarely need to use mouse or touchpad. And with Netbeans at least, but I suspect all big three, regex search replace is there if I need it.
I think that's true, but more for GC-based languages than ones that are used for systems programming. Rust, C++, and to a lesser extent C all require a lot of learning to know what not to do at the language level.
The project: http://yosaiproject.github.io/yosai
Would you read blog posts about porting Java to python if I wrote them? I was considering applying to talk about this at PyCon.
I don't use C++ so I could be way off base, just putting forth a possible explanation
Oh the fun of writing CORBA and DCOM....
Also, for me the major difference is that, in C++, you have the books to learn to write C++ and then the books to learn to write good C++ code (Scott Meyers' books) which I would say are incredibly important, unlike in any other languages where you might do well without these types of books.
More differences off the top of my head:
* Java gets a lot of benefit from having Object as the base class of nearly everything. It would be a long write-up to explore all the implications, but suffice it to say that the new C++ `any` and `variant` are attempts to get some of the features that Java has been taking for granted for decades.
* C++ is full of Undefined Behavior, which officially can do anything up to and including Launch the Missiles. Undefined behavior can be caused by something as innocuous as using an iterator the wrong way.
* C++ has barely any reflection mechanisms, which sounds like no big deal, but it prevents things that Java programmers take for granted, like high-powered debuggers, standard off-the-shelf database abstraction layers, and dependency injection mechanisms.
* C++ has value semantics, not reference semantics. That means that `SomeObject a = b;` is a copy by default. Sometimes. You can write SomeObject to behave either way. Or in some quirky (probably broken) combination of the two. This seems like a little thing, but it has wide implications in all sorts of design decisions.
* On the plus side, C++ culture includes determinism in cleaning up after yourself. This is related to, but different than, manual memory management. C++ has never needed a `finally` keyword and there's a good case that C++ is better for it. But it does mean that some things are subtly harder, like proper use of exceptions. C++ coders talk about 'exception safe code', a term I don't hear about in Java conversations all that often.
* Java is OOP with some functional stuff mixed in. C++ is typically similar, but the "modern C++" style is increasingly moving toward something... else? Something more like the STL and less like adventures in class taxonomy.
There are a lot more differences than that even, but maybe that will give everyone a flavor for how it's different. It's very different.
Counter point, C++'s templates and preference for value types means that downcasting is rarely needed. `variant` also has no equivalent direct equivalent in Java, because it can only be "downcast" to one of the named variants whereas `Object` can be downcast to any type in the program.
> * C++ has barely any reflection mechanisms, which sounds like no big deal, but it prevents things that Java programmers take for granted, like high-powered debuggers, standard off-the-shelf database abstraction layers, and dependency injection mechanisms.
C++ prefers to do its metaprogramming at compile time. For instance you can get type safe sql[1]. C++ added features needed to do this kind of work only recently in C++11, and has not had the time or the guidance from the language committee for these types of libraries to gestate. Whereas Java has standardized library interfaces for just about anything.
Regarding debugging, C++ has excellent debugging tools. While its true Java can give the debugger more information, C++ gives you more predictable execution (by not having a JIT) which can make debugging easier.
Dunno if that's a counterpoint. I'll agree everything you said there. I was saying Java uses the downcast in a lot of situations that C++ doesn't. And it uses downcast to achieve features that are not there or not as developed in the C++ ecosystem. It looks like C++ is ready to catch up, but these things need to percolate through the library ecosystem over time.
> C++ prefers to do its metaprogramming at compile time.
Terminology is a little muddled here, but I was talking about both compile time and run time metaprogramming. C++ has little support for either while Java has a pretty robust system for each. Java has things like JMX, JMS, and JDBC Template as standard things while C++ has at best a hodge-podge of things that don't necessarily play nice with each other.
Yes, because [smart] pointers, memory [de]allocation and all that stuff is just as easy as "new Object()" and forget the rest. Not to mention the Java collections library vs. STL.
So IMO it's not a valid reason for a Python dev learn Java over C++
You format your code anyway, right? So what's the difference if it actually means something?
I'm personally keen on using % on vi or clicking on the braces for selecting scope in Eclipse and ACME. I also find them aesthetically appealing much like Lisp parenthesis.
The indentation works, more or less, but imho layout should be in a coding standard document not in the language specification. The problems I've had with Python's significant whitespace are maimed lambda functionality and for one liners (limits to if/else/loops/etc without braces).
(And I believe that import braces comment is a bit of a joke, it gives an error message "not a chance" iirc. :-) )
Why, in this day and age, learn Java unless you absolutely must? (which you probably will, at some point, but if you're lucky, maybe avoid it). It was a pretty miserable language to begin with, and has since been surpassed in just about every way.
If you're thinking about using Java for a project, you can probably use C, Rust, or JS/Python/Ruby/etc. Hell, you could even use Haskell, ML, Lisp, or Smalltalk, if you're that sort of person.
But don't use Java if you can avoid it. It will make you feel better, likely improve your productivity, and make you stop wishing that you could commit seppuku.
Hobbyist programmer, Schemer (although not smug about it, really), gamer, voracious reader, and highschool student.In the industry, I can understand why you might have to learn it. I just don't understand why you'd want to.
But then, I never liked Java: maybe I just don't "get it".
Worry not, your Scheme kool-aid will fade out eventually.
>Worry not, your Scheme kool-aid will fade out eventually
It's not Kool-Aid. I can tell because I am still capable of criticising Scheme, and am not in awe of it.
Scheme has a weak stdlib (which is both good and bad), its string handling is painful at best, as srfi-13 doesn't provide a lot of common functionality, its function names are painfully long (call-with-current-continuation. Really? What would you call 'do' if you hadn't inherited it from maclisp? iterate-over-variables-incrementing-until-condition?) Which matters a lot when your whole language is made up of them, or things that look like them (how many times do you want to type 'vector-ref'?). Scheme has no dynamic variables. Chicken, my scheme of choice, and the most viable one for real work, lacks a decent debugger. Gambit and Guile have good debuggers, but Guile is slow, and Gambit has no libraries, so you can't get anything done. Schemestill doesn't have a standard imperative macro system. And the SSC is still working on R7RS-large, which will finally bring together a stdlib large enough to write scheme portable across implementations without snapping and spending the rest of your life in a corner, dribbling about syntax-rules.
I like scheme: it's both syntactically and semantically small, beautifully clean, and even decent for some kinds of real work.
But it's not even close to perfect, or even ready for industry.
I suppose my hatred of Java did give me a bias against it here...
from com.companyName.module.class import myFunction
and it just works. And it's terrible because you're doing crazy things like mixing Java paradigms with Python's style and it gets a bit nuts.But you're making money, solving problems, and in the end, it's all about the trade-offs. For my work, Jython nails that sweet spot. I would run screaming if I saw it stand alone, but I won't spite it given my alternative is VBA. (Which I also won't shit on - VBA has saved my bacon more than a few times!)
Sometimes it's even the best tool for the job.
public static void main(String[] args) {
StringBuffer output = new StringBuffer();
Process p;
try {
p = Runtime.getRuntime().exec("pwd");
p.waitFor();
java.io.BufferedReader reader =
new java.io.BufferedReader(new java.io.InputStreamReader(p.getInputStream()));
String line = "";
while ((line = reader.readLine())!= null) {
output.append(line + "\n");
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(output.toString());
}
}/home/jobe/runs/jobe_AnIK6J
probably not a good sign....
Do python repls let you execute anything on the host?
for (Integer i = 0; i < 10; i++ ) {
System.out.println(i);
}Otherwise, wouldn't it be simpler to just profile to find the slow places in your existing code -- then rewrite those in C? You can use the scripting language for most code, where it shines -- speed of development. And still get a good speed of execution.
If you need even more speed (you wouldn't really get less memory usage!), then sure... Java is one way to go for a Python/Ruby/Perl/PHP guy. But... when is it the best choice?
My attitude is that I hope to choose at least one thing -- the stack or the problem area. If I can do that, I should be quite happy.
To not want to leave a geographic location is of course valid choice -- probably often a healthier one than mine, but in this phase of my life, I prioritize doing things I enjoy quite highly. (I would do Windows anyway, if the money was right or I could do it from e.g. Japan. :-) )