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
Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Zombywuf posted:

I don't use memcached these days. Last time I did I used it as a db cache. Turns out the db didn't need caching and I should have told the people pestering me about caching to go gently caress themselves. All it did was add complexity and it could go for weeks with memcached down and no-one noticed, turns out my time was best spent making the db fast, which it was.

This poo poo is endemic when semi-technical users tell you how to improve the performance of a system - it's always a x-y problem except there's no solution because poo poo can always be faster...

Adbot
ADBOT LOVES YOU

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
ErikTheRed: If I understand that correctly, the whole thing is equivalent to this oneliner, plus bugs.
code:
public static String moveDecimal(String number, int places) {
  return new java.math.BigDecimal(number).movePointRight(places).toString();
}

Johnny Cache Hit
Oct 17, 2011

Zombywuf posted:

I don't use memcached these days. Last time I did I used it as a db cache. Turns out the db didn't need caching and I should have told the people pestering me about caching to go gently caress themselves. All it did was add complexity and it could go for weeks with memcached down and no-one noticed, turns out my time was best spent making the db fast, which it was.

Yeah, I really cannot understand why people think "boy, my DB is slow" and think "I better throw some more software at this!"

If your database is really bumping up against CPU/memory constraints, it's far cheaper to throw hardware at the problem than it is to pay a programmer to think about how to properly add database-level caching. And if it's not you're probably doing something stupid.

Look Around You
Jan 19, 2009

ErikTheRed posted:

Oh man, I don't even know what to say here

code:
public static String moveDecimal(String pValue, int pBy)
{
	String lZeros = "00000000000000000000000000000";
	int lFoundAt;
	int lDecimalLength = 0;
	String lValue = null;
	lFoundAt = pValue.indexOf(".");
	if (lFoundAt >= 0)
		lDecimalLength = pValue.length() - lFoundAt - 1;
	if (lFoundAt > 0)
		lValue = pValue.substring(0, lFoundAt);
	else
		lValue = "";
	if (lDecimalLength > pBy && lDecimalLength > 0)
	{
		lValue += pValue.substring(lFoundAt + 1, 
lFoundAt + pBy + 1) + "." 
+ pValue.substring(lFoundAt + pBy + 1);
	}
	else if (lDecimalLength == pBy && lDecimalLength > 0)
	{
		lValue += pValue.substring(lFoundAt + 1, lFoundAt + pBy + 1);
	}
	else if (lDecimalLength < pBy && lDecimalLength > 0)
	{
		lValue += pValue.substring(lFoundAt + 1);
		lValue += lZeros.substring(0, pBy - lDecimalLength);
	}
	else if (lDecimalLength == 0)
	{
		if (lFoundAt < 0) lValue = pValue;
		lValue = lValue + lZeros.substring(0, pBy);
	}
	return lValue;
}

The best part is the Hungarian notation not for types or for usage, but for loving scope. lLocal and pParameter is just so loving absurd.

E: tables

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Zombywuf posted:

You're quite right, the data storage *does* make a difference. Tell me, how do you implement a star schema in Redis? Normalise HBase for data size minimisation? Cluster data in Cassandra to maximise temporal and cache locality? Organise data access patterns in memcache to minimise contention while maintaining some degree of transactional integrity?

Please don't claim you don't need to do these things unless you can provide me with a stack of benchmarks.

You don't need to do those things with those tools because you have matched tasks with the wrong tools.

raminasi
Jan 25, 2005

a last drink with no ice

tef posted:

I'd wager that ruby is easier to pick up for php developers than python, or perhaps, ruby is easier to write php in than python is - python has immutable strings, explicit self, an explicit unicode type, and semantic whitespace.

You think semantic whitespace makes python harder to write? I just started learning it, and I vastly prefer ruby because of its lisp roots (which are much more noticeable, by contrast, than I thought they would be), but I really do like the semantic whitespace.

raminasi fucked around with this message at 23:34 on Jun 22, 2012

crazyfish
Sep 19, 2002

GrumpyDoctor posted:

You think semantic whitespace makes python harder to write? I just started learning it, and I vastly prefer ruby because of it's lisp roots (which are much more noticeable, by contrast, than I thought they would be), but I really do like the semantic whitespace.

I didn't much like semantic whitespace when I started Python (and it still irks me a little bit) but it at least makes it a great language for instructors - the code needs to be readable to compile.

PrBacterio
Jul 19, 2000

crazyfish posted:

I didn't much like semantic whitespace when I started Python (and it still irks me a little bit) but it at least makes it a great language for instructors - the code needs to be readable to compile.
What I don't like about semantic whitespace is the lack of an (unindented) end-of-block token on its own line, separating the indented block from the code that follow. When I have control structures nested to a level of several indentations deeper than the surrounding code, having code on the next line just suddenly going back to having more than one level fewer of indentation can be kind of annoying imho.

EDIT: To be clear, I'm talking about something like this.
Python code:
def FooBar(some, parameters, orsomething):
	SomeCodeGoesHere()
	AndSoOn()
	while SomeConditionHolds():
		MoreCode()
		if SomethingElse():
			NowDoSomething()
	#now at this point the indentation suddenly pops back two levels at once,
	#without any token marking the change --
	#some kind of "end of block" marker as a placeholder for the
	#correct level of indentation for code that goes after would be nice to
	#have at this point
	CleanupAfterTheLoop()

PrBacterio fucked around with this message at 23:35 on Jun 22, 2012

tef
May 30, 2004

-> some l-system crap ->

GrumpyDoctor posted:

You think semantic whitespace makes python harder to write?

It doesn't make it harder to learn, it's more of an obstacle to whiny programmers.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

PrBacterio posted:

What I don't like about semantic whitespace is the lack of an (unindented) end-of-block token on its own line, separating the indented block from the code that follow. When I have control structures nested to a level of several indentations deeper than the surrounding code, having code on the next line just suddenly going back to having more than one level fewer of indentation can be kind of annoying imho.

EDIT: To be clear, I'm talking about something like this.
Python code:
def FooBar(some, parameters, orsomething):
	SomeCodeGoesHere()
	AndSoOn()
	while SomeConditionHolds():
		MoreCode()
		if SomethingElse():
			NowDoSomething()
	#now at this point the indentation suddenly pops back two levels at once,
	#without any token marking the change --
	#some kind of "end of block" marker as a placeholder for the
	#correct level of indentation for code that goes after would be nice to
	#have at this point
	CleanupAfterTheLoop()

FWIW, most (all?) of the favored Python editors have whatever you call those vertical line thingies that show the level of indentation you're at.

bobthecheese
Jun 7, 2006
Although I've never met Martha Stewart, I'll probably never birth her child.

Golbez posted:

Uh. Here is the prototype for that function:
code:
string number_format ( float $number [, int $decimals = 0 ] )
IT ALREADY CASTS TO FLOAT. If you give it a $number that isn't a float, that $number gets cast to float automatically. This seems to betray a horrible, horrible mistake somewhere deep inside PHP, that "float (float)$number" is somehow going to return a different result than "float (float)$number". This is loving amazing.

Silly Golbez, type hinting isn't for primitives! Just because the prototype has hinting in the documentation, that doesn't actually mean anything - type hinting in PHP only works on objects, and doesn't cast anything; only crashes if the wrong type of object was supplied.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

PrBacterio posted:

What I don't like about semantic whitespace is the lack of an (unindented) end-of-block token on its own line, separating the indented block from the code that follow. When I have control structures nested to a level of several indentations deeper than the surrounding code, having code on the next line just suddenly going back to having more than one level fewer of indentation can be kind of annoying imho.

EDIT: To be clear, I'm talking about something like this.
Python code:
def FooBar(some, parameters, orsomething):
	SomeCodeGoesHere()
	AndSoOn()
	while SomeConditionHolds():
		MoreCode()
		if SomethingElse():
			NowDoSomething()
	#now at this point the indentation suddenly pops back two levels at once,
	#without any token marking the change --
	#some kind of "end of block" marker as a placeholder for the
	#correct level of indentation for code that goes after would be nice to
	#have at this point
	CleanupAfterTheLoop()

If it's hard to read, don't write it that way. If it's because you have too many locals to refactor it correctly, you should encapsulate stuff in a class or something and quit fetishizing primitives.

Zombywuf
Mar 29, 2008

BonzoESC posted:

You don't need to do those things with those tools because you have matched tasks with the wrong tools.

I've yet to find a good example of a task that fits those tools.

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

Zombywuf posted:

I've yet to find a good example of a task that fits those tools.

Come on man, you're basically saying all the engineering staff at Twitter and Facebook are idiots.

JewKiller 3000
Nov 28, 2006

by Lowtax
Facebook gave up on Cassandra, they don't use it. They use innoDB from MySQL with lots of rules like "no joins" that amount to making it a sharded key-value store.

Doctor w-rw-rw-
Jun 24, 2008

JewKiller 3000 posted:

Facebook gave up on Cassandra, they don't use it. They use innoDB from MySQL with lots of rules like "no joins" that amount to making it a sharded key-value store.

They didn't give up on Cassandra for MySQL, though - they moved Messages over to hBase, if I recall because Cassandra's eventual consistency wasn't cutting it after they integrated chat and messages into the same product. I do believe Reddit uses Cassandra, if that means anything.

trex eaterofcadrs posted:

Come on man, you're basically saying all the engineering staff at Twitter and Facebook are idiots.
Relational databases are holy swiss-army knives that can do everything, didn't you know? Why use two tools that do something specific well, when you can configure one good enough for both use cases? :shepface: Inconceivable!

PrBacterio posted:

What I don't like about semantic whitespace is the lack of an (unindented) end-of-block token on its own line, separating the indented block from the code that follow. When I have control structures nested to a level of several indentations deeper than the surrounding code, having code on the next line just suddenly going back to having more than one level fewer of indentation can be kind of annoying imho.
Technically, DEDENT and INDENT are tokens in Python. That said, I kind of dislike Python for team projects because $FAVORITE_EDITOR will have different tabstops and mix tabs and spaces unless you standardize the editing environment. It's a bit of a pain, albeit a minor, easily-resolved one.

Doctor w-rw-rw- fucked around with this message at 06:32 on Jun 23, 2012

revmoo
May 25, 2006

#basta
This thread needs to be in its own forum with noindex and nofollow and a robots.txt

Doctor w-rw-rw-
Jun 24, 2008

revmoo posted:

This thread needs to be in its own forum with noindex and nofollow and a robots.txt

Why? Are you finding it on google?

revmoo
May 25, 2006

#basta
Nope I'm just saying people might participate a bit more.

bobthecheese
Jun 7, 2006
Although I've never met Martha Stewart, I'll probably never birth her child.
"Private programmers poo poo-bagging employers' code bases and other co-workers chat"

Just rolls off the tongue.

Hammerite
Mar 9, 2007

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

PrBacterio posted:

What I don't like about semantic whitespace is the lack of an (unindented) end-of-block token on its own line, separating the indented block from the code that follow. When I have control structures nested to a level of several indentations deeper than the surrounding code, having code on the next line just suddenly going back to having more than one level fewer of indentation can be kind of annoying imho.

EDIT: To be clear, I'm talking about something like this.
Python code:
def FooBar(some, parameters, orsomething):
	SomeCodeGoesHere()
	AndSoOn()
	while SomeConditionHolds():
		MoreCode()
		if SomethingElse():
			NowDoSomething()
	#now at this point the indentation suddenly pops back two levels at once,
	#without any token marking the change --
	#some kind of "end of block" marker as a placeholder for the
	#correct level of indentation for code that goes after would be nice to
	#have at this point
	CleanupAfterTheLoop()

You could just add # comments where indentation goes back more than one level, as a visual aid. Or use an editor that highlights that stuff for you, as others have said.

that awful man
Feb 18, 2007

YOSPOS, bitch

trex eaterofcadrs posted:

Come on man, you're basically saying all the engineering staff at Twitter and Facebook are idiots.

Are you suggesting that they aren't?

edit:

revmoo posted:

This thread needs to be in its own forum with noindex and nofollow and a robots.txt

Just move it to FYAD. Only logged-in users will be able to see it, and we can post the goatman to our hearts' content. It's a win-win situation.

that awful man fucked around with this message at 08:26 on Jun 23, 2012

KaneTW
Dec 2, 2011

I vote for TCC.

Zombywuf
Mar 29, 2008

Doctor w-rw-rw- posted:

I do believe Reddit uses Cassandra, if that means anything.
Reddit, famed for their uptime, just like Twitter. Facebook seem quite good at attempting to correct past mistakes.

quote:

Relational databases are holy swiss-army knives that can do everything, didn't you know? Why use two tools that do something specific well, when you can configure one good enough for both use cases? :shepface: Inconceivable!
Now you're just being silly. Vertica is excellent for data warehousing workflows and Solr is excellent for faceted queries of static data. Both will outperform a relational db in those specific use cases. The best part is you don't sacrifice data integrity with these tools.

I'm also really itching for an excuse to use Riak.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
This is almost a parody; it's like if the Keyston Kops were developers. "This is a config error," "this is fake," "this is a bug," "this is fixed," "it's back," "it's gone"

Look Around You posted:

The best part is the Hungarian notation not for types or for usage, but for loving scope. lLocal and pParameter is just so loving absurd.
Hwaaaaaaaaughgghghgh

tef
May 30, 2004

-> some l-system crap ->

Zombywuf posted:

I'm also really itching for an excuse to use Riak.

Me too :gay:

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
C#, ASP.Net MVC with the Razor engine, and Entity Framework 4 kick rear end. Also the nuget package support gives you a very fink/macports/package manager type of interface to automatically pull dependencies in. Also the EntityFramework power tools rock - right-click, reverse engineer classes, and boom it spits out POD objects corresponding to your existing database. Never write explicit data access code again, but with LINQ you can still create query expressions functionally that get translated into joins and the like under the hood.

C# is a great language to learn - with the lambdas and LINQ, dynamic support, delegates (function pointers), type inference, async/await, etc it has far surpassed Java and will give you a good stepping stone to the other C languages if you ever want to move that way.

Plus learning a new platform will break all those assumptions you have in your brain that come from always working on Unix, or Apache, or in dynamic languages, etc. Until you step into something completely different you won't realize how limited you were.

bobthecheese
Jun 7, 2006
Although I've never met Martha Stewart, I'll probably never birth her child.
php:
<?
foreach ( $_POST as $k1 => $v1 )
   $$k1 = $v1;
foreach ( $_GET as $k1 => $v1 )
   $$k1 = $v1;
?>
"Oh," says some developer, "You disabled register_globals because it was a massive security flaw? Ok, well I enabled it again for you! In a way that you can't disable with the php.ini! Aren't I great?"

Sinestro
Oct 31, 2010

The perfect day needs the perfect set of wheels.

bobthecheese posted:

php:
<?
foreach ( $_POST as $k1 => $v1 )
   $$k1 = $v1;
foreach ( $_GET as $k1 => $v1 )
   $$k1 = $v1;
?>
"Oh," says some developer, "You disabled register_globals because it was a massive security flaw? Ok, well I enabled it again for you! In a way that you can't disable with the php.ini! Aren't I great?"



This gif from the Political Cartoons thread sumarized my feelings towards that festering shitnugget. The best way to deal with this sort of thing is to help them figure out why it is wrong, instead of attempting to correct them based on authority alone.

KaneTW
Dec 2, 2011

bobthecheese posted:

php:
<?
foreach ( $_POST as $k1 => $v1 )
   $$k1 = $v1;
foreach ( $_GET as $k1 => $v1 )
   $$k1 = $v1;
?>
"Oh," says some developer, "You disabled register_globals because it was a massive security flaw? Ok, well I enabled it again for you! In a way that you can't disable with the php.ini! Aren't I great?"

How do these people even learn to code jeez. "Oh look let's just allow any variable to be controlled by the user! I have no idea how this can go wrong :downs:"

Suspicious Dish
Sep 24, 2011

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

bobthecheese posted:

php:
<?
foreach ( $_POST as $k1 => $v1 )
   $$k1 = $v1;
foreach ( $_GET as $k1 => $v1 )
   $$k1 = $v1;
?>
"Oh," says some developer, "You disabled register_globals because it was a massive security flaw? Ok, well I enabled it again for you! In a way that you can't disable with the php.ini! Aren't I great?"

How is register_globals a massive security flaw? Did someone think that values from $_POST were more secure than those from $_GET?

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Sinestro posted:



This gif from the Political Cartoons thread sumarized my feelings towards that festering shitnugget. The best way to deal with this sort of thing is to help them figure out why it is wrong, instead of attempting to correct them based on authority alone.

Create a git precommit hook that shows this gif if it finds variable variables ($$) in the commit file.

KaneTW
Dec 2, 2011

Suspicious Dish posted:

How is register_globals a massive security flaw? Did someone think that values from $_POST were more secure than those from $_GET?

No, that's not the point (and in fact, GET variables override POST variables). The point is that allowing variables to be set freely by the user is going to gently caress poo poo up.

Golbez
Oct 9, 2002

1 2 3!
If you want to take a shot at me get in line, line
1 2 3!
Baby, I've had all my shots and I'm fine

bobthecheese posted:

Silly Golbez, type hinting isn't for primitives! Just because the prototype has hinting in the documentation, that doesn't actually mean anything - type hinting in PHP only works on objects, and doesn't cast anything; only crashes if the wrong type of object was supplied.

But it does cast! When you give it a numeric string, it will cast that to a float when running the function, right? So why doesn't ... I mean, it ... :eng99:

Suspicious Dish
Sep 24, 2011

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

KaneTW posted:

No, that's not the point (and in fact, GET variables override POST variables). The point is that allowing variables to be set freely by the user is going to gently caress poo poo up.

I'm confused how, though. I do know that GET variables override POST variables, but I'm not sure why that matters at all. They're done as the first thing by the interpreter - any page script that uses variables initializes them first, right?

Hammerite
Mar 9, 2007

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

Strong Sauce posted:

Create a git precommit hook that shows this gif if it finds variable variables ($$) in the commit file.

PHP code:
$x = 'name';
${$x} = 'Bob';
echo 'My name is '.$name;
:viggo:

Hammerite
Mar 9, 2007

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

Suspicious Dish posted:

...any page script that uses variables initializes them first, right?

That is what _should_ happen, but you can't rely on it. If you use an uninitialised variable, it generates a "notice" level error and PHP treats it as having the value null.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Oh, right. You can disable global notices at runtime with a function call. Thanks, PHP.

Doctor w-rw-rw-
Jun 24, 2008

Strong Sauce posted:

Create a git precommit hook that shows this gif if it finds variable variables ($$) in the commit file.

Doesn't go far enough. Pushing $$ to production should be a fireable offense.

Adbot
ADBOT LOVES YOU

Suspicious Dish
Sep 24, 2011

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

Strong Sauce posted:

Create a git precommit hook that shows this gif if it finds variable variables ($$) in the commit file.

PHP code:
<?
foreach ( $_POST as $k1 => $v1 )
   ${${k.'1'}} = $v1;
foreach ( $_GET as $k1 => $v1 )
   ${${k.'1'}} = $v1;
?>

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