News for hackers. Stuff that matters.
Re:Ask HN: What are these low quality “code snippet” sites? by shmde on Wednesday December 01, 2021 @01:32PM (#29407321)
Just to chip in with a very minor annoyance, I hate how google puts up w3schools results above MDN for anything related to JS/HTML.
Re:Ask HN: What are these low quality “code snippet” sites? by a_e_k on Wednesday December 01, 2021 @02:27PM (#29408044)
Hell, yesterday I searched for `python string split`.

Stupid w3schools was the first hit. The official library reference documentation on python.org (which was what I was looking for) didn't turn up until nearly the bottom of the 2nd page of search results!! Beyond frustrating.

Re:Ask HN: What are these low quality “code snippet” sites? by projproj on Wednesday December 01, 2021 @02:15PM (#29407902)
Check out tomdn.com. I created it to make it easier to get to MDN. E.g., instead of googling array.map, just type tomdn.com?array.map. It will take you straight to MDN docs on Array.prototype.map. Other things work as well, like tomdn.com?object.keys, tomdn.com?css.color, tomdn.com?htmlel.button, etc.

If there is a pattern it doesn't recognize, you end up on the MDN search results page.

edit: More info. about how it works is available here: https://github.com/tayler/tomdn

Re:Ask HN: What are these low quality “code snippet” sites? by hnarn on Wednesday December 01, 2021 @03:50PM (#29408959)
What value does this provide over simply Googling or DDG'ing "array.map mdn"? It's shorter and the first result for me is (unsurprisingly) MDN on both, and I don't have to run my searches through an unknown third party.

DDG also has !bangs for this specific purpose and !mdn does, as expected, lead you to MDN.

Re:Ask HN: What are these low quality “code snippet” sites? by projproj on Wednesday December 01, 2021 @04:20PM (#29409279)
Valid questions. I just think it's faster. One action on tomdn.com instead of 1. DDG "array.map mdn", 2. Find MDN result (usually first), 3. Click result, 4. See docs.

Bangs are great, just shorter again to use tomdn.com: - `!mdn array.map` leads me to https://developer.mozilla.org/en-US/search?q=array.map, which I have to scan the results and click on. - tomdn.com?array.map leads me to the exact page in the docs. https://developer.mozilla.org/en-US/docs/Web/Javascript/Refe...

This may or may not be valuable, but I like saving the extra steps for something I do many times a week. Basically this calculation (https://xkcd.com/1205/) works out for me + the fun of working on a new project.

edit: >I don't have to run my searches through an unknown third party

Very sympathetic to this concern. Feel free to host yourself -- it's a single html file. https://github.com/tayler/tomdn

Re:Ask HN: What are these low quality “code snippet” sites? by striking on Wednesday December 01, 2021 @05:20PM (#29409903)
`! mdn array.map` takes you right to MDN
Re:Ask HN: What are these low quality “code snippet” sites? by projproj on Wednesday December 01, 2021 @05:55PM (#29410222)
Totally had no idea. Thanks for the tip. I guess tomdn.com is for non-ddg users only.
Re:Ask HN: What are these low quality “code snippet” sites? by bbarn on Wednesday December 01, 2021 @01:37PM (#29407398)
I've seen several developers google "w3schools someDomEvent" because they are conditioned by those search results. Has it accidentally become a halfway useful site?
Re:Ask HN: What are these low quality “code snippet” sites? by kilburn on Wednesday December 01, 2021 @02:49PM (#29408298)
> Has it accidentally become a halfway useful site?

It has. It is nowhere near the quality of MDN, but also nowhere nearly as bad as it used to be.

W3Schools has less information than MDN. This is bad for the experienced, but a relief for people who are entering the trade.

As an example, consider an inexperienced web developer that wants to do something when a button is clicked. They google for it and find these two pages:

- https://www.w3schools.com/jsref/event_onclick.asp . Right there in the middle of the page is an example snippet that will get the job done. If I scroll down I see other ways to do it, all of them fully contained (i.e.: I can copy-paste it to some website and they will work).

- https://developer.mozilla.org/en-US/docs/Web/API/Element/cli... . There's a table of things I don't understand (Bubbles? Cancellable?), two lengthy discussions about weird edge cases in some browsers, and (finally!) a single not-so-simple example that is not even enclosed in <script> tags.

What website do you think they'll pick?

Re:Ask HN: What are these low quality “code snippet” sites? by valenaut on Wednesday December 01, 2021 @01:41PM (#29407449)
It's fine for simple things. I referenced it a lot when I was first learning JS and HTML because it was usually at the top of Google results. I think MDN is strictly better.
Re:Ask HN: What are these low quality “code snippet” sites? by vlunkr on Wednesday December 01, 2021 @02:39PM (#29408188)
IMO it is a legitimately useful site, but strictly for beginners, and probably only for html/css. It teaches you the basics and has the sandbox to test things out. It's fine, just not what you want to see when you're looking for actual documentation.
Re:Ask HN: What are these low quality “code snippet” sites? by myohmy on Wednesday December 01, 2021 @02:50PM (#29408303)
I used it to learn CSS way back in the day and it still seems to be a good balance between too little and too much for the beginner, so I still send my newbies there.

Not surprised it shows higher than the actual spec. I think the HN community is just getting to the greybeard stage (I'm still cutting out grays), and this is our version of JUST READ THE MAN FILE

Re:Ask HN: What are these low quality “code snippet” sites? by blahyawnblah on Wednesday December 01, 2021 @04:59PM (#29409673)
I do the same, but with "mdn" instead of "w3schools"
Re:Ask HN: What are these low quality “code snippet” sites? by 5e92cb50239222b on Wednesday December 01, 2021 @02:15PM (#29407891)
Are you positive the first term wasn't prefixed by a hyphen-minus?
Re:Ask HN: What are these low quality “code snippet” sites? by Kiro on Wednesday December 01, 2021 @05:40PM (#29410094)
I prefer W3Schools to MDN.