|
pseudorandom name posted:The could've made format strings use "yyyy", "mm", "dd" etc. instead, which would be both easy to remember and easy to read. Minutes or months?
|
# ? Apr 12, 2012 01:16 |
|
|
# ? May 14, 2024 11:21 |
|
pseudorandom name posted:The could've made format strings use "yyyy", "mm", "dd" etc. instead, which would be both easy to remember and easy to read. Why is using a bunch of different character codes that necessarily will have overlap (minutes vs months, the number of different ways of shortening a day/month) easier to read than reading a date in the format you want it to look like? I don't see why its such a terrible idea. It feels like the backlash against it is just because it's different.
|
# ? Apr 12, 2012 01:17 |
|
Every time I use strftime or its ports in a language, I have to look the format up. I'd be happy with something that took an example format and translated it to the equivalent format. If you're going to use placeholders no matter what, though, I see the logic in making them resemble an actual time.
|
# ? Apr 12, 2012 01:22 |
|
pokeyman posted:Every time I use strftime or its ports in a language, I have to look the format up. I'd be happy with something that took an example format and translated it to the equivalent format. http://strfti.me is your friend, friend.
|
# ? Apr 12, 2012 01:24 |
|
Thanks! That gets me halfway there.
|
# ? Apr 12, 2012 01:33 |
|
yaoi prophet posted:Minutes or months? yyyy/mm/dd HH:MM:SS The main problem with the Go formats is they chose a completely retarded date format for the 1234567 ordering, although I guess they had to in order to avoid using 1 AD as the year.
|
# ? Apr 12, 2012 01:37 |
|
Actually, that's a pretty clever idea and I like it, assuming it works for edge cases like "20060102" where there are no clear delimiters.
|
# ? Apr 12, 2012 02:20 |
|
pseudorandom name posted:yyyy/mm/dd What about names for days of the week/months? What if you want to put other text in there like "He was assassinated at 4:03:23"; how do you stop that from turning into "He was a23a23inated at 4:03:23"?
|
# ? Apr 12, 2012 02:27 |
|
Fren posted:Really? Of all the loving things to fall for NIH syndrome. Who doesn't know the strftime codes by heart? Is there some horrible flaw with strftime that I'm not aware of? It has codes you have to know by heart or look up. For Go, all you need to know is "01/02 03:04:05PM '06 -0700" and it's self-documenting in your source code too.
|
# ? Apr 12, 2012 02:27 |
|
yaoi prophet posted:What about names for days of the week/months? What if you want to put other text in there like "He was assassinated at 4:03:23"; how do you stop that from turning into "He was a23a23inated at 4:03:23"? Some of their example formats: code:
|
# ? Apr 12, 2012 02:28 |
|
BonzoESC posted:Some of their example formats: Sure, I believe that Go's thing can parse it. I just don't think you can extend YYYY/MM/DD hh:mm:ss to cover it.
|
# ? Apr 12, 2012 02:30 |
|
Suspicious Dish posted:They're considering adding a promise/Deferred to the standard library instead of using continuation passing, which should help things a bit. Unfortunately, you can't emulate inlineCallbacks. And that's why C# is adding async/await. Let the compiler turn your code inside out later.
|
# ? Apr 12, 2012 04:30 |
|
yaoi prophet posted:What about names for days of the week/months? What if you want to put other text in there like "He was assassinated at 4:03:23"; how do you stop that from turning into "He was a23a23inated at 4:03:23"? "Day" → "Wed" "Fullday" → "Wednesday" "Mon" → "Apr" "Month" → April And Go's format has the same collision problem with its own magic character sequences.
|
# ? Apr 12, 2012 04:44 |
|
pseudorandom name posted:"Day" → "Wed" - Steve
|
# ? Apr 12, 2012 04:47 |
|
What about with other natural languages? Can I replace Monday with понедельник and have it work?
|
# ? Apr 12, 2012 05:12 |
|
Nope, nor is the result of time.Format localized.
|
# ? Apr 12, 2012 05:18 |
|
I'm not advocating for Go's format, I'm advocating for strftime. It'd be neat to build a strftime format generator that works on Go's algorithm, though.
|
# ? Apr 12, 2012 05:36 |
|
Ender.uNF posted:And that's why C# is adding async/await. Let the compiler turn your code inside out later. Note that the latest working draft for ES.next includes dummy syntax for generators, but says that semantics of what it means aren't in the current draft. They also have a reference to a YieldExpression under 11.13, but don't provide a definition. But at least that with these primitives, you can build a simple trampoline. code:
|
# ? Apr 12, 2012 05:36 |
|
Lonely Wolf posted:yeah, those format by example strings shook me the first time I saw them and I have to check the docs to write them but they do have the nice property that if I see leterip posted:I don't see why its such a terrible idea. It feels like the backlash against it is just because it's different. With this, it looks like the date and time are significant rather than the format of the date and time, it's confusing to anyone new to Go and to anyone just skimming code it's easy to get mixed up. Consider: http://play.golang.org/p/Vkbx2djlF5 I wouldn't hesitate to say most people would expect t.Format("2006-01-02") to be doing something with the date 2006-01-02, not creating a datetime format string from it.
|
# ? Apr 12, 2012 09:24 |
|
The Gripper posted:I wouldn't hesitate to say most people would expect t.Format("2006-01-02") to be doing something with the date 2006-01-02, not creating a datetime format string from it. I agree, it seems like a good idea but they should have called it something like "FormatByExample" instead of just "Format".
|
# ? Apr 12, 2012 09:31 |
|
The Gripper posted:If you look at code with a datetime format string from any other language you immediately know "hey, that's the format of a datetime". So your argument is that because it's different people might be confused by it? There's only one way to format dates in Go with the standard library, so if you're familiar with Go that's a non-issue. Imagine if Go was the standard way and they came out with strftime. You could make the same argument the other direction.
|
# ? Apr 12, 2012 11:29 |
|
leterip posted:So your argument is that because it's different people might be confused by it? There's only one way to format dates in Go with the standard library, so if you're familiar with Go that's a non-issue. Imagine if Go was the standard way and they came out with strftime. You could make the same argument the other direction. Edit; it's a novel idea and simplifies creating format strings, but in practice it is confusing (hang around in the #go-nuts irc channel and see how often people come in confused about this exact thing). Also I wasn't arguing that it's confusing because it's different to strftime, just that when I see a date I expect the interesting part to be the date, not the formatting of it's elements. (and since it wasn't mentioned, the format strings can't be just any date/time, they have to be a datetime constructed from it's formatting rules e.g. rather than remembering that %H is hour in 24-hour time, you have to remember "15" has that meaning. I can't find a page that actually lists the meaning of each set of digits, but off the top of my head 15 = 24hr hour, 04=minutes, 03=seconds, 2006=year, 01=month, 02=day. This instead of %H, %M, %s, %y, where mistakes are immediately obvious). It's really just a bad, confusing system. The Gripper fucked around with this message at 13:43 on Apr 12, 2012 |
# ? Apr 12, 2012 13:03 |
|
The Gripper posted:My argument is that using an actual date/time as a format string is confusing, because everywhere else (and I mean everywhere, not just in Go) a written date or time means "this date or time" not "any date that fits this format". Using HH:nn:ss also has the benefit of differentiating a format string from a date or time; in Go the meaning of "12:34:56 2006-01-01" different (literal datetime or datetime format string) depending on where it is used. To not be pedantic, the only time the context changes is when it is used in a specific method of a specific type. It's not like format strings are littered throughout code confusing people as to if they are specifying a date or not. There are literally two functions that accept a layout and in both cases it is clear from the local context that it is a format string, if not just by the calling method, but by the fact that it is specifying a specific date/time that if you are familiar with Go is clearly a format time. The Gripper posted:Edit; it's a novel idea and simplifies creating format strings, but in practice it is confusing (hang around in the #go-nuts irc channel and see how often people come in confused about this exact thing). The Gripper posted:Also I wasn't arguing that it's confusing because it's different to strftime, just that when I see a date I expect the interesting part to be the date, not the formatting of it's elements.
|
# ? Apr 12, 2012 15:11 |
|
leterip posted:Isn't that amazing that you could define what those were off the top of your head with minimal exposure? quote:But how many of those questions are because someone confused the format string with a date string in the code, as you suggest is the problem? Honestly it tries to solve a problem ("time format strings are confusing") and instead makes a carbon copy of the problem with more confusing element names (digits instead of %X). It's a net negative for the developer (you still need to know the substitutions as you would with strftime, however they no longer have a letter attached that gives it meaning) and there's marginal benefit to an observer (you can see what the result will look like immediately). I prefer strftime formats over Go's implementation because it is better, not because I'm opposed to positive change.
|
# ? Apr 12, 2012 15:34 |
|
The Gripper posted:I honestly couldn't tell you which digits represent minutes and seconds, and the same with which digits represent days and which represent months. I could have them backwards, I just guessed at their order. Compared to strftime where mixing up %M and %s is obvious, mixing up 03 and 04 in go is not. The Gripper posted:There have been numerous that have mistaken the use of Format() and related methods, maybe not mistaking the format string with date in the code, but definitely mistaking the required parameter as being "a date" rather than "a format string". So because they were unfamiliar with this different system they had an issue with how the format was specified. Once they learned about how the system worked, there were no more problems. There could be an argument for better documentation on the methods that take a layout, but that's not a problem with the system. The Gripper posted:Honestly it tries to solve a problem ("time format strings are confusing") and instead makes a carbon copy of the problem with more confusing element names (digits instead of %X). It's a net negative for the developer (you still need to know the substitutions as you would with strftime, however they no longer have a letter attached that gives it meaning) and there's marginal benefit to an observer (you can see what the result will look like immediately).
|
# ? Apr 12, 2012 15:45 |
|
leterip posted:Code is read a lot more than it is written. Being able to see exactly what the output format will look like is a huge win. Quick! Is "02/01/06" DMY or MDY?
|
# ? Apr 12, 2012 16:02 |
|
leterip posted:%m vs %M "Wait is it day-month-year because it'd make sense numerically or is it month-day-year because it's made by Americans who somehow believe their system is the most intuitive?" edit: bah
|
# ? Apr 12, 2012 16:04 |
|
leterip posted:Being able to see exactly what the output format will look like is a huge win. You're right you still have to know how to format strings. There is no formatting specification that would remove that need. The point in that instead of having to memorize how strftime works or go look it up, you can just derive it because it is totally logical with no arbitrary decisions in what letters or capitalization means what. I don't think this is a argument either of us can win, so let's agree that we both like different things!
|
# ? Apr 12, 2012 16:10 |
|
Ender.uNF posted:And that's why C# is adding async/await. Let the compiler turn your code inside out later. There's TameJS for node that gives you the same concept for doing inline callbacks with a slightly altered syntax design. I haven't used it myself so I can't vouch for quality, but OkCupid is using it in production, so it must be decently stable.
|
# ? Apr 12, 2012 16:38 |
|
Janin posted:http://golang.org/pkg/time/ edit: oops, missed a page of jabber Brecht fucked around with this message at 18:33 on Apr 12, 2012 |
# ? Apr 12, 2012 18:31 |
|
https://bugs.php.net/bug.php?id=54547 With rasmus reply!
|
# ? Apr 12, 2012 20:20 |
|
Well php users can't count that far on their hands so why would their scripts ever need to?
|
# ? Apr 12, 2012 20:26 |
|
Apparently all database columns are varchar too. That sure explains a lot of the MySQL databases I see. Foreign keys? Pfffffft, that's for losers.
|
# ? Apr 12, 2012 22:44 |
|
Ender.uNF posted:Apparently all database columns are varchar too. Wait, all textual columns are varchar, or all columns are varchar?
|
# ? Apr 13, 2012 04:30 |
|
Huragok posted:Wait, all textual columns are varchar, or all columns are varchar? All. That's the only explanation I can think of for why auto-converting all string comparisons to numbers "makes things easier" when working with a database. My naive approach would be to store numbers in the database and convert the request parameter to a number explicitly, thus performing a basic sanity check against a random value submitted from an anonymous internet user, but then again I'm not a PHP developer.
|
# ? Apr 13, 2012 07:13 |
|
Ender.uNF posted:All. That's the only explanation I can think of for why auto-converting all string comparisons to numbers "makes things easier" when working with a database. My naive approach would be to store numbers in the database and convert the request parameter to a number explicitly, thus performing a basic sanity check against a random value submitted from an anonymous internet user, but then again I'm not a PHP developer. The mysql lib returns values as strings for all columns, but stores them correct internally. It requires extra queries to find out what type a column actually is (or storing them in your application somehow) for properly casting the values to their right types. That is still not an excuse to do type-mangling the way PHP does, but at least they're correct about MySQL's behaviour.
|
# ? Apr 13, 2012 07:40 |
|
Yeah not sure why you assumed PHP forced some kind of weird internal MySQL representation, but you can create tables with ints, varchars, text, dates just like normal, it just pulls them out as strings since the reasoning is you're just going to output them to HTML.
|
# ? Apr 13, 2012 08:35 |
|
I was making a joke about people who just create varchar columns for everything because I (wrongly) assumed the mySQL API couldn't be that stupid. Then I made a joke about the "naive" approach because even an entry-level programmer should know that you should both perform sanity checks and validity checks on *anything* sent to you, especially when it comes from the web. My attempt at humor has been outfoxed by awful open source software yet again.
|
# ? Apr 13, 2012 20:57 |
|
Well, without a custom boxing system (I shudder at the thought of mysql_val_t), I can't see how a library could do better. In fact, it seems sane to send number types over the wire as strings in case the application language's type system and the library language's type system don't correlate 1:1. For instance, Python's integer type has no upper limit, and if they sent BIGINTs as 32-bit integers over the wire, then you'd lose a bit of data. And even if they sent a custom variable-length byte representation like protocol buffers, it's still technically strings :cobert:. Postgres does the same thing as well. It looks like a WTF at first, until you realize the decision here.
|
# ? Apr 13, 2012 22:33 |
|
|
# ? May 14, 2024 11:21 |
|
Oracle PL/SQL: code:
|
# ? Apr 14, 2012 00:51 |