4 ms·
>There are a few people who frequently have this complaint, but I don't think it's a real problem. If you actually need to do Y in a situation where most people
by coldtea 6y ago
>There are a few people who frequently have this complaint, but I don't think it's a real problem. If you actually need to do Y in a situation where most people who think they need to do Y are wrong, it's not everyone else's responsibility to divine that you are the magical case.
Well, that's strange, because what they do is still divining. They try to divine "what you actually wanted", even though you asked another thing.
Even worse, a lot of the time the one doing the asking has explicitly said "I know this is unorthodox" or "just answer how to do Y please, don't give me your 'better' options".
It's especially annoying when what you what to do is hack something (and not do it the official way), bypass some restriction that absolutely prevents X, try an alternative style, push the envelope, or generally think Y is better even though the "conventional" sheep-like answer is "do X".
An example of the latter would be trying to use Java with simple POJOs and lite patterns in ~2005, and everybody suggesting you go through some monstrous J2EE setup with half the GoF book thrown in instead because that's "idiomatic".
Or e.g. trying to ask about trying to use a regex to quickly parse some known-quantity HTML where regex will work just fine (say, extract all href out of all a elements), and everybody insisting they lecture you on proper html parsing instead, not caring about your use case.
- dsr_ 6y ago'a lot of the time the one doing the asking has explicitly said "I know this is unorthodox" or "just answer how to do Y please, don't give me your 'better' options".' After being burnt by a person who never wanted to do anything in a conventional, well-supported way* and kept making that explicit request, I have given up volunteering my time to appease them. At work I get paid to say "I know a couple of ways of doing that, but if you could tell me more about your problem and the constraints, I can give a better answer." *Problem: router and three laptops need to be networked. Conventional solution: ethernet cables or wifi. Requested solution: IP over serial (SLIP or PPP) over USB-serial connectors. Had not purchased USB-serial adapters.
- AnIdiotOnTheNet 6y ago> After being burnt by a person who never wanted to do anything in a conventional, well-supported way* and kept making that explicit request, I have given up volunteering my time to appease them. That's fine and completely fair. Just don't provide unasked for answers as an alternative.
- fiddlerwoaroof 6y agoI’ve found (on both sides of the conversation) it’s really effective to find a third party that consistently asks what X is: when I’m on the “answering” side of this problem, I’ve generally found that saying something like “Y is impossible” or “Y can be done this way but that’s usually a bad idea, why do you ask?” Goes a long way to being effective at answering the question.
- pwdisswordfish8 6y ago> known-quantity HTML where regex will work just fine (say, extract all href out of all a elements), Regex doesn’t work fine even on that. You still need to tell apart actual tags from contents of attributes, comments, uninterpreted contents of <script>, and so on. A regex alone doesn’t give you the ability to do that. If you want to parse HTML, you need a parser. Simple as that.
- AnIdiotOnTheNet 6y agoOnly if you care about absolute accuracy in sufficiently complex pages. There are many use cases I can think of that really don't.
- TeMPOraL 6y agoParsing HTML with regexes is fine if you're not solving a general case. A regex "parser" will carry implicit assumptions about the document structure. Like, I know "<div.+>.+foo\s+([a-z]+)" will work, because I've crafted it for a specific site whose sources I've seen.
- ziml77 6y agoNot sure why you're downvoted. What you're describing is perfectly reasonable. Like you might be scraping a page with no user-generated content. Regex can make a lot of sense because if the regex stops matching, the page probably changed enough that a parser wouldn't stop it from breaking the scraping either.
- coldtea 6y ago>Regex doesn’t work fine even on that. Most of the time it works just fine for my purposes. And it's not like I don't know alternatives. And I've written a toy compiler in the past (C with classes subset), done heavy XSLT work, know how to write a parser (manually, with flex/yacc, with PEG), have parsed XML with SAX, DOM, XOM, have used xpath expressions, css and jquery selectors, and used libs like BeautifulSoup. Most of the time a quick regex will do just fine for that purpose. See, I don't intend to send the href's to the ISS or to some medical equipment that will blow up if, god forbid, I accidentally found an A tag in a comment or inside a script or attribute. And I'll probably run another regex or simple editor or awk filter to get rid of some false positives and I'll be fine. >If you want to parse HTML, you need a parser. That's a tautology, so it's always true. If on the other hand you just need to extract some information from an HTML file, and you can just open the bloddy file and see its structure and it is perfectly servicable with a regex, you might not need a parser at all. Simple as that.
- dirkt 6y ago> Well, that's strange, because what they do is still divining. Then don't make them devine, outline your X in a short sentence. Ignore those who still divine. Listen to those who tell you that Y is really hard, but to solve X, you can try Y' instead.
- anoncake 6y agoNo. The question is about Y. Not about X, not about my life story. Only Y, so everything else is just a distraction and does not belong in the question.
- Can_Not 6y ago> Then don't make them devine Nobody is making them devine, they do it themselves and pat themselves on the back for reading that XY problem article and spamming XY "answers" everywhere.