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
pigdog
Apr 23, 2004

by Smythe
Most of the discussion here really stems from the fact that different people argue over rules which apply to different levels of the Dreyfus model. The rules that you'd set for a beginner or advanced beginner are different from these that apply for an expert.

For a 2-year-old the rule is simply "DO NOT TOUCH THESE WALL THINGS, OUCHY OUCHY".
For a 8-year old the rule might be, "Never touch or shove anything into the wall outlets except for proper plugs on things".
For an adult the rule may be "Don't mess around with the outlets except when you're sure you switched the power off at the mains".
The next level may be "Well you may touch one of the wires even when the power is on, as long as you're isolated from the ground and not touching any other wires"

Same thing for anything code-related. It makes better sense to offer the beginners concrete and hard rules, which they may grow out of, rather than trying to explain the intrinsics of electricity to a 2-year-old.

Adbot
ADBOT LOVES YOU

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

Help, my program is broken? Like the whole thing, somewhere!!!?!?!?

shrughes
Oct 11, 2008

(call/cc call/cc)

Gism0 posted:

[url]http://www.daniweb

Say no more.

Jewel
May 2, 2009

pigdog posted:

Most of the discussion here really stems from the fact that different people argue over rules which apply to different levels of the Dreyfus model. The rules that you'd set for a beginner or advanced beginner are different from these that apply for an expert.

For a 2-year-old the rule is simply "DO NOT TOUCH THESE WALL THINGS, OUCHY OUCHY".
For a 8-year old the rule might be, "Never touch or shove anything into the wall outlets except for proper plugs on things".
For an adult the rule may be "Don't mess around with the outlets except when you're sure you switched the power off at the mains".
The next level may be "Well you may touch one of the wires even when the power is on, as long as you're isolated from the ground and not touching any other wires"

Same thing for anything code-related. It makes better sense to offer the beginners concrete and hard rules, which they may grow out of, rather than trying to explain the intrinsics of electricity to a 2-year-old.

Adding on to this, usually when something's not dangerous (IE personal coding for learning's sake), the best way to learn is to do things yourself and make mistakes. Asking "What's the best way to do X" isn't necessarily beneficial because you won't know why it's best to do X that way, it's best just to try and accomplish X, figure out what problems you have, and then try to fix those problems, or ask about how best to solve those specific problems if it's something complex.

LOOK I AM A TURTLE
May 22, 2003

"I'm actually a tortoise."
Grimey Drawer

pigdog posted:

Same thing for anything code-related. It makes better sense to offer the beginners concrete and hard rules, which they may grow out of, rather than trying to explain the intrinsics of electricity to a 2-year-old.

There are a lot more 2-year-olds doing programming than electrical work, though.

Zombywuf
Mar 29, 2008

Volte posted:

It is my belief that (possibly catalogued in some arcane Greek tome) there are some numbers between 10 and 3000.

My experience of bad code-bases causes me to believe otherwise.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
His averaging system is pretty great

BliShem
Dec 21, 2008

Aleksei Vasiliev posted:

His averaging system is pretty great

code:
do
{
// new averaging system
float pp;
float x;
float xx;
float xxx;
float xxxx;
float xxxxx;
float xxxxxx;
float xxxxxxx;
float xxxxxxxx;
float xxxxxxxxx;
float xxxxxxxxxx;
float xxxxxxxxxxx;
float xxxxxxxxxxxx;
float xxxxxxxxxxxxx;
float xxxxxxxxxxxxxx;
float xxxxxxxxxxxxxxx;
float xxxxxxxxxxxxxxxx;
float xxxxxxxxxxxxxxxxx;
float xxxxxxxxxxxxxxxxxx;
float xxxxxxxxxxxxxxxxxxx;
float xxxxxxxxxxxxxxxxxxxx;
...
1. surrounding with do.. while means the code can be easily moved into a macro
2. using float instead of double - shows deep understanding that normal usage doesn't require double precision and saves precious stack space.
3. intuitive naming scheme - easy to see that xxxxx comes before xxxxxxxx, no dependency on numerals (culture independent!)
4. no variables named tmp
5. has comments, but not too many
6. no costly memory allocations

Probably better than anything I've ever written, A++ would hire to work on my banking system

Amarkov
Jun 21, 2010
code:
void Math::Av()
Literally every possible thing is wrong about this function header oh my god.

Bonfire Lit
Jul 9, 2008

If you're one of the sinners who caused this please unfriend me now.

BliShem posted:

4. no variables named tmp
yeah but it has both more than 10 lines AND more than 7 variables

The Gripper
Sep 14, 2004
i am winner
It also has several XXX variables, not very worksafe at all.

quiggy
Aug 7, 2010

[in Russian] Oof.


From that same page:

code:

        cout<<"--------------------------------------------------------------------------------"<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
:allears:

nuvan
Mar 29, 2008

And the gentle call of the feral 3am "Everything is going so well you can't help but panic."

A part of me is tempted to fix this. The rest of me notes that it's over 5000 lines long, and is screaming in horror.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
nuvan: There's no way in hell I'm gonna take that plunge, but I am morbidly curious to know what it's supposed to do and just how simple it could be. Go for it, man!

edit: Or we could golf it. What do you guys think?

Internet Janitor fucked around with this message at 02:29 on Nov 27, 2012

bobthecheese
Jun 7, 2006
Although I've never met Martha Stewart, I'll probably never birth her child.
Speaking of poorly named variables...

code:
SELECT ...
FROM (SELECT ... 
     FROM ... 
     WHERE ...
     GROUP BY ... 
  UNION ALL 
     SELECT ...  
     FROM ...
     WHERE ...
     GROUP BY ...) AS tblFoo 
GROUP BY tblFoo.hour;
It's not a table, the naming convention in the database is to POST-fix 'Tbl' (I have no loving idea why), and 'Foo' describes precisely nothing about the purpose or nature of the data.

Fuckers.

Blue Footed Booby
Oct 4, 2006

got those happy feet

Encountered some neato code today in the guts of an ancient VB6 app that hooks up to some MS Access databases (note plural):

code:
if maSomeVariable = [MAGIC HARD-CODED VALUE] then
    107 lines of code
elseif maSomeVariable <> [SAME MAGIC VALUE] then
    88 lines of code
else
    67 lines of code
endif
Just for the record, maSomeVariable is a global string.

It's not the worst horror ever but this code is like that everywhere. Everyone who's looked at it hates it about as much as I do. I'm working on replacing the whole app but holy hell, every time I fire up the VB6 IDE I feel like I've developed a new and exotic form of cancer.

PrBacterio
Jul 19, 2000
Well apart from the fact that it's testing against the same value twice, and that the second condition can never fail after the first one, it seems to me like whoever wrote this is just using strings as enumeration constants, which I wouldn't necessarily call a horror if the language doesn't offer them natively. I've never used VB, does the language have enumerations?

EDIT: vvv If you had actually *read* my post, you would have noticed that no, I did not miss that the final else clause contains dead code, seeing how my post begins with "apart from that ..." vvv

PrBacterio fucked around with this message at 15:10 on Nov 27, 2012

BliShem
Dec 21, 2008

PrBacterio posted:

Well apart from the fact that it's testing against the same value twice, and that the second condition can never fail after the first one, it seems to me like whoever wrote this is just using strings as enumeration constants, which I wouldn't necessarily call a horror if the language doesn't offer them natively. I've never used VB, does the language have enumerations?

Did you miss the part where there's 100 lines of code inside the body each if?
Also, I'm pretty sure that the last 'else' clause is unreachable code.

Doctor w-rw-rw-
Jun 24, 2008

BliShem posted:

Did you miss the part where there's 100 lines of code inside the body each if?
Also, I'm pretty sure that the last 'else' clause is unreachable code.
I haven't done VB in close to twenty years (like, in elementary school), but based on my reading, this is only true if you assume Nothing <> ??? == true for any ??? that is not Nothing.

http://stackoverflow.com/questions/649951/and-not-in-vb-net

Catalyst-proof
May 11, 2011

better waste some time with you

nuvan posted:

A part of me is tempted to fix this. The rest of me notes that it's over 5000 lines long, and is screaming in horror.

I'll buy you a forums upgrade if you turn the monstrosity into some 30 line paragon of elegance.

Doctor w-rw-rw-
Jun 24, 2008

WHOIS John Galt posted:

I'll buy you a forums upgrade if you turn the monstrosity into some 30 line paragon of elegance.

Hell, why not. So will I.

BliShem
Dec 21, 2008

Doctor w-rw-rw- posted:

I haven't done VB in close to twenty years (like, in elementary school), but based on my reading, this is only true if you assume Nothing <> ??? == true for any ??? that is not Nothing.

http://stackoverflow.com/questions/649951/and-not-in-vb-net

Both the link and MSDN only talk about having the right-side of the comparison be Nothing, but I haven't done VB ever so I dunno.

http://msdn.microsoft.com/en-us/library/0x9tb07z.aspx

MSDN posted:

When checking whether a reference (or nullable value type) variable is null, do not use = Nothing or <> Nothing. Always use Is Nothing or IsNot Nothing.

And the very next line:

MSDN posted:

For strings in Visual Basic, the empty string equals Nothing. Therefore, "" = Nothing is true.

"Don't do it, but if you do, here's what will happen"

Jethro
Jun 1, 2000

I was raised on the dairy, Bitch!

bobthecheese posted:

Speaking of poorly named variables...

code:
SELECT ...
FROM (SELECT ... 
     FROM ... 
     WHERE ...
     GROUP BY ... 
  UNION ALL 
     SELECT ...  
     FROM ...
     WHERE ...
     GROUP BY ...) AS tblFoo 
GROUP BY tblFoo.hour;
It's not a table, the naming convention in the database is to POST-fix 'Tbl' (I have no loving idea why), and 'Foo' describes precisely nothing about the purpose or nature of the data.

Fuckers.
I'm not seeing too much that's objectionable here. When you're joining a bunch of tables together it's nice to have reasonable aliases so you don't have to keep asking yourself "which table is A? Which table is AA?", but if tblFoo isn't being joined to anything, it's not like you have to go hunting for the definition. Heck, probably the only reason it even has a name at all is because T-SQL requires them for derived tables.

As for putting Tbl at the end of table names, sometimes it's nice to know when you're working directly with a table or with a view. It's not like you're going to run into the problem of Hungarian notation where the name is out of sync with the type.

Zamujasa
Oct 27, 2010



Bread Liar

Hammerite posted:

I think Zamujasa was calling it cargo-cult because the author begins by using a database escape function, when the data seems not to be destined for a database. Thereby displaying a lack of insight into what the purpose of the escape function is and why it might appear in other code the author had seen.

This is correct. :shobon: It's using MySQL escapes to stuff data into a pseudo-XML structure. The cargo cult comment was about it, too, since he's obviously just using it from other places, but next time I'll elaborate more.

The thing that receives these (fake) XML strings is a real joke, too. It doesn't even conform to its own (asinine) spec, so if you followed the way they said to lay it out (with the two different newline escape codes as a container... yep, no whitespace allowed here), it'd fail. You had to use several for some reason.

And of course the message you get if it fails to understand what you sent?
code:
<Response><Error>The XML was malformed<Error></Response>
:jerkbag:

Zamujasa fucked around with this message at 22:47 on Nov 27, 2012

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
In spite of my comment earlier, I have begun fiddling with that horrendous C++ program. I'm finding it oddly relaxing to delete swaths of code and replace them with simple loops and conditionals. It seems to be a CLI shell of sorts, containing a wide array of semi-useful utility functions, from (buggy) unit conversion to (buggy) random number generation. Amazingly, there are a few loops and arrays in the code, which indicate the author was at least dimly aware of these concepts. I feel like I'm exploring a grand cathedral of idiocy.

Strong Sauce
Jul 2, 2003

You know I am not really your father.





It just feels like a big troll since I originally saw the link from some 4chan related site.

raminasi
Jan 25, 2005

a last drink with no ice

Otto Skorzeny posted:

Clay is more promising than Rust imo

Clay doesn't have a GC. I get what it's for, but it's not the thing I'm missing. I basically just want C# to compile to native.

Amarkov
Jun 21, 2010

Zamujasa posted:

<Error>The XML was malformed<Error>

Just count yourself lucky that this error doesn't trigger on itself.

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

GrumpyDoctor posted:

Clay doesn't have a GC. I get what it's for, but it's not the thing I'm missing. I basically just want C# to compile to native.

:psyduck: what would you hope to gain from this?

Zamujasa
Oct 27, 2010



Bread Liar

Amarkov posted:

Just count yourself lucky that this error doesn't trigger on itself.

Most of the problem stems from the fact they call it XML but don't actually use XML. Surprise.

There's no <?xml header, there's not even a real root tag. It requires very specific formatting because derp.

Room Temperature
Oct 16, 2007

mildly amusing

BliShem posted:

Both the link and MSDN only talk about having the right-side of the comparison be Nothing, but I haven't done VB ever so I dunno.

http://msdn.microsoft.com/en-us/library/0x9tb07z.aspx


And the very next line:


"Don't do it, but if you do, here's what will happen"

Those are two different cases. The first case is talking about comparing any nullable variable to Nothing to test if it's null. The second case is talking about comparing a string to Nothing to test if it's empty.

It's still weird and unintuitive though.

raminasi
Jan 25, 2005

a last drink with no ice

Otto Skorzeny posted:

:psyduck: what would you hope to gain from this?

Okay, my hyperbole may have obfuscated my point a little. I want a high-level language that allows me to (relatively) quickly build and deploy business applications to a variety of platforms (not just Windows). I don't need bleeding-edge performance or fully deterministic resource release or any of that stuff. I understand the roles of those features - I've needed and used them myself - but they don't solve problems that I, in my personal work, spend much time confronting. My remark about C# was just meant to highlight that while I like it quite a bit as a language it's tied to .NET.

Clay seems fantastic for the times when I need all the cool stuff that C++ can do but don't want to actually use C++, because, well, C++. But those times are infrequent for me. When my requirements are a) manage my resources unless I ask you not to and b) don't require a framework or a VM or anything to run, there just doesn't feel like a lot of space to work in.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Mono is actually pretty good these days, or so I hear.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
What's wrong with requiring a VM?

ToxicFrog
Apr 26, 2008


Suspicious Dish posted:

What's wrong with requiring a VM?

Windows deployment of JVM-based stuff is a colossal pain in the rear end, in my experience.

I haven't had much trouble with CLR/.NET/mono-based stuff, though.

Progressive JPEG
Feb 19, 2003

I'm a pretty big fan of Go. Compiles to native code, garbage collected, easy to make bindings to C libs. The way it treats interfaces is also pretty much the best thing ever.

The name is annoying but I find that using 'golang' tends to work when googling for things.

SavageMessiah
Jan 28, 2009

Emotionally drained and spookified

Toilet Rascal

beoba posted:

I'm a pretty big fan of Go. Compiles to native code, garbage collected, easy to make bindings to C libs. The way it treats interfaces is also pretty much the best thing ever.

The name is annoying but I find that using 'golang' tends to work when googling for things.

Yep, and then you can use https://github.com/lxn/walk for guis and such. Hard to beat a single statically linked executable with no external dependencies for simplicity of deployment.

raminasi
Jan 25, 2005

a last drink with no ice
Yeah, I have some friends that are big Go fans. I should probably check it out.

The Gripper
Sep 14, 2004
i am winner
On the other hand, Go's garbage collector is considered one of the weaker parts of it currently (at least as of Go1, there has been work on it since though I haven't seen any "Eureka!" posts on their mailing list yet).

I only mention it because the GC seems important to you, and for certain applications there are caveats you'd want to research/test thoroughly before making a commitment.

Adbot
ADBOT LOVES YOU

Progressive JPEG
Feb 19, 2003

The Gripper posted:

On the other hand, Go's garbage collector is considered one of the weaker parts of it currently (at least as of Go1, there has been work on it since though I haven't seen any "Eureka!" posts on their mailing list yet).

I only mention it because the GC seems important to you, and for certain applications there are caveats you'd want to research/test thoroughly before making a commitment.

Yeah I'd heard the same thing, but haven't really 'experienced' it, though I've been fairly careful to avoid mallocing things willy-nilly.

Now that Go1's out, I'm hoping that's the sort of thing they'll be concentrating on. Given that Google also did V8 and Dalvik I'm hopeful they'll eventually be able to scrounge up a reasonable GC implementation for Go as well.

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