Live data from Hacker News

How true hackers write JavaScript

news.ycombinator.com

91–100 of 342 posts

Re: How true hackers write JavaScript

#91

More garbage ycombinator hero worship. 'True Hackers' ? Grow up!

One trait of true hackers is that they actually create things. As in "hack something together".

And yeah, this playful attitude to "just do it" tends to goes away when people become adults.

So in my book, it is better to grow down!

Re: How true hackers write JavaScript

#92
post #6

function onready () { recoll(); } document.addEventListener("DOMContentLoaded", onready); Just attach recoll() directly. There's no benefit of going via onready().

You don't have to make every piece of code 100% tight. onready is actually the kind of function that you very likely want to add more lines to in the future, so why not leave it in? (I'm willing to bet it had more lines at some point in the past.)

Re: How true hackers write JavaScript

#93
post #11

This is neat (how the up/downvote onclick handler sends the info to the server). new Image().src = el.href; Where href looks like this: vote?id=xxxxxxxx&how=up&auth=yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy&goto=item%3Fid%3Dzzzzzzzz#wwwwwwww

Is this a GET request? What if my browser wants to peek ahead on some links?

Re: How true hackers write JavaScript

#96
post #70

function hidestory (ev, el, id) { for (var i=0; i That 3 there is the problem with “simple” JS. It’s tightly coupled to the HTML but they live in completely different places. On a side note this 3 should be at least assigned to a variable with a meaningful name.

hidestory() is not even used anywhere ; why is it here for? Debugging?

Like JS is never attached to a HTML template ?

Re: How true hackers write JavaScript

#97
It works... every criticism beyond that is just an argument about taste, although personally I think it's unnecessarily terse.

I've written uglier code and gotten paid for it. ¯\_(ツ)_/¯

Re: How true hackers write JavaScript

#98
I don't understand why people are dissing this.

It does what it's designed to do, and fills a specific need for one website. It's not there as a teaching aid, nor is it meant to be shared for other people to use elsewhere.

Not everything has to be gold-standard code full of perfect variable names, extensive comments and good whitespacing. If you have a day job that isn't primarily writing code, and/or you are likely to be the only person ever working on that code, who cares if it's not up to the standard that people around here seem to expect of every project?

As long as the code works, anything else is just gravy. If you were to peel back the layers on all the major websites out there, I'm sure you'd find less than stellar code everywhere.

Re: How true hackers write JavaScript

#99
post #70

function hidestory (ev, el, id) { for (var i=0; i That 3 there is the problem with “simple” JS. It’s tightly coupled to the HTML but they live in completely different places. On a side note this 3 should be at least assigned to a variable with a meaningful name.

hidestory() is not even used anywhere ; why is it here for? Debugging?

It's called by the "hide" link under each story on the top page.

Re: How true hackers write JavaScript

#100
post #15

Either run it through a minifier or have the whole thing unminified, these single lined functions look horrific, and are saving characters for the sake of it. Terrible naming, e.g. 'vis' -> reading the function it means toggle visibility, so it should be called 'toggleVisibility', you shouldn't have to read what the function is doing to understand what it will do. You ever get a bug in your code, It's not fun to look…

> Terrible naming, e.g. 'vis' -> reading the function it means toggle visibility, so it should be called 'toggleVisibility'

But it doesn't toggle visibility. It sets visibility.

Post reply on HN