Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
EssOEss
Oct 23, 2006
128-bit approved
Ah, I see what you mean now.

Adbot
ADBOT LOVES YOU

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome
When I used to work in the build department, I inherited some real doozies. The build scripts were giant shell scripts running under MKSTools. Probably half of the code we compiled was generated by a process I won't pretend I even came close to understanding. There was a lot of necessary complexity because we built for a shitload of different platforms, but one thing really stuck out.

The guy who wrote the bulk of the build scripts really wanted inheritance in his shell scripts. In order to accomplish this, the script searched through the 'parent' shell script for a particular line (not some kind of obvious comment delimiter like "#---THIS IS A DELIMITER---", just another line of a shell script), then took that line and the next 50 or however many, and piped it to a file. He then sourced that file, deleted it, then called functions that the now-deleted file had. It must have taken me a week to figure that poo poo out. And he did it in like four places.

Steampunk Mario
Aug 12, 2004

DIAGNOSIS ACQUIRED

rotor posted:

When I used to work in the build department, I inherited some real doozies. The build scripts were giant shell scripts running under MKSTools. Probably half of the code we compiled was generated by a process I won't pretend I even came close to understanding. There was a lot of necessary complexity because we built for a shitload of different platforms, but one thing really stuck out.

The guy who wrote the bulk of the build scripts really wanted inheritance in his shell scripts. In order to accomplish this, the script searched through the 'parent' shell script for a particular line (not some kind of obvious comment delimiter like "#---THIS IS A DELIMITER---", just another line of a shell script), then took that line and the next 50 or however many, and piped it to a file. He then sourced that file, deleted it, then called functions that the now-deleted file had. It must have taken me a week to figure that poo poo out. And he did it in like four places.

:psyduck:

It blows my mind that anybody that would know how to do that would actually do it.

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

Drx Capio posted:

:psyduck:

It blows my mind that anybody that would know how to do that would actually do it.

yep. to my way of thinkin', there are times when code duplication is just fine, considering the alternatives.

ashgromnies
Jun 19, 2004

rotor posted:

yep. to my way of thinkin', there are times when code duplication is just fine, considering the alternatives.

So basically he wanted subroutines? I'm not an expert bash scripter(I just use it for automating things I do all the time) but from what I understand, couldn't he just write out separate shell files containing the code block he glommed and just call those? Or does using source give the functions access to lexical variables?

That's actually really, really genius in a way.

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

ashgromnies posted:

So basically he wanted subroutines? I'm not an expert bash scripter(I just use it for automating things I do all the time) but from what I understand, couldn't he just write out separate shell files containing the code block he glommed and just call those? Or does using source give the functions access to lexical variables?

That's actually really, really genius in a way.

He wanted inheritance so he wouldn't have to duplicate code. I would imagine he could have separated out the stuff he wanted to share and sourced it from both files, but he was clearly much better at shell scripting than I am, so maybe there's some subtlety I'm missing.

And yeah, it was pretty ingenious. But so much wasted time could have been saved with a few simple goddamn comments giving me some kind of idea that he was doing this very tricksy thing.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Often, the source of these horrors is someone trying to do something brilliant, even proper, but not knowing or having a succint/correct way of expressing it.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

Triple Tech posted:

Often, the source of these horrors is someone trying to do something brilliant, even proper, but not knowing or having a succint/correct way of expressing it.

Example: Duff's Device.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

TRex EaterofCars posted:

Example: Duff's Device.

No, Duff's Device is brilliant in every way.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Found this in the PHP manual. It's like the guy knew he wanted some kind of conditional execution, but forgot about the "if" keyword.

code:
switch (TRUE)
{
 case ($phlen < 7):
   $ext = $ph;
   break;
 case ($phlen == 7):
   sscanf($ph, "%3s%4s", $pfx, $exc);
   break;
 case ($phlen > 7 AND $phlen < 10):
   sscanf($ph, "%3s%4s%s", $pfx, $exc, $ext);
   break;
 case ($phlen == 10):
   sscanf($ph, "%3s%3s%4s", $area, $pfx, $exc);
   break;
 case ($phlen == 11):
   sscanf($ph, "%1s%3s%3s%4s", $cty, $area, $pfx, $exc);
   break;
 case ($phlen > 11):
   sscanf($ph, "%1s%3s%3s%4s%s", $cty, $area, $pfx, $exc, $ext);
   break;
}

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

Ryouga Inverse posted:

No, Duff's Device is brilliant in every way.

It's an awesome hack... But come on, it's a hack. Using fallthrough like that is an anti-pattern unless you REALLY need the speed, like Tom Duff did. Anyone else using it is just masturbating.

Incoherence
May 22, 2004

POYO AND TEAR

pokeyman posted:

Found this in the PHP manual. It's like the guy knew he wanted some kind of conditional execution, but forgot about the "if" keyword.
:psyduck:

Okay, that's a pretty good one. I'm surprised that works at all.

Jethro
Jun 1, 2000

I was raised on the dairy, Bitch!

pokeyman posted:

Found this in the PHP manual. It's like the guy knew he wanted some kind of conditional execution, but forgot about the "if" keyword.

code:
switch (TRUE)
{
 case ($phlen < 7):
   $ext = $ph;
   break;
 case ($phlen == 7):
   sscanf($ph, "%3s%4s", $pfx, $exc);
   break;
 case ($phlen > 7 AND $phlen < 10):
   sscanf($ph, "%3s%4s%s", $pfx, $exc, $ext);
   break;
 case ($phlen == 10):
   sscanf($ph, "%3s%3s%4s", $area, $pfx, $exc);
   break;
 case ($phlen == 11):
   sscanf($ph, "%1s%3s%3s%4s", $cty, $area, $pfx, $exc);
   break;
 case ($phlen > 11):
   sscanf($ph, "%1s%3s%3s%4s%s", $cty, $area, $pfx, $exc, $ext);
   break;
}
:aaaaa:
Sometimes if{} else if {} just isn't elegant enough.

JawnV6
Jul 4, 2004

So hot ...

Jethro posted:

:aaaaa:
Sometimes if{} else if {} just isn't elegant enough.

I've seen that a lot in hardware, it makes a lot of sense in that domain. But I really hope that nobody's moving from HDL's to PHP, I can't imagine the horribly broken code that would come from that background.

MrMoo
Sep 14, 2000

TRex EaterofCars posted:

It's an awesome hack... But come on, it's a hack. Using fallthrough like that is an anti-pattern unless you REALLY need the speed, like Tom Duff did.

The performance can actually be terrible as the increment is quite expensive, I found this out with a basic vector add & multiply. Array offsets work better ([n+1], [n+2], ...).

nebby
Dec 21, 2000
resident mog

tef posted:

See, where you might use "result" I would use bln_flg_tst_cnd_args_x.
My god. I haven't been in here in weeks, and the first thread I open you guys are still making fun of me... I'm.. speechless.

For the record, say what you will about "bln_flg_tst_cnd_args_x", but I still think calling a return value "ret" or "result" is the goddamn stupidest idea I saw posted in all of those trainwrecks of threads I started.

Edit: And just for fun, I thought I'd post some of my own code since you guys find my style of naming a Coding Horror! :) It's a little functional library I built for Java yesterday since I'm writing Android apps and Java is soooo verbose:

code:
public class F {
  public static <S, T> List<T> map(List<S> in, Cl<S, T> cl) {
    List<T> rg = new ArrayList<T>();
		
    for (int i = 0; i < in.size(); i++) {
      rg.add(cl.r(in.get(i)));
    }
		
    return rg;
  }
	
  public static <T> List<T> select(List<T> rg, final Clp<T> cl) {
    final List<T> rgSelect = new ArrayList<T>();
		
    each(rg, new Clv<T>() { public void r(T t) {
      if (cl.r(t)) { rgSelect.add(t); }
    }});
		
    return rgSelect;
  }
}

Cl<S,T> indicates a Java closure (which is just a anonymous class meeting one of the interfaces below) mapping from type S to T.. Clp<T> is a predicate closure (T => boolean), Clv<T> is (T => void) and Clvv is double void closure (void => void).

So
code:
public interface Cl<S, T> {
  T r(S in); 
}

public interface Clp<T> {
  public boolean r(T obj);
}

public interface Clv<T> {
  void r(T in); 
}

public interface Clvv {
  void r(); 
}
Here's an example, this takes a list of nodes that point to time blocks (tblk's) and selects the subset of nodes in that list that have the node for the learning period (nodeLrg) as their parent's parent. For sample, we might have 4 learning periods and have a set of time blocks to work with, and we want to just select those falling under period 2.

code:
List<Node> rgNodeTblkForLrg = F.select(rgNodeTblk, new Clp<Node>() { public boolean r(Node node) {
  return node.getParentNode().getParentNode() == nodeLrg;
}});
Bring on the hate, but I'd love to see your examples of functional constructs in java that don't read like a goddamn essay.

nebby fucked around with this message at 06:54 on Mar 29, 2008

floWenoL
Oct 23, 2002

nebby posted:

...I still think calling a return value "ret" or "result" is the goddamn stupidest idea I saw posted in all of those trainwrecks of threads I started.

I assume you're not counting your own posts.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

MrMoo posted:

The performance can actually be terrible as the increment is quite expensive, I found this out with a basic vector add & multiply. Array offsets work better ([n+1], [n+2], ...).

If you read about the history of the code, Duff was working for Industrial Light & Magic trying to program some kind of video system and the normal while (count--) {*to = *from++;} just wasn't cutting it. He wrote the switch as a forced-hand loop-unroll/jump-table combo. Pretty standard idiom in assembler, he just moved it to C.

But I guess I don't understand your comment; you're saying that a register increment is expensive? inc reg is probably the cheapest op you can perform aside from the nop. Maybe I just don't understand what you mean.

Take into account this was written in 1983, and while there certainly were vector processors back then, I don't think his target was one.

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

nebby posted:

My god. I haven't been in here in weeks, and the first thread I open you guys are still making fun of me... I'm.. speechless.

When it comes to mocking inane bullshit, we've got pretty long attention spans.

nebby
Dec 21, 2000
resident mog

rotor posted:

When it comes to mocking inane bullshit, we've got pretty long attention spans.
Yeah. One thing I think I've come to conclude is that one small thing that would go a long way towards a middle ground between my (supposedly crazy) viewpoints and the "gently caress it do whatever you want and use 'common sense'" viewpoint is a convention to use noun-adjective instead of adjective-noun in variable names and return type-verb in method names (or, at the very least, be consistent.)

I've been digging into some 3rd party code and sometimes it's the "RunningActivity" and other times it's the "ActivityToRun". Sometimes it's "RedColor" and sometimes it's "ColorRed". Is "CountApples" a function pointer to something that counts apples and returns nothing, or a variable containing a number of apples/a function that gets the count of apples?

Victor
Jun 18, 2004
I'm all for a few intelligent conventions like what you've just posted (I'm not sure if the actual ones you posted are good or not). Consistency is really the important thing, within any given code base. And don't make it drastically different from other code bases you're going to be working on. Give the brain fewer differences so that the differences it does process are the relevant ones.

FrantzX
Jan 28, 2007

nebby posted:

Yeah. One thing I think I've come to conclude is that one small thing that would go a long way towards a middle ground between my (supposedly crazy) viewpoints and the "gently caress it do whatever you want and use 'common sense'" viewpoint is a convention to use noun-adjective instead of adjective-noun in variable names and return type-verb in method names (or, at the very least, be consistent.)

I've been digging into some 3rd party code and sometimes it's the "RunningActivity" and other times it's the "ActivityToRun". Sometimes it's "RedColor" and sometimes it's "ColorRed". Is "CountApples" a function pointer to something that counts apples and returns nothing, or a variable containing a number of apples/a function that gets the count of apples?

I suppose the variable/function type would give some information. But not all of program in a strongly-typed language like C# or Java.

MrMoo
Sep 14, 2000

TRex EaterofCars posted:

you're saying that a register increment is expensive? inc reg is probably the cheapest op you can perform aside from the nop.

This:
code:
        int i = 0;
        count8 = len >> 3;              /* 8-way unrolls */
        if (count8)
        {
                while (count8--) {
                        d[i  ] ^= gfmul( b, s[i  ] );
                        d[i+1] ^= gfmul( b, s[i+1] );
                        d[i+2] ^= gfmul( b, s[i+2] );
                        d[i+3] ^= gfmul( b, s[i+3] );
                        d[i+4] ^= gfmul( b, s[i+4] );
                        d[i+5] ^= gfmul( b, s[i+5] );
                        d[i+6] ^= gfmul( b, s[i+6] );
                        d[i+7] ^= gfmul( b, s[i+7] );
                        i += 8;
                }

/* remaining */
                len %= 8;
        }

        while (len--) {
                d[i] ^= gfmul( b, s[i] );
                i++;
        }
Is faster than this, on a 3Ghz Xeon.
code:
    register n = (len + 7) / 8;
    switch (len % 8) {
    case 0: do { *d++ ^= gfmul( b, *s++ );
    case 7:      *d++ ^= gfmul( b, *s++ );
    case 6:      *d++ ^= gfmul( b, *s++ );
    case 5:      *d++ ^= gfmul( b, *s++ );
    case 4:      *d++ ^= gfmul( b, *s++ );
    case 3:      *d++ ^= gfmul( b, *s++ );
    case 2:      *d++ ^= gfmul( b, *s++ );
    case 1:      *d++ ^= gfmul( b, *s++ );
               } while (--n > 0);
    }
The array offsets are free on Intel processors.

MrMoo fucked around with this message at 08:31 on Mar 29, 2008

zootm
Aug 8, 2006

We used to be better friends.

nebby posted:

For the record, say what you will about "bln_flg_tst_cnd_args_x", but I still think calling a return value "ret" or "result" is the goddamn stupidest idea I saw posted in all of those trainwrecks of threads I started.
If you're using a variable to build the result of a function, result seems a pretty natural name for the variable. Because it contains the result.

nebby posted:

Cl<S,T> indicates a Java closure (which is just a anonymous class meeting one of the interfaces below) mapping from type S to T.. Clp<T> is a predicate closure (T => boolean), Clv<T> is (T => void) and Clvv is double void closure (void => void).
There's a bunch of frameworks for Java which do stuff a bit like this (and these aren't really closures, the term used in Java is "anonymous inner class" for this sort of thing, and "functor" for the pattern you're following). They're a reasonable-if-verbose analogue to closures.

"Predicate<T>" seems a better name than "Clp<T>" (it is, after all, the name being used for its addition to Java in the next version), for what it's worth. Also, Clvv is java.lang.Runnable except less self-documenting. Also also if Runnable is useful to you, java.util.concurrent.Callable<T> probably will be too, which is a combination you missed.

nebby posted:

Bring on the hate, but I'd love to see your examples of functional constructs in java that don't read like a goddamn essay.
Considering you've basically replicated the existing stuff for this sort of thing and made the variables slightly shorter at the cost of readability, it seems unlikely the examples would read significantly differently. Java is a verbose language in general and encoding the variable names isn't going to help any more with readability than removing all the vowels would.

On the other hand that kind of construct is definitely handy, which is why it's been implemented so many times in the past, and presumably why people seem to be finally integrating it into Java's libraries themselves. I'm not sure how I feel about closures in Java in general, though – Josh Bloch makes a good case showing the complexity they add to the language while removing readability, since there's been little actual consultation on the current BGGL Closures proposal. The proposal may well go through, though.

I don't know BGGL closures but with Scala (another JVM language), your last code example would look like this:
code:
val timeblocksUnderLearningNode = F.select(timeblocks, _.getParentNode.getParentNode == learningNode );

zootm fucked around with this message at 15:53 on Mar 29, 2008

nebby
Dec 21, 2000
resident mog

zootm posted:

If you're using a variable to build the result of a function, result seems a pretty natural name for the variable. Because it contains the result.
The reason that this is a bad name, IMHO, is because the concept of a "result" is one in the domain of programming languages, not a concept in the domain you are writing the code for. It's about as meaningless as "x" or "i", which I also think are bad. (In my case above I use i, but only because the stuff being built there is completely detached from any domain, it's just some basic language enhancements.)

For example, if you are writing a method called countOfApplesInBasket() that returns a count of apples, if I see the line "result += 1;" I have to look at context to determine wtf result is. In this case, it's a count of apples. It's much nicer to just call it something like "countApples", it doesn't require context and gives the variable a much more meaningful name. The "but you can always look at context" defense is what I got a lot of in my old threads but it's entirely missing the point because the overall goal of naming itself is to minimize the amount of unnecessary cross referencing of context by the programmer.

The fact that it is the value being returned (and the fact that the concept of "return values" exists in my language) shouldn't impact the name of my variables in a method written against a certain domain like apple counting. I'd argue that the vast majority of the time there is a better name than "result" or "x" or "i".

And yeah, I realize "Runnable" and "Predicate" (and in .NET "Action") exist but my main issue is that when you are talking about something as fundamental as closures (or 'functors' as you put it, but Java anonymous inner classes pseudo-capture final variables and this variables so I think they are closures) that every extra bit of verbiage hurts and learning a few acronyms basically gets the ugly syntax out of the way so you can avoid reading it altogether (The terms 'Predicate' and 'Action' and 'Runnable' aren't necessary in non-lovely languages, they're just implicit in the syntax, so it's hard to argue they add some value to describing what is going on in this case.) You'll note I just throw all the anonymous inner class declaration crap on the end of the line even though that's not canonical Java formatting.

And yeah, I like Scala from what I've read so far, but time constraints are keeping me from trying to get my Android app running on Scala (which actually works, supposedly.) I'll do it eventually though :)

Edit: Here's the same code with 'common sense' applied. It's probably more intuitive to most of the readers of this forum, but it feels like a sack of molasses to me, it turns what should be a one-liner in any sane language into an abomination.

code:
List<Node> timeBlockNodesForPeriod = FunctionalUtil.select(timeBlockNodes, 
  new Predicate<Node>() { 
    public boolean predicate(Node node) {
      return node.getParentNode().getParentNode() == nodeForCurrentPeriod;
    }
  }
});

nebby fucked around with this message at 17:55 on Mar 29, 2008

hey mom its 420
May 12, 2007

I agree with nebby that there's almost always a better name for a variable that is returned by a method or function than result.

Although I disagree that i is a bad name, because it's almost exclusively used for loop counters and has become a sort of a standard for them. When you see some_collection[i] in a loop, you know what that i stands for. That's for languages like C and such, proper higher level languages shouldn't force you to write boilerplate code :v:.

ndb
Aug 25, 2005

Extremely similar to another person, but one time, in a program assignment that converted an infix expression to a postfix expression in C++, I had to convert every digit 1-9 to a integer from a string and put that on a stack. Thankfully, there was only digits 0-9 used.

The day after I turned it in, I remembered the atoi() function and how it would've made my life easier. :doh:

Also, when I was first learning VB 6 (when I was 15 or 16 or so), I made a text adventure game without knowing anything about classes, inheritance, or anything remotely Object-Oriented.

Each room was in a very long array of strings, and each restriction on the room had to be manually coded in. Items in an array of strings as well, and their use depended on their number in the array. Arrays and hardcoding were used a lot.

I actually wish I still had the source code. Might be fun to take a look at.

zootm
Aug 8, 2006

We used to be better friends.

nebby posted:

For example, if you are writing a method called countOfApplesInBasket() that returns a count of apples, if I see the line "result += 1;" I have to look at context to determine wtf result is. In this case, it's a count of apples. It's much nicer to just call it something like "countApples", it doesn't require context and gives the variable a much more meaningful name. The "but you can always look at context" defense is what I got a lot of in my old threads but it's entirely missing the point because the overall goal of naming itself is to minimize the amount of unnecessary cross referencing of context by the programmer.
Just "apples" would suffice - why bother saying it's a count when it could be nothing else? On the other hand, generally speaking, if "result" is confusing, your method is too complex and you should simplify it.

nebby posted:

The fact that it is the value being returned (and the fact that the concept of "return values" exists in my language) shouldn't impact the name of my variables in a method written against a certain domain like apple counting. I'd argue that the vast majority of the time there is a better name than "result" or "x" or "i".
"result" just works well when you want a succint way to describe that you're building up the result to a self-describing function. Of course result shouldn't be used if it's at all confusing or ambiguous, but in sensible code it shouldn't ever be.

nebby posted:

And yeah, I realize "Runnable" and "Predicate" (and in .NET "Action") exist but my main issue is that when you are talking about something as fundamental as closures (or 'functors' as you put it, but Java anonymous inner classes pseudo-capture final variables and this variables so I think they are closures) that every extra bit of verbiage hurts and learning a few acronyms basically gets the ugly syntax out of the way so you can avoid reading it altogether. You'll note I just throw all the anonymous inner class declaration crap on the end of the line even though that's not canonical Java formatting.
Canonical Java formatting is something of a myth, but I don't think the spread-out version is any less readable. In particular, though, I don't think that the encoded names convey any useful information or make the code any more readable. I doubt anyone would even notice the fact that it's marginally shorter unless on a particularly-limited screen width, which hardly seems a useful case to optimise for.

Also, in this case "closure" isn't even what the objects are. "Closure" (or "anonymous inner class") is the language feature that you use to generate them. The actual objects are functors, or function objects, or just functions, or whatever you want to call them.

nebby posted:

And yeah, I like Scala from what I've read so far, but time constraints are keeping me from trying to get my Android app running on Scala (which actually works, supposedly.) I'll do it eventually though :)
My workmate got a Scala app running on J2ME, although it requires a little bytecode fiddling (relies on things like Comparable).

nebby posted:

Edit: Here's the same code with 'common sense' applied. It's probably more intuitive to most of the readers of this forum, but it feels like a sack of molasses to me, it turns what should be a one-liner in any sane language into an abomination.
I wouldn't say that Java wasn't a "sane" language, this is just a particular area where it falls over. Considering the language family it's from it's hardly surprising that it falls over here.

hey mom its 420
May 12, 2007

zootm posted:

Just "apples" would suffice - why bother saying it's a count when it could be nothing else? On the other hand, generally speaking, if "result" is confusing, your method is too complex and you should simplify it.
Well it could be a list of Apple objects, so I'd probably use num_apples or something. I don't know, I guess functions shouldn't be so complicated that you don't know what result gives you but it doesn't hurt to give it a more meaningful name.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

MrMoo posted:


The array offsets are free on Intel processors.

Well, it's not equivalent code, but I see your point. FYI, Duff's device needs the jump-table generated by the switch statement because of unaligned data sets. Also, his target was most likely not an Intel 8086 series processor with free index offsets.

Volte
Oct 4, 2004

woosh woosh
Variable names should balance clarity and brevity. num_apples is a perfect variable name while n (too short), number_of_apples (too long), and apples (too ambiguous) aren't very good names for the same variable. result is useful in some places. For example if you are checking the return value/error code of many functions it's useful to have a single variable to do it in rather than cluttering the sub with a ton of one-off variables.

Z-Bo
Jul 2, 2005
more like z-butt

nebby posted:

Bring on the hate, but I'd love to see your examples of functional constructs in java that don't read like a goddamn essay.

I think you are completely missing why your blog posts were so epic and are seared into our brains: You were mentored by Charles Simonyi, and yet completely misrepresent his position on intentional programming.

People have given me poo poo in the past for misrepresenting subjects, and I deserved it... even if in some cases I felt like the opposing party was being a grammar nazi. You appear to think it is Nebby versus the World.

nebby
Dec 21, 2000
resident mog

Z-Bo posted:

I think you are completely missing why your blog posts were so epic and are seared into our brains: You were mentored by Charles Simonyi, and yet completely misrepresent his position on intentional programming.
I don't see how I can be misrepresenting them when the lead dev at Simonyi's company (who is a real wizard, IMHO) told me my blog put forward the best argument he had ever read for Hungarian (assumingly apart from those written by Charles.)

quote:

You appear to think it is Nebby versus the World.
On this topic in this forum it probably is me vs. everyone else, more or less. I don't recall anyone even slightly agreeing with me, and hey, check out my awesome avatar which I've held on to :)

That's not saying anything about any other topic in any other forum or audience -- when I sent some of the posts to other 'converts' not on SA they agreed with what I was saying and rolled their eyes at some of the replies that were made :)

You're forgetting that I explicitly said in all my posts I intentionally post on subjects that are controversial in order to spice things up. I don't think that I'd be contributing much if I posted another "how do I implement this data structure" or "how awesome is Ruby on Rails" thread.

nebby
Dec 21, 2000
resident mog

Bonus posted:

Although I disagree that i is a bad name, because it's almost exclusively used for loop counters and has become a sort of a standard for them.
Yeah, I mean, I catch myself using "i" when I know better. The problem is, I see it as a bad habit when most see it as acceptable. When you are writing a loop, you can quickly get into trouble if you have nested loops and have i, j, or even k being used. Additionally, and more importantly, using "i" is ignoring an opportunity to introduce a good name into the code. You're looping over it for a reason, so you should usually opt to provide hints as to why you're doing so in the name. If you are looping over a list of apples that need to be put into another bucket, instead of "i", you could use "iAppleForBucket" and not worry about confusing it with another loop variable and potentially remove a comment saying "// We loop over the apples for the bucket" !

nebby fucked around with this message at 20:46 on Mar 29, 2008

more falafel please
Feb 26, 2005

forums poster

nebby posted:

Yeah, I mean, I catch myself using "i" when I know better. The problem is, I see it as a bad habit when most see it as acceptable. When you are writing a loop, you can quickly get into trouble if you have nested loops and have i, j, or even k being used. Additionally, and more importantly, using "i" is ignoring an opportunity to introduce a good name into the code. You're looping over it for a reason, so you should usually opt to provide hints as to why you're doing so in the name. If you are looping over a list of apples that need to be put into another bucket, instead of "i", you could use "iAppleForBucket" and not worry about confusing it with another loop variable and potentially remove a comment saying "// We loop over the apples for the bucket" !

I don't need that comment:
code:
for (int i = 0; i < bucketOfApples.size(); ++i)
{
    bucketOfApples[i].bob();
}
Yes, there may be better ways of doing it, but I don't believe you honestly can't look at that loop and immediately know what it's doing. That comment would be entirely superfluous. If it said // Bob all the apples in the bucket, that'd be one thing, but calling the loop var appleToBob wouldn't change that.

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

Z-Bo posted:

I think you are completely missing why your blog posts were so epic and are seared into our brains: You were mentored by Charles Simonyi, and yet completely misrepresent his position on intentional programming.
its seared into my brain because it was so immensely beef-brained. I think the stupidest part was where nebby proclaimed that hungarian was great becaus it was essentially a DSL for every project, as though that was a good thing .

uXs
May 3, 2005

Mark it zero!

more falafel please posted:

I don't need that comment:
code:
for (int i = 0; i < bucketOfApples.size(); ++i)
{
    bucketOfApples[i].bob();
}
Yes, there may be better ways of doing it, but I don't believe you honestly can't look at that loop and immediately know what it's doing. That comment would be entirely superfluous. If it said // Bob all the apples in the bucket, that'd be one thing, but calling the loop var appleToBob wouldn't change that.
appleToBob would be a bad name for it anyway, because i isn't the apple, it's the index of the apple in the bucket.

nebby
Dec 21, 2000
resident mog

rotor posted:

a DSL for every project, as though that was a good thing .
This isn't a revolutionary idea:

http://en.wikipedia.org/wiki/Domain-driven_design
http://en.wikipedia.org/wiki/Language-oriented_programming

I've worked on a number of software projects and in every case, regardless if we liked it or not, we developed a DSL around what it was we were building in our day to day communication. The choice wasn't if we had a DSL, of course we did, we were building something, but in what words we chose to use.

nebby fucked around with this message at 21:26 on Mar 29, 2008

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

nebby posted:

This isn't a revolutionary idea:

No, but it's still a bad one. We went over and over this in the last thread. If you have a good point, you're not getting it across very well. The fact that someone told you that your blog post was an eloquent expression of Simonyi's ideas tells me all I need to know about Simonyi's ideas.

Adbot
ADBOT LOVES YOU

Scaevolus
Apr 16, 2007

http://luke.breuer.com/time/item/MeditechCodeProcessor/318.aspx

code:
Regex field = new Regex(@"
    (?<comment>
        (?:
            ^;\s*\n
        )?
        (?:
            ^;.*?
            (?:
                \ -\s*(?<sequence>\d+)
            )?
            \s*\n
        )?
        (?:
            ^;.*\s*\n
        ){0,5}
    )
    (?<setup>
        ^[^;]
        (?:
            .(?!@S)
        )*
        \s*\n
    ){0,3}
    (?<assignment>
        ^[^;].*\^@S
    )", RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace);

Scaevolus fucked around with this message at 22:46 on Mar 29, 2008

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply