- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
If you only need to write an average of one line of code in language A to accomplish the same task as ten lines of code in language B, that is an advantage for language A. It's irrelevant how many actual lines of code are behind that one line, because the programmer doesn't have to write those lines of code to complete the task at hand.
Sp: "Reinventing the wheel". Talk about chronic NIH syndrome...
Admin
It's not fair to blame me for reinventing Perl and calling it Python.
Admin
If you told me there is a good, easy-to-use C library that searches for words in a list of strings, then you might have a good point for C.
Admin
Not just spaces, you need start and end of string as well. And considering we speak a language (not true for everyone) where correct sentences end with a dot, ... you're in for a whole lot of trouble if you think word separation is easy The very least you will need is a character class including all punctuation except the dash, plus the space (only the normal space), the start of string on one side, and end of string on the other side.
Over simplifying makes everything look easy and one-liner without using the proper tools ...
But . seeing how this is opposed with the hash/sort/binsearch, the same arguments will have to be taken into account for the hash when splitting the string.
Admin
Well .. Yale you're a good troll I'll give you that.
But to make the comparison really really fair, we should include all possible platform-related code that enables that C to be processed on virtualy any CPU, and then the few versions of python that run your code, plus all the platform-related coded that enables running it on a few cpus on a few OS's.
Tell you what I'm pretty sure you'll have less LOC with python since it runs on virtually nothing compared to C.
However, the main fact remains : C is faster, the actual code behind the work IS much shorter, ANYTHING you implement in C will not be slower because you're not using the base library function, and it can be as smart as you want it to be because there are no limits.
Still, good trolling Yale it's impressively borderline.
Admin
Good trolling again, but everyone knows MLOC is not the answer.
No decent programmer spends most of his time typing, instead favoring thinking and reducing the required coding by orders of magnitude in the process.
Reinventing the wheel sounds funny, but if the wheel was as fucked up as most of the code available from the work of others, I'm pretty sure cars would still be under 1 MPG.
Now java gluers may be all the rage today, they're still not coders.
Gluing together half a dozen botched libraries to make bloatware does not count as programming, sorry.
Admin
yes, it's called perl.
Admin
Your oneliner seems to have at least the following issues, most of which have already been mentioned in the context of the OP:
Why not just use index?
return grep(index($searchText, $_) >= 0, @searchTerms) ? 1 : 0;
Obviously replace grep with List::Util::first_idx (and check for >= 0) for efficiency if you're expecting more than a handful of search terms.
Admin
Admin
Good point, and one that'd sway it slightly towards a regex-based solution actually, as it'd be easier to take things like this into account (although I wouldn't be surprised if it was possible to do a DFA-merging equivalent of Aho-Corasick, which would make this whole debate moot).
CAPTCHA: uxor...U XOR ME?
Admin
Mandatory Suicide, massacre on the front line. Dun Dun Dun Duh!
Admin
If both are static, the whole article's a WTF from start to finish. Every last word. If neither is, testing on real data and real search terms is the only sane approach. (Complex matchers can slow things down by causing problems with data locality; this is counter-intuitive by comparison with normal algorithmic analysis.)
Admin
Some people, when confronted with a problem, think “I know, I'll use regular expressions.” Now they have two problems.
Admin
Some people, when confronted with regular expressions, think "I know, I'll use that quote". Now they have two head wounds.
Admin
TruthTable... that's sexy. We have one in our basement. It's all shiny, with hinges and straps and everything.
Admin
Jed is brave, I would have not even bothered reply to the guy who sent an email to everyone on such a matter.
Good luck Jed !
Admin
It's only more readable if you're an idiot.