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
Adahn the nameless
Jul 12, 2006

Aleksei Vasiliev posted:

Oracle PL/SQL:
code:
declare
    x varchar2(1);
begin
    x := '';
    if x = '' then
       dbms_output.put_line('PL/SQL does not suck');
    else
       dbms_output.put_line('PL/SQL sucks');
    end if;
end;

> PL/SQL sucks

What's the rationale for this behavior?

Adbot
ADBOT LOVES YOU

pseudorandom name
May 6, 2007

The empty string is stored as null, and null doesn't compare equal to anything.

edit: Further Googling suggests its even worse than that, because str1 <> str2 won't be true if one is null and the other isn't.

pseudorandom name fucked around with this message at 02:56 on Apr 14, 2012

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

Mogomra posted:

I'm actually really interested to hear what the issues with Node.js are.
The issues maybe aren't so much with node.js, but with its promoters' tendency to ignore the long history of the events vs. threads question, and say things like "node.js never blocks" because they don't realize that the thing node.js does actually is blocking.

Suspicious Dish
Sep 24, 2011

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

Gazpacho posted:

The issues maybe aren't so much with node.js, but with its promoters' tendency to ignore the long history of the events vs. threads question, and say things like "node.js never blocks" because they don't realize that the thing node.js does actually is blocking.

That paper is from 1978, and talks about OS design in terms of process and forking. It also says that the two have equivalent performance: "in general, we have observed that a message-oriented operating system kernel implemented by a dedicated team on a friendly machine architecture can be made very efficient relative to the basic cycle time of that machine."

And of course, what they mean by "doesn't block" is that node.js is based around asynchronous stuff, like callbacks. I recently wrote a Deferred implementation in Mozilla JavaScript (it uses gjs and GNOME libraries for various helper things, not complete, doesn't send errbacks, etc.) to show off how asynchronous code may look in ES.next. I'll have to finish my Deferred blog post one of these days.

that awful man
Feb 18, 2007

YOSPOS, bitch

pseudorandom name posted:

edit: Further Googling suggests its even worse than that, because str1 <> str2 won't be true if one is null and the other isn't.

No, that's how it's supposed to work. In SQL, a NULL value represents missing or unknown data, so it isn't equal to a null string (which is known data that just happens to not have any characters in it).

It's sort of like how in C a null string is a non-null pointer to a zero-terminated array of characters that doesn't have anything before the terminator, and a null pointer doesn't point to anything at all.

This is why the code snippet is broken: Oracle turned a string literal into a null value when it should not have.

tef
May 30, 2004

-> some l-system crap ->
At a node.js talk I attended I asked 'How does error handling work' and 'Multicore'.

Mogomra
Nov 5, 2005

simply having a wonderful time

tef posted:

At a node.js talk I attended I asked 'How does error handling work' and 'Multicore'.

20,000,000 "error" event handlers and the "cluster" module :supaburn:

SavageMessiah
Jan 28, 2009

Emotionally drained and spookified

Toilet Rascal

Aleksei Vasiliev posted:

Oracle PL/SQL:
code:
declare
    x varchar2(1);
begin
    x := '';
    if x = '' then
       dbms_output.put_line('PL/SQL does not suck');
    else
       dbms_output.put_line('PL/SQL sucks');
    end if;
end;

> PL/SQL sucks

This is because an empty string is the same as null in Oracle and = always returns false if one of its operands is null. Even if both are null. If that was x is '' it would work iirc.

Coding horrors: I've written a web app framework in plsql.

edit: beaten to death

ijustam
Jun 20, 2005

SavageMessiah posted:

This is because an empty string is the same as null in Oracle and = always returns false if one of its operands is null. Even if both are null. If that was x is '' it would work iirc.

Coding horrors: I've written a web app framework in plsql.

edit: beaten to death

I think SQL Server is the same way. '= NULL' and 'IS NULL' behave differently.

mobby_6kl
Aug 9, 2009

by Fluffdaddy

ijustam posted:

I think SQL Server is the same way. '= NULL' and 'IS NULL' behave differently.

They do, (NULL = NULL) is FALSE while (NULL IS NULL) is TRUE.

But at least an empty string is not null:
code:
declare @x as varchar(2);
set @x = ''
select case when @x is null then 'empty string is null' else 'empty string is not null' end
>empty string is not null

Funking Giblet
Jun 28, 2004

Jiglightful!

mobby_6kl posted:

They do, (NULL = NULL) is FALSE while (NULL IS NULL) is TRUE.

But at least an empty string is not null:
code:
declare @x as varchar(2);
set @x = ''
select case when @x is null then 'empty string is null' else 'empty string is not null' end
>empty string is not null

Also depends on the ANSI NULLS setting

Zamujasa
Oct 27, 2010



Bread Liar
I think the fact that the empty string is treated as NULL is a horror in itself. MySQL had a good explanation for what NULL means and its example used a field for a phone number: "NULL means you don't know the phone number, while an empty string means that you know there is no phone number".

Treating an empty string like NULL seems like a bad idea.

Zombywuf
Mar 29, 2008

Zamujasa posted:

I think the fact that the empty string is treated as NULL is a horror in itself. MySQL had a good explanation for what NULL means and its example used a field for a phone number: "NULL means you don't know the phone number, while an empty string means that you know there is no phone number".

Treating an empty string like NULL seems like a bad idea.

Urgh, the empty string in your phone number field means you need better constraints. NULL means you forgot both to normalise and that some people have multiple phone numbers.

revmoo
May 25, 2006

#basta
Not sure exactly what is going on here...

code:
$request_id=$this->db->query("select max(request_id) as rid from atable where request_id>=200000")->row()->rid;
if($request_id>0){
        $request_id=$request_id+1;
}
else {
        $request_id=200000;
}

Flownerous
Apr 16, 2012
How else are you going to debug auto-increment?

geonetix
Mar 6, 2011


Looks more like a magic "starting point" fallback constant. As in, if there are apparently no request_ids above 200000, create one.

On the looks of that alone, it is something that's introduced at some point where somebody thought: "Hey! Request ids must start at 200000!". There might be an actual reason for it, there might also not be one. We'll never know. The greatest horror in it is the lack of documentation and the use of a magic constant.

zeekner
Jul 14, 2007

There's also the bit where he's calling row() without checking num_results() first. CodeIgniter will actually throw a proper exception if you try to access a row in an empty cursor.

But I wouldn't expect a PHP programmer to know what an exception is.

Zamujasa
Oct 27, 2010



Bread Liar
"I'll have to create some crafty encryption [...] might be more secure than SSL!"

No boss please don't do this. :ughh:

php:
<?
            if ($num_rows > 0){
                $row = mysql_fetch_assoc($result);
                $csvarray = explode(",",$row['csv']);
                foreach($csvarray as $k) {
                    
                    if ($k = $idtofind) {
                        $goodtogo = 1;
                    }

                }

                mysql_free_result($result);
                
                if (isset($idtofind)) {
                    
                    if ($goodtogo=1) {
?>
More Boss code.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Please tell me those are assignments in the conditionals, and that PHP's assignment operator doesn't turn into an equality operator.

revmoo
May 25, 2006

#basta
Haha no they are definitely assignment operators. PHP isn't THAT awful.

IAMKOREA
Apr 21, 2007
About MineCraft:

Captain Capacitor posted:

Gladly. I know one of my favorite facts so far is the cubic lighting calculations (every block has to consider its neighbours and neighbours of neighbours).

I'm trying to teach myself computation - can someone please explain to me a better way to do this? Is this an area where a dynamic programming algorithm would greatly reduce the amount of computation necessary?

Suspicious Dish
Sep 24, 2011

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

IAMKOREA posted:

I'm trying to teach myself computation - can someone please explain to me a better way to do this? Is this an area where a dynamic programming algorithm would greatly reduce the amount of computation necessary?

Global Illumination Radiosity can be done on a discrete scale, like Minecraft, in a direct manner.

The Gripper
Sep 14, 2004
i am winner

Suspicious Dish posted:

Global Illumination Radiosity can be done on a discrete scale, like Minecraft, in a direct manner.
Wouldn't this be exceptionally slow, even compared to the current system? I can't imagine any implementation of GIR in Minecraft would result in playable framerates even on the best hardware.

I don't have a better answer though, other than to say that Minecraft has a ton of small surfaces that each get lit individually (each block), and that the player can change at their leisure. A lot of things can be pre-computed when you don't have a dynamic world like in Minecraft, and working with larger surfaces means you can cut down on the work as well. I don't disagree that Minecrafts lighting is awful though, I threw a hack on my netbook with lighting entirely cut out and it ran flawlessly vs. the <1fps I get with lighting enabled.

evensevenone
May 12, 2001
Glass is a solid.
The real question is why a game where everything is a giant ugly block would need radiosity.

Suspicious Dish
Sep 24, 2011

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

The Gripper posted:

Wouldn't this be exceptionally slow, even compared to the current system? I can't imagine any implementation of GIR in Minecraft would result in playable framerates even on the best hardware.

I don't have a better answer though, other than to say that Minecraft has a ton of small surfaces that each get lit individually (each block), and that the player can change at their leisure. A lot of things can be pre-computed when you don't have a dynamic world like in Minecraft, and working with larger surfaces means you can cut down on the work as well. I don't disagree that Minecrafts lighting is awful though, I threw a hack on my netbook with lighting entirely cut out and it ran flawlessly vs. the <1fps I get with lighting enabled.

With a small number (<100) of light sources, it should be much faster than the current system. Keep in mind that this is global illumination radiocity, and that you're doing light accumulation on a block level, not on a pixel level.

evensevenone posted:

The real question is why a game where everything is a giant ugly block would need radiosity.

Because it's a good method for doing lighting calculations.

The Gripper
Sep 14, 2004
i am winner

Suspicious Dish posted:

With a small number (<100) of light sources, it should be much faster than the current system. Keep in mind that this is global illumination radiocity, and that you're doing light accumulation on a block level, not on a pixel level.
Makes sense, I completely missed that you could just treat each block the same as you would a single pixel in a typical gir renderer, and compared to pixels in a typical scene the number of blocks is really, really low.

nielsm
Jun 1, 2009



Suspicious Dish posted:

With a small number (<100) of light sources, it should be much faster than the current system. Keep in mind that this is global illumination radiocity, and that you're doing light accumulation on a block level, not on a pixel level.

Not only that, you only need to recalculate lighting when something changes, and you can probably take a shortcut and only recalculate e.g. 15 blocks in each direction from the changed block.

The Gripper
Sep 14, 2004
i am winner

nielsm posted:

Not only that, you only need to recalculate lighting when something changes, and you can probably take a shortcut and only recalculate e.g. 15 blocks in each direction from the changed block.
You'd probably not be able to do that because I think the game is designed to be as irritating to the developer as possible. If you have a gigantic room and punch a hole in the roof exposing sunlight you'd probably want the floor to receive some light at any depth. If you limited it to any arbitrary number of close-by blocks I'm sure the first thing that some sperger would do is make a giant strip-mine with a lid on it, take the lid off last then post on the forums "NOTCH YOU ARE AWFUL I DUG A HOLE AND THE LIGHTING IS BROKEN".

One of the more annoying things about the system is that the lighting needs to consider blocks that aren't even visible (out of range), otherwise entering an area with a roof high enough to be out of your view distance would be bright, until you moved your way closer to that roof.

I think in multiplayer the blocks are sent with the lighting value attached, so that it actually works at all.

The Gripper fucked around with this message at 18:34 on Apr 18, 2012

pseudorandom name
May 6, 2007

Minecraft stores sky lighting and height map data independent of the block lighting.

Scaevolus
Apr 16, 2007

nielsm posted:

Not only that, you only need to recalculate lighting when something changes, and you can probably take a shortcut and only recalculate e.g. 15 blocks in each direction from the changed block.

That's basically what Minecraft does.

Frozen Peach
Aug 25, 2004

garbage man from a garbage can
We're migrating to MSSQL 2008 (from 2000 :downs:). Finally we can switch to PHP PDO with an official SQL Driver for Linux. Oh wait, what's that? It only works on 64bit RHEL? drat. At least we can use DBLIB now, right?

Oh, nevermind both are ridiculously broken on PHP 5.2.4 (we're on Ubuntu 08.04 LTS) and doesn't support PDOStatement::nextRowSet(). I guess I'll update the test server to 10.04 and then to 12.04 Final Beta to get PHP 5.4. We'll be installing new servers in a few weeks anyways.

What's that? Ubuntu 12.04 isn't going to ship with PHP 5.4? Surely 5.3.10 is good enough. DBLIB was patched a few months ago. Nope! nextRowset() is only available in 5.4. Awesome. But wait, there's a PPA with 5.4 on it?

DBLIB works! Hurray! ... what are all these cursor errors? Oh I see, MARS isn't enabled on the connection string that's an easy fix! You know, if MARS was supported by the DBLIB driver. Scratch that idea. Oh well, back to ODBTP.

*ODBTP fails to build on 5.4* :smithicide:

I'm now in the process of building a brand new server install with Ubuntu 64bit. Finally got to the point that apache is serving our primary website with a hacked together SQL Native Client driver from RHEL. Now I just have to get tomcat working again.

PHP: Always a horror.

duck monster
Dec 15, 2004

Today I stumbled across a simple set of words that describe a real thing that ought cause any coder with a sense of his industry to imediately break out into a rash.

"LegacyJ : Enterprise JavaBeans and XML with COBOL"

Just saying it is like committing a hate-crime against IT workers. I'm pretty sure if my boss pulled up and said "Hey we got a job writing J2EE stuff with heaps of XML configuration using COBOL on a Java stack!" I'd probably start lighting fires.

The Gripper
Sep 14, 2004
i am winner

duck monster posted:

Today I stumbled across a simple set of words that describe a real thing that ought cause any coder with a sense of his industry to imediately break out into a rash.

"LegacyJ : Enterprise JavaBeans and XML with COBOL"
Reminds me of this:

dis astranagant
Dec 14, 2006

Why'd I have to read that right before bed?

pigdog
Apr 23, 2004

by Smythe

The Gripper posted:

Reminds me of this:


It's not as funny as it could be, because Erlang is actually pretty awesome. :)

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

duck monster posted:

Today I stumbled across a simple set of words that describe a real thing that ought cause any coder with a sense of his industry to imediately break out into a rash.

"LegacyJ : Enterprise JavaBeans and XML with COBOL"
If you consider COBOL dead maybe your "sense of the industry" isn't quite as good as you think. :smug:

Zombywuf
Mar 29, 2008

There's a difference between thinking something is dead and wishing to see its mutilated corpse being feasted upon by pigs.

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

duck monster posted:

Today I stumbled across a simple set of words that describe a real thing that ought cause any coder with a sense of his industry to imediately break out into a rash.

"LegacyJ : Enterprise JavaBeans and XML with COBOL"

Just saying it is like committing a hate-crime against IT workers. I'm pretty sure if my boss pulled up and said "Hey we got a job writing J2EE stuff with heaps of XML configuration using COBOL on a Java stack!" I'd probably start lighting fires.

This springs to mind for some reason.
http://publib.boulder.ibm.com/infocenter/wsdatap/v3r8m1/index.jsp?topic=%2Fxs40%2Fconvertingbetweenjsonandjsonx06.htm

BigRedDot
Mar 6, 2008

The Gripper posted:

Reminds me of this:

How funny, we were just talking with a guy from Riak about their stuff.

Adbot
ADBOT LOVES YOU

Zamujasa
Oct 27, 2010



Bread Liar
php:
<?
// END CODE FROM testcreateinfo.php
}}}}}}
}// goodtogo = 1, infoid passed is available to the passed username/password
 }// end of check to see if info id is passed
} // end of valid user/pass test and info return
} // end of is api command 'doeverything'
mysql_close($con);
} // End of is api functions?>
:smithicide:

(The lack of formatting here isn't some error, there are about 4 copies of this file and this is how they are: left justified. boss doesn't believe in indentation because he does coding on a 1024x768 TV and indents are just wasted space. :suicide:)


Edit: Oh, the snip from the last post is from this file, too, but run through a code reformatter. (Rest assured, it was left-justified too.)

Zamujasa fucked around with this message at 18:39 on Apr 19, 2012

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