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
PrBacterio
Jul 19, 2000

Toady posted:

COBOL is not uncommon in the banking industry.
I know that. I also know that people still use MUMPS in the medical or insurance sectors or wherever it was used for. I was only saying that that's a horror imo :ohdear:

Adbot
ADBOT LOVES YOU

SlightlyMadman
Jan 14, 2005

qntm posted:

I just want you to know that I laughed at this. The other guy didn't get it, but I did. Well done.

I don't get it, what the gently caress's a COBOA?

Zombywuf
Mar 29, 2008

SlightlyMadman posted:

I don't get it, what the gently caress's a COBOA?

The mathematical dual to a Boa Constrictor.

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

Zombywuf posted:

The mathematical dual to a Boa Constrictor.

A boa relaxer.

Toady
Jan 12, 2009

qntm posted:

I just want you to know that I laughed at this. The other guy didn't get it, but I did. Well done.

I got it. :)

PrBacterio posted:

I know that. I also know that people still use MUMPS in the medical or insurance sectors or wherever it was used for. I was only saying that that's a horror imo :ohdear:

COBOL today has classes, .NET and JVM support, C bindings, and other useful stuff. I've never had to work with it, but I wonder if it's such a horror to use in practice since so much high-dollar industry still depends on it.

evensevenone
May 12, 2001
Glass is a solid.

crazyfish posted:

While not a specific piece of quotable code, this library (Kernel Mode Linux) horrified me: http://www.yl.is.s.u-tokyo.ac.jp/~tosh/kml/

I know a lot of robotics people using realtime Linux have really big problems with stuff like this, you get stuck either writing very big very complicated kernel modules or else having to implement shared memory which is really tricky. I'm not an OS person so I don't know all the details, I just know it was a big deal at the last place I worked (which was using linux for robotics).

You obviously aren't going to put something like that on your web server anyway, it's for embedded systems and stuff.

Honestly it's probably better than having grad students write kernel modules.

raminasi
Jan 25, 2005

a last drink with no ice
I think I might have posted this before, but I'm going to again because it just bit me in the rear end again and I wouldn't want anyone to miss it.

Here's some neat code from a library I'm using:
code:
/// CORE_DIAGFILE is file name for core_error(..) output.
const char* CORE_DIAGFILE = "Core_Diagnostics";  // global file name 

/// core_error is the method to write Core Library warning or error messages
/** 	Both warnings and errors are written to a file called CORE_DIAGFILE.
 *	But errors are also written on std:cerr (similar to std::perror()).
 * */
// Usage: core_error(message, file_with_error, line_number, err_type)
//   where err_type=0 means WARNING, error_type=0 means ERROR
void core_error(std::string msg, std::string file, int lineno, bool err) {
  std::ofstream outFile(CORE_DIAGFILE, std::ios::app);  // open to append
  if (!outFile) {
     // perror("CORE ERROR: cannot open Core Diagnostics file");
     std::cerr << "CORE ERROR: can't open Core Diagnostics file"<<std::endl;
     std::exit(1); //Note: do not call abort()
  }
  outFile << "CORE " << (err? "ERROR" : "WARNING")
     << " (at " << file << ": " << lineno << "): "
     << msg << std::endl;
  outFile.close();
  if (err) {
     char buf[65];
     // perror((std::string("CORE ERROR") + " (file " + file + ", line "
     //        + core_itoa(lineno,buf) +"):" + msg + "\n").c_str());
     std::cerr << (std::string("CORE ERROR") + " (file " + file + ", line "
             + core_itoa(lineno,buf) +"):" + msg + "\n").c_str();
     std::exit(1); //Note: do not call abort()
  }
}
Internal library error? We should log it somewhere. But where? How about a file! What directory should that file be in? I know, let's use the CURRENT directory! I'm sure any program using this library won't have any trouble at all creating and modifying a file in the current directory, and besides, if there's a problem, we can always rely on trusty old exit(1).

If this doesn't seem bad, think about the fact that it's entirely undocumented.

Good thing I have this source so I can recompile the drat thing - I came dangerously close to being able to spend my time constructively.

Zhentar
Sep 28, 2003

Brilliant Master Genius

Toady posted:

I wonder if it's such a horror to use in practice since so much high-dollar industry still depends on it.

Both MUMPS and COBOL (and many other similar languages) originated in an era where decking out your minicomputer with 256kB of RAM was a significant expense, and you might expect 100+ concurrent users in that. Designing interpreted languages and writing code with them to meet those requirements required a lot of horrors. People think the languages are unequivocally awful because they pretty much only ever see MUMPS/COBOL code that was written 30 years ago or written by people who think it still is 30 years ago, (or worse, have to maintain it), because modern code in those languages written with decent style is really dull.

Hughlander
May 11, 2005

GrumpyDoctor posted:

I think I might have posted this before, but I'm going to again because it just bit me in the rear end again and I wouldn't want anyone to miss it.

Here's some neat code from a library I'm using:

Internal library error? We should log it somewhere. But where? How about a file! What directory should that file be in? I know, let's use the CURRENT directory! I'm sure any program using this library won't have any trouble at all creating and modifying a file in the current directory, and besides, if there's a problem, we can always rely on trusty old exit(1).

If this doesn't seem bad, think about the fact that it's entirely undocumented.

Good thing I have this source so I can recompile the drat thing - I came dangerously close to being able to spend my time constructively.

Am I broken by thinking that the coding horror was the fact that the function wasn't taking const std::string references?

An MMO server process I worked on years ago used 40% of the CPU time in the std::string constructor at one point during it's alpha...

Zombywuf
Mar 29, 2008

Hughlander posted:

Am I broken by thinking that the coding horror was the fact that the function wasn't taking const std::string references?

It was the first thing I noticed, but I kept reading.

raminasi
Jan 25, 2005

a last drink with no ice

Hughlander posted:

Am I broken by thinking that the coding horror was the fact that the function wasn't taking const std::string references?

An MMO server process I worked on years ago used 40% of the CPU time in the std::string constructor at one point during it's alpha...

I was so pissed off by its mere existence that I didn't even see that.

This library is used as a foundational part of a larger library that's advertised as "generally thread-safe." What does that mean? Well, I found out that if you use this foundational library, as opposed to one of three other choices, nothing's thread-safe. A fact which also isn't documented anywhere - I had to email the creators to learn this. I spent so much time making my fancy-pants algorithm parallelizable, too. That was an awkward conversation to have with my boss. "You know how I said the program's algorithm can theoretically use as many cores as you can throw at it? About that..."

Sedro
Dec 31, 2008

Hughlander posted:

Am I broken by thinking that the coding horror was the fact that the function wasn't taking const std::string references?
This part caught my eye
code:
//   where err_type=0 means WARNING, error_type=0 means ERROR

Deep Dish Fuckfest
Sep 6, 2006

Advanced
Computer Touching


Toilet Rascal
It's just really forward-thinking and supports quantum computing.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Zhentar posted:

Both MUMPS and COBOL (and many other similar languages) originated in an era where decking out your minicomputer with 256kB of RAM was a significant expense, and you might expect 100+ concurrent users in that. Designing interpreted languages and writing code with them to meet those requirements required a lot of horrors. People think the languages are unequivocally awful because they pretty much only ever see MUMPS/COBOL code that was written 30 years ago or written by people who think it still is 30 years ago, (or worse, have to maintain it), because modern code in those languages written with decent style is really dull.

I was exposed to some COBOL when I worked at a telco and I think you're right. The 'new' COBOL being produced by the department was totally different; relatively readable, fast (for COBOL), and had all kinds of neat add ons linked in. Then I would look at the legacy code that they were replacing/updating and it was crazy. It was like reading assembler in another alphabet or something; the commands made almost no sense, and every line of 'feature' code had 10 comments on it explaining why this would explode if certain strong typing conventions (that weren't built into the language) weren't followed.

ninjeff
Jan 19, 2004

Sedro posted:

This part caught my eye
code:
//   where err_type=0 means WARNING, error_type=0 means ERROR

No horror here, just treating all warnings as errors. Best practices, really.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
As you may know, Java doesn't support unsigned integers. In trying to find the reasons for this, I ran into this helpful post.

quote:

Let us say we store the age of a person.
code:
unsigned int age;
Now, we have a problem, what if the age of the person is not known? we are comming up with a great plan of using a value '-1', which means 'not known'.

"What if I want to use a signed integer? Then unsigned integers are no good!"

quote:

The requirement is, only if the users age is above 18 they should be allowed to perform some action. If they didnt specify the age, he should be blocked. Let us see, how to write the code...

code:
if(age<18){>
printf("You should be above 18 years to access this feature");
return;
}
On seeing the code, it is common to assume that '-1' is less than '18' if the user didnt specify the age, so he will automatically blocked.

But if you check the C specifications, you can find out that any 'signed' variables will be converted to 'unsigned' automatically if both appear in the same expression.

It means, the value '-1' will be converted into its unsigned counter part i.e. 0xFFFF. This is definitly more greater that '18' thus allowing the user to continue the blocked activity.

This is just a trivial example, but this will make it very difficult to trace the problem in the real life projects. To avoid such potential problems, java removed the 'unsigned' keyword.

"You see, if I use this undocumented trick to avoid making the check for unknown age explicit it can lead to errors! Clearly unsigned integers are the problem here."

quote:

This reason may look weird, but there is not much to achieve introducing 'unsigned' when compared to the drawbacks. The omission of unsigned data types is controversial. There are reasons where unsigned could help. Example, having unsigned will increase the maximum limit for the data type. All other reasons revolve around this reason. But this could be solved by using a bigger numeral. Example, instead of unsigned int, we can use long. similarly for unsigned short, we can use 'int'. Still, 'long' doesnt have any alternative other than 'BigInteger' wrapper classes.

Yes the only reason people want unsigned integers is to increase the upper bound. Cryptography, communication standards, these things don't exist.

tef
May 30, 2004

-> some l-system crap ->
unsigned integers in my java? it is more likely than you think

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.
That guy is an idiot, this is the real reason:

Gosling posted:

For me as a language designer, which I don't really count myself as these days, what "simple" really ended up meaning was could I expect J. Random Developer to hold the spec in his head. That definition says that, for instance, Java isn't -- and in fact a lot of these languages end up with a lot of corner cases, things that nobody really understands. Quiz any C developer about unsigned, and pretty soon you discover that almost no C developers actually understand what goes on with unsigned, what unsigned arithmetic is. Things like that made C complex. The language part of Java is, I think, pretty simple. The libraries you have to look up.

Whether Gosling is right or wrong is debatable (I believe he is right, most rank-and-file developers suck absolute rear end and are unwilling to educate themselves), but I have wished for an unsigned type other than char often enough that I think it was a mistake to omit it.

Vanadium
Jan 8, 2005

quote:

On seeing the code, it is common to assume that '-1' is less than '18' if the user didnt specify the age, so he will automatically blocked.

But if you check the C specifications, you can find out that any 'signed' variables will be converted to 'unsigned' automatically if both appear in the same expression.

:psyduck:

Good loving thing 18 is a signed integer constant then

qntm
Jun 17, 2009

quote:

Let us say for 'unsigned int', java adds the keyword 'uint'. Then,

code:
uint a = 10;
int b = 20;

uint c = a + b // should throw compilation error.
We should instead use,

code:
uint a = 10;
int b = 20;

uint c = a + (uint)b // should work
This will guarantee the strong type checking nature of Java and satisfying the needs of the programmers - A win-win situation for both the Java architects and for the Java Programmers.

sets b to -1, blindly casts it to uint without checking its magnitude, yielding the exact same problem

Opinion Haver
Apr 9, 2007

code:
java.lang.AssertionError: expected: java.util.ArrayList<[2, 5]> but was: java.util.ArrayList<[2, 5]>
Type erasure leads to some pretty annoying error messages.

tef
May 30, 2004

-> some l-system crap ->

qntm posted:

sets b to -1, blindly casts it to uint without checking its magnitude, yielding the exact same problem

numeric towers are hard let's go casting. personally I question why the omission of unsigned but the inclusion of floats :q: given they cause complications similar in nature

nielsm
Jun 1, 2009



tef posted:

numeric towers are hard let's go casting. personally I question why the omission of unsigned but the inclusion of floats :q: given they cause complications similar in nature

But how else could you write financial applications if you don't have a way for decimal numbers!

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

nielsm posted:

But how else could you write financial applications if you don't have a way for decimal numbers!

You bastard

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

TRex EaterofCars posted:

That guy is an idiot, this is the real reason:

Gosling posted:

For me as a language designer, which I don't really count myself as these days, what "simple" really ended up meaning was could I expect J. Random Developer to hold the spec in his head. That definition says that, for instance, Java isn't -- and in fact a lot of these languages end up with a lot of corner cases, things that nobody really understands. Quiz any C developer about unsigned, and pretty soon you discover that almost no C developers actually understand what goes on with unsigned, what unsigned arithmetic is. Things like that made C complex. The language part of Java is, I think, pretty simple. The libraries you have to look up.

Whether Gosling is right or wrong is debatable (I believe he is right, most rank-and-file developers suck absolute rear end and are unwilling to educate themselves), but I have wished for an unsigned type other than char often enough that I think it was a mistake to omit it.

Personally I think calling c "complicated" because of unsigned ints is a horror too. Even if that was the case I don't buy his argument - if signed were default then those stupid developers (opps, I mean J. Random Developer) could continue blissfully unaware, while people who actually know what they're doing wouldn't have to start doing bit hacking in order to fulfill misguided efforts to keep Java "simple."

Besides, unsigned arithmetic is more straightforward to understand than two's compliment arithmetic.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

HappyHippo posted:

Besides, unsigned arithmetic is more straightforward to understand than two's compliment arithmetic.

Exactly!

TasteMyHouse
Dec 21, 2006
two's compliment arithmetic is the same as unsigned arithmetic. What are you talking about?

Impotence
Nov 8, 2010
Lipstick Apathy

nielsm posted:

But how else could you write financial applications if you don't have a way for decimal numbers!

I've seen code where
php:
<?
$price1 = mysql_result($dbprice1);
$price2 = mysql_result($dbprice2);

$price = $price1.'.'.$price2;
?>
oh, and the price fields in the database are varchars

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


Biowarfare posted:

oh, and the price fields in the database are varchars

How else are we supposed to support multiple currencies?!

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

TasteMyHouse posted:

two's compliment arithmetic is the same as unsigned arithmetic. What are you talking about?

In that you undertake the same operations, yes, but the encoding of negative numbers is not clear to the uninitiated.

Hughlander
May 11, 2005

Doc Hawkins posted:

How else are we supposed to support multiple currencies?!

Specify all prices in Buttcoins and then convert to your dated paper currencies!

raminasi
Jan 25, 2005

a last drink with no ice
Just found this gem of a response on stackoverflow to a question about, well, stack overflows:

quote:

I found a workaround in VC. Basically I increase the stack size to 100 000 000, don't know if it allows this limit for my application (not dll or library) within VC. The function inside the exe file is recursive but I don't let it go on until completion. I can then call this exe file as many times as I want from another program and dump the intermediate results to disk and continue until the desired result is obained. It's not the fastest way to run the code but at least the results are good and no stack overflows.
The problem this is designed to address is something involving passing images around on the stack or something. It kind of shut my brain down so I'm not really sure.

Zamujasa
Oct 27, 2010



Bread Liar

Biowarfare posted:

I've seen code where
php:
<?
$price1 = mysql_result($dbprice1);
$price2 = mysql_result($dbprice2);

$price = $price1.'.'.$price2;
?>
oh, and the price fields in the database are varchars

That'll throw an error too because mysql_result requires two parameters, one for the resource and one for the row. :downs:


Hammerite posted:

That can be used to find out what's stored in the variable named $name. As in, if you have a variable $name and you want to know what's in the variable whose name is the value stored in $name then you can use $$name. It is ridiculous and I have no idea what you would use it for that isn't stupid.

As far as I know you can't find out what the name of a variable is by any similar means, it doesn't really make sense because a given value could be pointed to by more than one variable (or no variable at all). I just re-read the quoted post and realised I don't really understand what the guy is talking about. But I do know it's stupid.

There actually is a use I run into every now and then, but it's pretty rare. It usually doesn't hurt, though.

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

Zamujasa posted:

That'll throw an error too because mysql_result requires two parameters, one for the resource and one for the row. :downs:

In older (and possibly modern, gently caress if I know) versions of PHP you could implicitly refer to the connection like that.

TasteMyHouse
Dec 21, 2006
code:
typedef int LONG;
:(

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Zamujasa posted:

There actually is a use I run into every now and then, but it's pretty rare. It usually doesn't hurt, though.

Do go on.

NotShadowStar
Sep 20, 2000

TRex EaterofCars posted:

In older (and possibly modern, gently caress if I know) versions of PHP you could implicitly refer to the connection like that.

Yep, you can still do that. mysql_* has an implicit, invisible connection if you don't specify a connection handler on mysql_connect. Ramsus Lerdorf, stealing a bunch of poo poo from Perl but didn't really understand what Perl was doing.

Ursine Catastrophe
Nov 9, 2009

It's a lovely morning in the void and you are a horrible lady-in-waiting.



don't ask how i know

Dinosaur Gum

NotShadowStar posted:

Yep, you can still do that. mysql_* has an implicit, invisible connection if you don't specify a connection handler on mysql_connect. Ramsus Lerdorf, stealing a bunch of poo poo from Perl but didn't really understand what Perl was doing.

I think that's the definition of 90% of PHP, Perl, and Javascript tutorials on the internet.

HURR PERL USES COMMA FOR CONCATENATION WHEN USING PRINT HURR

Optimus Prime Ribs
Jul 25, 2007

NotShadowStar posted:

Yep, you can still do that. mysql_* has an implicit, invisible connection if you don't specify a connection handler on mysql_connect. Ramsus Lerdorf, stealing a bunch of poo poo from Perl but didn't really understand what Perl was doing.

I have to wonder: is Ramsus just a gigantic meat-head or is PHP an elaborate troll?

Adbot
ADBOT LOVES YOU

Bhaal
Jul 13, 2001
I ain't going down alone
Dr. Infant, MD
I answered that question for myself years ago when discovering PHP's variables are case sensitive whereas functions are not.

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