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…
How true hackers write JavaScript
281–290 of 342 posts
Re: How true hackers write JavaScript
#282Everything 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…
Really? Most Javascript developers live in the world of trillion-dollar startups serving billions of people? That's why they need Kubernetes, React, and 2000 nodejs modules to show a couple of confirmation dialogs on the SOHO website they are working on.
Re: How true hackers write JavaScript
#283Either 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…
Re: How true hackers write JavaScript
#284Either 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…
I couldn't disagree more with your first sentence - being able to see all those functions in the first page of the code above the fold is what makes this 10 times easier to understand than any React or Angular component I have ever seen. In fact if a function doesn't fit on one line, it should be refactored into simpler functions until it does. Oh for a full UI framework like this made of single line functions - One…
Re: How true hackers write JavaScript
#285But 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…
Re: How true hackers write JavaScript
#286There 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 u…
It's terse and effective, I suppose, but it was really interesting measuring pixels to judge comment nesting.
The JS itself is fine. It's the markup that's a mess.
Re: How true hackers write JavaScript
#287Earlier quoted context omitted.
> It costs almost nothing more to write "event" instead of "ev" or "removeElement" instead of "remEl", but it makes the code much more readable. No, it doesn't. Unless you're an absolute beginner, it takes you a couple of seconds to realize that in this codebase, "ev" (or "evt" or even "e") means "event". The same goes for "remEl". If that's consistent, then it's not a big deal at all. Having less characters makes co…
>Having less characters makes code more readable (or rather "scannable") as well, it's just another tradeoff. Only to a point, otherwise minified js would be more legible than plain source. It takes "a couple of seconds" to scan the codebase and find out what el or ev refer to, but it would take zero seconds if they were just called "event" or "element."[0] There's no gain in readability from shaving off one or two c…
I think it's generally frowned upon, though. For example, I believe "event" is defined as a global in browsers (on window, perhaps?), so you run the risk of shadowed variables and accidentally referring to the wrong thing.
Re: How true hackers write JavaScript
#288I'm not sure if this was linked fatously, but this is actually pretty good JS. - All functions - The functions are simple and decomposed into smaller functions - No usages of "this" (except one necessary one in an event handler) - No ham fisted attempts at doing OOP with JS Only complaints really are naming and code style is overly compact which would potentially make it harder to understand, but in this context I th…
Re: How true hackers write JavaScript
#289I 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…
You will.
> As long as the code works, anything else is just gravy.
These attitudes are really making some projects collapse like hell. If you agree to it, you need to stop writing code unless it's just for you.
> I'm sure you'd find less than stellar code everywhere
If this makes you feel proud of writing shit code, you need to stop as well.
Re: How true hackers write JavaScript
#290But 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…