Live data from Hacker News

How true hackers write JavaScript

news.ycombinator.com

111–120 of 342 posts

Re: How true hackers write JavaScript

#111
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'…

> 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's easier to make suboptimal assumptions.

To the defense of the title, in my experience, whenever label "hacker" was used on programmer or code, it meant "difficult to read, full of hard to maintain shortcuts and tricks" kind of code. Really always, I don't ever remember it to be used in any other sense.

Re: How true hackers write JavaScript

#112
There might be more appreciation for "how future maintainers write JavaScript", but that's not cool and it takes a couple of decades more experience.

Looks a lot like "read-only" web code I've encountered on projects, where waves of people decided it's easier to work around what's already there than amend it (and that's also how you end up with 20,000 line CSS files).

Re: How true hackers write JavaScript

#115
post #111

Earlier quoted context omitted.

>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'…

> 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's easier to make suboptimal assumptions. To the defense of the title, in my experience, whenever label "hacker" was used on programmer or code, it meant "difficult to read, full of hard to maintain shortcuts and tricks" kind…

True this

Re: How true hackers write JavaScript

#116
There are some polarized opinions in this thread. Someone wrote That might be one of the most readable pieces of code that I've ever read. Apparently it improves readability immensely to rename 'forEach' to 'aeach'.

To be honest the code is not very readable, but it is very simple and self contained. It would be very easy to dive into to fix a bug because there are no external dependencies or frameworks you have to understand.

The list of one-liners at the top seem like a very minimal 'jQuery'-like layer. Perfectly fine except for the l33t identifier names.

But there is also some really fragile coupling to the HTML, e.g.:

   for (var i=0; i 
I wouldn't dare to modify the HTML when the JavaScript looks like this! What are the three elements which are being removed? Why exactly three? Probably the author and maintainer of the code knows, but this is the kind of coupling where nobody except the original author would dare to change anything. Perhaps this why HN still uses tables for presentation - nobody dares to change it?

Re: How true hackers write JavaScript

#118

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?

No it isn't, any more than C++ is the assembly of your operating system.

Assembly has the terseness that it does because of constraints that javascript doesn't have -- this javascript looks the way it does because the author wanted it to look like lisp code, not because it has to.

Re: How true hackers write JavaScript

#119
post #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!

In defense of some adults, I think a key point here is to realize that it's very different to do something alone, basically for yourself, and with the idea of (mostly) learning and exploring, that working with other people, for other people, and expecting the thing you are working on to keep functioning for the foreseable future.

I think it's important to understand both contexts (and practice them!).

Re: How true hackers write JavaScript

#120
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…

I believe there is a difference between gold-standard perfect code and just making "beginners mistakes".

It costs almost nothing more to write "event" instead of "ev" or "removeElement" instead of "remEl", but it makes the code much more readable. You might gain 1s for writting remEl instead of removeElement but you will loose more seconds in the future trying to remember what remEl stands for, or having to check what abbreviation you chose for that function.

It's just something programmers learn with experience (even when working alone) : abbreviations are a false good idea, and people are just pointing that out.

Post reply on HN