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
SavageMessiah
Jan 28, 2009

Emotionally drained and spookified

Toilet Rascal
It seems like the more someone is concerned about random people stealing their code, the shittier it is.

Adbot
ADBOT LOVES YOU

Ursine Catastrophe
Nov 9, 2009

It's a lovely morning in the void and you are a horrible lady-in-waiting.



don't ask how i know

Dinosaur Gum

SavageMessiah posted:

It seems like the more someone is concerned about random people stealing their code, the shittier it is.

I can't hear you over the sound of how awesome my homebrewed encryption scheme is. It's way better than bcrypt or RSA, and it's all written in PHP, but I can't show it to you because it's SECRET. :v:

Sinestro
Oct 31, 2010

The perfect day needs the perfect set of wheels.

OriginalPseudonym posted:

I would say "Use \r so that it's non-obvious (depending on their text editor) that there's newlines", but it doesn't appear that PHP recognizes those as newlines unless it's explicitly enabled. Oh well.

:allears: Oh PHP...

ToxicFrog
Apr 26, 2008


SavageMessiah posted:

It seems like the more someone is concerned about random people stealing their code, the shittier it is.

Now that I think about it, that kind of makes sense.

If you're good, you can write simple stuff like that easily, and you know that other good programmers can as well, which means there's no reason to keep it secret.

If you aren't, it's a terrible ordeal to get it written and even once you're done it only just barely works. But since they think they're good, that means it must have been a really loving hard problem they just solved! Which means a solution for it must be valuable in some way, and they should protect it.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
That plus if you have a lick of sense about you, you'll feel stupid sharing terrible code so you'll only share better code.

Ursine Catastrophe
Nov 9, 2009

It's a lovely morning in the void and you are a horrible lady-in-waiting.



don't ask how i know

Dinosaur Gum

pokeyman posted:

That plus if you have a lick of sense about you, you'll feel stupid sharing terrible code so you'll only share better code.

I would think that should be reversed- if you're bad and you know it, you'll want to share your code so you can get better.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

OriginalPseudonym posted:

I would think that should be reversed- if you're bad and you know it, you'll want to share your code so you can get better.

The problem with most bad developers is that they don't know they're bad. It's usually the opposite; they think they're awesome.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
ToxicFrog: I think you nailed it hard.

'I find this really difficult' + 'I got it to work' = 'I am a goddamn genius'.

It's actually pretty impressive how well that generalizes to other situations.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Internet Janitor posted:

ToxicFrog: I think you nailed it hard.

'I find this really difficult' + 'I got it to work' = 'I am a goddamn genius'.

It's actually pretty impressive how well that generalizes to other situations.

Absolutely. Good developers will take "I found that really difficult" to mean "I don't know enough about how to do this correctly" and study the poo poo out of it. And that applies at all levels, up from basic string manipulation to architecting major applications with a ton of moving parts.

Ursine Catastrophe
Nov 9, 2009

It's a lovely morning in the void and you are a horrible lady-in-waiting.



don't ask how i know

Dinosaur Gum

Ithaqua posted:

Absolutely. Good developers will take "I found that really difficult" to mean "I don't know enough about how to do this correctly" and study the poo poo out of it. And that applies at all levels, up from basic string manipulation to architecting major applications with a ton of moving parts.

I don't know about other people, but if something's literally difficult, then my first reaction is to stop it right there because I'm probably doing something wrong. Coding is easy, you just have to come at it from the proper angle.

raminasi
Jan 25, 2005

a last drink with no ice

OriginalPseudonym posted:

I don't know about other people, but if something's literally difficult, then my first reaction is to stop it right there because I'm probably doing something wrong. Coding is easy, you just have to come at it from the proper angle.

I was looking over someone else's code today. He had rolled his own "alphabetize this list of strings" algorithm. It was C#. I kept thinking "man, this guy isn't nearly lazy enough."

NotShadowStar
Sep 20, 2000

OriginalPseudonym posted:

I don't know about other people, but if something's literally difficult, then my first reaction is to stop it right there because I'm probably doing something wrong. Coding is easy, you just have to come at it from the proper angle.

It depends on the experience level and problem domains, really. If a long time Java or other strictly OO based programmer walks into the same problem problem that uses Clojure or Scala, it's going to be really difficult for them.

Ursine Catastrophe
Nov 9, 2009

It's a lovely morning in the void and you are a horrible lady-in-waiting.



don't ask how i know

Dinosaur Gum

NotShadowStar posted:

It depends on the experience level and problem domains, really. If a long time Java or other strictly OO based programmer walks into the same problem problem that uses Clojure or Scala, it's going to be really difficult for them.

I admit that coming from different programming backgrounds is going to trip you up, but that's all the more reason to pause and start looking around. Chances are good that you're not the first person who's had to do X problem before, and seeing a handful of "this is how I did it" examples can be enough to kickstart your mind into the proper paradigm to get moving in the right direction.

Which is not to say "Copy paste 110,000 lines of code, splice them together, and call it a day". There's reinventing the wheel, and then there's gluing together a full-sized car out of micro machines with spunk and used gum.

plushpuffin
Jan 10, 2003

Fratercula arctica

Nap Ghost
This guy really, really likes using string.Join().

code:
List<string> list = new List<string>();
foreach(DataObject x in collection)
{
    list.Add(x.IntegerProperty.ToString());         
}

list.Sort( delegate(string a, string b) { return Int32.Parse(a).CompareTo(Int32.Parse(b)); } );

MessageBox.Show(string.Format("blah blah blah: {0}", string.Join(", ", list.ToArray())));

plushpuffin fucked around with this message at 14:26 on Oct 18, 2011

1337JiveTurkey
Feb 17, 2005

OriginalPseudonym posted:

Which is not to say "Copy paste 110,000 lines of code, splice them together, and call it a day". There's reinventing the wheel, and then there's gluing together a full-sized car out of micro machines with spunk and used gum.

I'm more used to the crushing a luxury car into a vaguely wheel shaped object paradigm.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Bhaal posted:

And that's fine and all, but I just hate how you can't easily itemize an allotment for "habit-break and reeducate client to accept the changes they came to me for in the first place" on the SOW.

You certainly can, it's called "training."

SlightlyMadman
Jan 14, 2005

BonzoESC posted:

You certainly can, it's called "training."

I can't even get most clients to agree to signing a proposal with "testing" on it, let alone "training." We've taken to just putting all that stuff in as "project management" which they mysteriously seem fine with, but you can only make that number so big.

Zombywuf
Mar 29, 2008

Sooooo
code:
def foo(a, ):
doesn't appear to be an error in Python.

Damnit Guido.

Johnny Cache Hit
Oct 17, 2011

Zombywuf posted:

Sooooo
code:
def foo(a, ):
doesn't appear to be an error in Python.

Damnit Guido.

Tuples in Python can be a bit funky. A single element tuple requires a comma:
code:
>>> (1)[0]
TypeError: 'int' object is not subscriptable

>>> (1,)[0]
1
But for multiple-element tuples:
code:
>>> (1,2,3) == (1,2,3,)
True
(1,2)[0]
So for zero or many element tuples, the parenthesis are important... but for one element tuples, the comma is important.

Python's def follows the same (bizarre) rules.

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"
Tuples are defined by the comma. Parenthesis just make it easier to use as an expression; they're not necessary when defining one.

code:
>>> 1
1
>>> 1,
(1,)
>>> 1,2,3
(1, 2, 3)
The trailing-comma-in-procedure-definition is different. In Python, anything that accepts a comma-separated list will allow a trailing comma. This makes it easier to extend long lists of things.

code:
>>> [1,2,]
[1, 2]
>>> def foo(a,b,): pass
... 
>>> {'a': 1, 'b': 2,}
{'a': 1, 'b': 2}

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

Janin posted:

Tuples are defined by the comma. Parenthesis just make it easier to use as an expression; they're not necessary when defining one.

code:
>>> 1
1
>>> 1,
(1,)
>>> 1,2,3
(1, 2, 3)
The trailing-comma-in-procedure-definition is different. In Python, anything that accepts a comma-separated list will allow a trailing comma. This makes it easier to extend long lists of things.

code:
>>> [1,2,]
[1, 2]
>>> def foo(a,b,): pass
... 
>>> {'a': 1, 'b': 2,}
{'a': 1, 'b': 2}

Yeah, the only dodgy part of any of that is the (1) is not a tuple thing, but it's understandable and why would you want to declare a single-element tuple like that anyway?

Why would you want "def f(a, )" or, more realistically, "def f(a, b, c, d,)" to be an error?

Zombywuf
Mar 29, 2008

Jonnty posted:

Why would you want "def f(a, )" or, more realistically, "def f(a, b, c, d,)" to be an error?

Because I'm far more likely to have left a comma lying around by mistake than to have put it there deliberately. I mean, why not just ignore any lines that can't be parsed? Would make it easier right?

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


SlightlyMadman posted:

Since they neglected to put a break in that loop, just add 1,000,000 blank lines to the end of that config file. The site will mysteriously slow down and you can blame it on lovely hosting.

Or claim you think you can optimize the site if some overtime will get approved. Remove 10-20% of the blank lines, goof off for the rest of the time, collect money, repeat as needed.

I hear this works great with usleep() and anything AJAX-y.

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

Zombywuf posted:

Because I'm far more likely to have left a comma lying around by mistake than to have put it there deliberately. I mean, why not just ignore any lines that can't be parsed? Would make it easier right?

It's something which can sometimes happen for good reasons (ease of updating lists), barely ever happen for bad reasons and sometimes happen as an innocuous mistake, why should it be an error? Your line of "it's unnecessary, STOP EVERYTHING" leads to trailing whitespace being an error.

Zombywuf
Mar 29, 2008

Jonnty posted:

It's something which can sometimes happen for good reasons (ease of updating lists), barely ever happen for bad reasons and sometimes happen as an innocuous mistake, why should it be an error? Your line of "it's unnecessary, STOP EVERYTHING" leads to trailing whitespace being an error.

In python, excess leading whitespace is an error. :colbert:

But yeah, I've been bitten by the fact that python doesn't complain when you leave commas lying about more times than I've been bitten by languages being strict about them. In general the syntax of a language should be strict, otherwise you end up with abominations like automatic semicolon insertion and HTML.

The worst part is that pylint doesn't even give a warning. Le sigh.

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

Zombywuf posted:

In python, excess leading whitespace is an error. :colbert:

But yeah, I've been bitten by the fact that python doesn't complain when you leave commas lying about more times than I've been bitten by languages being strict about them. In general the syntax of a language should be strict, otherwise you end up with abominations like automatic semicolon insertion and HTML.

The worst part is that pylint doesn't even give a warning. Le sigh.

How has it bitten you? The only thing I can think of is actually getting rid of an argument by accident or something, which is pretty contrived.

Zombywuf
Mar 29, 2008

Jonnty posted:

How has it bitten you? The only thing I can think of is actually getting rid of an argument by accident or something, which is pretty contrived.

By my doing some refactoring, getting distracted for a moment and then pylint (running in the background in emacs) telling me "Everything's ok, no syntax errors here". Then all my unit test fail at the call site instead of at the location of the error.

Optimus Prime Ribs
Jul 25, 2007

Doc Hawkins posted:

Or claim you think you can optimize the site if some overtime will get approved. Remove 10-20% of the blank lines, goof off for the rest of the time, collect money, repeat as needed.

Too bad I can't pull that ruse. I get paid by the year. :(
I'll just stick to fixing up all this horrible code I've been running in to.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Zombywuf posted:

By my doing some refactoring, getting distracted for a moment and then pylint (running in the background in emacs) telling me "Everything's ok, no syntax errors here". Then all my unit test fail at the call site instead of at the location of the error.

You should be running your unit tests in the background too, that way you'll know better when a particular change has caused one to fail :colbert:

TasteMyHouse
Dec 21, 2006
Apparently, in VC++6, this worked:

code:

for(int i=0;i<end1;++i)
{
   //do stuff
}

for(i=0;i<end2;++i)
{
   //do other stuff
}

nielsm
Jun 1, 2009



TasteMyHouse posted:

Apparently, in VC++6, this worked:

VC10 still has a compiler option to allow that broken scoping, look under the C/C++ > Language settings. But yeah, better fix the code.

Optimus Prime Ribs
Jul 25, 2007

nielsm posted:

VC10 still has a compiler option to allow that broken scoping

Why would you want to do this? :confused:

SlightlyMadman
Jan 14, 2005

I can't remember for the life of me, but I was working with some horrible scripting language not long ago that would actually throw AN ERROR if you tried to do that CORRECTLY. Declaring "int i" a second time would tell you that i was already defined. I ended up having to declare all of my iterators at the top of the function.

TasteMyHouse
Dec 21, 2006

nielsm posted:

But yeah, better fix the code.

I have to before gcc sees it and refuses to speak to me ever again.

baquerd
Jul 2, 2007

by FactsAreUseless
Dynamic scoping has its place, just not there.

tractor fanatic
Sep 9, 2005

Pillbug

Optimus Prime Ribs posted:

Why would you want to do this? :confused:

well you HAD to do that in VC6.0 since

code:
for(int i=0;;);
for(int i=0;;);
was a compile time error.

Opinion Haver
Apr 9, 2007

Better to just have iterators.h that you #include at the top of every file:
code:
int i;
int j;
int k;

Zombywuf
Mar 29, 2008

BonzoESC posted:

You should be running your unit tests in the background too, that way you'll know better when a particular change has caused one to fail :colbert:

Working on it, but emacs's compile mode doesn't quite do what I want. It would still have the problem that the error would be reported at the call site, not at the line of code with the error.

Optimus Prime Ribs
Jul 25, 2007

tractor fanatic posted:

well you HAD to do that in VC6.0 since

code:
for(int i=0;;);
for(int i=0;;);
was a compile time error.

Well isn't that cute.

Adbot
ADBOT LOVES YOU

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Optimus Prime Ribs posted:

Why would you want to do this? :confused:
if you have old code that you just want to compile and not spend several years fixing

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