Live data from Hacker News

How true hackers write JavaScript

news.ycombinator.com

251–260 of 342 posts

Re: How true hackers write JavaScript

#251

Earlier quoted context omitted.

> As long as the code works, anything else is just gravy. Nonsense. Maintainability almost always matters. As the adage goes: code shouldn't merely work, it should clearly work. > 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. Indeed, but Sturgeon's Law shouldn't make us feel better.

> Nonsense. Maintainability almost always matters. The last three large corporations I worked for never cared about maintainability because the application or portal would only be in use for maybe a year or 18 months before a complete rewrite or total redesign. All of the recent projects I've been on take the same approach. Get it stood up, make it look pretty and release it. Because agile development makes business…

the application or portal would only be in use for maybe a year or 18 months before a complete rewrite or total redesign

Why on earth is this such a popular idea? Do customers somehow prefer to see all the buttons in new places and old urls broken every other year?

Re: How true hackers write JavaScript

#252

Everything has a context. If your site has: - minimal functionality - rarely if ever changes - is maintained by a very small group (Hacker News) ...then something like the example linked is perfect. Most web app developers don't live in this world. The more common situation is: - large and/or transient teams - large quantity of inter-dependent features - constant changes ...which means that the thing you need to opti…

Right, and "true hackers" aren't team players if they're slanging this all over the place.

Re: How true hackers write JavaScript

#253
post #202

Earlier quoted context omitted.

I like what this guy did, talking about native methods. However it's too flexible for me, I prefer to have the most minimal functionality in order to ensure consistency in my code. But maybe that's just me. If the library opens up too many possibilities, then I have both the "problem of choice" when writing code, and also it's more difficult to refactor down the line if you want to change lib. Whereas using your own…

I've been using this for years – it's not the end of web development but an awful lot of projects don't need more framework than can fit in a tweet: let $ = (selector, scope=document) => { return scope.querySelector(selector); }; let $$ = (selector, scope=document) => { return Array.from(scope.querySelectorAll(selector)); };

My personal microframework:

    const node = (tag = 'div', attributes = {}, inner) => {
        const e = document.createElement(tag);

        for(const [key, value] of Object.entries(atrributes))
            e.setAttribute(key, value);

        if(inner) e.innerHTML = inner;

        return e;
    };
The premium version contains an additional:

    e.child = (a,b,c) => { const f = node(a,b,c); e.appendChild(f); return f; };

Re: How true hackers write JavaScript

#254
post #221
post #189

Earlier quoted context omitted.

And I bet there are some people here using IE. And old browsers.

I would REALLY love to see the browser usage statistics for HN :)

Well.. I might be an outlier, I use OmniWeb and Camino as they give the best results with my 2005 Mac. So I'm still living in the Pre-=> Age.

Re: How true hackers write JavaScript

#257

Earlier quoted context omitted.

>> Modern web apps are less about being performant and minimal, and more about dealing with the complexities of large software teams If that's true, then the app will likely have what I call a "programmer's interface" (which is especially common in most enterprise web apps I encounter). Those apps might be solid from a code perspective, but don't tend to be very user friendly. I tend to think that modern web apps are…

The fancy-lookin' sites are the ones which hijack basic keyboard functionality, scroll in weird ways, etc. I can't be the only person who finds browser default behavior more intuitive and usable in general. Why does "UX" so often mean mouse-heavy and always favor the beginner over the power-user.

I agree that following browser default behavior is more intuitive in general. I'm not a fan of scroll jacking.

I'd say apps skew towards mouse-heavy because controls are on-screen and therefore discoverable. It takes a good deal of product-market fit before you can count on your users knowing/caring enough about your app to remember keyboard shortcuts.

Most apps are grown by adding users, so optimizing for the new user is more important to the business until a certain level of maturity and market saturation is reached.

Applications with a dedicated professional user base can go deeper into power-user territory sooner since they can charge more per user, and new users expect there to be a learning curve.

Re: How true hackers write JavaScript

#258
Am I the only one who thinks this is unreadable?

    var on = !afind($(id), collapsed());
    (on ? addClass : remClass)($(id), 'coll');
where

    function afind (x, a) { var i = apos(x, a); return (i >= 0) ? a[i] : null; }
where

    function apos (x, a) { return (typeof x == 'function') ? posf(x,a) : Array.prototype.indexOf.call(a,x) }
where

    function posf (f, a) { for (var i=0; i 

Re: How true hackers write JavaScript

#259
But where is Webpack??? Why aren't they using ES7 decorators and lambda syntax? Each one of those functions should be broken out into its own separate source file and they should be using classes, not functions. For the love of god, how do they trust this code will do the right thing without the obligatory type safety of a shoe-horned type system?

And what is with this code returning false for everything? Everyone knows you're supposed to return JSX wrapper in another DIV in order to talk to browsers!

Lastly, how could they ever expect this solution to scale? I bet this is only slightly worse than okay for a hack-a-thon but hell would surely freeze over the minute a single user was forced to use it!

It's a maintenance nightmare. It's far better to start with some webpack + react boilerplate. Each one of the dependencies means that someone else is maintaining the code, so you can wash your hands of that responsibility and sleep well knowing internet elves are maintaining your web app!

Re: How true hackers write JavaScript

#260

But where is Webpack??? Why aren't they using ES7 decorators and lambda syntax? Each one of those functions should be broken out into its own separate source file and they should be using classes, not functions. For the love of god, how do they trust this code will do the right thing without the obligatory type safety of a shoe-horned type system? And what is with this code returning false for everything? Everyone kn…

Come on.
Post reply on HN