Live data from Hacker News

How true hackers write JavaScript

news.ycombinator.com

121–130 of 342 posts

Re: How true hackers write JavaScript

#121

https://twitter.com/triskweline/status/798443082740023296 > Valve's Steam Store renders on the server, uses ancient jQuery 1.8, loads 12 unminified JavaScripts. > It moved 3.5 billion dollars in 2015.

Why is rendering on the server part of that list?

Re: How true hackers write JavaScript

#122
post #72

The authors is quite lazy or cannot type fast enough, so he has to create all those cryptic abbreviations: `rks` for `ranks`, `unv` for `unvote`, etc. Which makes it really hard to read. But it's especially the inconsistent use of camelcase in function names than makes me think it's pretty amateurish.

Hard to read? The sum total of the script fits on 2-3 pages at most, no single function exceeds about 10 lines, if you have trouble reading and reasoning about that code then something is wrong.

functions will not be any line longer by writing ranks instead of rks, but it will greatly improve readability.

You can have the exact same code wihtout abbreviations, and I can assure you that it will still be 2-3 pages long, with very short functions.

Re: How true hackers write JavaScript

#123
post #72

The authors is quite lazy or cannot type fast enough, so he has to create all those cryptic abbreviations: `rks` for `ranks`, `unv` for `unvote`, etc. Which makes it really hard to read. But it's especially the inconsistent use of camelcase in function names than makes me think it's pretty amateurish.

>But it's especially the inconsistent use of camelcase in function names than makes me think it's pretty amateurish.

Despite its size, this .js file has been modified throughout many many years probably by various authors.

Re: How true hackers write JavaScript

#125
post #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.)

[deleted]

Re: How true hackers write JavaScript

#126

Um, is this supposed to be a criticism? Because this is MUCH better than sites loading megabytes worth of scripts to do nothing more than render text, have dozens of floating elements everywhere, auto playing videos that follow you, "use our app" buttons, etc... JS is the assembly of the web, do you also criticize games written in assembly?

macOS just notified me that one tab in Safari was using so much memory it was threatening performance of my laptop. The website in question? https://idioms.thefreedictionary.com/ It was close to 2Gb RAM usage. Bunch of ad-tracking stuff, I assume, as Firefox and its related processes seem to be using less than 1250mb with 6 tabs open, including the site mentioned in 2 tabs. My firefox has uBlock origin installed.

Seemed related to the second paragraph in your comment

Re: How true hackers write JavaScript

#127
post #86

In most places this code would never pass a code review and would be considered plain unacceptable. I guess I'd prefer some place where this code style is the norm.

So you would like to work a place with no code review? You will be happy to hear that many many workplaces have no code review at all.

> So you would like to work a place with no code review?

How does this follow from my statement?

Re: How true hackers write JavaScript

#128
post #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…

>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? Future you that has to decipher the code. Why make it hard on yourself? Software is a living thing eventually a decision will need to be made about it and without understanding what it does it'…

Eh, it's only 150 lines of simple functions without external dependencies. It's simple enough to understand and modify on the spot. As long as these are not expected to grow significantly in the future, I don't see why it'd be making it hard on yourself (and if it does grow, then it can always be refactored).

Re: How true hackers write JavaScript

#129
post #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…

> As long as the code works, anything else is just gravy

I'll try to incorporate this in my next job interview :)

Re: How true hackers write JavaScript

#130

Um, is this supposed to be a criticism? Because this is MUCH better than sites loading megabytes worth of scripts to do nothing more than render text, have dozens of floating elements everywhere, auto playing videos that follow you, "use our app" buttons, etc... JS is the assembly of the web, do you also criticize games written in assembly?

> JS is the assembly of the web, do you also criticize games written in assembly?

If it's a typical platformer from 1980s, now. If it's a modern game with a modern game's complexity, it would never be finished in assembly anyway.

Post reply on HN