|
Pavlov posted:Even with a US keyboard, I would use a language that uses 「Japanese quotation marks」, just because I think they look spiffy. sempython
|
# ? May 31, 2016 22:15 |
|
|
# ? Jun 8, 2024 08:48 |
|
Most of the time when I look at my old code unhappiness stems from realizing my old assumptions in designing the codebase were flawed, incomplete or no longer valid. Sometimes you need a first stab at a problem and some time to see these kinds of design mistakes. For things that are naturally self-contained I'm more likely to look back and see a mixture of opportunities to improve and pleasantly clever bits.
|
# ? May 31, 2016 22:16 |
|
Xerophyte posted:Oh yes, the layouts themselves are horrors in a lot of ways. I maintain that the person who looked at the $ character and thought "that'd make a good special character in my spiffy programming language" was a bit blinkered, though. It's not used in any good language I can think of, unless you count regex strings or non-user-facing stuff like name mangling.
|
# ? May 31, 2016 22:17 |
|
Soricidus posted:It's not used in any good language I can think of, unless you count regex strings or non-user-facing stuff like name mangling. I was going to counteroffer Perl and PHP, but you had to go and add that "good" modifier there. (Disclaimer: I like Perl, but I would not want to work in a Perl shop)
|
# ? May 31, 2016 22:35 |
|
Soricidus posted:It's not used in any good language I can think of, unless you count regex strings or non-user-facing stuff like name mangling. String interpolation in C# 6.
|
# ? May 31, 2016 22:41 |
|
Soricidus posted:You could try trigraphs. Mega-rude.
|
# ? May 31, 2016 22:41 |
|
raminasi posted:String interpolation in C# 6. Also anonymous closure arguments in Swift. They're really nice when the closure is tiny.
|
# ? May 31, 2016 23:04 |
|
M31 posted:Or C! Trigraphs are going to be removed in C++17, with IBM being dragged kicking and screaming about their "totally real but we can't talk about them" EBCDIC-using customers. Hopefully C will follow?
|
# ? Jun 1, 2016 00:49 |
|
https://blog.devmastery.com/how-to-win-the-coding-interview-71ae7102d685quote:A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward. Allowances may be made for adjustments to capital letters, punctuation, and word dividers. Examples in English include “A man, a plan, a canal, Panama!”, “Amor, Roma”, “race car”, “stack cats”, “step on no pets”, “taco cat”, “put it up”, “Was it a car or a cat I saw?” and “No ‘x’ in Nixon”. Okay... quote:On this particular challenge, I am expecting many will use RegEx as a part of the solution. Edit: quote:Before I start though, I have to say, if a company is going to hire a developer based solely and entirely on a piece of code the developer wrote in an interview, you probably don’t want to work there. Ah, but of course we cannot forget culture fit. sarehu fucked around with this message at 01:52 on Jun 1, 2016 |
# ? Jun 1, 2016 01:48 |
|
Unsurprisingly his example of a good solution is kinda poo poo.
|
# ? Jun 1, 2016 01:54 |
|
b0lt posted:Trigraphs are going to be removed in C++17, with IBM being dragged kicking and screaming about their "totally real but we can't talk about them" EBCDIC-using customers. Hopefully C will follow? Those are digraphs though, and they're not going to be removed for a while.
|
# ? Jun 1, 2016 02:06 |
|
Xerophyte posted:On that note, it remains slightly annoying to me how English and US-centric a lot of the character conventions in programming are. ${}[]| and co aren't particularly easy to type on a good half of the world's keyboards, yet languages keep using them all over the drat place. Backticks are by far the worst in the swedish/nordic/german layouts, since ` is a chord resulting in a dead key meaning half the time you end up writing á instead of `a. My other language is RTL and an entirely different alphabet. I have to use "alt-shift" to change languages multiple times a minute, when I'm talking to friends while looking up programming-related stuff. I manage, and so can you. If you want things to be different, go back in time and make it so that the Swedes had invented and popularized programming or whatever. See if you can fend off the Israelis, Iranians, and Chinese who are trying to mess around with the same timeline, though.
|
# ? Jun 1, 2016 02:38 |
|
Plorkyeran posted:Unsurprisingly his example of a good solution is kinda poo poo. Is this where we all trip over each other to make a better implementation and do point-by-point teardowns of solutions we don't like? JavaScript code:
|
# ? Jun 1, 2016 06:21 |
|
Internet Janitor posted:I was surprised to discover that evidently JS regexes don't have a symbol equivalent to a-zA-Z0-9. This would also be simpler if JS Strings were genuinely Arrays. Isn't that \w? Edit: Double checking apparently that also includes underscores. Huh.
|
# ? Jun 1, 2016 06:42 |
|
They didn't even parallelize the palindrome check
|
# ? Jun 1, 2016 06:45 |
|
I have no idea why, but I have consistently seen multiple cases where people where people try to check if something is a palindrome by doing:JavaScript code:
|
# ? Jun 1, 2016 07:06 |
|
Writing a function that logs to the console when doing something very simple with no dependencies is just retarded. That guy is definitely high on the sense that he's a PROFESSIONAL JavaScript developer and from sniffing his own farts.
|
# ? Jun 1, 2016 07:13 |
|
Suspicious Dish posted:I have no idea why, but I have consistently seen multiple cases where people where people try to check if something is a palindrome by doing: Because they can see that the "obvious" solution of checking whether string == reverse(string) ends up checking each letter twice, and they're too clever for their own good.
|
# ? Jun 1, 2016 07:19 |
|
quote:“Do I need to handle unicode characters?” Obviously the answer is no isPalindrome("aaą"); > true canis minor fucked around with this message at 07:39 on Jun 1, 2016 |
# ? Jun 1, 2016 07:36 |
|
Absurd Alhazred posted:My other language is RTL oh god trigger warning that poo poo dude I literally still have nightmares about bidi text handling, over a year after I last worked on anything that involves it is the thing where numbers are always LTR actually good from your perspective? because it's the reason there is never a nice simple case
|
# ? Jun 1, 2016 07:52 |
|
I was going to say that he says that about regex, but then doesn't actually use regex as part of his model solution. But technically, he does - he uses it to filter out non-letter characters before he gets to the actual work of determining if it's a palindrome. I guess that's all he meant by "use regex as part of the solution". It's poor communication on his part, because he's unnecessarily drawing attention to a relatively unimportant preparatory step, which misleads the reader into thinking that the use of regex will be the meat of the solution. All round a fairly dubious article.
|
# ? Jun 1, 2016 10:15 |
|
I don't know if this is the right one because I don't really want to think about it too hard, but I have seen people check for palindromes with regex recursion. This is a perl regex (only works in certain versions or something?) code:
|
# ? Jun 1, 2016 10:22 |
|
Heres a new one, A project decided to use bitmasks to store permissions in an int64. They now have 65 permissions needed....
|
# ? Jun 1, 2016 10:56 |
|
TheresaJayne posted:Heres a new one, Hope their compiler supports uint128_t!
|
# ? Jun 1, 2016 11:31 |
|
feedmegin posted:Hope their compiler supports uint128_t! VB.net
|
# ? Jun 1, 2016 11:40 |
|
Aren't palindromes like the classic example of the recursive version being simpler to read and easier to conceive. How is any regex, at all, better and more comprehensible than:code:
The iterative version isn't that much harder to implement (even using that while(var++ && var--) syntax argued about earlier), and either is way better than going straight to regular expressions imo. edit: code:
The MUMPSorceress fucked around with this message at 16:14 on Jun 1, 2016 |
# ? Jun 1, 2016 16:06 |
|
The regex was used because part of the problem statement was to ignore non-letters (and casing). I admit I have trouble thinking of a better way than a regex to strip out undesirable characters, unless the language being used specifically has a function that happens to meet my needs.
|
# ? Jun 1, 2016 16:15 |
|
TooMuchAbstraction posted:The regex was used because part of the problem statement was to ignore non-letters (and casing). I admit I have trouble thinking of a better way than a regex to strip out undesirable characters, unless the language being used specifically has a function that happens to meet my needs. i can't think of any languages that don't have functions for moving to all caps, no caps, and stripping whitespace. stripping punctuation is a wrinkle i hadn't thought of for sure.
|
# ? Jun 1, 2016 16:23 |
|
LeftistMuslimObama posted:Aren't palindromes like the classic example of the recursive version being simpler to read and easier to conceive. How is any regex, at all, better and more comprehensible than: Well, for one, it would terminate.
|
# ? Jun 1, 2016 16:26 |
|
LeftistMuslimObama posted:i can't think of any languages that don't have functions for moving to all caps, no caps, and stripping whitespace. stripping punctuation is a wrinkle i hadn't thought of for sure. If you also take into account unicode, it suddenly becomes a big pain in the rear end, too. Like combining characters: Les Mis\u030erables = Les Misérables Reverse it! selbare\u030siM seL = selbareśiM seL Oops, the accent is over the wrong character now. (Example stolen from Jon Skeet: https://codeblog.jonskeet.uk/2009/11/02/omg-ponies-aka-humanity-epic-fail/)
|
# ? Jun 1, 2016 16:29 |
|
TooMuchAbstraction posted:The regex was used because part of the problem statement was to ignore non-letters (and casing). I admit I have trouble thinking of a better way than a regex to strip out undesirable characters, unless the language being used specifically has a function that happens to meet my needs. An if statement? Does everything have to be a precanned library function?
|
# ? Jun 1, 2016 16:31 |
|
rjmccall posted:Well, for one, it would terminate. Lol, I always gently caress that up.
|
# ? Jun 1, 2016 16:32 |
|
OddObserver posted:An if statement? Does everything have to be a precanned library function? No, I was saying that in the absence of some kind of stripNonLetters() library method, a regex would be the only other good option for removing non-letter characters from a string that I can think of. And in fact I wouldn't be surprised if such a library method were just a thin wrapper around a regex anyway. I mean, sure, you can iterate over every character and test if the char value of the character falls between 65 and 90 or 97 and 122 (or look up if the character is in a whitelist by other methods), assuming you're happy assuming ASCII. I don't think that's a superior solution though.
|
# ? Jun 1, 2016 16:36 |
|
Unicode has no notion of string reversal, so I think it's fair to treat the input as an opaque sequence of code points or whatever.
|
# ? Jun 1, 2016 16:54 |
|
Who said you need to mutate the string at all? (Well, C-form normalization probably is a good idea, yes). Edit: what I mean is, whole thing is easily doable in a manner similar to the "collapsing walls" quick sort partition function, just w/o swaps. OddObserver fucked around with this message at 17:05 on Jun 1, 2016 |
# ? Jun 1, 2016 16:58 |
|
Thought I'd try doing it the "proper" C++ way, using iterators, and avoid string copying and redundant comparisons. Reverse iterators turn out to be kind of a pain. Would have been nice if they could directly be compared to forward iterators, or if there were a consistent way to "toggle" the reverse-ness of an iterator.code:
eth0.n fucked around with this message at 17:15 on Jun 1, 2016 |
# ? Jun 1, 2016 17:13 |
|
I can count the number of times I've had to reverse a string in the past 20 years on zero fingers. Teachers should probably do a better job coming up with assignments that actually have application in the real world. Want to teach regex? Make them parse logs for specific data. Want to teach recursion? Implement quicksort or something.
|
# ? Jun 1, 2016 17:24 |
|
Using a regex is still bad because you need to at minimum perform a bunch of writes and likely an allocation. You have a fixed number of valid characters to test against, so you can just skip everything that isn't valid in constant time per character and run through with a forward and backward iterator in O(N) where N is the length of the input. Testing against both the character's upper/lower also takes constant time per test. As you need to at minimum read the whole string to check the characters, you're already at the best asymptotic time with reasonable use of memory and you can get on with your day and doing something relevant.
|
# ? Jun 1, 2016 17:50 |
|
leper khan posted:Using a regex is still bad because you need to at minimum perform a bunch of writes and likely an allocation. You have a fixed number of valid characters to test against, so you can just skip everything that isn't valid in constant time per character and run through with a forward and backward iterator in O(N) where N is the length of the input. Testing against both the character's upper/lower also takes constant time per test. As you need to at minimum read the whole string to check the characters, you're already at the best asymptotic time with reasonable use of memory and you can get on with your day and doing something relevant. I can write a regex to strip invalid characters a hell of a lot faster than I can write the relevant whitelist and loop to do it manually. Is the manual approach more efficient? Probably. But I'll be getting on with my day doing something relevant faster if I make full use of the available tools.
|
# ? Jun 1, 2016 18:14 |
|
|
# ? Jun 8, 2024 08:48 |
|
Soricidus posted:oh god trigger warning that poo poo dude In Hebrew numbers are spoken LTR/big-endian, so it works out well for typing. I have just realized, though, that people using physical typewriters must have been writing numbers RTL/little-endian.That must have been an irritation, both getting used to it, and then getting used to the new way.
|
# ? Jun 1, 2016 18:25 |