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
FlapYoJacks
Feb 12, 2009

Carbon dioxide posted:

You misspelled MongoDB.

I hear it's webscale

Adbot
ADBOT LOVES YOU

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today

ratbert90 posted:

I hear it's webscale
webscale: a difficult-to-remove residue that accumulates on a project that process large amounts of HTTP.

boo_radley
Dec 30, 2005

Politeness costs nothing

Ralith posted:

webscale: a difficult-to-remove residue that accumulates on a project that process large amounts of HTTP.

You just need some webtenders friend and that web scale will come right off

Absurd Alhazred
Mar 27, 2010

by Athanatos

Ralith posted:

webscale: a difficult-to-remove residue that accumulates on a project that process large amounts of HTTP.

The medical term is diPHPtheria.

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!
"Names must be descriptive", indeed.
code:
self.configuration = {
  ' Thi': self.read_name,
  '  Re': self.read_keyvalue,
  '  Ru': self.read_keyvalue,
  '  Ru': self.read_keyvalue,
  '  To': self.read_keyvalue,
  ' Tha': self.read_name,
  '  To': self.read_keyvalue,
  '  Ap': self.read_keyvalue,
  '  Sl': self.read_keyvalue,
  '  La': self.read_keyvalue,
  '  To': self.read_keyvalue,
  '  Co': self.read_keyvalue,
}

steckles
Jan 14, 2006

There is a series of inventory control machines that are used by some of our clients. I've been tasked with evaluating how difficult it would be to add support for them to our software. I spent a few hours reading docs, chatting with the company's implementation people, and playing with a simulator they provided. When I present my findings at the next dev meeting, I had this exchange with one of the other programmers:

Me: ...and you talk to the devices via ODBC.
Him: Isn't ODBC on its way out?
Me: I... that's debatable and not relevant.
Him: Shouldn't we use an API instead?
Me: Um... you don't... this isn't... I...
Him: I just think we should use something modern, like an API.
Me: ...

Sometime our sales guys say weird cargo cult stuff like this, but this guy has been programming for almost 20 years.

Happy Thread
Jul 10, 2005

by Fluffdaddy
Plaster Town Cop
Student code doesn't count as a horror, but circumstances forced me to fix some of it myself, so let's all dive in. In a large class with animation based projects, one student turned in a remake of the phone game Crossy Road, where you jump around cars like in Frogger. They did a good job:



The course website showcases finished projects. On it I noticed that theirs was the slowest to load for some reason, making it impossible to flip through all the submissions without Crossy Road locking the index page up, so I ran Chrome's profiler on it. It lit up all their calls to create pretty much anything in the game. It was slow to create a row of grass, or the player, or any of the other simple primitive shapes in the scene.

I looked deeper and found that every ground strip, every car, the player, even the scene itself all extended a base class that called this code:

code:
constructor(context) {
		super(context);
		this.submit_shapes(context, getShapes())
...
Here, submit_shapes is a function we provided them. It's good for sending data over to the graphics card (a relatively slow communication line) -- data such as where the points of a cube or of a car are located in 3D. The graphics card will keep those points in a small buffer locally instead of you needing to re-send the same thing over and over every time such a common shape needs to be drawn. To draw each shape's triangles, the GPU just manipulates its local buffer instead of re-inventing the wheel. Or at least that was the idea.

But what's this call to getShapes() they added? We didn't give them that part. Well, it turns out we did. Function getShapes() turned out to be inexplicably wrapping a very complex demo I had made for them showing how to generate tons of different possible shapes using math, by taking arbitrary steps to get to the next row or column of a deformed sheet. My demo code showed how to define lots of possible arbitrary deformations (as JavaScript arrow functions), generated a lot of shapes using them, and stored them all in big arrays of points at the end. It was meant to be a full demonstration of possibilities, and never to be used for real, much less called more than once. The shape in my avatar came from that demo:



This Crossy Road game didn't just call it more than once, it called it every single time a strip of the ground or piece of a car needed to be made. All because one of the included shapes in my demo was a cube. Rather than putting "new Cube()" in their class that drew the ground or whatever, calling only the 10-line Cube class that copies its little array over to the GPU (or better yet only ever doing it once during the program since it's always the same), they instead for every ground strip just re-called that whole demo and made the CPU painstakingly re-calculate all the demo shapes' huge arrays again.

They created a custom pyramid shape too by using their own small class, but again, rather than putting "new Pyramid()" inside their other class that needed a pyramid, they instead added their pyramid to the end of my huge list of demos, running the whole thing every time they wanted one.

code:
var shapes = { 
      good_sphere : new Subdivision_Sphere( 4 ),     // A sphere made of nearly equilateral triangles / no singularities
      vase        : new Grid_Patch( 30, 30, sin_rows_func, rotate_columns_func,   [[0,1],[0,1]] ),
      box         : new Cube(),
      ghost       : new Grid_Patch( 36, 10, sample_star_func, sample_two_arrays,  [[0,1],[0,1]] ),
      shell       : new Grid_Patch( 10, 40, line_rows_func, transform_cols_func,  [[0,5],[0,1]] ),
      waves       : new Grid_Patch( 30, 30, sin_rows_func, sin_columns_func,      [[0,1],[0,1]] ),
      shell2      : new Grid_Patch( 30, 30, sample_star_func, sample_two_arrays2, [[0,1],[0,1]] ),
      tube        : new Cylindrical_Tube  ( 10, 10, [[0,1],[0,1]] ),
      open_cone   : new Cone_Tip          (  3, 10, [[0,1],[0,1]] ),
      donut       : new Torus             ( 15, 15 ),
      gem2        : new ( Torus             .prototype.make_flat_shaded_version() )( 20, 20 ),
      bad_sphere  : new Grid_Sphere       ( 10, 10 ),    // A sphere made of rows and columns, with singularities
      septagon    : new Regular_2D_Polygon(  2,  7 ),
      cone        : new Closed_Cone       ( 4, 20, [[0,1],[0,1]] ),     // Cone.  Useful.
      capped      : new Capped_Cylinder   ( 4, 12, [[0,1],[0,1]] ),    // Cylinder.  Also useful.
      axis        : new Axis_Arrows(),          // Axis.  Draw them often to check your current basis.
      prism       : new ( Capped_Cylinder   .prototype.make_flat_shaded_version() )( 10, 10, [[0,1],[0,1]] ),
      gem         : new ( Subdivision_Sphere.prototype.make_flat_shaded_version() )(  2     ),
      swept_curve : new Surface_Of_Revolution( 10, 10, ....
      pyramid     : new Pyramid()
    };
It must have been calling this thousands of times. All things considered, it was a miracle the game only took about ten seconds to load up.

To prevent this I added a line "if( cached_shapes ) return cached_shapes;" at the beginning of their getShapes() where a global cached_shapes starts as null and gets set at the end of getShapes(). No more long load times, and the index page doesn't hang when flipping to their project in the showcase.

The rest of their code was reasonably impressive, with abstract superclasses of every shape and lots of subcategories of drawable objects each organized nicely into little files... but with just that one big oversight.

Happy Thread fucked around with this message at 02:02 on Dec 12, 2017

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!
"If I can reproduce it, I can fix it. If I cannot reproduce it, I cannot fix it".

Well then, I'd put my :10bux: on you not being able to fix it.

Eela6
May 25, 2007
Shredded Hen
I don't know if this counts as a coding horror, exactly, but...

java script: The Good Parts posted:

Unlike most other programming languages, there is no separate integer type, so 1 and 1.0 are the
same value. This is a significant convenience because problems of overflow in short integers are completely
avoided, and all you need to know about a number is that it is a number. A large class of numeric type errors is avoided

Are Is they? Are Is they really?

Also, I love this: "problems of overflow in short integers are completely avoided", as though you couldn't avoid that problem by, say using a 64-bit int by default (or, like Python, using arbitrary-precision integers)

Eela6 fucked around with this message at 23:44 on Dec 11, 2017

CPColin
Sep 9, 2003

Big ol' smile.
Just looked for the first time at the HTML source a vendor-provided web app generated. The page has 75 style sheets and an 18-line ASCII art logo at the top. The logo incorrectly capitalizes the name of the product. Also I changed somebody's last name to "><b> and exactly what you'd expect happened.

Carbon dioxide
Oct 9, 2012

In ponylang, which, despite the name, seems to be a reasonably serious if unfinished programming language, and which actually looks kinda neat... they decided to have divide by zero return the number 0, because otherwise the error handling would get too annoying.

canis minor
May 4, 2011

Eela6 posted:

I don't know if this counts as a coding horror, exactly, but...


Are Is they? Are Is they really?

Also, I love this: "problems of overflow in short integers are completely avoided", as though you couldn't avoid that problem by, say using a 64-bit int by default (or, like Python, using arbitrary-precision integers)

So, problem of short integers is solved by not using short integers? Pretty tautological, I'd say.

Also, my browser feels a bit suicidal now

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


Eela6 posted:

I don't know if this counts as a coding horror, exactly, but...


Are Is they? Are Is they really?

Douglas Crockford is completely convinced of the virtue of a language having only one built-in number type, though he does not think javascript has the right one.

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!

Doc Hawkins posted:

Douglas Crockford is completely convinced of the virtue of a language having only one built-in number type, though he does not think javascript has the right one.
The rational conclusion here is that 1.0*"1"==1. Either we use types to advantage, or their indistinguishability to advantage. The middle route seems... most wasteful and more confusing.

Sedro
Dec 31, 2008

Doc Hawkins posted:

Douglas Crockford is completely convinced of the virtue of a language having only one built-in number type, though he does not think javascript has the right one.

What hardware actually supports base10 though?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Doc Hawkins posted:

Douglas Crockford is completely convinced of the virtue of a language having only one built-in number type, though he does not think javascript has the right one.

single-cycle additions but comparisons to zero require 255 checks. lmao.

lifg
Dec 4, 2000
<this tag left blank>
Muldoon

steckles posted:

There is a series of inventory control machines that are used by some of our clients. I've been tasked with evaluating how difficult it would be to add support for them to our software. I spent a few hours reading docs, chatting with the company's implementation people, and playing with a simulator they provided. When I present my findings at the next dev meeting, I had this exchange with one of the other programmers:

Me: ...and you talk to the devices via ODBC.
Him: Isn't ODBC on its way out?
Me: I... that's debatable and not relevant.
Him: Shouldn't we use an API instead?
Me: Um... you don't... this isn't... I...
Him: I just think we should use something modern, like an API.
Me: ...

Sometime our sales guys say weird cargo cult stuff like this, but this guy has been programming for almost 20 years.

Your living in my favorite Dilbert strip!

http://dilbert.com/strip/1995-11-17

Eela6
May 25, 2007
Shredded Hen

canis minor posted:

So, problem of short integers is solved by not using short integers? Pretty tautological, I'd say.

What I'm trying to say is that he implies the alternative to using floats for ints is using shorts for ints. What language does that?

Jeb Bush 2012
Apr 4, 2007

A mathematician, like a painter or poet, is a maker of patterns. If his patterns are more permanent than theirs, it is because they are made with ideas.

Doc Hawkins posted:

Douglas Crockford is completely convinced of the virtue of a language having only one built-in number type, though he does not think javascript has the right one.

"make everything floats" is a bad idea, "make everything into a number type optimised around the ease of implementing printf" is a baffling idea

Van Kraken
Feb 13, 2012

Jeb Bush 2012 posted:

"make everything floats" is a bad idea, "make everything into a number type optimised around the ease of implementing printf" is a baffling idea

We’re all floats down here

JawnV6
Jul 4, 2004

So hot ...

Sedro posted:

What hardware actually supports base10 though?
BCD has native instructions on x86 and some other lesser architectures. It's not "base10 support" that DEC64 would need, but those dark corners still exist.

ugh:

quote:

The exponent can be unpacked at no cost on x64 architecture because the least significant byte can be accessed directly.
Claims like this always bug me though. "I have instructions that grab al" is not equivalent to "no cost." Just ask those OCaml folks.

Lime
Jul 20, 2004

Suspicious Dish posted:

single-cycle additions but comparisons to zero require 255 checks. lmao.

Not defending this thing, but you don't need 255 checks, you would just mask off the exponent.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Lime posted:

Not defending this thing, but you don't need 255 checks, you would just mask off the exponent.

yeah i know, but nan semantics are weird.

> There is a special value called nan that has a coefficient of 0 and an exponent of -128.

was curious what doug did.

https://github.com/douglascrockford/DEC64/blob/master/dec64.asm#L1444

oh

Carbon dioxide
Oct 9, 2012

http://shitcode.net/

duck monster
Dec 15, 2004

Had an issue at work where a grid navigation control on a web table wasnt working quite sensibly.
On page one clicking > would go to a page starting at record 201. Then on 201 clicking > would go to 2211 , then 22311 and so on.

Turns out javascript was taking the record number, adding 20, then adding 1 *as a string*, the reason being that for some reason the REST endpoint was putting quotes around the index. And Javascript being a dumpster fire of a language, instead of typecasting it to an int, or raising an error , decided 20 + '1' = '201'.

I hate my job.

Meat Beat Agent
Aug 5, 2007

felonious assault with a sproinging boner

Sedro posted:

What hardware actually supports base10 though?

The 6502 series, aka God's own architecture

Corla Plankun
May 8, 2007

improve the lives of everyone

duck monster posted:

Had an issue at work where a grid navigation control on a web table wasnt working quite sensibly.
On page one clicking > would go to a page starting at record 201. Then on 201 clicking > would go to 2211 , then 22311 and so on.

Turns out javascript was taking the record number, adding 20, then adding 1 *as a string*, the reason being that for some reason the REST endpoint was putting quotes around the index. And Javascript being a dumpster fire of a language, instead of typecasting it to an int, or raising an error , decided 20 + '1' = '201'.

I hate my job.

:lol: @ the fact that that paging is broken even without the javascript horror.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
perhaps the endpoint quoted the index because in a strongly-typed language on the other end it happens to be a 64-bit int, and if it were interpreted as a JS number it would parse as a double and lose precision?

necrotic
Aug 2, 2005
I owe my brother big time for this!
I'm the user clicking "Next" 9 quintillion times.

repiv
Aug 13, 2009

Internet Janitor posted:

perhaps the endpoint quoted the index because in a strongly-typed language on the other end it happens to be a 64-bit int, and if it were interpreted as a JS number it would parse as a double and lose precision?

Twitters API legitimately has to encode Tweet IDs as strings because they exceeded 2^53 Tweets, so the IDs can no longer be represented as Javascript numbers :bravo:

Taffer
Oct 15, 2010


repiv posted:

Twitters API legitimately has to encode Tweet IDs as strings because they exceeded 2^53 Tweets, so the IDs can no longer be represented as Javascript numbers :bravo:

They weren't using an ID format that could represent an arbitrarily large number of unique Id's? :psyduck:

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

Taffer posted:

They weren't using an ID format that could represent an arbitrarily large number of unique Id's? :psyduck:

To be honest, if you asked me to pick an ID format for something, I'd probably pick 64-bit int by default. That's 18 sextillion! That's a lot! The fact that this is limited to 9 quadrillion in Javascript would not have immediately leapt out to me as a problem.

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

duck monster posted:

And Javascript being a dumpster fire of a language, instead of typecasting it to an int,

But it does, just not in the case of the + operator, which is legal on strings. Had it been -, / or *, the string would have been converted to a number first. That's how you end up with so many accidental NaNs in Javascript code: if a string can't be converted to a proper number, it's converted to NaN instead, which propagates through all operations

Javascript is a really simple language (to a fault) and it's not hard to fully learn it. Treat it as the language it is, instead of the languages it looks like, and it won't be so surprising

Pollyanna
Mar 5, 2005

Milk's on them.


I still don’t understand how 64-bit is somehow different between Javascript and anywhere else. :psyduck:

repiv
Aug 13, 2009

Pollyanna posted:

I still don’t understand how 64-bit is somehow different between Javascript and anywhere else. :psyduck:

Javascript doesn't have integers, all numbers are represented as 64-bit floats. Those can only store exact integers up to 53-bits long and silently become imprecise beyond that.

code:
> Math.pow(2, 53) - 1
9007199254740991

> Math.pow(2, 53)
9007199254740992

> Math.pow(2, 53) + 1
9007199254740992

ulmont
Sep 15, 2010

IF I EVER MISS VOTING IN AN ELECTION (EVEN AMERICAN IDOL) ,OR HAVE UNPAID PARKING TICKETS, PLEASE TAKE AWAY MY FRANCHISE

Pollyanna posted:

I still don’t understand how 64-bit is somehow different between Javascript and anywhere else. :psyduck:

quote:

JavaScript Numbers are Always 64-bit Floating Point
Unlike many other programming languages, JavaScript does not define different types of numbers, like integers, short, long, floating-point etc.

JavaScript numbers are always stored as double precision floating point numbers, following the international IEEE 754 standard.
...
Integers (numbers without a period or exponent notation) are accurate up to 15 digits.
https://www.w3schools.com/js/js_numbers.asp

Unlike, say, .NET, where a long integer is a signed 64-bit integer, and not a floating point value.

quote:

long -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 Signed 64-bit integer
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/long

Taffer
Oct 15, 2010


TooMuchAbstraction posted:

To be honest, if you asked me to pick an ID format for something, I'd probably pick 64-bit int by default. That's 18 sextillion! That's a lot! The fact that this is limited to 9 quadrillion in Javascript would not have immediately leapt out to me as a problem.

Unless there's a peculiar need for speed I just default to a full-length UUID for anything that needs an identifier. It's overkill but I know it's always big enough :v:


E: I dumb

Elman
Oct 26, 2009

code:
private static String BLANK_SPACES = "                      ";

CPColin
Sep 9, 2003

Big ol' smile.
Not even final, ugh!

Adbot
ADBOT LOVES YOU

Volguus
Mar 3, 2009

Taffer posted:

Unless there's a peculiar need for speed I just default to a full-length UUID for anything that needs an identifier. It's overkill but I know it's always big enough :v:


E: I dumb

There's always need for speed, and there's never a need for arbitrarily reducing it. The system will have enough bottlenecks as it is, why introduce a new one for no reason? UUIDs are fine if you have distributed databases, but if you don't, why bother?

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