Are you kidding me, Java?

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
TheBuzzSaw
Chaos Rift Junior
Chaos Rift Junior
Posts: 310
Joined: Wed Dec 02, 2009 3:55 pm
Current Project: Paroxysm
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Contact:

Are you kidding me, Java?

Post by TheBuzzSaw »

Tell me what you think this program outputs. Do not cheat. When you do cheat, post your reaction in spoiler tags.

Code: Select all

package javaapplication6;

public class JavaApplication6
{
    public static void main(String[] args)
    {
        String s = null;
        s += "ASDF";
        System.out.println(s);
    }
}
I hate this language so much.
User avatar
bbguimaraes
Chaos Rift Junior
Chaos Rift Junior
Posts: 294
Joined: Wed Apr 11, 2012 4:34 pm
Programming Language of Choice: c++
Location: Brazil
Contact:

Re: Are you kidding me, Java?

Post by bbguimaraes »

The single fact that, just to run the goddamn program, I have to create a folder named javaapplication6 with a file name JavaApplication6.java (both case sensitive), compile it and call it with "java -cp . javaapplication6.JavaApplication" makes me want to punch the language creators in the face.

No matter what people tell me about it, to me Java is bad design decision after bad design decision. I've used some decent software written in it (tomcat, weka) and the greatest memory I have is the complete pain the setup was.
Tim Wilson
ES Beta Backer
ES Beta Backer
Posts: 9
Joined: Tue Jan 22, 2013 2:20 pm
Programming Language of Choice: C++ & Python
Location: Western Pennsylvania

Re: Are you kidding me, Java?

Post by Tim Wilson »

It's "nullASDF," right?
:lol:
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Are you kidding me, Java?

Post by Falco Girgis »

What, you think I have a Java environment set up and ready to go to test this? ;)
User avatar
TheBuzzSaw
Chaos Rift Junior
Chaos Rift Junior
Posts: 310
Joined: Wed Dec 02, 2009 3:55 pm
Current Project: Paroxysm
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Contact:

Re: Are you kidding me, Java?

Post by TheBuzzSaw »

Tim Wilson wrote:It's "nullASDF," right?
:lol:
It

is

a

DISGRACE!
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Are you kidding me, Java?

Post by dandymcgee »

I have no idea.. but it SHOULD throw an exception the moment you try to += anything to a null value. I doubt it does, but I've never had a reason to learn Java.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
gamenovice
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 78
Joined: Fri Nov 12, 2010 7:49 pm
Current Project: wii u dev, sdl, and some unity 3D
Favorite Gaming Platforms: PC, GAMEBOY, GAMECUBE, WII, 3DS,PS2
Programming Language of Choice: C#,C++,Java
Location: Tampa,FL
Contact:

Re: Are you kidding me, Java?

Post by gamenovice »

for those of you who learned c# and c++ first, count your blessings
without code, we wouldnt have life as we know it...
User avatar
TheBuzzSaw
Chaos Rift Junior
Chaos Rift Junior
Posts: 310
Joined: Wed Dec 02, 2009 3:55 pm
Current Project: Paroxysm
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Contact:

Re: Are you kidding me, Java?

Post by TheBuzzSaw »

dandymcgee wrote:I have no idea.. but it SHOULD throw an exception the moment you try to += anything to a null value. I doubt it does, but I've never had a reason to learn Java.
That is exactly what I thought. I can get past the fact that it allows it to happen... but I cannot get past what the actual result is.
User avatar
bbguimaraes
Chaos Rift Junior
Chaos Rift Junior
Posts: 294
Joined: Wed Apr 11, 2012 4:34 pm
Programming Language of Choice: c++
Location: Brazil
Contact:

Re: Are you kidding me, Java?

Post by bbguimaraes »

Well, I just tried it in javascript and it seems it inherited other things besides its name...
User avatar
Light-Dark
Dreamcast Developer
Dreamcast Developer
Posts: 307
Joined: Sun Mar 13, 2011 7:57 pm
Current Project: 2D RPG & NES Platformer
Favorite Gaming Platforms: NES,SNES,N64,Genesis,Dreamcast,PC,Xbox360
Programming Language of Choice: C/++
Location: Canada

Re: Are you kidding me, Java?

Post by Light-Dark »

Image
<tpw_rules> LightDark: java is a consequence of inverse moore's law: every 18 months, the average program will be twice as slow. therefore, computers always run at the same percevied speed. java's invention was a monumental step
Image
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Are you kidding me, Java?

Post by dandymcgee »

bbguimaraes wrote:Well, I just tried it in javascript and it seems it inherited other things besides its name...
Yeah.. but JavaScript breaks literally every existing language rule and paradigm. It's both extraordinarily flexible and ridiculously illogical at the same time.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Are you kidding me, Java?

Post by Falco Girgis »

That is absolutely fucking bizarre... I mean, obviously any JIT language has to be pulling some behind-the-scenes bullshit to even implement the concept of a "null reference" (a reference is implemented as an autodereferenced pointer, so a "NULL" reference is technically impossible).

If you're interested in knowing what the fuck the JIT compiler is doing to let this happen, here it is:
http://stackoverflow.com/questions/4260 ... gs-in-java

Also, thanks for posting this, you bastard. Almost spit out my coffee.
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: Are you kidding me, Java?

Post by Ginto8 »

It certainly looks insane, but the reason it is that way is so you can do something like:

Code: Select all

System.out.println("x = " + x);
and have it print out something sensible in all cases, including where x is null. There is no value of x other than null where that line ought to fail (all objects have a toString() method, and primitives have their own conversions), unless exceptions are thrown in x.toString(). So instead of making it cause a catastrophic program failure, it just converts it to a string value signifying its value: "null".


I still think it's less insane than PHP's false == "no" stuff.
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
TheBuzzSaw
Chaos Rift Junior
Chaos Rift Junior
Posts: 310
Joined: Wed Dec 02, 2009 3:55 pm
Current Project: Paroxysm
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Contact:

Re: Are you kidding me, Java?

Post by TheBuzzSaw »

Ginto8 wrote:I still think it's less insane than PHP's false == "no" stuff.
PHP isn't even worthy of being considered a language.

http://me.veekun.com/blog/2012/04/09/ph ... ad-design/
User avatar
THe Floating Brain
Chaos Rift Junior
Chaos Rift Junior
Posts: 284
Joined: Tue Dec 28, 2010 7:22 pm
Current Project: RTS possible Third Person shooter engine.
Favorite Gaming Platforms: PC, Wii, Xbox 360, GAME CUBE!!!!!!!!!!!!!!!!!!!!!!
Programming Language of Choice: C/C++, Python 3, C#
Location: U.S

Re: Are you kidding me, Java?

Post by THe Floating Brain »

Falco Girgis wrote:What, you think I have a Java environment set up and ready to go to test this? ;)
:lol:
Oh Java, what a terrible language XD
"Why did we say we were going to say we were going to change the world tomorrow yesterday? Maybe you can." - Myself

ImageImage
Post Reply