http://defyallchallenges.com/
Posts made by jergosh
-
What might be 'scoreboarding'?
I was recently asked by a friend of mine who is a translator to explain what is 'scoreboarding,' as she is about to translate some sort of EU meeting on that subject. Quick google/wiki search reveals that apparently it's a scheduling algorithm invented for a mainframe dating back to 1964 and I can't think of any wider context to that, or reason why a EU working group would discuss it. My best guess so far is that the word has another meaning which I am unable to find. Could anyone familiar with the term provide me with some more info?
TIA.
Greg
-
RE: C++ - what's the default method of opening a file passed to main via *argv[]?
Do have a look at getopt() (it's POSIX C I think). There are also versions for cpp (http://www.math.utah.edu/docs/info/libg++_39.html) and some more fancy versions implemented as classes ( http://ulisse.elettra.trieste.it/services/doc/libg++/libg++.html#SEC83 )
HTH,
Greg
-
RE: A Newbie Coding
As a person who is in contact with a huge number of people were introduced to programming in C, I'd discourage you from starting with low-levelish languages. The technical details connected with the computer architecture are often confusing, it's easy to make a mistake with which the compiler won't help you at all and you're likely to be very frustrated by hunting elusive bugs. I think you'll be best off starting with Python. You'll be able to concentrate on the concept you're trying to implement without worrying about technicalities. It's syntax encourages clarity and brevity which are foundations of good style. It also has a very universal but not overwhelmingly large standard library. From what I'm told, Ruby is similar in idea. I believe MIT uses Scheme for it's introductory courses which is quite a recommendation. Stay away from Java unless you hope to find work as a programmer. Pascal is plain stupid.
-
RE: "OO" WTF
How about a reference/pointer to it? Perhaps the compiler thinks it's smarter then the programmer and returning an object would be less efficient? Just a wild stab in the dark.
-
RE: How Not to Get Laid.
A friend of mine sent me a link to this site, and I thought it'd be good to share here. Similar to WTF, people share stories of their sexual blunders. Great reading:
How Not to Get Laid: http://hntgl.com/
Aye, some of these are fucking brilliant. Not brilliant fucking perhaps, but there you go ;)
-
RE: Programming style question
Note that they don't suggest that it's better to always use a short variable name, only that *context* and *clarity* are the key. If you have a short function, and it's clear from context what i and c stand for within that function, then i and c are perfectly valid. If you've got a longish function with a dozen local variables, i and c could get lost in the shuffle. Use your common sense. Also, go upside the head of whatever TA suggested PositionInLineFromLeftSide and tell him it's from me.
I'm aware of that, I find this fragment useful because I'm taught to use long variable names regardless of context ;)
-
RE: Programming style question
I'm not aspiring to control the discussion, I hoped to get answers to my question and so far I got 4 of them (out of 54 posts).
For the record, in the meantime I found an excellent quote from The Practice of Programming by Brian Kernigham and Rob Pike:
"Programmers are often encouraged to use long variable names regardless of context. That is a mistake: clarity is often achieved through brevity."
-
RE: Programming style question
I asked for pointers to reference not for style guidance.
Besides, at least I'm not calling people names.
-
RE: Programming style question
I would encourage descriptive names used for every variable. If you meant using i as an increment counter for a for loop, which you seem to, than that is fine. It's common to see it:
for(int i=0; i<x; i++)Really? I thought it was my own invention http://www.google.com/codesearch?q=%22int+i%22&hl=en&btnG=Search+Code . Forgive a bit of sarcasm but you not only state the obvious but also go off topic. I asked for pointers to reference not for style guidance.
I think of i as an increment or index. In the programming community the majority of developers should recognize this. However, when it comes to VB .NET I generally say intIndex instead, simply because VB .NET's syntax is more word like and having a single character variable name in the middle doesn't flow well. Usually the for loops iteration variable is used to index something; hense, intIndex.
See above.
I can't remember ever seeing c used for an input character so I would shy away from that. I would recommend you use a more descriptive name. And although I've seen pos used on occassion, a more descriptive name would still be a benefit here. This one is more personal preference since it's still pretty easy to guess what it represents.
You've never seen while ((c = getchar()) != EOF) ? Whoa. You might want to have a glimpse at ANSI C by K&R. Also, http://www.google.com/codesearch?hl=en&lr=&q=%22char+c%22&btnG=Search
The length of variable names shouldn't affect the actual program execution: I assume variable names are all replaced with an index or address in the binary executable. Make your variable names as descriptive as necessary to see it and immediately have a good guess as to what it represents. That said, don't make variable names longer than they need to be. That's just more work for yourself and other programmers that maintain the code.
Overly long names make even simple expressions exceed standard line length. Same for function calls.
Btw, it occured to me that PositionInLineFromLeftSide is not only redundant but also plain wrong. When we get characters from standard input there's in fact no left side. I imagine that if I used an Arabic terminal (if such a thing exists) than beginning of the line would be on the right. Thus, beginning, not left side. And the default for the beginning is the beginning.
-
RE: Programming style question
All this regards, as I probably should have said in the first place, a twenty line text processing program where there's only one char var and two ints. Curiously enough, those single letter naming conventions are used in K&Rs ANSI C which happens to be our textbook. Personally, I'm all for descriptive names and would settle for, say, 'positionInLine' but my lecturer claimed that 'only I know that c is a char' and 'only I know that the position is from the left' which led to me to asking here for pointers to literature (which btw != 'What naming conventions are best?'). That said, many thanks for all the replies.
[quote=RayS]what do you do when you're juggling 50 chars? c1, c2 ... c50?[/quote]
You've never heard of strings, arrays or data structures in general, have you?
-
RE: Programming style question
I don't know of any authority that forbids using standard naming conventions.
-
Programming style question
I recently had a bit of, erm, heated discussion over variable naming in my programming assignment. I followed the standard naming convention of calling an int 'i', a char 'c', position in line 'pos' etc. but was told to change them to ForLoopCounter, InputCharacter and PositionInLineFromLeftSide respectively (on may say wtf?!). Could anybody please point me to some books on the style of programming where using overly long var names is explicitly discouraged?
TIA,
J.