4 ms·
I'm currently trying to learn Rust, but if my motivation were "I need a fast language and don't want to deal with safety issues", I'd use Java. It's plenty fast
by adrianN 10y ago
I'm currently trying to learn Rust, but if my motivation were "I need a fast language and don't want to deal with safety issues", I'd use Java. It's plenty fast (especially compared to something like Ruby!), the ecosystem is huge and tooling is extremely mature.
- EugeneOZ 10y agoJava has not so great reputation about safety.
- copperx 10y agoPlease expound on that. Garbage collection, no pointer arithmetic, and array bounds checking seems like good safety features.
- duneroadrunner 10y agoWell, I don't know about java's reputation, but there's this: http://www.cvedetails.com/product/19117/Oracle-JRE.html?vendor_id=93 http://www.cvedetails.com/product/19117/Oracle-JRE.html?vend... http://www.cvedetails.com/product/1526/SUN-JRE.html?vendor_id=5 http://www.cvedetails.com/product/1526/SUN-JRE.html?vendor_i...
- chungy 10y agoSecurity exploits say nothing about the language's memory safety design. Java still qualifies as a safe language.
- EugeneOZ 10y agoAs a safe language from race conditions or memory leaks?
- adrianN 10y agoThe Java VM is written in C though.
- rat87 10y agoThere are many java vms The most popular(hotspot/openjdk) is written in c++/assembly
- EugeneOZ 10y agoGC is not about safety at all, sorry. I'm not going to start flamewar, but just to answer your question: https://www.google.com/#newwindow=1&q=null+pointer+exception https://www.google.com/#newwindow=1&q=null+pointer+exception
- lmm 10y agoNo sum types (the Java alternative to Rust enums is the horribly verbose visitor pattern, so a lot of the time people don't bother). null. A verbose and unabstractable "checked exception" system (that the standard library uses poorly in places) that leaves many users resorting to unchecked exceptions (panics) instead. Uninitialized field problems because methods are virtual even when called from superclass constructors. Excessive overhead to custom types that leads to using weakly typed Strings etc. rather than domain types. Poor abstraction facilities that lead to a culture of "magic" annotations and runtime reflection (or worse, proxies and bytecode manipulation) e.g. @Transactional, @Inject. Java is safer than C, but it's a long way behind a modern functional language like Rust.
- enqk 10y agoThat's interesting because it is based on the same principles of not letting developers do harmful thing as a way to guarantee security.
- EugeneOZ 10y agoRust uses RAII for memory-safety, not just language constructions to raise some limitations.
- cesarb 10y agoJava's bad safety reputation comes mostly from the Java plugin, where many inventive ways to bypass its sandbox have been discovered. When used as a normal programming language, without depending on it for sandboxing (that is, when all code running in the JVM is trusted), its safety is quite good. (Java also has a not so great reputation about speed. That one also comes from the Java plugin, which often took minutes to start up, while keeping the Netscape browser UI locked up.)
- the_why_of_y 10y ago... and just to add to that, if you look at the other popular sandboxed client-side runtimes, i.e., Adobe Flash and various JavaScript-enabled browsers (all of them implemented in C++), you will find a similar number of critical vulnerabilities.
- EugeneOZ 10y agoI see a lot of NPE in IntelliJ IDEA, especially EAPs. It's not browser's plugin.
- the8472 10y agoNPEs are not a security issue in the same sense as a buffer overflow or null pointer dereference.
- hueving 10y ago>It's plenty fast Unless you need guarantees that can't be offered by garbage collection.
- adrianN 10y agoJava is pretty popular for HFT applications. I think most programs are less latency sensitive than that. But of course, Java is not for you if you have hard real time constraints.
- fpoling 10y agoIn some cases those HFT installations are tuned not to run full Java GC within 8 hours during the trading day. Then they are rebooted.
- njs12345 10y agoThat sounds interesting - have you got any more details on exactly how they set this up?
- gravypod 10y agoYou can also use the Java Unsafe class to squeeze performance (every last bit) by recycling objects. I'm sad to say that I've had to do that at least once to make some vector math work. Edit: Check out https://dzone.com/articles/understanding-sunmiscunsafe https://dzone.com/articles/understanding-sunmiscunsafe
- fpoling 10y agoA person on a conference has not mentioned details. The reason for Java is productivity and access to a bigger pool of developers.
- notsoeasy 10y ago> I think most programs are less latency sensitive than that. Hardly, compared to anything that takes user input and aims at 60/120 FPS (where you inevitably end up bypassing GC if you can't force it to run when you want to). https://www.quora.com/Is-Java-overtaking-C++-in-the-HFT-world https://www.quora.com/Is-Java-overtaking-C++-in-the-HFT-worl... > One thing about HFT is that the speed of the language oddly doesn't matter much. You are talking about latencies of 20 milliseconds, and any language can do 20 milliseconds since CPU times are measured in nano-seconds rather than milisecond. and > If you are playing in the sub 10 microsecond range doing everything in C++ helps a lot. [..] A lot of high frequency strategies run in the 20-30 microsecond time frame. I think this is where a lot of diversity in terms of setup occurs. and > To lower execution costs, we need a low latency system that has good determinism in response times. You cant pause for hash table rebucketing or garbage collectors or the OS taking away your time slice or moving you to a diferent processor or whatever. There are guys who try this in Java, and spend most of their time trying to make Java work deterministically. Good luck and > If you are in ultra HFT then C++ is the only answer (besides custom hardware - FPGA & ASIC). You just can't afford garbage collector.
- masklinn 10y ago> if my motivation were "I need a fast language and don't want to deal with safety issues", I'd use Java. It's plenty fast Context is pretty important to the original comment: > python/ruby/whatever shops are using Rust because they need a fast language, but don't want to deal with safety issues. they're not looking for a fast language in isolation, they're looking for a fast language in the broader context of their existing technological stacks. Java doesn't help that much when you're looking into ways to speed up your Ruby application, at least not easily. Furthermore, Java has the issues that it's only fast when memory is plentiful and it has a long startup/running time, it's "eventually fast" if you will.
- the8472 10y agoJava's FFI story is not as good as rust's though. So if you're interacting with the OS / native libs a lot then it might not be a good choice. Although there's JNR and JNA and it might become a standard feature at some point in the future[0]. But for a good FFI experience you also need arrays-of-structs, which means you need value types in java. So it's a long journey to get there. [0] http://openjdk.java.net/jeps/191 http://openjdk.java.net/jeps/191