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
Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...
Something I found in our codebase today, slightly paraphrased:
code:
FILE *pFile = 0;
int someValueToBeLogged = ...;

...

void logStuff(const char *const message)
{
    char buffer[1024];
    if (pFile) {
        snprintf(buffer, 1024, "%s: %d", message, someValueToBeLogged);
        fprintf(pFile, buffer);
    }
}
Props for using snprintf instead of sprintf, but still... :bang:

Adbot
ADBOT LOVES YOU

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Plorkyeran posted:

When possible, just find other stuff to work.

I wasted the entire day yesterday because ClearCase decided to stop working on my machine. It got gradually worse, to the point that I could not even open a new terminal window or log in remotely.
Only good thing is that I got a workstation upgrade out of it.

We're planning to transition to Git Real Soon Now. I can't decide whether to wish for it or be terrified about it. I'm sure I'll have plenty of horrors for this thread when it happens.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

JawnV6 posted:

Typing is typically on y'all's critical path?

No, but spending five minutes watching somebody do a task I could do in as many seconds, is.

My own nemeses are people who don't know what a path name is. You can type emacs butt/fart/dick.txt, you don't have to loving cd there first.:argh:

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...
Just today I was notified about a crash by the people porting our elder-gods-created codebase to GCC 4.8 [1]. The mechanism for running constructors for static objects has changed, and it conflicts with a nasty hack we are using in a few hundred shared libraries [2]. Time to update the comment documenting this hack, again. [3]

[1] Currently on 4.1 since we're still using RHEL 5. Our customers are very, very conservative and need serious arm-twisting to agree to OS updates.
[2] Luckily the affected code is mostly auto-generated.
[3] That comment starts with a quote from Canto III of Dante's Inferno, and goes downhill from there.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Hammerite posted:

Are there misspellings in your code base? It is statisitically likely.

Most people working on our code are not native English speakers (me neither). So we get grammatical errors as a bonus.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Suspicious Dish posted:

The second problem is that traditional regular expression languages don't have any inherent composability. There's no way to say delimiter = '-' | ' ' | ''; and then use (\d{3})? $delimiter (\d{3}) $delimiter (\d{4}). Because of this, you also see a lot of clever trickery in common regex syntax to group some parts together, and a lot of "code golf" that makes it dense and unreadable. Trying to understand a regular expression is like reverse engineering assembly code, almost.

Lex is 39 years old. How much more traditional can you get?

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

eithedog posted:

City: Munster, Country: Germany (unless there's Munster in Germany as well)?

http://de.wikipedia.org/wiki/Munster
http://de.wikipedia.org/wiki/Münster

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Subjunctive posted:

When it starts to be a tree-with-exceptions ("let's share this one case to save space...") is when you start taking nips out of your bourbon flask during compiles and randomly keying cars in the parking lot.

It's called a DAG. :colbert:

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Volmarias posted:

Outside of Unix style file permissions, when would you realistically use octal?

I recently had a use for octal constants, when defining the settings for a device register with two 3-bit fields. But that's perhaps the second time in a 20+ year career that I've found them useful.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Internet Janitor posted:

code:
ij@red$ gforth
Gforth 0.7.0, Copyright (C) 1995-2008 Free Software Foundation, Inc.
Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
Type `bye' to exit

123 456 + . 579  ok
$BEEF . 48879  ok
071 . 71  ok
078 077 - . 1  ok
hex 123 456 + decimal . 1401  ok
32 base ! abcd decimal . 339341  ok

Yeah, but in forth you can also do things like
code:
: 4 5 ;
3 4 + . 8 ok

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Athas posted:

APL. ⌈ is the maximum function, ⌊ is the minimum. Similarly, ⌽ is reversal along the last axis, while ⊖ is along the first axis, and, of course, ⍉ reverses all axes.

The rabbit hole goes all the way, too: ⍎ is the "eval" function. Conceptually, it is "turn text into APL value". What, then, is the behaviour of the obviously inverse symbol, ⍕? Well, it is the pretty-printer, of course, as that turns APL values into text! Oh, and the function for multiplying by π is of course ○.

Richard Stallman posted:

Rho, rho, rho of X
Always equals 1.
Rho is dimension; rho rho rank.
APL is fun!
And that is the entire extent of my APL knowledge.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

down with slavery posted:

Looks like an inverted chart of "what programming language should I choose first" answers
No, that's this one:

:rock:Lisp:rock:

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...
Something I noticed today (typed in from memory so probably not 100% accurate):
code:
INT32 value = /* read from HW register which has 31 significant bits */;
INT32 value1 = (value << 1) >> 1;
INT32 value2 = (value & 0x40000000) ? (value | 0x80000000) : (value & 0x7fffffff);
return (value1 == value2) ? value1 : value2;
:eng99:

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Jewel posted:

Isn't that whole thing just
code:
INT32 value = /* read from HW register which has 31 significant bits */;
return (value & 0x40000000) ? (value | 0x80000000) : (value & 0x7fffffff);
Or did you mistype it?

It's supposed to be a sign extension from 31 to 32 bits, yes. But obviously the author didn't trust that the simple way to do it (shift left, then right) would work. As for the thought process (if any) that led to doing it twice, and to the utterly insane last expression - I have no idea.

The fun bit? There are probably some chips in your smartphone, and your car, that were tested using the software containing this beauty.:unsmigghh:

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Spatial posted:

Our compile times are in excess of 4 minutes right now.

Try a couple of hours. For an incremental build. :shepicide:
Want to run regression tests? Start the build when you leave, and hope the server that schedules the hardware for online tests doesn't die overnight, as it did yesterday.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Suspicious Dish posted:

The best documentation is:

code:
/**
 * ThingInfo getInfoAboutThing(Thing thing)
 * @thing: A Thing to get info about.
 * 
 * Get info about a Thing @thing.
 *
 * Returns: A ThingInfo that contains the info for Thing @thing.
 */

You'd love working on our codebase. You wouldn't.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Hughlander posted:

The last time I was paid to write C the compiler wouldn't complain about, but would ignore any part of an identifier after 8 letters.

ratbert90 posted:

Wow, that compiler must have been horribly lovely.

In 1985 or so, all C compilers were that lovely.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Flobbster posted:

OS X 10.10 is only theoretical and if anyone ever actually figures out a way to install it, they would be computing with infinite algorithmic efficiency turn into lizards.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Steve French posted:

Ugh it's foo, bar, baz, *then* quux I am surrounded by amateurs

HEATHENS!

foo, bar, baz, zip, qux, quux, quuux, ...

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...
Since this is the coding horrors thread, I'm sure most of you know about Duff's device already.

But have you seen Stroustrup's device (PDF)?
C++ code:
typedef decltype(x) T;
static std::unordered map<T,size t> jump_targets;

switch (size t& jump_to = jump_targets[x]) {

default:
  if (P1(x)) {
    if (P2 (x)) {
      if (P4(x)) { jump_to = 4; case 4: s4;} else
      if (P5(x)) { jump_to = 5; case 5: s5;}
      jump_to = 2; case 2: s2;
    } else
    if (P3(x)) {
      if (P6(x)) { jump_to = 6; case 6: s6;} else
      if (P7(x)) { jump_to = 7; case 7: s7;}
      jump_to = 3; case 3: s3;
    }
    jump_to = 1; case 1: s1;
  } else { jump_to = 0; case 0: ; }
}

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

baka kaba posted:

Don't be silly, it clearly gets tomorrow's date today, when today is tomorrow and tomorrow is today

Is your name Arnie?

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Voted Worst Mom posted:

Let me personally assure you that gcc has never and will never accept that nonconformant code without error.

Let me quote from the original, pre-standard, Annotated C++ Reference Manual (Ellis & Stroustrup):

quote:

6.5.3 The for Statement
[...]
If the for-init-statement is a declaration, the scope of the names declared extends to the end of the block enclosing the for-statement.

It goes on to comment:

quote:

[...] the same name cannot be used to control two for loops in the same scope.
code:
for (int i = 0; i<100; i++) {
  // ...
}
for (int i = 0; i<100; i++) { // error: `i' defined twice
  // ...
}

Every C++ compiler behaved this way before the standard came out.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Joda posted:

In what way is this a "a magic pseudo-variable?"

E: In what way is it even a variable?

Assignment to this used to be the way to do dynamic object allocation, before Stroustrup came up with new. This is the main reason why this is a pointer (it should have been a reference all along).

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

HappyHippo posted:

Seriously. I mean it's great in many ways, and it's very powerful, but man there are some dumb choices. Another good one: even though LaTeX has a standard convention for commands with arguments (the arguments are in { } braces following the command, eg "\frac{a}{b}") if you want to get an integral (or summation) sign with limits you need to use subscript and superscript. "\int" is the integral sign, "\int_a^b" is an integral from a to b. Why would you do that? It's not like it's taking the integral symbol and putting those superscripts/subscripts, the engine treats this as a special case. I always define my own sensible command so I can type "\intlimits{equation}{lower limit}{upper limit}" like it should have been in the first place.

The "\int_a^b" notation is inherited from base TeX, while "\frac" is LaTeX specific.
Also, "\int_a^b" is not actually a special case; in an inline formula, the limits will be typeset as sub/superscripts, it's only displayed formulas that are treated specially.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Plorkyeran posted:

LaTeX is pretty much nothing but a giant mass of historical warts.

Also TeX itself is not really a programming language; it's almost all macro expansion and text substitution, with a few special horrors like \expandafter thrown in.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Spatial posted:

Someone's got a vfork() up their rear end in a top hat

:nms:http://i.imgur.com/JV5cpXs.jpg:nms:
(from the Schadenfreude thread.)

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Xenoveritas posted:

The amusing thing about this "do the right thing" discussion is that Unix is the classic example of the Worse is Better design philosophy, and fork() sounds like a great example. It's a simple API and a simple concept. Rather than doing the right thing, it goes for "simple" and simply doesn't worry about the problems it causes. The caller can deal with those on their own.

fork() actually is older than Unix (it came from a system called GENIE).

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Subjunctive posted:

Get off the main thread. Then tell me where to send my 5-figure consulting invoice.

gently caress every OS with a single-threaded event loop.
yes I'm still bitter that BeOS didn't go anywhere

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

ExcessBLarg! posted:

However, "function-like" macros can generate all sorts of expressions that wouldn't be valid [...]

I had reason to curse function macros just yesterday. Defined a class something like this:
code:

class Butt {
  int major, minor;

public:
  Butt(int major_, int minor_) : major(major_), minor(minor_) {}

  // bunch of other methods
};
Didn't compile, because sys/types.h was included somewhere down the line, and that #defines macros "major()" and "minor()". :shepicide:

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

IT BEGINS posted:

list]
[*] A co-worker refuses to stop putting spaces between function names parenthesis, despite being the only developer who does so. When asked why, his response is "that's how they do it in C".
[/list]

Am I crazy? Is this crazy?

No; yes. Only idiots put spaces between a function name and parenthesis in C/C++, and only idiots put no space between a keyword (if/for/while/switch/...) and a parenthesis.
But the real morons are those who put blanks behind an open paren, or before an closing one.

When I see something like this, I know it's not going to be a good day:
code:
  if( obviousBoolean == true )
    {
      ...
    }

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Firstkind posted:



This is a loving picture of programming languages up to 2001. I have taken classes for years of my life and know FOUR. C,C++,C# and Java.

You don't know four programming languages. You know four dialects of one. OK, you could argue that object orientation is a fairly major feature, so C could be considered to be more of an ancestor to the others, but it's still all imperative.

But don't worry too much about that. You'll probably never encounter a job that requires something fundamentally different, like a functional (Lisp, Haskell etc.) or—God forbid—logical programming language. As for all those toy scripting languages like Ruby, Python or whatever the current fashion is, as you become more experienced you should be able to pick those up as you go.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Wardende posted:

You can write procedural or functional code in all of those languages.

Yes. You can also do logical programming using C++ template metaprograms, but that doesn't mean it's a good language for doing that.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Hughlander posted:

http://thedailywtf.com/articles/What_Is_Truth_0x3f_ posted:

enum Bool
{
True,
False,
FileNotFound
};

Amateurs.

IEEE 1164 posted:

The primary data type std_ulogic (standard unresolved logic) consists of nine character literals in the following order:

Character Value
'U' uninitialized
'X' strong drive, unknown logic value
'0' strong drive, logic zero
'1' strong drive, logic one
'Z' high impedance
'W' weak drive, unknown logic value
'L' weak drive, logic zero
'H' weak drive, logic one
'-' don't care

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

xzzy posted:

Python. :smug:
Occam. :agesilaus:

Anybody remember the transputer?

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

fritz posted:

Those that belong to the emperor
Embalmed ones
Those that are trained
Suckling pigs
Mermaids (or Sirens)
Fabulous ones
Stray dogs
Those that are included in this classification
Those that tremble as if they were mad
Innumerable ones
Those drawn with a very fine camel hair brush
Et cetera
Those that have just broken the flower vase
Those that, at a distance, resemble flies

That looks like Cyc
PS: your tags are leaking.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

fritz posted:

How does this hypothesis explain having 8 bit bytes but 7 bit characters?

7 bit plus parity.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Suspicious Dish posted:

I don't think you understand how difficult what a piece of poo poo ICCCM compliance is in practice.

quote:

In summary, ICCCM is a technological disaster: a toxic waste dump of broken protocols, backward compatibility nightmares, complex nonsolutions to obsolete nonproblems, a twisted mass of scabs and scar tissue intended to cover up the moral and intellectual depravity of the industry's standard naked emperor.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

TheresaJayne posted:

I think i have seen a lot of this, Its where they get an error once, and find the solution there and apply that solution as boilerplate everywhere.

Or more likely, paste some codes they got from the internet.
Otherwise known as Cargo Cult programming.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

QuarkJets posted:

i write all of my code to check the current date and if the current date is before the code's last revision date then i start formatting the nearest disk

Bernard S. Greenberg came up with an interesting strategy to prevent that happening in Multics.

Adbot
ADBOT LOVES YOU

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

ChickenWing posted:

variable goes on the left aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa :psyboom:

Something like this is legal in C :pervert:
code:
int fart[42];
23[fart] = butt;

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