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
tef
May 30, 2004

-> some l-system crap ->

MononcQc posted:

Erlang only got SMP support in 2006 (R12B, if memory serves me right). The way it was done was by having a scheduler represented as an OS thread

Aside: couldn't you just run one erlang vm per core before this to get smp like behaviour?

Adbot
ADBOT LOVES YOU

MononcQc
May 29, 2007

tef posted:

Aside: couldn't you just run one erlang vm per core before this to get smp like behaviour?

Yes. That was a way to gain parallelism from distribution. Now that you mention it, it could have been an acceptable alternative.

The only problem is that you have useless overhead when needing to serialize every Erlang term into its binary representation and then deserialize it on the other side, on top of the memory overhead for multiple runtimes. Might not be THAT bad given Erlang is not really the best choice for CPU-bound tasks anyway.

nerdfish
Dec 26, 2003
If in doubt, fish it.
I'm sure this is a classic, though I never actually came across this gem before today:
code:
typedef struct someTreeNode {...} someTreeNode;
void supposedTreeBalancingFunction(someTreeNode node) {...}

someFunction() {
    someTreeNode* hello;
    //do some stuff with it here...

    //and every now and then
    supposedTreeBalancingFunction(*hello);
}
Says it's there because "the performance of unbalanced trees is unacceptable." He put the star there, so apparently he knows about pointers. This is a PhD student though, which leaves me a bit confused

Zombywuf
Mar 29, 2008

Parantumaton posted:

I feel that I've put way too much effort on this whole debacle. Argh.

Never before have I seen such effort put into completely missing the point. Nor such a hilarious misuse of a trendline.

Fecotourist
Nov 1, 2008
A complex exponential would have given a better fit to the data.

Parantumaton
Jan 29, 2009


The OnLy ThInG
i LoVe MoRe
ThAn ChUgGiNg SeMeN
iS gEtTiNg PaId To Be A
sOcIaL MeDiA sHiLl
FoR mIcRoSoFt
AnD nOkIa

Zombywuf posted:

Never before have I seen such effort put into completely missing the point. Nor such a hilarious misuse of a trendline.

Point was apparently missed, trendline was misused on purpose - it was a statistic, not an analysis. Apparently I should've cashed in and added the sarcmark to the graph's title to highlight that.

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

nerdfish posted:

This is a PhD student though, which leaves me a bit confused

There's no guarantee that someone who is a Ph.D. student in computer science knows anything about real programming. (HCI students, I'm looking at you. :v: )

I'm not going to touch the usual argument about how much programming ability is "right" or "appropriate" to be expected for someone in "computer science", but the coding abilities of CS grad students run the entire spectrum from "code wizard" to "what's a pointer". Sadly, the same goes for the professors.

jandrese
Apr 3, 2007

by Tiny Fistpump
This is especially true in CS departments that are really just an offshoot of the math department, run by math professors. They'll show you proofs of algorithms all day long, but lord help you if one of them discovers a compiler.

See: Most "AI" researchers.

JasonV
Dec 8, 2003
So, I don't know much about programming, but the boss heard I knew a bit and asked me to take a look at this php/sql inventory management system they've been having problems with. Apparently, the contractor they've got doing it is having trouble actually fixing bugs and was wondering if I might offer any insight.

code:
$ ls *.php | wc -l
241

$ ls confirm*
confirm.php  confirm2.php  confirm3.php  confirm4.php  confirm4add.php  confirm4added.php  confirm5.php

$ ls hidden*
hiddenValues1.php  hiddenValues3.php  hiddenValues5.php    hiddenValuesServiceInventory.php
hiddenValues2.php  hiddenValues4.php  hiddenValuesALL.php

$ wc -l *.php

 [--snip--]

  43546 total

$ grep function *.php | wc -l
5

$ grep class *.php | grep -v class= | wc -l
0
The real horror is the boss is probably going to ask me (who's already told him I know next to nothing about PHP/SQL) if I can fix it...

Edit: And this:

code:
$ wc -l viewproduct.php
3038 viewproduct.php

$ grep function viewproduct.php | wc -l
0

$ grep "if " viewproduct.php | wc -l
204

JasonV fucked around with this message at 00:54 on Feb 3, 2010

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





tef posted:

Aside: couldn't you just run one erlang vm per core before this to get smp like behaviour?

Yes, but Erlang does dirty tricks with shared memory that don't work with multiple vm processes.

MononcQc
May 29, 2007

the talent deficit posted:

Yes, but Erlang does dirty tricks with shared memory that don't work with multiple vm processes.

AFAIK, the only shared memory you have is for atoms, which are stored in a global table that doesn't get garbage collected (this is being worked on by the Ericsson guys at the moment) and binary data over a certain size. The rest is never shared across other processes (even ets tables) because it would require some kind of stop-the-world garbage collection that would gently caress up the soft real-time requirements of the language. Shared-nothing allows them to individually GC processes when they're done or after they hit a certain size without messing with the rest of the world.

What dirty tricks did you have in mind?

E: maybe it's time to start a new Erlang megathread

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.

MononcQc posted:

E: maybe it's time to start a new Erlang megathread
Mmmm, delicious Erlang…

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





MononcQc posted:

AFAIK, the only shared memory you have is for atoms, which are stored in a global table that doesn't get garbage collected (this is being worked on by the Ericsson guys at the moment) and binary data over a certain size. The rest is never shared across other processes (even ets tables) because it would require some kind of stop-the-world garbage collection that would gently caress up the soft real-time requirements of the language. Shared-nothing allows them to individually GC processes when they're done or after they hit a certain size without messing with the rest of the world.

What dirty tricks did you have in mind?

E: maybe it's time to start a new Erlang megathread

Messages are just a pointer to the sending process' heap. If the message is just matched against, there is no copy. Even when there is a copy, it's often deferred until GC time. Exceptions exist, as always.

Warning, this is as of R11, things are probably different by now.

Hav
Dec 11, 2009

Fun Shoe

JasonV posted:

Edit: And this:

code:
$ wc -l viewproduct.php
3038 viewproduct.php

$ grep function viewproduct.php | wc -l
0

$ grep "if " viewproduct.php | wc -l
204

Just don't actually cat that file, or you'll probably invoke some tentacled beastie from the nether realms attracted by the rhythm of the 'Ifs'. I'll bet it's a procedural horror. Are they paying the contractor in office supplies?

nbv4
Aug 21, 2002

by Duchess Gummybuns

JasonV posted:

So, I don't know much about programming, but the boss heard I knew a bit and asked me to take a look at this php/sql inventory management system they've been having problems with. Apparently, the contractor they've got doing it is having trouble actually fixing bugs and was wondering if I might offer any insight.

code:
$ ls *.php | wc -l
241

$ ls confirm*
confirm.php  confirm2.php  confirm3.php  confirm4.php  confirm4add.php  confirm4added.php  confirm5.php

$ ls hidden*
hiddenValues1.php  hiddenValues3.php  hiddenValues5.php    hiddenValuesServiceInventory.php
hiddenValues2.php  hiddenValues4.php  hiddenValuesALL.php

$ wc -l *.php

 [--snip--]

  43546 total

$ grep function *.php | wc -l
5

$ grep class *.php | grep -v class= | wc -l
0
The real horror is the boss is probably going to ask me (who's already told him I know next to nothing about PHP/SQL) if I can fix it...

Edit: And this:

code:
$ wc -l viewproduct.php
3038 viewproduct.php

$ grep function viewproduct.php | wc -l
0

$ grep "if " viewproduct.php | wc -l
204

you forgot one essential command:

code:
$ rm *
horror solved

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

JasonV posted:

code:
$ grep function *.php | wc -l
5

http://betterthangrep.com/

(okay so it doesn't provide any improvements in this particular use-case, but...)

Lamont Cranston
Sep 1, 2006

how do i shot foam

Supervillin posted:

Saw this gem from a coworker today. IPs have been changed to protect the innocent. Spacing modified to hopefully protect the innocent forum tables.

php:
<?

?>

See? PHP doesn't need exceptions!

geetee
Feb 2, 2004

>;[
Something appears to be missing.

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction
I just figured it was the worlds only example of good php code.



:cool:

POKEMAN SAM
Jul 8, 2004

geetee posted:

Something appears to be missing.

he just cut out the long part of the post...

geetee
Feb 2, 2004

>;[
:doh: Ugh, this is what happens when you spend all day dealing with horrors at work. Sorry for being retarded.

Null Pointer
May 20, 2004

Oh no!
A couple of years ago I started making a compiler for a toy language. I ended up getting busy, so it got pushed onto the back-back-back burner. Usually that's where my projects go to die, but I really liked some of my ideas and wanted something to come of it.

This weekend I finally found the time and the inspiration. I opened up the code and... hey, it's pretty good! It's well-commented and well-designed. All of my missing AST visitors are generating errors so I know exactly where I left off. I'll have no problem jumping back in and getting to work.

Unfortunately, I lost the documentation for the language.

RedZone
Dec 6, 2005

This is more of an intentional comical horror but pretty cool to look at: Calculating pi to an arbitrary number of digits, in C#

Sebbe
Feb 29, 2004

RedZone posted:

This is more of an intentional comical horror but pretty cool to look at: Calculating pi to an arbitrary number of digits, in C#

code:
label0012:
            goto label0009;
Come on, that's just a cheap trick.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Null Pointer posted:

Unfortunately, I lost the documentation for the language.

This is why I put docs in source control with the code.

Yakattak
Dec 17, 2009

I am Grumpypuss
>:3

This, it isn't terrible but it just unnerves me.

code:
if( nil != img)
In terms of working, that works perfectly, readability it's an abomination. Why does it have to be backwards? When did someone ever learn that way? I always read them as "If object is null" not "If nil is not object". I dunno; this just makes me mad.

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

Yakattak posted:

This, it isn't terrible but it just unnerves me.

code:
if( nil != img)
In terms of working, that works perfectly, readability it's an abomination. Why does it have to be backwards? When did someone ever learn that way? I always read them as "If object is null" not "If nil is not object". I dunno; this just makes me mad.

This is considered safer in languages (like C and Objective-C, assuming by your example), where any expression is allowed inside an if clause. It's meant to prevent errors caused by accidentally using = instead of ==:
code:
if (img = nil) { ... }
This will compile fine and give the wrong results, but if (nil = img) will fail to compile.

Technically it isn't necessary if the operator is !=, but the author is just doing it for symmetry's sake.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

Yakattak posted:

In terms of working, that works perfectly, readability it's an abomination. Why does it have to be backwards? When did someone ever learn that way? I always read them as "If object is null" not "If nil is not object".

I know that in Java, when I'm comparing strings I often type something like

code:
if ("foobar".equals(string)) {...}
rather than

code:
if (string.equals("foobar")) {...}
because the former is null-safe. It's splitting hairs, but I think this approach is more concise and at least as readable as something like this:

code:
if ((string != null)&&(string.equals("foobar")) {...}

king_kilr
May 25, 2007
Ah java, was my_str == "foobar" really that hard.

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

king_kilr posted:

Ah java, was my_str == "foobar" really that hard.

Yeah, considering that they overloaded + as a special case for Strings, I don't see why they didn't overload == and != as well. They can't very well argue some kind of purity when it comes to operators.

Painless
Jan 9, 2005

Turn ons: frogs, small mammals, piles of compost
Turn offs: large birds, pitchforks
See you at the beach!

king_kilr posted:

Ah java, was my_str == "foobar" really that hard.

Within the constraints of Java's lovely type system, making that the equivalent of "my_str.equals( "foobar" )" would just make problems worse.

Parantumaton
Jan 29, 2009


The OnLy ThInG
i LoVe MoRe
ThAn ChUgGiNg SeMeN
iS gEtTiNg PaId To Be A
sOcIaL MeDiA sHiLl
FoR mIcRoSoFt
AnD nOkIa

king_kilr posted:

Ah java, was my_str == "foobar" really that hard.

Operator overloading would be a godsend in Java, even if it would be limited to a very small subset of items.

For example I've hit a snag where I was porting a legacy project to a new in-house library originally extracted from the said legacy project and while the class names were actually the same, packages and some methods were not so I had to create an adapter between the OldImportantThing and NewImportantThing.

The problem was that I could only take the adapter so far without operator overloading, parts of the legacy application relied on the fact that ImportantThingProvider contained only a few of these ImportantThings at any given time so one could just compare the two by if(importantOne == importantTwo) { doStuffWith(importantOne); } . With the adapter the actual ImportantThing was still the same but since Adapter instances were created in everywhere where they were needed instead of the ImportantThingProvider which now was in the new library that obviously didn't work at all.

Related refactorings were made but since the legacy application is partly Reflection-based there's no knowing if some "hidden" part still uses direct comparison instead of .equals(). So far we haven't seen any issues but we'll see what comes up in the future...

ehnus
Apr 16, 2003

Now you're thinking with portals!

Flobbster posted:

This is considered safer in languages (like C and Objective-C, assuming by your example), where any expression is allowed inside an if clause. It's meant to prevent errors caused by accidentally using = instead of ==:
code:
if (img = nil) { ... }
This will compile fine and give the wrong results, but if (nil = img) will fail to compile.

Technically it isn't necessary if the operator is !=, but the author is just doing it for symmetry's sake.

What compilers these days don't warn about assignment in a conditional?

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
Putting constants first is getting pretty close to jumping at your own shadow and biting the heads off chickens territory

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

ehnus posted:

What compilers these days don't warn about assignment in a conditional?

Objective-C using gcc (since that was the example the OP used) doesn't seem to issue a warning, since the following is a very common initialization pattern:
code:
if (self = [super init]) {
    // do stuff
}
return self;

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
That's using -Wall ?

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
gcc doesn't even have an option to warn about it. If such an option did exist, there's no way it'd be in -Wall, as that only includes warnings about things which are commonly considered objectionable and trivial to fix.

[e] Oh, I'm stupid and looked at completely the wrong thing.

Plorkyeran fucked around with this message at 00:43 on Feb 8, 2010

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

Otto Skorzeny posted:

That's using -Wall ?

Ah, looks like -Wall gets it:

code:
- (id) init
{
    if (self = [super init])
    {
        x = 5;
    }
    
    return self;
}

quote:

Test2.m: In function '-[TestObject init]':
Test2.m:13: warning: suggest parentheses around assignment used as truth value

Maybe I ought to start using -Wall :v: Not for this, but all the other good reasons.

Nigel Danvers
Oct 29, 2009

code:
int main( int argc, char** argv) 
{
	int a = 0;
	if ( a = 1 )
	{
		return 0;
	}
	return 1;
}
g++ -Wall test.cpp -o test
test.cpp: In function ‘int main(int, char**)’:
test.cpp:4: warning: suggest parentheses around assignment used as truth value
[code]

That's gcc 4.4 if it makes any difference.

Adbot
ADBOT LOVES YOU

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Not using -Wall is the real coding horror :colbert:

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