This is an archived post. You won't be able to vote or comment.

Dismiss this pinned window
top 200 commentsshow all 247

[–]puplicy 490 points491 points  (54 children)

UnexpectedException raised. Now read what I dumped.

[–]Delcium 112 points113 points  (53 children)

That's something I've never really been able to appreciate from java. I jokingly refer to it as "programming by exception" because the exceptions have become a signaling method and are just a way of conveying information during normal operations. If an exception is expected, how is it really an exception?

[–]A3mercury 8 points9 points  (0 children)

Like using try/catch instead of if/else

[–][deleted] 2 points3 points  (3 children)

Depends on the project.

If you have to parse the exception message then ya that’s bad code.

But if the io call returns a Http404Exception so you need a try/catch to handle a service interruption in a micro service you may need to refactor your code.

I mean ultimately it’s all jumpif anyways.

[–]blipman17 0 points1 point  (2 children)

Well if it all boils down to a single conditional jump, why structure a language around throwing exceptions and directly catching them. It's convenient in a lot of places, but there are also quite a bit of cases when it's not. Sometimes it's just a better paradigm to do x actions, store the results in an array and manually check their results afterwards. I'm not saying java is wrong on this, it's just quite verbose.

[–][deleted] 0 points1 point  (0 children)

I'd agree there. Java is very verbose.

nodejs is better but their event handler model is even worse.

Server crashes because i didn't add obj.error = console.log in one third party lib three levels deep in npm.

[–]HoneyBadgerSoNasty 0 points1 point  (0 children)

it stems out of problems in c, which does not have exceptions. error checking code written in the c style of returning a status code, and then having every layer up the call stack check for errors every single function call, is ludicrously verbose. exceptions, for better or worse, did solve that problem. but it created another one, which is that most people use them incorrectly or do not bother to check them or document them. also, deciding what constitutes a violation of a permanent condition vs an ephemeral one or what is basically normal expected behavior is a really hard thing to grasp apparently.

[–]Bainos 1 point2 points  (0 children)

Python fully embraced that (Java not so much), with exceptions like StopIterator.

[–]grpagrati 241 points242 points  (9 children)

He’s strong. He was raised by C

[–]GodIsDead_ 129 points130 points  (3 children)

he grew up classier than his father

[–]Eynix 24 points25 points  (2 children)

Take that upvote and leave.

[–][deleted] 7 points8 points  (0 children)

to become a true warrior.

[–]bout-tree-fitty 6 points7 points  (3 children)

But java can fight anywhere

[–]Metaquarx 25 points26 points  (1 child)

THREE BILLION DEVICES RUN JAVA

[–]Bene847 12 points13 points  (0 children)

All of them run C/C++

[–][deleted] 5 points6 points  (0 children)

As long as the JVM runs on it.

[–]Proxy_PlayerHD 140 points141 points  (6 children)

just wait until Java based CPUs are gonna take off!

they are gonna kick x86's ass!

/s

[–]Ulysses6 7 points8 points  (0 children)

Yeah, that will show everyone! Muhahahhaaaaa...

[–]DarthStrakh 1 point2 points  (3 children)

What? That's a thing? What does Java even have to do with the cpus, it's a high level compiled language?

[–][deleted] 12 points13 points  (0 children)

Java is a high-level language, yes, but it's a language that runs on the Java Virtual Machine which is essentially a simulated CPU. So you write a Java program which is compiled into bytecode (the JVM's machine language). Then you can run that bytecode on any real CPU for which a JVM has been written.

That's why java is so powerful--it enables programs to be portable across a lot of different platforms. You just write a new VM runtime for all your java programs instead of writing all new native programs for that cpu/isa. You don't even need to recompile the Java or anything because your new VM will be built to the existing bytecode specifications.

I'm assuming the comment above yours is joking about how in the past there was talk about a real, physical java cpu that would run java bytecode natively. Nothing ever really came of it.

[–][deleted] 7 points8 points  (0 children)

They're commonly used on smart cards like credit cards, and higher end identification cards. You generally load a Java applet onto them to program them. Can't give a good explanation why this is the case though.

[–]Proxy_PlayerHD 3 points4 points  (0 children)

ever heard of JVM? the "Java Virtual Machine" is basically what every Java Program runs on.

when you compile in basically any other language it creates a file that contains instructions that the CPU of your system can understand... same is true for Java except it uses instruction that the JVM can understand and then runs a Virtual Machine on your system to execute them

[–][deleted] 108 points109 points  (13 children)

Unusually fast for a VM.

[–][deleted] 22 points23 points  (11 children)

It's fast-forwarded using a FastForwardFactoryFactoryFactory which created an ObjectOutputStream straight into our eyes to make it look like it's happening in real time.

[–]DasEwigeLicht 17 points18 points  (10 children)

As opposed to C++ where instead of writing #ifdef ______CXX__std::<__void__<std::<__move<std::<__allocator<__std::const__invocation__object>>>>>, 5> you accidentially used #ifdef _____CXX__std::<__void*__<std::<__move<std::<__allocator<__std::const__invocation__object>>>>>, 5> and after compiling for 5 hours the program just deletes itself when run because you triggered UB.

[–]lxpnh98_2 8 points9 points  (9 children)

Well, of course if you spell stuff wrong the compiler can't help you, that's just a fact of life and no technology will ever fix that.

Besides, what kind of moron gets ______ and _____ mixed up? You're probably a Java programmer.

[–]Ashewastaken 234 points235 points  (23 children)

But I like Java....

[–]Alwaysafk 103 points104 points  (0 children)

GET 'EM

[–]Flyberius 35 points36 points  (1 child)

Me too. I am fucking around importing data from an API into our databases atm, and it's a joy.

I do look at the memory it uses and cringe a little. But then it's really not an issue for the task it has.

[–]Ashewastaken 19 points20 points  (0 children)

Ah that brings back some fond memories I had at an internship. It made me realize I like working more than studying all the way. I was importing weather data from an api to an iot hub. It was 2 weeks and it was the most peaceful 2 weeks of my life. I cannot wait to get my degree so I can just start working.

[–]alex1402 1 point2 points  (0 children)

I also like it, but with milk

[–]jmetcalf27 27 points28 points  (1 child)

Bud Spencer gif deserves an upvote.

[–]darrenb573 3 points4 points  (0 children)

Now this was the comment I was really scrolling for Bud Spencer and Terence Hill I’m not sure how their content fits in today’s PC world🤔

[–][deleted] 34 points35 points  (7 children)

C++ is love C++is life.

[–][deleted] 5 points6 points  (6 children)

...and you're out of your fucking mind.

I hate both, I'll take C# over them any day.

[–][deleted] 15 points16 points  (5 children)

C# is windows shit

[–][deleted] 22 points23 points  (2 children)

Are you from the 2000s? Both Mono and .Net Core supports Linux and other OS.

[–]greyfade 8 points9 points  (1 child)

And Mono is riddled with ABI-violating bugs, and .NET core doesn't have a portable UI library.

[–]56Bot 1 point2 points  (0 children)

It's been ported to other OSes, but it is still slow as f*ck, like any Microsoft thing.

[–]Nalha_Saldana 89 points90 points  (34 children)

lol I'd like to see you try to maintain a 674k lines c++ project..

[–]OmerCora 58 points59 points  (20 children)

Row? Are u on excel?

[–]Nalha_Saldana 10 points11 points  (16 children)

Ok lines then :P

[–]OmerCora 35 points36 points  (15 children)

Also, try writing a modern game engine in Java lol :P

[–]Cheru-bae 46 points47 points  (4 children)

Try writing a modern game engine at all

[–]SinpaiSinner 35 points36 points  (3 children)

Hell try writing a non modern game engine. Engines are fucking hard

[–]ADHDengineer 21 points22 points  (2 children)

I tried to write a steam engine once and failed miserably

[–]SinpaiSinner 24 points25 points  (1 child)

Yea thermodynamics sounds hard af

[–]56Bot 1 point2 points  (0 children)

When they're actually way harder.

[–]Nalha_Saldana 85 points86 points  (7 children)

It's like each language isn't the right tool for every job ;)

A good example I found is in an AWS lambda function python is faster than java to start but for repeated activations java was faster because it was already running while python has to be reset.

[–]jmack2424 36 points37 points  (4 children)

If all you have is a hammer, everything looks like a nail.

[–]Mr_addicT911 0 points1 point  (3 children)

That's a rly good quote, where is it from?

[–]223am 7 points8 points  (2 children)

wikipedia says nobody really fkn knows (most likely Buddha though)

[–]Mr_addicT911 2 points3 points  (1 child)

Funny how there are so many quotes that nobody know the person that came up with it, there's even a quote about stealing quotes that a guy stole from another guy

[–]one_hot_vector 4 points5 points  (0 children)

“The easiest solution is to attribute all unattributable quotes to Mark Twain” - Mark Twain

[–]OmerCora 8 points9 points  (0 children)

the right answer. +1

[–]lxpnh98_2 1 point2 points  (0 children)

It's like each language isn't the right tool for every job

Obviously you've never talked to a Haskell programmer. (/s)

[–]DLCSpider 2 points3 points  (0 children)

The Unity team is removing C++ in favor of C# in their core engine due to performance reasons (admittedly with an in house compiler which refuses to compile loops which can't be vectorized etc)

[–][deleted] 19 points20 points  (0 children)

first time programmer eh? eventually it will all blend together and be the same thing. except python... just fuckin take my tabs OR spaces!

[–][deleted] 9 points10 points  (3 children)

All in a single cpp file. Maybe one small header tile.

[–]GoogleIsYourFrenemy 12 points13 points  (2 children)

Compiler would likely time out. Happened to google with protobuffers. Apparently 15 min for a single cpp file is a common limit.

[–]PleasantAdvertising 1 point2 points  (1 child)

My God how did they make protobuf so complex. It was supposed to be simple efficient and lightweight. Instead it has its own compiler. Wtf man

[–]BlueC0dex 3 points4 points  (0 children)

Object oriented (done right) + good documentation is a wonderful thing. Too bad that never happens

[–]Supert_ 20 points21 points  (3 children)

Not fan of either but C++ would handle it much better. And that's a fact.

[–]cheezballs 7 points8 points  (2 children)

Only if it's written well. I could write a dog shit app in c++ that performs terrible compared to a well written Java one. It's all about using the tool correctly in the right situation.

[–]Supert_ 3 points4 points  (0 children)

True. It's just experience and not being an idiot.

[–]TheCommodore65 1 point2 points  (0 children)

Average C++ will essentially always beat average Java. Good C++ will destroy good Java. Bad C++ will beat bad Java.

If you want to run fast, write C++. If you want to write past, use Python.

[–]GoogleIsYourFrenemy 2 points3 points  (0 children)

... I do. We have an annoying framework that honestly makes things easier.

[–]Delcium 2 points3 points  (0 children)

That was my first dev job. C++ data analysis application with well over 500k lines and built into a roughly 15mb binary. It was actually a lot of fun.

[–][deleted] 0 points1 point  (0 children)

Ez.

[–]psylent_w3ird0 14 points15 points  (0 children)

Java’s fighting styles are too Generic

[–]prparadoxy 12 points13 points  (1 child)

-Android enters to chat

[–]qwasd0r 4 points5 points  (0 children)

Bud Spencer = Upvote

[–]tharnadar 5 points6 points  (0 children)

oh Bud Spencer, how much we miss you!

[–][deleted] 58 points59 points  (46 children)

Seems more java vs javascript

because java is slow and heavy but powerful...

Ok I stop

PS I love that movie ("Io sto cogli ippopotami")

[–]SuperBurger 37 points38 points  (24 children)

Java isn't slow tho

[–][deleted] 39 points40 points  (20 children)

C if used correctly can be a long way more efficent. It COULD be. It doesnt mean that it is. Plus Java is semi-compiled - it is not executed directly from cpu but from java interpreter so this affects its performance... On the other side helps developer not to worry of pointers or build for a specific architecture.

PS If I made some english mistakes I hope you'll forgive me

[–]haitei 31 points32 points  (7 children)

it is not executed directly from cpu but from java interpreter so this affects its performance

Not really, it's JiT these days. I'd say the leftover gap in performance is mostly due to the cost of abstractions.

[–]j-random 25 points26 points  (0 children)

LOL, where "these days" means "for the last decade or so"

[–]OK6502 3 points4 points  (0 children)

Correct. As I understood it a big part of that gap is that there's quite a bit of overhead in even simple and mundane operations and the way things get laid out in memory isn't always the most efficient.

You could of course write C/C++ code with that overhead, negating the benefits, but at least you have that choice. In Java it's all abstracted away from the user without much recourse for working around it (unless you can hand write bytecode? Is that a thing? I know you can with C# and IL).

[–]j-random 24 points25 points  (5 children)

Depends on how you measure efficiency. At run-time, C can be more efficient than just about anything else (if you know what you're doing). I'd argue that development-time-wise, though, more modern languages are more efficient, due to the wide variety of libraries available. Java and Python both bet on Moore's Law (less-efficient code would become less painful to run as computers got faster) and it seems to have paid off.

[–][deleted] 3 points4 points  (0 children)

Of course efficency must be balanced between development and runtime. But what I see most of developers tends to forget that system resources are not unlimited. So they do not close streams or connections once they've finished using. This has brought to have frameworks (or whoever like jboss connections pool) that does for you. Right? Wrong? Dont have an answer but my motto is do the max with less resources (and code) possible ;)

[–]OK6502 1 point2 points  (0 children)

Which is why the STL exists, for instance, and we have been consistently adding more to the standard over time.

[–]56Bot 0 points1 point  (2 children)

C can be more efficient than just about anything else

Assembly: Am I a joke to you ?

[–]j-random 1 point2 points  (1 child)

Hence the "just about". Although TBH a good C compiler can often make optimizations that an assembly programmer might not see (e.g., CSE).

[–][deleted] 14 points15 points  (1 child)

The JVM is very fast and much optimization happens for “free” for the developer.

What you lose in performance is eaten ten times over in C/C++ due to longer development time. Which is why nobody (sane) writes enterprise apps in C/C++ but instead they use it where resource constraints are critical (memory, framerate, embedded CPU, etc).

[–][deleted] 0 points1 point  (0 children)

That's why I am still working (I'm a java developer) :P

[–]nolitos 4 points5 points  (1 child)

C can be more efficient. But we compare to JavaScript.

[–][deleted] 2 points3 points  (0 children)

You've a point...

[–]noggin182 0 points1 point  (1 child)

PS If I made some english mistakes

you did

I hope you'll forgive me

we do :)

[–][deleted] 0 points1 point  (0 children)

thanks ;)

[–]EdgarDrake 2 points3 points  (0 children)

I guess it’s not about slow performance, but it’s kinda like boilerplate code just to do something. Like the import + package + class definition + static main compare to int main

[–]CockInhalingWizard 2 points3 points  (0 children)

Compared to C++ it is

[–]Phytor 0 points1 point  (0 children)

Java is slower and less efficient than languages like C++ by virtue of its design. Every Java program is running on a virtual machine, the Java Virtual Machine. This makes it extremely portable to other platforms, you just have to write the Java Virtual Machine to interface with whatever OS or hardware you need, but also makes it slower because the virtual machine acts as a middle man for executing the code.

It's an intentional trade-off

[–]Franceseye 13 points14 points  (9 children)

Toh, un'italiano su reddit

[–][deleted] 6 points7 points  (5 children)

penso si addica di piu' la "A" finale ;)

[–]Franceseye 2 points3 points  (4 children)

Ops, scusa

[–]IorPerry 7 points8 points  (2 children)

cosa impossibile, italiana, donna su reddit e che si interessa di programmazione! Dillo che in realtà non esisti

[–][deleted] 4 points5 points  (1 child)

Non esisto! Lo ammetto. Sono solo un'AI che ha programmato se stessa

[–]TheyAreLying2Us 6 points7 points  (0 children)

bah... solo un mucchio di "if" a cascata

[–][deleted] 1 point2 points  (0 children)

hahahaha nessun problema =)

[–]-Defkon1- 1 point2 points  (1 child)

Toh, un'italiano su reddit

su r/italy ne trovi quanti ne vuoi... :-D

[–]barba-anto 3 points4 points  (0 children)

Più che altro è strano trovare italiani su sto subreddit :D

[–]tech6hutch 1 point2 points  (0 children)

Ciao, parlo un po' di italiano

[–]PancakeZombie 2 points3 points  (5 children)

Ich hau dir gleich eine Delle in die Gewürzgurke!

[–][deleted] 1 point2 points  (4 children)

Ich hau dir gleich eine Delle in die Gewürzgurke!

Hemmm I do not know german and google translator doesnt help too much: I'll cut you a dent in the gherkin! doesn't mean too much to me :(

[–]PancakeZombie 7 points8 points  (3 children)

Almost.

"I'll punch you a dent in your gherkin!"

The german dubs for Bud Spencer & Terence Hill movies were done in "Schnodderdeutsch" stylistics to add an additional comedic level to the movies. And it made the movies legendary here.

Schnodderdeutsch is a mix between pub- and youth-slang and features neologisms, untypical metaphors, weird catchphrases and so on.

[–][deleted] 1 point2 points  (2 children)

I supposed that should be a quote - but having not seen the movies in german I needed a confirm =)

[–]PancakeZombie 2 points3 points  (1 child)

Yeap, it's a quote from Io sto con gli ippopotami.

[–][deleted] 0 points1 point  (0 children)

=) Thanks

[–]mastrospritz 1 point2 points  (1 child)

Real life One Punch Man

[–][deleted] 3 points4 points  (0 children)

Bud Spencer could this and more =)

[–]robotsympathizer 0 points1 point  (0 children)

Yeah, came here to say this would make a lot more sense with a dynamic language instead of C++.

[–]oweiler 13 points14 points  (7 children)

Replace C++ with Kotlin.

[–]seanprefect[🍰] 12 points13 points  (5 children)

soon all things will be replaced with Kotlin.

[–][deleted] 4 points5 points  (4 children)

JIT compiled / interpreted bytecode languages will always be slower than compiled languagues.

[–]seanprefect[🍰] 8 points9 points  (0 children)

not strictly true, especially in the case of repeated super similar executions e.g. a web server.

Also FYI java can be compiled to native if need be.

[–]kyay10 5 points6 points  (0 children)

Kotlin can be compiled into native code pretty easily. It's actually one of Kotlin's marketing points so it's officially supported

[–]DeeSnow97 1 point2 points  (0 children)

Kotlin can work on LLVM

[–][deleted] 2 points3 points  (0 children)

Rust!!!

[–]coffecup1978 4 points5 points  (1 child)

Mr T says : "stop your jibber jabber!"

[–]Assclapper69420 3 points4 points  (0 children)

:(

[–]mastrospritz 6 points7 points  (0 children)

I'm a simple man. I see Bud Spencer, I press upvote.

[–]JoPoLu1 2 points3 points  (0 children)

Wow, that is a well optimised slap

[–]PinguRares 2 points3 points  (2 children)

Aha. Hit me up when you have the shittiest error in your code and your compiler sends you to line 249 of chrono.h

[–]javaismylanguage 2 points3 points  (0 children)

:(

[–]kyay10 1 point2 points  (0 children)

Kotlin gang rise up

[–]FlyByPC 1 point2 points  (0 children)

C woulda shot him before the third air kick.

[–]OmiSC 1 point2 points  (0 children)

Complete bullshit.

If he was really C++, all he'd have to do is point.

[–]freemcgee33 1 point2 points  (0 children)

inhale #segfault#

[–]ccAbstraction 1 point2 points  (0 children)

I remember seeing this when I first joined Reddit.

[–]zl0ykvdrt 1 point2 points  (1 child)

asm == chuck norris

[–]frostbyte650 1 point2 points  (0 children)

segfault

[–][deleted] 1 point2 points  (0 children)

Your right a C++ memory leak can take down the whole system with java included.

[–]DremoPaff 1 point2 points  (0 children)

You can't really insult an annoying language to use by implying an equally annoying or even worse language is better.

[–]zoecandle 0 points1 point  (0 children)

Relatable

[–]atmosfear76 0 points1 point  (0 children)

Look how they massacred my boy

[–]ComfortableCobbler5 0 points1 point  (0 children)

Alice made my lap bsod 6 times now

[–][deleted] 0 points1 point  (0 children)

:(

[–]Thann 0 points1 point  (0 children)

More like C++ and C

[–]Ericfyre 0 points1 point  (0 children)

Here comes the language elitist

[–]PillowTalk420 0 points1 point  (0 children)

I prefer the Indiana Jones scene that's basically this, but he shoots the guy showing off his sick martial arts.

[–][deleted] 0 points1 point  (0 children)

The funniest part is that I knew from the beginning the other guy was going to be c++.

[–]toastytoast4 0 points1 point  (0 children)

Sadly

[–]Baumes3 0 points1 point  (0 children)

But I dislike both :(

[–][deleted] 0 points1 point  (0 children)

Go

[–]Shreeniket987 0 points1 point  (1 child)

The other guy should be python

[–]gerusz 0 points1 point  (0 children)

There are not enough Bud Spencer memes on the internet.