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...

HardDisk posted:

:stare:

What's happening there?

C array notation is mostly syntactic sugar. The following two expressions are defined to have identical meanings:
code:
x[y]
*(x+y)
Since addition is commutative, so is array element access.

Adbot
ADBOT LOVES YOU

Zopotantor
Feb 24, 2013

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

nielsm posted:

fooficate(x * -invert)

That does something different.

Zopotantor
Feb 24, 2013

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

Biowarfare posted:

Copy of terraria (2) real.cs.bak

:airquote:version control:airquote:

Zopotantor
Feb 24, 2013

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

loinburger posted:

He probably has sexual fantasies about his mother, but then again, who doesn't.

s/his/your/

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...
APL, eh?

quote:

Rho, rho, rho of X
Always equals one;
Rho is dimension, rho rho rank,
APL is fun!

Zopotantor
Feb 24, 2013

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

ExcessBLarg! posted:

I'm guilty of using parentheses with "function-like" keywords like sizeof. It's a little weird, although not entirely uncommon to smash control flow keywords (if, for, while) against the condition parenthesis. Common C style guides (KNF/style(9) and Linux kernel) do include space there, I think in part to distinguish them from function calls, but also because those keywords also introduce expression blocks anyways.

If you merely put an if/for/while against a parenthesis, I will frown at your code and move on. If you do this, however, I will curse you and your descendants to the seventh generation:
code:
if( butt ) {...}
for( fart=... ) {...}
while( dick ) {...}

Zopotantor
Feb 24, 2013

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

Xarn posted:

Yeah, my work is at C++03 in name of portability...

For me it's backwards compatibility. So far RedHat refuses to guarantee that the C++11 ABI in RHEL 7 will remain stable. :argh:

Zopotantor
Feb 24, 2013

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

Ant Attack was pretty rad.

Zopotantor
Feb 24, 2013

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

Pavlov posted:

Pff, are you saying you don't browse by just curl-ing the pagesource?

Look at this poser. Telnet to port 80 and type in your GET request.

Zopotantor
Feb 24, 2013

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

Hammerite posted:

I still don't understand why you'd use #define rather than using const variables for the constants and functions for the macros-with-arguments.

One reason for using macros in preference to functions is that when you use __FILE__ and __LINE__ inside a macro, they refer to the location where the macro is used. This is really handy for tracking down bugs using a log of HW register reads & writes.
To do something similar with a function, you'd have to pass __FILE__ & __LINE__ to every invocation.

Zopotantor
Feb 24, 2013

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

Sounds suspiciously like Ken Thompson's scenario (Reflections on Trusting Trust). Does anybody know where or when this supposedly happened?

Zopotantor
Feb 24, 2013

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

Soricidus posted:

There's no point modifying the compiler on a single computer unless it's the build server that produces os updates, unless we're talking some os that delivers updates only in source form, which seems kinda unlikely even in the 1980s?

Tip: If you can get your hands on Thomas J. Ryan's The Adolescence of P-1, do so. It's long out of print, the premise is ridiculous, but it's a neat read. It also has the greatest (IMHO) last line in literary history.

Wikipedia. Warning: Spoilers the whole thing, including the final gag.

Zopotantor
Feb 24, 2013

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

xzzy posted:

listserv is the coding horror, I've never liked the idea of sending commands by sending an email to a special address. Email is for messages, not controlling software. :colbert:

Ftpmail was a godsend when I was behind a corporate firewall, before SOCKS came around.

Zopotantor
Feb 24, 2013

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

Karate Bastard posted:

This is a good time to post this:

https://www.usenix.org/system/files/1311_05-08_mickens.pdf

Contains phrases like "I had the modest goal of translating a file read into a network operation", and "I HAVE NO TOOLS BECAUSE I’VE DESTROYED MY TOOLS WITH MY TOOLS".

Horrors abound. Merry Christmas you guys :)

This guy knows. However:

quote:

THERE IS NO HARDWARE ARCHITECTURE THAT IS ALIGNED ON 7.
I have actually had to work on a system that had 7-byte aligned memory. The hardware guys had forgot to account for ECC in their design, and they "solved" the problem by using 1 byte out of every 8 for the ECC bits. The ECC bits were hidden and had no address.

Zopotantor
Feb 24, 2013

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

ratbert90 posted:

Strewn about the project I inherited are C files, in these C files are bullshit like this:

C code:

/*
 * Enables and starts the Blue Alert daemon.
 */

#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main(int argc, char *argv[]) {
	/* Release cwd */
	chdir("/");

	/* Close fds and sockets */
	int fd;
	for(fd=0; fd<sysconf(_SC_OPEN_MAX); fd++) close(fd);

	/* Become process group leader */
	setsid();

	setuid(0);

	system("/sbin/chkconfig PROGRAM on >/dev/null 2>&1");
	system("/etc/init.d/PROGRAM start >/dev/null 2>&1");
}				

what in the gently caress? WHAT IN THE GOD drat gently caress?

Edit* I copy and pasted the whole c file.

Seriously, apart from the brace placement and missing error checks this is perfectly clear and even nicely documented. Every one of these statements has a purpose. You just seem to lack the information needed to understand why someone would want something like it.

As far as I can tell, this is intended to start a daemon process, avoiding several pitfalls caused by various warts of UNIX-like systems:
- The chdir avoids leaving a reference to the original working directory.
- Closing all file descriptors (portably, even) similarly avoids leaving references to other files, and prevents information to leak to the started process.
- setsid prevents signals to be propagated from the parent's process group to the new daemon (think Ctrl-C).
- I think the setuid is to make the process run as the real root user; I assume that the program will have its setuid bit set to make this work.
Finally, chkconfig is a utility that installs a symbolic link to a startup script to be run at boot time, and the last statement runs that script explicitly so the daemon starts up immediately.

Zopotantor
Feb 24, 2013

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

Dr. Stab posted:

Yeah, I don't really get it. If anything single point of return takes more effort to trace.

Nah, just do this:
code:
...
if (butt) {
  fart = smell;
  goto rear end;
}
... tons of code ...

rear end: return fart;

Zopotantor
Feb 24, 2013

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

Shinku ABOOKEN posted:

Name and shame.

The UK also has insane libel laws, so better not.

Zopotantor
Feb 24, 2013

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

YeOldeButchere posted:

That's kinda similar to the way dynamically allocated arrays are implemented in most C++ compilers, really. Get a block of memory slightly larger than what you need, stick the number of elements in the array at the beginning, and return a pointer to the first array element to the user.

cfront on HP-UX used to do it differently. It stored the array size in a separately allocated block of memory, causing a slow memory leak when you deleted an array using the non-array delete operator. (This was ~25 years ago, I may not remember the details correctly.)

Zopotantor
Feb 24, 2013

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

Suspicious Dish posted:

C++ has order-of-magnitude-longer compilation times and isn't easily bindable to other languages because of name mangling. Qt, the competitive toolkit, requires a custom preprocessor to even make C++ usable for their use case.

Also, C++ is really, really lovely for creating libraries that need to be separately compiled, if you also want clients of the library to derive from the interface classes. This was one of the main problems with the BeOS API (which was very nice otherwise), "solved" by stuffing the interfaces full of dummy member variables and virtual functions.

Zopotantor
Feb 24, 2013

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

Munkeymon posted:

Cuntpunch said he started out of nowhere, which points to it not being that insipid habit.

Perhaps he read the reader letter in a recent CACM which advertised this as a good idea. it isn't when the compiler doesn't enforce it and the next merge scrambles your oh so carefully maintained comments

Zopotantor
Feb 24, 2013

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

JawnV6 posted:

Neither does "wait for the TX interrupt bit to be unset" but that generally trips the "no empty loops" condition. But I'm pretty sure breaking that out into
code:
while(true) {
  if(TXREG & TXINT == 0) {
    break;
  }
}
is taking a dump on readability.

That would fail code review at my workplace because it's missing a timeout check for when the hardware breaks and the bit remains stuck.

Zopotantor
Feb 24, 2013

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

Drangus McCafferty posted:

How about explicit message passing?

foo.__send__(:==, bar)

That's still not primitive enough, since it also returns something. Use actors or continuations.
Don't judge me, I read some of the old lambda papers a week ago.

Zopotantor
Feb 24, 2013

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

quiggy posted:

Every language is just syntactic sugar for subleq.

mov is Turing complete (PDF)

quote:

Thus, while it has been known for quite some time that x86 has far too many instructions, we can now contribute the novel result that it also has far too many registers.
:science:

Zopotantor
Feb 24, 2013

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

weird posted:

are there any languages other than lisp that do

Does Forth, technically.

Zopotantor
Feb 24, 2013

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

HappyHippo posted:

Because it's probably the most byzantine language ever created.

Verity Stob posted:

Whereas smaller computer languages have features designed into them, C++ is unusual in having a whole swathe of functionality discovered, like a tract of 19th century Africa.
Case in point: template metaprogramming used to be a curiosity (hey! the compiler can compute primes!), and then the C++ community decided they liked it and used it for ever more bizarre constructions.

Zopotantor
Feb 24, 2013

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

fleshweasel posted:

Swift is great and actually useful if you happen to be doing apple stuff.

Oh hi, language which treats the first parameter of a function call differently than the rest.
Just kidding, I like Swift. But no language is perfect.

Zopotantor
Feb 24, 2013

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

Carbon dioxide posted:

We're gonna run out of helium to cool the MRIs before this shitstorm is fixed.

Good news!

Zopotantor
Feb 24, 2013

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

hackbunny posted:

Coding horrors: Strong typing means pressing your keyboard keys very hard

Zopotantor
Feb 24, 2013

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

rarbatrol posted:

Recently a guy at work accidentally (nobody has any idea how) deleted 1/2 of our code base in one commit with a message like "lol idk why this is happening this is weird" and then rolled it back with the next commit.

Maybe... don't commit that poo poo in the first place?

hosed up his worktree and didn't know how to fix it?

Zopotantor
Feb 24, 2013

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

TooMuchAbstraction posted:

The real horror is that you forgot that quux comes after baz. :colbert:

Heretics! It's "foo, bar, baz, zip, qux, quux, quuux, ..."

Zopotantor
Feb 24, 2013

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

TooMuchAbstraction posted:

Something like a decade ago I watched a talk given by a programmer who got carpal tunnel syndrome but still needed to be able to code. During what little "real typing" time he had each day, he hacked one of the more modder-friendly voice recognition tools to add a bunch of special "words" that corresponded to actions and symbols that are common in programming but not in normal text. Like, "zzp" mean { and "pzz" meant }, and he had words for un/indenting, creating a ( ) and moving to the interior of the parens, etc.

https://www.youtube.com/watch?v=lQ91SVKryYU

Zopotantor
Feb 24, 2013

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

QuarkJets posted:

Looked around online and apparently this is a common problem with Matlab-compiled standalone executables, there is no solution and you just have to deal with it

Hey, at least you're not using it to design ASICs. That chip has more revisions than any of our other ones, and that includes the one where the main PLL had its output shorted to ground...

Zopotantor
Feb 24, 2013

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

Jethro posted:

The vast majority of the time users will enter data into a spreadsheet as a string representation, but then they want it to be treated as data, not a string. So it makes perfect sense to take strings that look like numbers, dates, or times and automatically convert them to numbers, dates, or times respectively.

An alarming number of scientific papers contain Excel errors.

Zopotantor
Feb 24, 2013

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

hyphz posted:

So, have you heard of the ZX Spectrum Next? It's a Euro-UK-ish project to restore the ZX Spectrum, one of the classic older games machines, using an FPGA-based board - but with a faster clock speed and a bunch of extra features. One of the extra features is hardware sprites.

The ZX Next is driven by a Zilog Z80 (or rather an FPGA Z80 that can run faster than the original did). To set up the hardware sprites, you use the Z80s port output opcodes to crank out 255 bytes of palletised color data to a particular port. The Z80 has several port output opcodes. You can output a value to a specified port, you can output to a port you specify in one of the 8-bit registers (C), and there's even a built-in OTIR instruction that does a self-contained loop, automatically passing through a section of memory and outputting each byte as it goes. Sweet, right?

Well, no. It's insane. See, the twist is that the Z80s port select lines actually carry 16 bits, not 8. So the port number you specify, via register C or in the instruction, only goes on the lower 8.

What goes on the upper 8? Well, if you output to a specified port, then the value you are outputting goes on those register select lines. So if you try to output $20 to port $75 using that method, it actually outputs to port $2075. Wonderful.

How about that nice looped version? That's even sillier. It puts the goddamn loop counter on. So instead of outputting byte by byte on port $75, it outputs on $0075, $0175, $0275, $0375 yadda yadda yadda.

Needless to say, this makes all those nice instructions into total chocolate fireguards on any system like the Next that actually uses the 16-bit port addresses. I really wonder if it was ever useful.

IIRC the Spectrum's ROM (at least the extended Interface 1 version) actually used the 16-bit feature.

Zopotantor
Feb 24, 2013

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

This seems to be type correct, I see no problem.

Zopotantor
Feb 24, 2013

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

Yes what?
Yes, sir!

Sorry, old Prolog joke.

Zopotantor
Feb 24, 2013

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

my girlfriend is Legos posted:

I'm writing some front end stuff for a partner of ours and found a bit of a peculiarity about their API. After first trying it out and fetching some data, on a hunch I decided to check the UNIX timestamp it returned. Sure enough, it was off by two hours. Their server is located in CET, so I figured they probably accidentally used DateTime.Now instead of DateTime.UtcNow when generating the timestamp. Fair enough, I guess that's an understandable mistake. I asked one of their developers if he knew about it, and turns out that nope, it was a very deliberate decision to return an integer named 'Time' that looks exactly like a UNIX timestamp but is secretly the server's local time minus 1/1 1970 00:00 UTC and thus doesn't conform to standard, because "in 99% of cases you want local time".

What do they on the switch to/from daylight savings time?

Zopotantor
Feb 24, 2013

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

Ranzear posted:

I was more responding to this part of your gripes, not the goto part. If you extract the methods of a classical object into static functions (and pass the appropriate object back into it) you can do procedural or even functional programming on fairly discrete data. There's no real need to return anything because you're just passing a big ol' chunk of state around.
It sounds as if you are emulating the way we used to emulate object-oriented programming in non-OO languages, in an OO language.

Zopotantor
Feb 24, 2013

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

Jabor posted:

Suffice to say that no, cloning the same remote into multiple different local repositories is not common git practice at all.

It is if you're working on multiple branches, and switching branches entails a 2+ hour recompile... :eng99:

Adbot
ADBOT LOVES YOU

Zopotantor
Feb 24, 2013

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

Linear Zoetrope posted:

I assume the branch switch changes some fundamental files everything else references so it can't reuse object/intermediate files from the other branch?

Interface definitions & headers, yeah. We have gotten better lately, there are actually people working on improving build times now.

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