8 ms·
Don't Roll Your Own
- giancarlostoro 4mo agoAt the same time, ask yourself "do I really need something special for this?" because the browser adds native support for things all the time.
- singiamtel 4mo agoI find that most datepickers are better than the browser's default. It's a shame that they can't be styled more
- julianozen 4mo agoYes, but having worked on the date picker at Airbnb I can assure you almost every custom implementation (probably ours too!) messes up date picking in some region in an important way
- neals 4mo agoExcept...?
- ceejayoz 4mo agoThere’s no except. They all suck in some specific way.
- childintime 4mo agoJust let me type the date in the user's local format and put in the dashes/slashes with a regex (and remove them again before applying insert/Backspace/Delete). Almost always this is so messed up and broken. And slow. Sigh. You anonymous code authors are always working to bring the user down, even when there is a 1000000:1 ratio between them and you.
- smrq 4mo ago"Just" Spoken like someone who's never had to work on a date picker.
- zamadatix 4mo agoI'm surprised no browser has a HTML based implementation which has been copied/extended in styling.
- paularmstrong 4mo agoI agree with a caveat: Default date pickers on mobile devices are very good. But on desktop browsers they are terrible. They break design continuity in a very ugly way and have quirks between browsers and systems. And personally, the popup calendar they provide just too small. If the system took over the date picker on desktop like it does on mobile devices instead of forcing the browser to handle it, I feel like we could get somewhere better.
- king_geedorah 4mo agoI just went and confirmed this because it’s not something I’ve really looked at and I agree. The date picker you get from a straight up <input type=“date”> on iOS webkit is pretty nice. The one in webkit on macOS isn’t quite as good, but is better than the one in firefox if only because firefox closes the picker when you type a year in to move far through time. Good thing firefox is open source.
- pwdisswordfishs 4mo ago> I find that most datepickers are better than the browser's You mean your browser's. There is no "the browser".
- Shellban 4mo agoThe Google Chrome team would like a word with you.
- pwdisswordfishs 4mo ago[flagged]
- joenot443 4mo agoI agree. The date range selector used in Google Flights is a near flawless control. The implementation can be done, it’s just hard.
- poisonborz 4mo agoFrom your perspective. Ask people using non-gregorian calendars.
- CrimsonRain 4mo agoThose people should set fire to all their digital devices, and be banned from everything digital.
- omnimus 4mo agoThe colonial powers have been saying that forever. You should simply use gregorian calendars. Then your date pocking starts to work.
- joenot443 4mo agoThe only countries which use non-gregorian in any official capacity are Ethiopia, Nepal, Iran, and Afghanistan, right?
- chihuahua 4mo agoTotally agree. What do engineers or designers think they're trying to accomplish when they mess with the scroll bar? Or the password field? "We are so sophisticated, the built in behavior is simply not good enough for us!" Congratulations, now your website is a shitty experience for your users. Well done.
- amarant 4mo agoIn my experience, it's never the engineers nor the designers who makes those decisions. Stuff like that always comes from higher up the ladder, some middle management figure who thinks he is smarter than he is, mandates such abominations and refuses to hear reason from the engineers and the designers. The engineers and designers then proceed to do as they're told because they like that nice fat paycheck at the end of the month more than they like the service they're building. Which is fair enough.
- cousin_it 4mo agoPortfolio websites of designers, where nobody's the higher authority but themselves, are full of scrolljacking and other fuckery.
- IcyWindows 4mo agoI don't know. Someone above mentioned that don't like their browser's date picker. Maybe they are a "middle management figure", but probably not.
- throawayonthe 4mo agothe date picker is the one i really disagree with because it really is terrible on most browsers
- setr 4mo agoNot liking it and having the conceit to replace it (and more importantly, shove your replacement into prod) are entirely different actions. The first is always legal. The second is more often questionable than not
- lysace 4mo ago> Don't roll your own page scrolling, link navigation, text selection, context menu, copy and paste, password field, or date picker. Javascript in the browser was a mistake. And if we had to have it, the suitable scope of it was what we had around 2004. Google invested tens of billions in it realizing they had a way of owning the browser space simply by making it insanely complex. Just hire all of the web standards people, tell them to go crazy and then also hire thousands of C++ browser developers for decades to implement everything. Boom, a moat!
- iainmerrick 4mo agoI understand the frustration but don’t take it too far. People often post great games here, cool visualisations, useful utilities. Hardly any of those would work at all without JavaScript. You can do terrible things with JS but you can do great things too.
- lysace 4mo agoThe cost of complexity is generally underestimated. (But hey, we can try out cool demos!)
- TacticalCoder 4mo ago> Javascript in the browser was a mistake. There are too many words in that sentence. Here are the words that can be removed: "browser", "in" and "the".
- ChrisMarshallNY 4mo agoI'm always an "It Depends" kind of guy. I have a personal issue with having a 500KB page load, so a button press can be animated.
- not_a_bot_4sho 4mo agoUgh you triggered me. I hate how most "modern" websites have MEGABYTES of JavaScript. CSS? Pack it in a js bundle with JSX and object literals. Images? Throw them in too, just make it load on demand. Hell, just put a <div id=root/> there and let js do the rest. It's not like we have browsers and networks and edge nodes optimized to render websites in other ways.
- Gud 4mo agoHonestly, your suggestions found just as awful. Bloated sites need to go. Putting makeup on the pig and it’s still a pig.
- ChrisMarshallNY 4mo agoI think the suggestions were a joke. It looks like you guys are both in alignment. CSS has advanced to a point, where you can add quite a bit of interactive “bling” to a site, with very little code.
- wxw 4mo agoUX standardizes as majorities begin to agree on patterns/interactions/concepts. Unfortunately, it’s 1) difficult to reach consensus 2) difficult to broadcast and 3) difficult to enforce. For example, even when major browsers achieve 1) and (e.g. implement a standard component) 2) and 3) are still huge gaps.
- yardstick 4mo ago> Among software developers, and especially among those who work on security-sensitive systems, there is a well-known maxim: Don't roll your own crypto. This does not mean that nobody is allowed to write cryptographic code. Someone has to. It means that, for ordinary production software that protects sensitive data of users, we should not rely on a private, unreviewed implementation that has not been vetted by the wider software development community. We should use established, vetted software packages or tools wherever possible. The great things about all these crypto libraries are: - Minimal to no dependencies - Coded by security conscious people - Often externally audited I wish more libs/deps are crafted like them. Until then the risk of rolling your own vs using a dep isn’t as different as it could be.
- leonidasrup 4mo agoDon't roll your own crypto, use what? OpenSSL ? LibreSSL, created as a response to the OpenSSL Heartbleed security vulnerability? Any alternative SSL/TLS library? Non-SSL/TLS cryptography? NaCL, Libsodium? Post-quantum crypto? There are many libraries, with different applications, protocol, crypto algorithms. Some implement everything, some implement secure minimum. Then the question is PKI, who do you trust your keys? Which SSL certificates do you trust?
- zephen 4mo ago"Don't roll your own" is perfectly sane advice... For those not trying to implement the dark patterns that enshittify the web. If you don't roll your own back button behavior, you've missed the opportunity to show a few more ads. If you don't make your window full screen on my shitty old tablet browser (yes, I'm looking at you, BBC), then it's far too easy for me to close your window. (Joke's on you, though -- my old Samsung tablet has a physical back button.)
- analogpixel 4mo agohttps://news.ycombinator.com/item?id=48141474 https://news.ycombinator.com/item?id=48141474 agreed, that page decided they needed to write their own scrolling logic and it made the page horrible.
- shermantanktop 4mo agoIf you don’t “roll your own,” you must choose from what other people have created. And in this space, there are a bewildering array of options, each of which carries some new pile of abstractions that make some things easy and other things hard. Many eyes are supposed to make bugs shallow. In the webdev space, many eyes on something like React lead to numerous opinionated alternatives, each successful enough to warrant consideration. This doesn’t seem to be slowing down, either. Meanwhile, vanilla HTML and DOM capabilities have never been stronger.
- iririririr 4mo agoso much this. tried to implement oauth recently. all providers only document their bloat-spyware-buggy javascript that creates a button and handles all in the client. then using libraries you are open to attacks in one hundred ways because those implement all the unrealistic things in the spec (including overriding issuer and setting crypto to nothing, via attacker controlled fields). after two days of evaluating i just gave up and wrote my own, server side and handling the singular case everyone uses. 20 lines, which was less then adopting the libraries.
- alcazar 4mo ago> Of all the things I mentioned above, the one that bothers me the most is custom scroll behaviour on websites. While I don't necessarily agree with the entire premise of the article - in particular, a well-designed range date picker is superior to two separate browser-native date pickers - I completely agree that custom scroll behavior needs to disappear.
- NooneAtAll3 4mo ago> Don't roll your own page scrolling. browser should not even let the page see this action > Don't roll your own link navigation. browser should not even let the page see this action > Don't roll your own text selection. browser should not even let the page see this action > Don't roll your own copy and paste. browser should not even let the page see this action I'm serious. WHY javascript code is even allowed to see all these actions of the user? We already loaded the page and rendered it - we users must already be free to do with the content as we please
- vitally3643 4mo agoIt should be illegal for a website to hijack text copying, right clicking, or keyboard shortcuts like Ctrl*f.
- VladVladikoff 4mo agoNo. There are already too many batshit insane laws trying to regulate the internet. We need less, not more.
- equinoxnemesis 4mo agoIndeed, people talk about technical solutions to social problems but there is also such a thing as trying a legal solution for a technical problem.
- js2 4mo agoAll of these annoyances and more can be blocked by StopTheMadness (available for iOS and macOS): https://underpassapp.com/StopTheMadness/ https://underpassapp.com/StopTheMadness/
- orhmeh09 4mo agoThis is one of the most useful programs I use every day. Works in Firefox too
- 4mo ago
- awongh 4mo agoIn the age of AI and npm supply chain attacks I feel like there are more reasons than ever to roll your own. One other possible title of this article could just be, don’t break UI conventions. Which is not the same thing. Instead of trying to download and configure a date time thing (for something app specific like domain specific date ranges) rather than having to rely on the configuration of a larger library, then having to manage all future major version upgrades (and some of these npm libraries have major versions every year!) why not just create your own smaller surface area component? It’ll be literally zero maintenance compared to managing an npm dependency in your app.
- Shellban 4mo agoCounterpoint: all of these things are built right into the user's browser, and browser vendors independently work to avoid attacks across the userbase without any intervention from web designers. In fact, if the browser itself is compromised, we probably have bigger problems anyway. By just letting the browser handle these tools, we do not need to spend any resources at all.
- bigstrat2003 4mo agoI'm going to go out on a limb and say there is never a valid reason to mess with page scrolling. It's just bad design and a terrible experience for the user.
- ethin 4mo agoI'd like to add: * Don't roll your own standard controls Seriously. Don't. You want a single-select box? Use a combo box or radio button group. Want an edit box? Use an edit box. Want a list that finds things as you type? That's in the standard too. Don't roll your own. This "roll our own controls for everything" bothers me to no end as a screen reader user, because practically nobody properly follows ARIA best practices, and that leads to a less accessible internet.
- LtWorf 4mo agoDon't worry, they bother everyone else as well since they are usually broken one way or the other.
- CrimsonRain 4mo agoThings wouldn't have gone this way if browser vendors and the working groups were not so lagging on adopting better UX for controls and had more built-in ways of customizing the looks. Take a look how long it took to be able to customize <select>. A hamburger menu or an accordion with proper viewport scrolling should be a couple of lines of html css...
- appplication 4mo agoYeah I could not agree more. I find myself wasting a lot of time building controls that really feel like they have probably been built ten thousand times before.
- Bender 4mo agoIf one really wanted to ruffle feathers they could make a script that checks out the latest source code for OpenSSL, OpenSSH maybe a few other communication daemons, makes just a few very subtle changes to a few ciphers, shim in some random nonsensical padding, static compile or containerize and distribute to a private network of systems in minecraft. Whatever you do don't teach AI how to do this or there could be a flood of VPN's speaking new but not really new ciphers that code breaking farms won't know what to do with and ciphers that are not known to exist and yet nobody ever really rolled their own. This concept was conceived whilst interacting with Rubix cube players.
- andai 4mo agoDon't fuck with the scroll bar should have its own article.
- nosioptar 4mo agoIt should be legal to cut off a dev's fingers if they fuck with the scrollbar.
- casey2 4mo agoWhat an odd idea. You should always write your own code whenever possible, that's how we get better things. It's not my job to make the standard better or to force a bad standard, it's your job to make the standard the obviously correct choice.
- wtallis 4mo ago> You should always write your own code whenever possible, that's how we get better things. No, that's how you end up with a mountain of bad half-assed implementations. You should only roll your own when truly necessary, and only after thoroughly understanding the problem and the existing mature solutions and honestly comparing that against your own ideas to see if you're missing important aspects of the problem. And even after doing all that, when it comes to implementing custom UI for something that already has a standard approach, you should still usually throw away your custom version because it won't be better by a wide enough margin to justify the effort users will need to invest in re-learning and breaking their existing habits. Save your UI experimentation for your personal tools, and don't inflict it on innocent users.
- bschwindHN 4mo agoI'd like to add "don't roll your own image viewer" twitter and google and google maps and so many have rolled their own and they completely suck compared to just letting the browser render an img tag. They inevitably fail on some bad multitouch interaction that affects the web page, and the image viewer container. Or they add some slow-as-molasses zooming effect.
- pvillano 4mo agoNobody cares that a browser's navigation buttons, address bar, tabs, or window controls don't match the current website. Probably because these things are obviously outside the extents of the web page. However, scrollbars, context menus, modal windows, and date pickers are rendered within the extents of the web page, and get replaced all the time. It is my opinion that these controls don't need to be styled to match the website, because they're not part of the website. They're part of the browser. Non-diegetic. Outside the fourth wall.
- pancsta 4mo agoHe’s totally right. It’s obvious.
- BrenBarn 4mo agoI'd go even more basic than this: only use native everything. It's a travesty that web pages are to use use custom controls or have any kind of look and feel different from the native OS ones. The look and feel of everything (every app, every webpage) should be determined by the end user, via their OS settings, not by the author of the app or document. What we have is designers being able to get to "my app/webpage looks the same for everyone"; what we ought to have is users being able to get to "every app/webpage looks the same for me".
- rozumem 4mo agoFor most users, link navigation for single page apps is far better than making round trips to servers which the 'traditional' browser would do.
- jason_oster 4mo agoThat depends entirely on how much needs to be downloaded for each round trip. A lean website can work just fine on complete trash connections like GPRS or Comcast without incremental loading. Web developers are not incentivized to make lean websites. SPAs add unnecessary complexity -> increasing page weight -> making finer grained incremental loading more important -> requiring even more code. It's a self-induced problem. As a corollary, McMaster Carr is often used as an example of a website that didn't fall into the SPA trap, and customers greatly benefit from that [1]. The front page weighs about 14 MB with all of the images, but the loading experience is great even with network throttling simulating a poor connection. There is a good reason the site has this reputation. Overengineering is the true root of all evil. Web developers cannot learn that fast enough. [1]: https://hn.algolia.com/?q=mcmaster+carr https://hn.algolia.com/?q=mcmaster+carr
- kazinator 4mo agoThe problem with Don't Roll Your Own is that Other People's Code gets more and more grotesque with each passing year. More bloat, more random dependencies, more churn. Other People are a headache in any industry; with Other People's code you have Other People problems by proxy.
- TZubiri 4mo ago> "there is a well-known maxim: Don't roll your own crypto." Fun fact, this was written shortly after one of the biggest linux vulnerabilities which was caused by a kernel crypto library, presumably to avoid userspaces rewriting their own crypto.
- okandship 4mo agothe split between documents and apps explains a lot of the pain here. if a page mostly presents content, hijacking selection, scroll, or copy should be treated as a regression
- rglover 4mo agoSometimes it makes sense to roll your own, sometimes it's a distraction. As always, judgment and taste matter to avoid mistakes and/or catastrophe.
- ryanschaefer 4mo agoA strange issue I’ve found is careless use of AI at my job has lead to many people rolling their own incomplete mini parsers. Think YAML parsers of a frontmatter that expects either `key: value` exactly or treats `item1, item2, …` as a list. It’s a litmus test I use to see if someone actually glanced over what the AI generated.
- Minor49er 4mo agoThis feels like a modern version of people writing regex to validate email addresses: employing a complicated, yet incomplete roll-your-own approach as the wrong solution to a problem
- xtiansimon 4mo agoTempest in a teacup. Don’t roll your own UI? You’d be apoplectic in the age of Macromedia Flash. Failure is. Let’s talk about the economics which permit bad webapps to continue in use. Illogical UI behaviors to be defended as “working as intended”. Or my favorite, UI redesign trend away from compact data dense UI towards open layouts with gobs of empty space (I guess it’s a touch UI compromise, because of “dashboards”). Or the financial incentives to remake the IP of excellent phone apps which end up looking and behaving worse. I suspect some must be tech debt, some reflect development job pool. But the rest? I blame MBAs No. I don’t mind roll your own. I mind rolling your own crap and defending the indefensible.