4 ms·
Not trying to be an asshole here, but can a Java evangelist try to convince me to use it over C++ on linux - without invoking the garbage collector. (I've +17 y
by hermitdev 10y ago
Not trying to be an asshole here, but can a Java evangelist try to convince me to use it over C++ on linux - without invoking the garbage collector. (I've +17 years experience in C++ & Python on Linux & Windows + 18 years C# experience on Windows). In my experience, Java has made a number of poor decisions in the language (i.e. requiring exception specifications, disallowing value types, and the generics implementation is shit). Why use it other than "cross platform?" Build times are crap, almost (but not quite) as bad as C++. Why use it? I'll admit I've zero experience using other JVM hosted languages, so part of why I differentiate the JVM versus Java, the language.
- chii 10y agoyou would use Java when you don't need explicit control of memory layout, and/or hard real time requirement. Java is much simpler to read and write, has many more libraries (which interoperate well together, unlike most C++ libs), and also many more developers to hire from. an all-around good choice.
- SakiWatanabe 10y agoJava is very good for enterprise development where the code has to be maintained. It's easier to read and contains less gotchas than C++. It is especially good when the team consists of people of varying coding competencies. Also nobody ever gets fired for choosing to develop using Java.
- hermitdev 10y ago> Java is very good for enterprise development where the code has to be maintained. I often hear this, but I've yet to see an example of "good" enterprise java. Instead, I oft see a pile of shit built on top of some java framework, claiming to be maintainable. C++ may not be the best choice for web development (probably wouldn't be my first choice), but Java hasn't proven great, either.
- thehardsphere 10y ago> C++ may not be the best choice for web development (probably wouldn't be my first choice), but Java hasn't proven great, either. Really? I feel like Java and the JVM are great for developing web apps with complex requirements, especially if they need to scale. Very few decent web development choices perform as well as the JVM does. I mean, part of the reason that "enterprises" have "shitty enterprise Java" is because "enterprises" will create "shitty enterprise anything," and the Java implementation often performs better than the alternatives.
- thehardsphere 10y ago> Also nobody ever gets fired for choosing to develop using Java. This is actually a negative. Java can be great if you have half-way decent people who make good choices with regards to libraries and frameworks and application servers and whatnot, but the choices that come from "nobody ever gets fired for" thinking are by far the worst ones. Example: IBM WebSphere. "Nobody ever got fired for choosing IBM," but they absolutely should be if they choose this giant shitpile. Anyone who has chosen this shit should be thrown into a wood chipper, unless they specifically chose it waste the maximum amount of time possible. Or, if it was invented to set Soviet computing back 30 years like the IBM 360, except that joke doesn't work anymore because the Cold War ended before Java was even a thing.
- paulddraper 10y agoJava was inspired by C++, wth three large additions, compile-once run anywhere (ergo JIT), GC, and memory safety. Throw the first two out the window and no wonder you aren't impressed. I would add to that open source libraries which are (1) of high quality and (2) easy to pull in, e.g. Maven. The C++ ecosystem has no package manager, and people write header only libraries blowing up compilation times. With Maven, I can add Guava, Ehcahe, AWS SDK, etc. and their transitive department in about 60 seconds in a simple, consistent way.
- hermitdev 10y agoYeah, Java was inspired by C++, and the designers decided to take the worst ideas and run with them: such as exception specifications. C++ & C# both realized they were a bad idea, and decided to do away with them. Java generics are also fucked up. They could have followed C#, but no, they had to do their own model, and they fucked it up.
- deleted 10y ago[deleted]
- Zombieball 10y agoI kind of get the impression you just want to bash the java language! :p I think the whole eco-system (including dependency management with maven) is definitely worth acknowledging the value of.
- paulddraper 10y agoJava generics hardly could have "followed" C#, seeing as Java released them in 2004, and C# in 2005.
- yawz 10y ago> + 18 years C# experience on Windows As far as I remember C# came out in 2000.
- hermitdev 10y agoOfficially, and you're really going to lampoon me because I was off by 1 year after 17?
- yawz 10y agoThat kind of mistakes looks a lot like bragging. ;) But mistakes happen, I guess :).
- hermitdev 10y agoIt was an honest mistake. I first tried .Net 1.0 while I was an intern at a Fortune 500 Comnpany. I first used it for a software engineering project (back when webforms were preferred).
- pjmlp 10y agoActually they just celebrated their 15th anniversary. https://blogs.msdn.microsoft.com/dotnet/2017/02/13/happy-15th-birthday-net/ https://blogs.msdn.microsoft.com/dotnet/2017/02/13/happy-15t...
- stickfigure 10y agoFormer 6+ year C++ programmer here who made the switch in the late 90s. Fast build times. Removal of problematic/abused features like automatic type conversion and operator overloading. Never having to hunt down a segfault. Good reflection facilities. Well-structured exceptions (despite the 'checked' misfeature). Compiler error messages are almost always intelligible and obvious - when you see them, which is rare, because the IDE just underlines bad code. Add opensource libraries to do almost anything with just a line of xml. You can work around checked exceptions by not using them, and Lombok eliminates most of the really annoying boilerplate (including checked exceptions with @SneakyThrows). The generics implementation isn't perfect but at least it doesn't require hours of parsing header files on every single build. I don't miss C++ at all.
- hermitdev 10y agoI work in finance, and I've cranked up warning levels to the max - I don't have any issues - except getting everyone on board. Once they realize why - it's smooth sailing. It can be hard when there is a language barrier, but you're best to combat it.
- aseipp 10y agoSo, basically, you didn't actually want anyone to answer your original question, from what I can tell -- you just wanted to repeatedly affirm you were right-all-along?
- d_burfoot 10y agoJohn Carmack just retweeted a link to this article about common programming errors in C++ and how to avoid them: https://software.intel.com/en-us/articles/the-ultimate-question-of-programming-refactoring-and-everything https://software.intel.com/en-us/articles/the-ultimate-quest... I estimate that 70% of those errors just cannot happen in Java.
- slededit 10y agoI decided to be pedantic and check. 1 - Language agnostic 2 - Agnostic - Java doesn't have memcmp but the same issue returning (-1, or < 0) could happen 3 - Agnostic (with the exception that java would throw for out of bounds) 4 - Agnostic 5 - Agnostic - Its a windows complication (you can write C++ without DllMain even in windows) 6 - C++ 7 - C++ 8 - C++ 9 - C++ 10 - C++ 11 - C++ 12 - Agnostic 13 - Agnostic 14 - Agnostic 15 - C++ 16 - Agnostic 17 - Agnostic (java has similar optimizations) 18 - Agnostic (inefficient code happens in any language) 19 - C++ 20 - C++ (maybe java would throw instead?) ... This is longer than I thought. 9 of the first 20 are C++ only.
- wuch 10y ago2. Language agnostic; Common in other languages, but some avoid it by using strongly typed enumeration instead of integer return type in comparison functions. 6. Languages with pointer arithmetic, especially that the cast that losses information is explicit. 8. It not at all obvious that silently ignoring the case failure is correct fix for this, or if there is any issue here at all. Generally common to languages with some kind of destructor and exceptions, though harmful in varying degrees. 11. Other languages generally make it impossible to write, or define order of operations. I think the most interesting observation you can make is how much of those problems are caused by some form of implicit conversion between types (also stopped after 20): 4. int -> bool 9. char -> *char 13. int -> bool 14. bool -> size_t 15. different enums 16. bool -> int This generally agrees with bug log that I keep. Implicit conversions being one of the most common source of problems in C/C++. When possible I just treat all implicit conversions as errors using compiler flags and make all casts explicit. Unfortunately this is something you can only do when working on new projects, and hard to enforce in templates.
- pjmlp 10y agoWell, I do consulting in Java, .NET and C++. Other than Android Studio and Gradle, Java build times are actually quite fast. Just yesterday I gave up on compiling Cocos2d-x, after around one hour. In Java I get to use the full language, not fighting with others about enabling RTTI and exceptions, or making proper use of C++ best practices instead of "C with C++ compiler". Also unless one is stuck with one OS and one C++ compiler, writing portable C++ code across multiple OSes and compilers is either #ifdefs everywhere or constraining ourselves to the subset of common features. Right now most commercial compilers for embedded systems are still on C++98. I recently saw presentations from BMW and Sony, where they mention moving into C++11. Who knows when they will allow C++14 on their codebase, maybe when C++20 gets released, most likely. If the code needs to be AOT compiled to native code, many third party JDKs do offer support for it, although they are mostly commercial. Also, the use of header files were already outdated in the 80's, versus what languages like Modula-2 and Object Pascal supported. We will need to wait for C++20 to have proper modules, hopefully. And best of all, no UB or compiler specific semantics, or change of language semantics between ISO revisions (auto vs decltype). I still look forward to see value types and the new FFI in Java 10.
- specialist 10y agoJava made me a better C++ dev. When I went back to C++ from Java (for a while), I just pretended it was Java, restricting myself to a rough subset of Java design idioms. C++ (circa 2000) had too much latitude, too many sharp edges. Java's constrained design vocabulary allows you to focus more on the problem, less on the implementation. I blazed. My code was super maintainable. I have no idea what C++ is like today. I eschew meta programming. Huge distraction. Very difficult to grok other people's code. Java's progressive incorporation of declarative, dynamic features is regrettable.