|
yippee cahier posted:Tell your boss you'll be in when it's light out and work 8 hours from whenever that is. Not having to work during winter
|
# ? Apr 17, 2018 19:45 |
|
|
# ? Jun 6, 2024 06:07 |
|
vvv ok I wasn't sure if coding horror drama would be appreciated
xtal fucked around with this message at 00:07 on Apr 18, 2018 |
# ? Apr 17, 2018 23:41 |
|
Looked it up a bit. Don't think that belongs here.
|
# ? Apr 17, 2018 23:52 |
|
UraniumAnchor posted:I have uncovered hell, and it is timezones. Is this you? Lol, talk about hell, jesus https://stackoverflow.com/questions/6841333/why-is-subtracting-these-two-times-in-1927-giving-a-strange-result
|
# ? Apr 23, 2018 21:58 |
|
Timezones are the loving devil.
|
# ? Apr 24, 2018 02:34 |
|
Zaphod42 posted:Is this you? Lol, talk about hell, jesus No, thankfully the oldest information I need to deal with 99% of the time is maybe 4-5 years old at the most. Anything older than that is audit (in the general sense, not a tax audit) territory only, and even with that the oldest info in the database is from 2006. That's a pretty wonderful 'bug', though.
|
# ? Apr 24, 2018 09:50 |
|
Groovy being Groovy:Java code:
Needless to say, this subtlety was not noticed by whoever wrote the code in my project that's loading some stuff from a database, calling sort(), and continuing on its merry way, leaving me to wonder why the order of the displayed data randomly flips on refresh! Edit: Here's the documentation for sort(), by the way: quote:Sorts the Collection. Assumes that the collection items are comparable and uses their natural ordering to determine the resulting order. If the Collection is a List, it is sorted in place and returned. Otherwise, the elements are first placed into a new list which is then sorted and returned - leaving the original Collection unchanged. It'll mutate the input! Maybe!
|
# ? Apr 24, 2018 21:57 |
|
iospace posted:Timezones are the loving devil. Worse than Daylight Savings? Time Zones at least somewhat make sense logically even though political divisions make them awkward. Daylight Savings is just a stupid archaic concept that needs to die and causes more problems than it solves (which is none).
|
# ? Apr 24, 2018 22:16 |
|
I’m at a conference and a guy was just showing how to push some code up using git and just did the old ‘mv foo.bak foo’
|
# ? Apr 25, 2018 01:29 |
|
code:
|
# ? Apr 25, 2018 03:06 |
|
No Safe Word posted:Worse than Daylight Savings? Time Zones at least somewhat make sense logically even though political divisions make them awkward. Daylight Savings is just a stupid archaic concept that needs to die and causes more problems than it solves (which is none). When you're trying to make libraries from scratch from one, the proper advice, as demonstrated in this thread is simply this: don't.
|
# ? Apr 25, 2018 03:12 |
|
Put another way, "I'm going to roll my own date library" is only better advice than "I'm going to roll my own crypto library" because the only person you're really likely to hurt is yourself.
|
# ? Apr 25, 2018 04:46 |
|
CPColin posted:Groovy being Groovy: that is wonderful
|
# ? Apr 25, 2018 06:39 |
|
I have finally found the worse thing than parsing xml with regex It’s parsing c code with regex
|
# ? Apr 25, 2018 07:36 |
|
Soricidus posted:I have finally found the worse thing than parsing xml with regex what on earth I'm curious about what scenario could make that even kind of work
|
# ? Apr 25, 2018 08:28 |
|
Jeb Bush 2012 posted:what on earth Regex engines haven't been limited to just regexes in decades and some of the more popular ones are pretty close to describing full on context-free languages. The rest comes town to tool, hammer, problem, nail, etc.
|
# ? Apr 25, 2018 08:37 |
|
dis astranagant posted:Regex engines haven't been limited to just regexes in decades and some of the more popular ones are pretty close to describing full on context-free languages. The rest comes town to tool, hammer, problem, nail, etc. I know that but trying to build a C parser in one still seems insane
|
# ? Apr 25, 2018 08:58 |
|
It's illadvised but it's just C, not something terribly complicated. Babby's first compiler project back in school was to write the lexer and parser for subset of C. I'm sure with the right application of brute force and ignorance you could at least get the basics bludgeoned together with just PCRE or something.
dis astranagant fucked around with this message at 09:08 on Apr 25, 2018 |
# ? Apr 25, 2018 09:02 |
|
dis astranagant posted:It's illadvised but it's just C, not something terribly complicated. even with regex extensions any CFL* is terribly complicated to parse *C isn't even a CFL, but I guess we can assume they weren't handling preprocessor directives properly here
|
# ? Apr 25, 2018 09:06 |
|
Jeb Bush 2012 posted:even with regex extensions any CFL* is terribly complicated to parse I'm assuming they knocked together a barely Turing Complete subset before reality started to sink in. Either that or they're one of those crazy people who do things like implement Turing Machines in Powerpoint. dis astranagant fucked around with this message at 09:14 on Apr 25, 2018 |
# ? Apr 25, 2018 09:10 |
|
Never look at the autocomplete engine for any editor ever, then. Or ctags.
|
# ? Apr 25, 2018 09:29 |
|
I'm a big fan of regexes (it's me, I'm the horror) and every once in a while someone asks me to do some parsing of arbitrary source code with them to strip out comments and such. It feels great to say they it can't be done that way, and that I wrote a book about why. My undergraduate thesis was on the subject and I ended up bumbling into making a lexical analyzer before I ever took a compilers course.
|
# ? Apr 25, 2018 12:51 |
|
Suspicious Dish posted:Never look at the autocomplete engine for any editor ever, then. Or ctags. Facts. I maintain a suite of language tools that's mostly implemented with a proper parser, but still has a few legacy components that depend on regex and ad hoc crawls over raw strings. The legacy stuff is a train wreck.
|
# ? Apr 25, 2018 13:50 |
|
CPColin posted:Groovy being Groovy: What about that makes it flip the order on refresh? Are the 'hash codes' just pointer addresses or something?
|
# ? Apr 25, 2018 14:03 |
|
Munkeymon posted:What about that makes it flip the order on refresh? Are the 'hash codes' just pointer addresses or something? Yep. In Java, Object.hashCode() returns something similar to the address of the object if you don't override it and Groovy inherited that. In Java, though, if you try to sort objects that don't implement Comparable, you sensibly just get an exception.
|
# ? Apr 25, 2018 14:29 |
|
CPColin posted:Yep. In Java, Object.hashCode() returns something similar to the address of the object if you don't override it and Groovy inherited that. In Java, though, if you try to sort objects that don't implement Comparable, you sensibly just get an exception. It is the address of the object usually: quote:As much as is reasonably practical, the hashCode method defined by class {@code Object} does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the Java™ programming language.)
|
# ? Apr 25, 2018 15:07 |
|
Not any more, apparently: https://stackoverflow.com/a/26975908
|
# ? Apr 25, 2018 20:34 |
|
CPColin posted:Not any more, apparently: Cool post, I was still under the impression that they were memory addresses
|
# ? Apr 25, 2018 20:38 |
|
Janitor Prime posted:Cool post, I was still under the impression that they were memory addresses Yeah, me as well, based on the quoted javadoc though. os::random() .... wouldn't have imagined.
|
# ? Apr 25, 2018 20:51 |
|
It's hilarious that HotSpot has a command-line argument for which hash code algorithm you want. It's sad that somebody somewhere has probably had to use it.
|
# ? Apr 25, 2018 20:54 |
|
CPColin posted:It's hilarious that HotSpot has a command-line argument for which hash code algorithm you want. It's sad that somebody somewhere has probably had to use it. Yeah holy poo poo, what? Also I love that "always const 1" is an option lol.
|
# ? Apr 25, 2018 21:00 |
|
HotSpot has used a generational (copying) collector for, like, 20 years. You cannot use the object address as a hash code with a copying collector.
|
# ? Apr 26, 2018 00:49 |
|
rjmccall posted:HotSpot has used a generational (copying) collector for, like, 20 years. You cannot use the object address as a hash code with a copying collector. Aha, that makes sense. Could you avoid copying the objects if you instead maintained a list pointers to which objects were in which generation? Although it would add memory overhead and the only advantage would be constant memory addresses so who cares I guess.
|
# ? Apr 26, 2018 01:17 |
|
You can use whatever you like as long as you memoize it somewhere. It'd just end up being whatever the address was the first time someone asked for the hash code. e: one of the big wins of generational garbage collection is that you can allocate memory by just bumping the pointer in your young generation. Then after a collection you end up with a pristine young generation so you can keep doing that. Going back to having to rummage around lists and deal with memory fragmentation would kind of defeat the point a little. Jabor fucked around with this message at 01:22 on Apr 26, 2018 |
# ? Apr 26, 2018 01:19 |
|
Jabor posted:You can use whatever you like as long as you memoize it somewhere. It'd just end up being whatever the address was the first time someone asked for the hash code. That could potentially create collisions between live objects right?
|
# ? Apr 26, 2018 01:21 |
|
Zaphod42 posted:That could potentially create collisions between live objects right? Technically yes, but it's not a problem if two objects have the same hash code.
|
# ? Apr 26, 2018 01:22 |
|
Jabor posted:Technically yes, but it's not a problem if two objects have the same hash code. ...unless your stupid code assumes it does. But that's not the JVM's problem.
|
# ? Apr 26, 2018 01:35 |
|
Also raw object addresses are terrible hash codes; you should always at least shift/rotate the alignment away.
rjmccall fucked around with this message at 02:10 on Apr 26, 2018 |
# ? Apr 26, 2018 02:08 |
|
Shouldn't the default implementation of GetHashCode() or equivalent just return 0? You should either explicitly define a hashing method or not get one at all.
|
# ? Apr 26, 2018 04:02 |
|
|
# ? Jun 6, 2024 06:07 |
|
Why? The default implementation is totally fine for any type that uses the default equality semantics, and being able to stick everything into a hash-based collection is really useful. Really the only thing you need is a way to enforce also implementing hashCode when you write a type with custom equality.
|
# ? Apr 26, 2018 04:24 |