|
fleshweasel posted:doubtless there is some static method you need to look up to use for this relatively common case in programming Nan's behavior is delightful when doing a bunch of number crunching on hole-filled data that you'd rather just run and then check for isNaN afterwards. I remember some code I looked at that for some reason used -9999999 instead of NaN and would just check to see if the result value was negative because it should never be negative.
|
# ? Aug 17, 2014 20:56 |
|
|
# ? Jun 6, 2024 16:00 |
|
the only horror there is returning nil if something isn't in the array i guess becausecode:
|
# ? Aug 17, 2014 21:08 |
|
that literally is the problem, yeah. [].first should not equal [nil].first
|
# ? Aug 17, 2014 21:12 |
|
[].first should throw an exception.
|
# ? Aug 17, 2014 21:24 |
|
Notorious b.s.d. posted:[].first should throw an exception. looking through the docs im surprised array can actually throw an exception at all. they should probably say "calling first on an empty array leads to UB" so spergs on stackoverflow can smugly respond to people asking why this abomination is allowed to occur.
|
# ? Aug 17, 2014 21:33 |
|
Notorious b.s.d. posted:[].first should throw an exception. it should return an empty optional
|
# ? Aug 17, 2014 21:41 |
|
ultramiraculous posted:it should return an empty optional eh the two are reasonably equivalent - one you have to check first and one you have to check afterwards. If you fail to do either check, you can get an exception. (called head and listToMaybe respectively in Haskell) gonadic io fucked around with this message at 22:15 on Aug 17, 2014 |
# ? Aug 17, 2014 21:43 |
|
ultramiraculous posted:it should return an empty optional in general ruby's type system is so crude and little-used by consumers that i'm not sure option types really "fit" this exists, and it kinda looks ok https://github.com/ms-ati/rumonade it is hard to imagine it being folded into the stdlib though
|
# ? Aug 17, 2014 21:54 |
|
Notorious b.s.d. posted:in general ruby's type system is so crude and little-used by consumers that i'm not sure option types really "fit" oh cool gonna mess with this Notorious b.s.d. posted:it is hard to imagine it being folded into the stdlib though
|
# ? Aug 17, 2014 22:25 |
|
Notorious b.s.d. posted:[].first should throw an exception. [1,2].first should also return 2 according to people a few pages ago
|
# ? Aug 17, 2014 22:31 |
|
shrughes is not people
|
# ? Aug 17, 2014 22:54 |
|
Notorious b.s.d. posted:[].first should throw an exception. battle-hardened ruby veterans try to only use methods like [].fetch(0)
|
# ? Aug 17, 2014 22:59 |
|
Symbolic Butt posted:battle-hardened ruby veterans try to only use methods like [].fetch(0) 'fetch' sickens me because it indicates that the library authors knew that [].first == nil was the wrong behavior they knew they hosed up and they left it broken because they probably already had five users or something
|
# ? Aug 17, 2014 23:36 |
|
i really like some cascading nulls (ideally typed) over exceptions for the most primitive operations. sure it loses some information, but it makes it a lot easier to reason about error conditions. the example problem of an array containing a literal null value in a position being indistiguishable from the position not existing i don't find so troubling though, one can just view arrays as being potentially non-contiguous (i.e. some position may be undefined) a matter of taste though certainly, and ruby does plenty of other stuff really wrong (including but not limited to not really going all the way with nulls either, neither cascading them or using them consistently)
|
# ? Aug 17, 2014 23:47 |
|
ruby 3 should make like python 3 and have breaking changes that are generally for the best, occasionally for the worse, and see like no uptake because of it
|
# ? Aug 18, 2014 00:00 |
|
FamDav posted:ruby 3 should make like python 3 and have breaking changes that are generally for the best, occasionally for the worse, and see like no uptake because of it
|
# ? Aug 18, 2014 00:04 |
|
ShadowHawk posted:Eh, python3 is taking off faster than ipv6! check your ipv6 figures poo poo has launched hard in 2014
|
# ? Aug 18, 2014 00:12 |
|
Symbolic Butt posted:battle-hardened ruby veterans try to only use methods like [].fetch(0) ruby and php share a lot in common - a sort of 'can do' attitude in response to errors or problems. just return nil, or in php's case a falsish item - the easiest way to build up software is just treating it like one big program in one big file. none of this poo poo surprises me any more. out of bounds indexing a list? no problem! redefining built in methods and objects on an ad-hoc basis? totally. php may have it's warts but at least it's the same warts everywhere. ruby on the other hand is a language wart toolkit.
|
# ? Aug 18, 2014 00:15 |
|
Notorious b.s.d. posted:check your ipv6 figures like what? other than chinese cellphones maybe (tmobile has an ipv6 thing i think?)
|
# ? Aug 18, 2014 00:19 |
|
FamDav posted:ruby 3 should make like python 3 and have breaking changes that are generally for the best, occasionally for the worse, and see like no uptake because of it ruby already breaks for minor versions. no-one cares. to explain: there are two types of rails projects - stuck. frozen in time because something massive has changed, but because everything is implicitly defined it's impossible to work out what needs to be changed easily. - alive. expect to bundler install after each pull. for the alive ones, dealing with ruby changes is easy. rails causes more issues than ruby breaking in minor versions. who cares, it's just the same old poo poo. for the stuck ones, it's ok, upgrading rails or any of the dependencies will never happen, so you don't have to worry about them. besides, it'll get rewritten from scratch in node.js or go or whatever because of the bad experiences with rails.
|
# ? Aug 18, 2014 00:21 |
|
Notorious b.s.d. posted:check your ipv6 figures
|
# ? Aug 18, 2014 00:21 |
|
ShadowHawk posted:python 3 migration
|
# ? Aug 18, 2014 00:23 |
|
tef posted:ruby on the other hand is a language wart toolkit.
|
# ? Aug 18, 2014 00:34 |
|
Notorious b.s.d. posted:check your ipv6 figures Yeah, we have some v6-only clusters now. probably only a few thousand machines, but a lot of cross-datacenter traffic is v6 now as well.
|
# ? Aug 18, 2014 00:37 |
|
for instance, depending on where i am in our codebase, hash#store(key, value) will either return the hash, or the stored value so code:
|
# ? Aug 18, 2014 00:39 |
|
ruby
|
# ? Aug 18, 2014 01:05 |
|
MALE SHOEGAZE posted:for instance, depending on where i am in our codebase, hash#store(key, value) will either return the hash, or the stored value i can't think of any reasons why that would be do you have any idea why it does that?
|
# ? Aug 18, 2014 01:45 |
|
Notorious b.s.d. posted:check your ipv6 figures lol, slowest migration ever no one is replacing all their ipv4 hardware/code until it breaks
|
# ? Aug 18, 2014 02:39 |
|
ruby is php for weeaboos
|
# ? Aug 18, 2014 04:14 |
|
an old friend of mine is porting some old ROM MUD code from C to Python3 and most of it has been just a bunch of regex work to get things up and running and its been neat to dig through 30 year old tech files like this:memory.txt posted:Merc Release 2.1
|
# ? Aug 19, 2014 07:38 |
|
ahmeni posted:
so much careful memory janitoring and then there's that
|
# ? Aug 19, 2014 14:19 |
|
quote:The hash code for a string is simply its length. ah, that's where Rasmus got the idea for PHP function-name hashing, then. mystery solved.
|
# ? Aug 19, 2014 14:20 |
|
Notorious b.s.d. posted:this except unironically azure owns so hard it is the easiest thing ever
|
# ? Aug 19, 2014 14:57 |
|
Careful Drums posted:azure owns so hard it is the easiest thing ever
|
# ? Aug 19, 2014 21:23 |
|
beep! beep! quality programmer coming through.
|
# ? Aug 19, 2014 22:37 |
|
akadajet posted:beep! beep! quality programmer coming through. haha holy poo poo that is fantastic, I'm going to get a really esoteric pep to be the smuggest python license plater.
|
# ? Aug 20, 2014 00:37 |
|
Lyon posted:haha holy poo poo that is fantastic, I'm going to get a really esoteric pep to be the smuggest python license plater. pep 435, the birth of the Enum
|
# ? Aug 20, 2014 02:06 |
|
Brain Candy posted:so much careful memory janitoring and then there's that i don't even get why. i mean if you're splitting the strings with a delimiter, you're reading through the whole thing. can you not even right a dumb/bad hash algo that uses maybe the length and the sum of the chars scanned over or something?
|
# ? Aug 20, 2014 02:16 |
|
ultramiraculous posted:i don't even get why. i mean if you're splitting the strings with a delimiter, you're reading through the whole thing. can you not even right a dumb/bad hash algo that uses maybe the length and the sum of the chars scanned over or something? muds have always been an amazing showcase of technical decisions that will fall to pieces if one character is out of place anywhere, cobbled together by grognards turned programmer
|
# ? Aug 20, 2014 02:36 |
|
|
# ? Jun 6, 2024 16:00 |
|
I propose we get rid of indexing entirely, to be replaced with the infix operator th: nthusers That way the lefthand argument is unambiguously ordinal.
|
# ? Aug 20, 2014 14:42 |