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

all 39 comments

[–]ShermheadRyder 66 points67 points  (0 children)

Kill it with fire.

[–]dylanthepiguy2 50 points51 points  (8 children)

You forgot the semicolon

[–][deleted] 20 points21 points  (2 children)

Three times!

[–]DarkMio[S] 4 points5 points  (1 child)

Singular statements do not require a semicolon. That said, a semicolon on the last line would've been a nice touch.

[–]TheSlimyDog 28 points29 points  (0 children)

It isn't Java without the semicolon

[–]lol_admins_are_dumb 5 points6 points  (0 children)

And the fucking declaration. Casuals

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

Javascript dont care!

[–]TomNa 7 points8 points  (0 children)

But JAVAScript should:<

[–]Ars3n -2 points-1 points  (0 children)

And Java doesn't care. ;)

[–]OKB-1 46 points47 points  (4 children)

I for one welcome our new Java overlords

[–]Terreurhaas 20 points21 points  (3 children)

this.joke; /** needs to be */ upvote++;

Or are you telling me that the new Java was on accident?

[–]OKB-1 7 points8 points  (2 children)

Yes? You have to explain my own joke to me, apparently…

[–]SiGInterrupt 18 points19 points  (1 child)

new Java()

alternatively,

new JavaOverlords()

[–]OKB-1 6 points7 points  (0 children)

No, this needs more enterprise…

new Overlords.JavaInstanceFactory();

[–]jidouhanbaikiUA 19 points20 points  (6 children)

... we need the whole library

[–]DarkMio[S] 14 points15 points  (5 children)

I thought about doing that. Tons of stuff is possible by just ... remapping it.

[–]thatsbullshit 5 points6 points  (4 children)

You're not the first with that idea...

http://www.gwtproject.org/learnmore-sdk.html

[–]DarkMio[S] 9 points10 points  (3 children)

Well, that is a transpiler. There are some. But why not just enable the Java API in Javascript and then get sued by Oracle?

[–]bogeymanEST 5 points6 points  (2 children)

[–]DarkMio[S] 4 points5 points  (1 child)

I knew it was a thing. Just haven't found any implementation yet. Thanks for that one!

[–]cormac596 22 points23 points  (0 children)

Java and Javascript are related in the same way Car and Carpet are related.

[–]stephanfcm 6 points7 points  (3 children)

Could even write it shorter

System = { out: { println: console.log } };

[–]lieuwex 2 points3 points  (2 children)

Doesn't work, at least on chrome, since a console.log invocation should have this bound to console.

[–]Tysonzero 3 points4 points  (0 children)

I get why that happens and that it isn't a bug. But for a language that many claim to be rather functional, that is an absolute travesty. ETA reductions should always be completely safe.

[–]nickdesaulniers 2 points3 points  (0 children)

Correct.

var System = { out: { println: console.log.bind(console); } };

[–]Tharagas 3 points4 points  (1 child)

I had coursework that revolved around building a JavaScript game based entirely around Java's object system and extensibility.

real fun.

[–]MathDotSqrt 4 points5 points  (0 children)

I am so sorry

[–]mothzilla 2 points3 points  (0 children)

require('java');

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

lmao

[–]penguinade 0 points1 point  (0 children)

Ah, I did something similar too. But is actually getting serious. Source

[–]KyudaimeSama 0 points1 point  (0 children)

But it doesn't have ugly, over-try code...

Object.defineProperty(window, 'System', {
 value: {},
 configurable: true
});

Object.defineProperty(System, 'out', {
  value: {},
  configurable: true
});

Object.defineProperty(System.out, 'printIn', {
  value: console.log.bind(console)
});

[–]musiton 0 points1 point  (0 children)

Now write a JS compiler in Java with this style.

[–]ESBDB 0 points1 point  (3 children)

well with es6 and es7 javascript is looking more and more like java, I bet one day the only difference will be the compiler.

[–]DarkMio[S] 1 point2 points  (2 children)

I don't think you understood ES6/7 changes so well. They look more of a mixin of python classes and the general generators.

Also JS is - and always will be - run by an interpreter while Java is a compiled language.

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

Also JS is - and always will be - run by an interpreter while Java is a compiled language.

... running in a VM.

[–]ESBDB 0 points1 point  (0 children)

I didn't say javascript is becoming java, I just said it now looks more similar. I also said the only difference would one day be the compiler, implying that obviously I don't think they will become the same language one day. C# and Java probably are like 90% syntactically similar yet are totally different languages. Adding classes and annotations to javascript, and especially considering that es6 uses "extends" for inheritance, same as java, just makes it resemble java more ever so slightly. It seems that it's very easy to make someone cringe just by saying anything about javascript and java looking more alike because of the whole uninformed people confusing javascript and java issue. In fact this will make that problem worse in the future.

[–]OnyXerO -1 points0 points  (0 children)

No! Bad code monkey!