r/javascript • • Dec 16 '18

Coming from Python to JS NSFW

const print = console.log

I found my safe space.

607 Upvotes

156 comments sorted by

View all comments

337

u/Pavlo100 Dec 16 '18

Here is the Java implementation for those who want to make their life harder

const System = {out: {println: console.log}};
System.out.println("why?");

98

u/blasto_blastocyst Dec 17 '18 edited Dec 17 '18
import com.half.your.ram.is.gone.for.no.reason;

0

u/[deleted] Dec 17 '18

[deleted]

211

u/themaincop Dec 17 '18
Java apps      Javascript apps 
           🤝  
    Using half your ram
   for no goddamn reason

69

u/rangeDSP Dec 17 '18

A text meme. This is amazing

13

u/mutexjp Dec 17 '18

shots fired

6

u/placidified Dec 17 '18

Was using VS Code to as my editor for our Python backend. VS Code kept using 10GB of memory !

Switched to PyCharm.

13

u/PM_ME_HTML_SNIPPETS Dec 17 '18

Oddly enough, I don’t think I’ve ever had that problem with Code, but have had a few runaway memory sessions with ST3.

9

u/AlexAegis Dec 17 '18

there was a bug a month or two ago in the Python Language Server which caused heavy memory leaks. Probably still has some issues.

→ More replies (2)

4

u/unquietwiki Dec 17 '18

Must install outdated JDK, to support libraries not updated since 2006 on SourceForge...

2

u/YasZedOP Dec 17 '18

Could you explain why this would result in more RAM usage?

→ More replies (1)
→ More replies (1)

37

u/loopsdeer Dec 17 '18 edited Dec 17 '18

Shouldn't that err? I think you need console.log.bind(console). On mobile, can't test. I just don't want to give Java'rs anymore ammunition

Edit: Wow I've never been more excited to be wrong and to be down-voted. I'm not sure when this bug was fixed, but FOREVER this would have caused Illegal Invocation error. If you don't believe me, just search "console.log illegal invocation". Another one to throw on the "well, in my day..." pile. Yay!

20

u/[deleted] Dec 17 '18 edited Dec 17 '18

Stop downvoting him, assholes.

This didn't work without binding up until, if I'm not mistaken, Node.js 8.x. I don't remember it causing any errors, if I remember correctly it used to silently fail (i.e. not print anything because the log function would simply log to global).

Then at some point log() didn't depend on console being it's this. I've never seen a single sentence of explanation why this was changed, I've never used this kind of aliasing in browser so I'm not even sure it's a Node.js console implementation bug or a V8 bug, nor how Firefox behaved before (doesn't need bind() now).

So he was right.

Edit: Ah, yes, just needed to scroll down and find another post re the same thing and presto:

https://chromium.googlesource.com/chromium/src.git/+/807ec9550e8a31517966636e6a5b506474ab4ea9

3

u/loopsdeer Dec 17 '18

Aw thanks for the defense! Ya I looked through the chromium and firefox bugs and it looks like these have been very quietly resolved within the past year and a half.

But as I said in my edit, this is just one more thing on the "in my day" category now. For those of us using JavaScript since before jQuery, that category is quite huge and ever-growing. It's actually kind of delightful to be wrong in this way.

7

u/[deleted] Dec 17 '18

I'm no Samaritan tho, just extremely irritated by immature Reddit behavior of downvoting people out of own ignorance. Downvoting non-abuse is bad enough, but this really makes my blood boil sometimes.

3

u/loopsdeer Dec 17 '18

Why don't we walk together back to r/pcj friend, and blow off some steam. We can kick some rust crates over on the way.

2

u/[deleted] Dec 17 '18

Yeah. /r/javascript is such a toxic place. Nobody truly embraced the Script here from what I see.

2

u/ESCAPE_PLANET_X Dec 17 '18

The more technical a sub is, the more the reflexive downvote behavior is present.

Especially in broad subs where I assume people are just full Dunning Krueger -ing it.

2

u/kingocad Dec 17 '18

My favourite “in my day” was this IE6 bug that caused IE6 to lose the name attribute when manipulating form dom elements, they would never submit but would be visible in the developer toolbar. Trying to track this down pre-stackoverflow was a nightmare!

I still have PTSD form that one!

6

u/EriktheRed Dec 17 '18

Works in my browser console

4

u/loopsdeer Dec 17 '18

Thank you for checking. Just got to my computer to test and yes! No error! See my edit for why I am excited

2

u/MonkeyNin Dec 18 '18

I'm all about economy of characters, so I use

Ω = console.log.bind(console)
Ω("hi world")
// hi world
→ More replies (2)

4

u/rodrigocfd Dec 17 '18

My browser tripled its memory usage by showing this piece of code.

3

u/[deleted] Dec 17 '18

What is wrong with your whole family line?

→ More replies (7)