HNHacker News
TopNewBestAskShowJobs

DCoder

1,260 karma · joined November 2, 2009

not here anymore
submissionscomments
DCoder··on Why Turning on HTTP/2 Was a Mistake
There's an argument to be made that this [0] (generated via [1]) is not something to be celebrated. But that's just me, not necessarily what the parent poster had in mind.

[0]: https://i.imgur.com/LhEahvi.png

[1]: https://www.evidon.com/solutions/trackermap/

DCoder··on Types will be part of Ruby 3 stdlib source
I'm sure some developers would manage such a project without TS. Good for them. I wouldn't maintain it that way because:

1. I don't have the mental capacity to keep every single function's argument/return shape in my head, or to manually check it every time I make a change. Unit tests can't deliver 100% code coverage in practice.

2. Nor do I want to perform refactorings with stone age tools like s/setFoo/setBar/g. Setting up type information lets my IDE understand which calls to .push() deal with a native Array and which ones deal with my own class, so it can rename the latter ones when I ask. I can also use tools like "Find References" and avoid false positives.

3. I'm not a one-man-band. My coworkers need to deal with this project too, and new developers need to be introduced to it from time to time, and types serve as documentation and guard rails for them much better than jsdoc or regular comments. (This also serves as a significant barrier against using anything more esoteric like Elm, because nobody around would be familiar with it. TypeScript adds just enough syntax on top of regular JS to keep JS users comfortable.)

---

I do use `any` (and `unknown`), I have no doubts that an edge case can crash my app because I didn't validate something, and I never expect third-party code to work flawlessly whether it has types or not. Rejecting TS completely because "but run time loopholes" is throwing the baby out with the bathwater (or to put it in a more hyperbolic way, being an anti-vaxxer because vaccines are not 100% safe from side-effects). TS and types are an additional safety net/force multiplier†, not a silver bullet. (That said, what is a silver bullet? Because I'd sure like one.)

---

† Only applies to a project that has passed its initial rapid prototyping phase. During wild prototyping rides, types can indeed slow you down. But that's really the same debate as RDBMS vs NoSQL.

DCoder··on Types will be part of Ruby 3 stdlib source
I started using TypeScript back when it was 0.8, before it even had generics. Does that make me a fanboy? I have a project with about 45k SLOC of TypeScript (using Knockout.js for presentation). There is really no way I would maintain that same project without types.

> For my work I look at horrible code bases, perfectly typed and strictly formatted by tslint.

There is no language that can stop people from producing horrible code.

DCoder··on How Not to Acknowledge a Data Breach
C&C also used to stand for the old game series Command & Conquer.
DCoder··on I found two identical packs of Skittles among 468 packs
Lego Mindstorms has a color sensor, so theoretically you can build that AI in Lego.
DCoder··on JQuery 3.4.0 Released
I'm not the parent poster, and I'm not sure if these are the regex selectors they had in mind, but nonetheless.

An example use case: the person writing the HTML ≠ the person writing the selectors. Browser extensions like Stylus, for example. If the HTML author did not bother to add a specific class you need, you have to resort to ugly methods.

In fact, this is a scenario I deal with regularly. I have a Chrome extension for video download sites that scans the current page for metadata (title, performers, release date, etc.) and decorates the download links with `download="…"` attributes, so that I can download a file with a properly formatted filename. I manually adapt this extension to every site I need, and quite often I need things like `a[href^=/model/]` † to distinguish links to performers from other links to get their text content. It's clearly not a situation the site authors worry about, and that's fine as long as I have a way to do this myself.

† This particular selector can be done without jQuery if you don't care about backcompat. In browser extensions, you usually don't. But it's still an answer to your question about when such selectors are needed.

---

Since I'm talking about this, that same browser extension can demonstrate some other complications brought on by React and CSS-in-JS:

1. CSS-in-JS turns class names into unreliable gobbledygook, so extracting metadata means more regex selectors and abominable DOM hierarchy selectors (`section>div>div:first-child>div` because nobody bothers with semantic <h2> or even .title anymore).

2. React makes DOM elements vanish and reappear instead of just hiding them, so that `download="…"` attribute I want to add has to go through a MutationObserver instead of just running once on page load.

DCoder··on JQuery 3.4.0 Released
This is the good old imperative-vs-declarative debate. jQuery is "(I think) I know what the current state of the UI is, make these changes", React is "I need the UI to be in this state, you figure out how to get it there".

In my experience, with jQuery you spend a lot more time making sure each and every event handler puts all UI elements in a correct state, often repeating yourself or calling the same helper functions. With React, all that computation is concentrated in render(), making it easier to reason about. And if you need to add a new UI element, reviewing all jQuery event handlers will again be a lot more work.

Of course, this assumes you are working on a real SPA with a lot of dynamic state, not on a reddit clone where all you need is a reply button to hide/show a textarea and a hidden field to track the parent post id.

DCoder··on JQuery 3.4.0 Released
And from which CDN?
DCoder··on Google AMP lowered our page speed, and there's no choice but to use it
> My email is on my profile

The 'Email' field in the profile is not visible to other users. You should add it to the 'About' field.

DCoder··on Facebook are 'morally bankrupt liars' says New Zealand's privacy commissioner
And maybe some way to forget the horrible material they have to sift through.
DCoder··on Facebook are 'morally bankrupt liars' says New Zealand's privacy commissioner
When RIAA/MPAA/etc. came with astronomical fines, those same companies suddenly created the capabilities to block things that even smelled like copyrighted material. Whatever your opinion of MAFIAA is, it would seem this sort of detection can be done when a large enough stick is presented.
DCoder··on Facebook Asking for Some New Users' Email Passwords
"It's your problem now!"
DCoder··on I Miss Rails
One more thing that IMO gets overlooked too often: TypeScript can typecheck your JSX markup. Compare that to any string-based templating engine, such as Knockout.js templates or jquery.tmpl, where you have to learn its snowflake DSL, you get no autocomplete, no checks for undefined variables or syntax errors…

If I never have to explain <!-- ko if: !condition --> vs <!-- ko ifnot: condition --> again, I'll be a happy man.

DCoder··on New in Chrome 73
> All I care about is solid support for standards and Chrome shines it that.

Except for cases when it doesn't feel like supporting the standard in question, or it claims their support is sufficient. A recent example could be support for <input autocomplete="..."> [0].

[0]: https://www.reddit.com/r/programming/comments/ar1qj1//egl52w...

DCoder··on New in Chrome 73
Was this motivated by something in the release notes, or are you just taking the opportunity to bang the Firefox drum? Should we expect this comment in every Chrome-related thread?
DCoder··on A Newly-Generated Create-React-App 2.1.5 App Has 1,568 Dependencies
Even if you have worked with that framework before, odds are six months have passed since then and the framework has changed 50% of its best practices. Using a tool like this also avoids stale documentation/tutorials.
DCoder··on Don’t Get Clever with Login Forms
Try Shift-Ins instead. It also performs pasting, but fewer people seem to be aware of it.

Trivia: Shift-Ins actually predates Ctrl-V :-)

DCoder··on My Chromecast Ultra would not start until I began answering 8.8.8.8
In theory, couldn't Firefox's certificate store blacklist the TLS certificate your website uses, with the same user-confusing result?
DCoder··on My Chromecast Ultra would not start until I began answering 8.8.8.8
It could also mean your internet not having some other sites which chose to side with Google.
DCoder··on How hard is it to have a conversation on Twitter? So hard even the CEO can’t
And yet something as basic as a preview is missing. Reddit's community-driven browser plugin ([0]) at least adds that, HN's counterpart [1] sorely needs it.

---

Come to think of it, is there a definitive guide to HN comment formatting? Implementing a preview feature in [1] would be doable if the markup is documented.

[0]: https://redditenhancementsuite.com/

[1]: https://chrome.google.com/webstore/detail/hacker-news-enhanc...

DCoder··on Android Phones Can Be Hacked Remotely by Viewing Malicious PNG Image
There was also the Windows Metafile mayhem [0].

[0]: https://en.wikipedia.org/wiki/Windows_Metafile_vulnerability

DCoder··on 38% of bugs at Airbnb could have been prevented by using types
Compiled code doesn't have to be unreadable.

Languages like C and C++ made it readable with debug symbols.

The web stack does the same with source maps. The TypeScript compiler also offers to emit .d.ts files with type information for reuse in other projects.

DCoder··on 38% of bugs at Airbnb could have been prevented by using types
"Takes many types" ≠ "cannot be typed". TypeScript supports decorators, union types, and `any`/`unknown` types.

Those generic use cases are good examples of flexible types, but I have a hard time seeing how

* "I don't know whether the `getMyReplies()` function returns a list of items, an iterator, a non-rewindable generator whose results I need to cache, or a closure with/without memoization" and

* "I don't know whether the singular Reply entity has a field called pid, parent_id, parentId, ParentID, ParentGUID, or parent_message_identifier"

are advantageous to rendering a list of replies.

DCoder··on 38% of bugs at Airbnb could have been prevented by using types
The JS libraries usually fail at the "do it well" part.

* UNIX tools don't get updated every week.

* UNIX tools don't get deprecated and replaced every month.

* When UNIX tools do update, the updates don't carry a risk of adding shady code from new maintainers because the original author "got bored lol" and handed the repo over to the first person who asked.

* When UNIX tools do update, the updates don't introduce unvetted and undocumented code that will, for example, start displaying Christmas decorations in your UI on certain dates.

How many UNIX tools actually come in "writing this from scratch is faster than searching for a tool that already does this, so I'll just write my own" size (except for `yes` and such)? Trick question: is trying to install a new UNIX tool similar to this [0]?

[0]: https://what.thedailywtf.com/post/1441806

DCoder··on 38% of bugs at Airbnb could have been prevented by using types
How long does your integration test take to run and report failures? Compared to instant feedback while you're writing the code, that's glacial.
DCoder··on Moving from Go to PHP Again
There's also Vimeo's Psalm [0].

[0]: https://github.com/vimeo/psalm

DCoder··on Moving from Go to PHP Again
I think the parent is objecting to the fact that annotations spray this "external" information right in the middle of the controller/model. FWIW, decent tools let you put this info in separate configuration files instead of code annotations, "decoupling" it from the code.
DCoder··on Moving from Go to PHP Again
> what more care do you need?

1. Generic typehints, for one. Typehinting half the methods as returning a generic `array` is not fun.

2. And that's before you even remember that PHP's array is both a vector and a hashmap, so you need to install a PECL extension or a third-party library to get proper Map/Sequence/etc.

DCoder··on Moving from Go to PHP Again
The exec bit is also important for accessing sub/directories. Although for that you should use X instead of x…
DCoder··on Add limits to amount of JavaScript that can be loaded by a website
Note that we already have examples of a certain resource limit. WebSQL and IndexedDB databases are capped to a maximum size per domain, and different browsers have different caps and different UX for configuring/bypassing them.

Granted, those technologies are not as widely used and that limit, if absent, would not inconvenience the user as quickly and easily as CPU/memory hogging does.

← PreviousPage 3 of 16Next →