|
loinburger posted:The "volatile" stuff was a bandage for a database cache that I'm probably going to just wind up getting rid of. It used to consist of about a half dozen of these Or just use a loadingcache
|
# ? Oct 4, 2015 01:00 |
|
|
# ? Apr 24, 2024 01:33 |
|
Blotto Skorzany posted:GHC did this in the past. It involved a Perl script called the "evil munger" or something like that. Does GHC still statically link the entire standard library whenever you compile something? I'm pretty sure I remember it doing that.
|
# ? Oct 4, 2015 06:37 |
|
Pavlov posted:Does GHC still statically link the entire standard library whenever you compile something? I'm pretty sure I remember it doing that. By default yes, but you can also dynamically link now. It's probably not a good idea - partly because dynamic linking has the usual problems, partially because it is exacerbated by Haskell programs usually using a large number of small libaries, resulting in a staggering number of dynamic libraries. And seconding that compiler-generated C - it is very readable. Certainly more readable than the C my own compiler generates.
|
# ? Oct 5, 2015 08:20 |
|
code:
Knyteguy fucked around with this message at 17:09 on Oct 5, 2015 |
# ? Oct 5, 2015 17:04 |
|
else after return makes me twitch.
|
# ? Oct 5, 2015 17:12 |
|
I think my favorite part is that no is true.
|
# ? Oct 5, 2015 17:14 |
|
Athas posted:By default yes, but you can also dynamically link now. It's probably not a good idea - partly because dynamic linking has the usual problems, partially because it is exacerbated by Haskell programs usually using a large number of small libaries, resulting in a staggering number of dynamic libraries. I just remember it producing massive Hello World programs last time I checked it out. Made me pretty suspicious of their compilation pipeline.
|
# ? Oct 5, 2015 19:54 |
|
Subjunctive posted:else after return makes me twitch. It's good, in a function like that one, because it makes it visually clear that there's a dichotomy. However, instead of being structured as "if (a) {x} else {if (b) {y} else {z}}", it should be structured as "if (a) {x} else if (b) {y} else {z}", because the nesting doesn't add anything.
|
# ? Oct 5, 2015 23:42 |
|
Hammerite posted:because the nesting doesn't add anything.
|
# ? Oct 6, 2015 03:00 |
|
The nesting seems reasonable to me. "else if" to me is the sort of thing where, if you dropped the previous if statement, the code ought to be able to work. For example if (foo == "hey") { } else if (foo == "ho") { }. In the horror above, the stuff in the else clause relies on the null checks failing. So you've got to have a "okay, field is not null in this world" situation established for all further branches.
|
# ? Oct 6, 2015 03:39 |
|
Pavlov posted:I just remember it producing massive Hello World programs last time I checked it out. Made me pretty suspicious of their compilation pipeline. GHC links statically. If you link dynamically (not recommended for various reasons), you get small binaries. If you link C statically you get binaries just as large.
|
# ? Oct 6, 2015 04:07 |
|
Hammerite posted:It's good, in a function like that one, because it makes it visually clear that there's a dichotomy. Except there are more than two paths. Why isn't the rest of the function also in elses?
|
# ? Oct 6, 2015 04:43 |
|
KaneTW posted:If you link C statically you get binaries just as large. This is not true. GHC generates gigantic code because the optimiser relies heavily on aggressive inlining (also why compilation is very slow), and because code for such a huge number of thunks is generated.
|
# ? Oct 6, 2015 06:32 |
|
Subjunctive posted:else after return makes me twitch. Also using == instead of .equals
|
# ? Oct 6, 2015 07:17 |
|
TheresaJayne posted:Also using == instead of .equals Based on the casing of ToString and ToLower, it's c#, not java, so == is perfectly fine, and in my opinion even preferable.
|
# ? Oct 6, 2015 08:57 |
|
dwazegek posted:Based on the casing of ToString and ToLower, it's c#, not java, so == is perfectly fine, and in my opinion even preferable. meh! you are right, being a java dev mainly i didnt notice the DBNull.. Multiple returns are the bane of enterprise devs, - not allowed but you want to fail fast
|
# ? Oct 6, 2015 09:22 |
|
ExcessBLarg! posted:In this particular case, the ifs don't add anything. I don't follow what you mean, unless you're saying that it should be rewritten like this: code:
Subjunctive posted:Except there are more than two paths. Why isn't the rest of the function also in elses? As to there being more than two paths, yes it's more a trichotomy than a dichotomy and the second sentence of my post addresses that. In general, what I'm saying is that it's good to do this: code:
sarehu posted:The nesting seems reasonable to me. "else if" to me is the sort of thing where, if you dropped the previous if statement, the code ought to be able to work. For example if (foo == "hey") { } else if (foo == "ho") { }. In the horror above, the stuff in the else clause relies on the null checks failing. So you've got to have a "okay, field is not null in this world" situation established for all further branches. I had not considered this perspective.
|
# ? Oct 6, 2015 09:29 |
|
Hammerite posted:I don't follow what you mean, unless you're saying that it should be rewritten like this: everyone knows the && goes at the start of the next line
|
# ? Oct 6, 2015 10:11 |
|
Soricidus posted:everyone knows the && goes at the start of the next line Tangentially related, I was unaware until well after I started programming as an occupation that convention, when one is dedicating a whole line to a comment, is to place the comment on the line before the thing one is commenting about, rather than on the line after. Which makes no sense, but what can you do.
|
# ? Oct 6, 2015 11:15 |
|
Hammerite posted:Tangentially related, I was unaware until well after I started programming as an occupation that convention, when one is dedicating a whole line to a comment, is to place the comment on the line before the thing one is commenting about, rather than on the line after. Which makes no sense, but what can you do. Hm, to me it does make sense. "I'm gonna do this now" *does this* "so I can next do THAT" *does that*.
|
# ? Oct 6, 2015 12:16 |
|
Yeah, I'd rather have context I need to understand a complex blob of code provided to me before I read said blob than after I've slowly trudged through it. Like a lot of stylistic stuff it doesn't really matter as long as everyone who has to read it is in agreement on the local convention, I suppose.
|
# ? Oct 6, 2015 12:23 |
|
Carbon dioxide posted:Hm, to me it does make sense. "I'm gonna do this now" *does this* "so I can next do THAT" *does that*. Much of the time my comments are just giving worked example values to demonstrate what the code does, so putting "// Now `x` is ['a', 'b', ...]" immediately after I just did something odd to `x` makes far more sense.
|
# ? Oct 6, 2015 12:26 |
|
Carbon dioxide posted:Hm, to me it does make sense. "I'm gonna do this now" *does this* "so I can next do THAT" *does that*. It makes no sense because it's inconsistent with what you do when you put a comment on the same line, which is to put the comment after the code it references. code:
|
# ? Oct 6, 2015 12:38 |
|
Hammerite posted:I don't follow what you mean, unless you're saying that it should be rewritten like this: Just extract it to an extension method called phpIsFalsy() and be done with it.
|
# ? Oct 6, 2015 12:40 |
|
Hammerite posted:It makes no sense because it's inconsistent with what you do when you put a comment on the same line, which is to put the comment after the code it references.
|
# ? Oct 6, 2015 13:06 |
|
Athas posted:This is not true. GHC generates gigantic code because the optimiser relies heavily on aggressive inlining (also why compilation is very slow), and because code for such a huge number of thunks is generated. I'm talking about the Hello World here.
|
# ? Oct 6, 2015 13:27 |
|
Hammerite posted:It makes no sense because it's inconsistent with what you do when you put a comment on the same line, which is to put the comment after the code it references.
|
# ? Oct 6, 2015 13:30 |
|
Volte posted:The second style is more for labelling things or writing quick asides about particular lines and writing any sort of prose there is going to get annoying fast. They are two different styles for two different purposes. Putting a standalone comment after the block to which it refers is a bit like "The preceding program contained scenes of violence and should not have been viewed by children."
|
# ? Oct 6, 2015 13:33 |
|
Volte posted:The second style is more for labelling things or writing quick asides about particular lines and writing any sort of prose there is going to get annoying fast. They are two different styles for two different purposes. That's as may be, but it doesn't have any bearing on whether the comment should go before or after the code to which it applies; you haven't offered here a reason for inconsistency on that matter to exist. quote:Putting a standalone comment after the block to which it refers is a bit like "The preceding program contained scenes of violence and should not have been viewed by children." Then putting a same-line comment after the code is also alike to doing that. Same-line comments and dedicated-line comments are not distinct in that regard. ExcessBLarg! posted:In many languages you can't put a same-line comment before code, only after. All the more reason why it would make the most sense for the convention to be that comments go after what they are in reference to. Hammerite fucked around with this message at 13:36 on Oct 6, 2015 |
# ? Oct 6, 2015 13:33 |
|
Hammerite posted:All the more reason why it would make the most sense for the convention to be that comments go after what they are in reference to. When comments are important to explaining the purpose or behavior of a piece of code, most people find it better to precede the code with a (whole-line) comment than succeed it. But in instances where the comment isn't really necessary to comprehension, it's just there as a label or reference, placing it at the end of the line keeps it "out of the way". As others have explained, the inconsistency is, therefore, due to different uses/purposes/degrees of importance. I wouldn't really have a problem with having a whole-line comment succeeding a line/block of code, but if the comment is important to understand the block I'd much rather read the comment first. ExcessBLarg! fucked around with this message at 14:21 on Oct 6, 2015 |
# ? Oct 6, 2015 14:16 |
|
The difference is that an end-of-line comment is quite clearly associated with a single line of code. A block comment is associated with an entire section of one or more lines. Striving for "consistency" between those two things in place of actual readability is hella foolish. I mean, (unless you're suggesting something seriously pants-on-head like putting function documentation at the end of the function instead of at the start), you have to "break consistency" at some point. Having block comments for small bits of code be consistent with block comments for slightly bigger bits of code is far more important than having block comments for small bits of code read like end-of-line comments.
|
# ? Oct 6, 2015 14:23 |
|
Hammerite posted:It makes no sense because it's inconsistent with what you do when you put a comment on the same line, which is to put the comment after the code it references.
|
# ? Oct 6, 2015 14:34 |
|
Maybe I'm splitting hairs here, but I generally consider same line comments to be "with" the code on that line rather than "after" it.
|
# ? Oct 6, 2015 14:46 |
|
Thanks for the thoughts on that. I like to understand what's important in presentation of code and how to make it easier to work with. (In case anybody got the wrong idea, I don't write code where comments come after the code... any more.) To contribute to the thread, I don't remember this coming up recently (trigger warning: PHP) http://www.i-programmer.info/news/98-languages/6758-the-reason-for-the-weird-php-function-names.html Rasmus had a "hash function" on function names that was just string length, and came up with idiosyncratic function names in such a way as to produce a good distribution of name lengths. That's why PHP functions aren't named consistently.
|
# ? Oct 6, 2015 15:06 |
|
KaneTW posted:I'm talking about the Hello World here. Ran a few tests using code:
code:
|
# ? Oct 6, 2015 15:40 |
|
Hammerite posted:Thanks for the thoughts on that. I like to understand what's important in presentation of code and how to make it easier to work with. (In case anybody got the wrong idea, I don't write code where comments come after the code... any more.) The real horror is php people not having the balls to remove old poo poo like this.
|
# ? Oct 7, 2015 13:47 |
|
A while ago I wrote a bash script to print mpd's currently playing song and status. For most songs it works fine, but today I played a song with a * in it and the script printed the contents of my home directory. I don't know if bash is the horror or if I'm the horror for using it even for lovely one-off scripts. Probably both.
|
# ? Oct 7, 2015 21:52 |
|
Quote more.
|
# ? Oct 7, 2015 21:53 |
|
Yep, that's what I did. I guess I was spoiled by languages with the concept of a string .
|
# ? Oct 7, 2015 21:57 |
|
|
# ? Apr 24, 2024 01:33 |
|
Shell has always been a minefield of quote and escape errors. One I came across a ways back was with a find command. In the script this appeared: find /somedir -name *.tgz Worked great when there was nothing in /somedir that matched the pattern. As soon as /somedir/file.tgz showed up it would only return that one file. Or if there was two tarballs you'd start getting invalid argument errors.
|
# ? Oct 7, 2015 22:22 |