Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 585 586 [587] 588 589 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 907697 times)

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #8790 on: January 15, 2016, 12:03:01 am »

I use editors that convert tabs to 4 spaces.

That way I only need to press tab once.

Additionally, I can do shift+tab to undo 4 indentions!
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8791 on: January 15, 2016, 12:03:49 am »

I like tabs because I hate having to count one-two-three-four spaces every time I indent, or when my code is slightly misaligned because I miscounted somewhere and I have to redo the entire thing to make sure that it's all correct, but it still looks weird in a way that I can't quite put my finger on and I think maybe it's because there's some sort of weird psychosomatic thing with the font, but then I realize that I've been using spaces in this file and tabs in another file so I have to either redo the tabs file or the spaces file, but I just noticed that I accidentally used one too many spaces in a block that's indented three levels so I backspace just once but GMS's IDE automatically unindents the entire block and aaaaaaaaaaaaaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

So I use tabs.

or

i'm reasonably sure most IDEs have that kind of thing

Additionally, I can do shift+tab to undo 4 indentions!

WHY DIDN'T I KNOW ABOUT THIS

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #8792 on: January 15, 2016, 12:05:48 am »

Even IDLE automatically turns tabs into spaces (and vice versa, if you want to do that for some insane reason), so I assume it's a pretty standard thing
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8793 on: January 15, 2016, 12:29:21 am »

spaces will always look consistent between various applications

for example, on b12 here tabs are 8 spaces and in notepad++ they're 4

so i just go with 4 spaces

Yeah, see, this is what I'm talking about though.  At work, everyone uses tabs.  I had to modify a number of libraries we didn't write a few times, and they were tabinated using two spaces.  The code was much harder to read for me since I'm used to 4-space tabs.  If it was tabinated using tabs, then the authors could write their scrunched up code and I could read it like I'm used to.

Maybe Notepad++ supports automatic conversion of tabs and spaces on existing code on the fly, like described above, but I don't think so.  Maybe a plugin exists for it.

Quote
Additionally, I can do shift+tab to undo 4 indentions!

Many IDEs I've used supported that for blocks of code, but I don't think Notepad++ supports doing it for single lines.  I'll have to test that in the morning.  In any case, I'm so used to backspace removing a whole tab that it would be pretty annoying to retrain myself for that.

Another thing about spaces is that I usually screw up selecting blocks of code.  I'll select one more or less space than I intended to.

I don't know, I guess it feels like IDEs have to jump through a lot of hoops to make spaces behave like tabs, when you could just use tabs.

Having said all of this, I think tabs are good for formatting comments next to lines of code.  That way you can guarantee that they line up if you need them to.  But for indentation, I just don't see any advantage to using spaces, and lots of annoyance.

Quote
Python hates tabs. That's why a lot of people don't like it. Because of one language that couldn't be arsed to use proper delimiters, which isn't so bad in itself, has caused real tab characters to clash wherever it comes up.

I'm pretty sure that Python accepts tabs just fine, but I don't think you can mix it with spaces in the same source file.  Doing so is a deadly sin in any language though.
Logged
Through pain, I find wisdom.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8794 on: January 15, 2016, 12:33:42 am »

notepad++ supports auto-tab-to-space and shift+tab for single-line unindentation

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8795 on: January 15, 2016, 01:16:06 am »

I'll have to try it out tomorrow.

You say that is supports converting tabs to spaces automatically, but does it go the other way around?  That's what I'd be interested in - converting a file with space indentation to tab indentation.  If it does support that, I wonder how it works.  Does it try to guess based on common multiples of spaces or something?  Or do you just have to tell it how many spaces become a tab?

And presumably it converts tabs back to spaces when saving the file?  If not, source control is going to be very unhappy.
Logged
Through pain, I find wisdom.

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8796 on: January 15, 2016, 01:46:42 am »

I'll have to try it out tomorrow.

You say that is supports converting tabs to spaces automatically, but does it go the other way around?  That's what I'd be interested in - converting a file with space indentation to tab indentation.  If it does support that, I wonder how it works.  Does it try to guess based on common multiples of spaces or something?  Or do you just have to tell it how many spaces become a tab?

And presumably it converts tabs back to spaces when saving the file?  If not, source control is going to be very unhappy.
There's [Edit -> Blank Operations -> Space to Tab (Leading)], which converts by multiples of your tab size (under [Settings -> Preferences -> Tab Settings]) and is a permanent conversion. You'd have to convert back before you save.

The "Replace by space" [Tab Setting] uses however many spaces instead of tabs. You want that one.
« Last Edit: January 15, 2016, 01:53:08 am by Bumber »
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #8797 on: January 15, 2016, 02:31:15 pm »

https://www.shadertoy.com/view/4dy3Rz#

I made a shader thing!

It's kinda cool.

I still don't understand how people make fancy transforming 3D screeensavers out of nothing but shaders though.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8798 on: January 15, 2016, 03:51:02 pm »

https://www.shadertoy.com/view/4dy3Rz#

I made a shader thing!

It's kinda cool.

I still don't understand how people make fancy transforming 3D screeensavers out of nothing but shaders though.
It appears like channel1 is supposed to be a normal map according to your code, but you supplied a bump map instead, and it doesn't even seem related to the colour texture. So I changed your shader up a bit to read normals from the bump map differentials.

Here's the code with working normals:
Code: [Select]
float pow(float x) {
return x*x;
}

float pendulum(float p, float m, float M) {
  return m+(sin(iGlobalTime*p)+1.)/2.*(M-m); 
}

float c_pendulum(float p, float m, float M) {
  return m+(cos(iGlobalTime*p)+1.)/2.*(M-m); 
}

float dist2(vec2 c1, vec2 c2) {
   return pow(c1.x - c2.x) + pow(c1.y - c2.y);
}

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
    vec2 uv = fragCoord.xy / iResolution.xy;
    vec2 xy = fragCoord.xy;
   
    vec3 light = vec3(0.0, 0.0, 0.4);
    light.x = pendulum(1.5, .2, .8) * iResolution.x;
    light.y = iResolution.y * 0.5;
    // phong lighting
vec3 c1 = texture2D(iChannel0, uv).xyz;
   
    //-------------------------------------------------------------------------------
    // differential of bump map is normal map
    vec3 a0 = texture2D(iChannel1, uv+vec2(0./iResolution.x,0./iResolution.y)).xyz;
    vec3 ax = texture2D(iChannel1, uv+vec2(1./iResolution.x,0./iResolution.y)).xyz;
    vec3 ay = texture2D(iChannel1, uv+vec2(0./iResolution.x,1./iResolution.y)).xyz;
    // bump map steepness parameter
    float s = 30.0;
    vec3 n = vec3(a0.r-ax.r, a0.r-ay.r, 1./s);
n = normalize(n);
    //-------------------------------------------------------------------------------

    vec2 temp = light.xy - xy;
    vec3 l  = vec3(temp.x, temp.y,
                   60.0 + c_pendulum(1.5, -20., 20.));
    l = normalize(l);
    float diffuse = dot(n, l);
   
    // flashlight effect
    float d = dist2(xy, light.xy);
    d = d / pow(iResolution.x);
    if (d < pow(light.z))
    {
        c1 *= pow(1. - d/pow(light.z)) * diffuse;
    }
    else
    {
      c1 = vec3(0.,0.,0.);   
    }
    fragColor.xyz = c1;
}
Logged

breadman

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8799 on: January 15, 2016, 05:09:24 pm »

Having said all of this, I think tabs are good for formatting comments next to lines of code.  That way you can guarantee that they line up if you need them to.  But for indentation, I just don't see any advantage to using spaces, and lots of annoyance.

My main beef with tabs is that they make diffs look stupid, particularly when placed in the middle of a line like that.  (Granted, diffs look even more stupid when some lines have tabs and others have spaces.)  Fortunately, the expandtab setting applies when using the tab key in the middle of a line, as well as for indentation.

On my latest project, in Python, we have one developer who prefers tabs, while the rest of us start files using Python's default of four spaces.  It mostly doesn't bother me, because my editor looks at each file to determine whether to insert tabs or spaces, except when copying code from one file to another.  Perhaps I should have it expand tabs before saving, just in case.

Granted, I'm the rogue developer who prefers to keep the indentation on whitespace-only lines, causing headaches for certain other text editors...
Logged
Quote from: Kevin Wayne, in r.g.r.n
Is a "diety" the being pictured by one of those extremely skinny aboriginal statues?

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8800 on: January 15, 2016, 07:08:03 pm »

Wow, I derped there.  I meant to say that spaces were good for formatting comments, not tabs.  That's where you want spacing to be consistent across editors.  Interestingly though, when I tried it just now, changing the tab width caused it to jump around anyway if the code was indented with tabs, presumably because different line lengths cause the lines to end at different tab stops occasionally.

My programming religious beliefs are being challenged.  :(
Logged
Through pain, I find wisdom.

TheBiggerFish

  • Bay Watcher
  • Somewhere around here.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8801 on: January 15, 2016, 07:11:47 pm »

I prefer spaces, myself.
Logged
Sigtext

It has been determined that Trump is an average unladen swallow travelling northbound at his maximum sustainable speed of -3 Obama-cubits per second in the middle of a class 3 hurricane.

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #8802 on: January 15, 2016, 08:55:25 pm »

Anyone who uses tabs is a filthy heathen. Deus vult.
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

spfifle

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8803 on: January 15, 2016, 11:52:12 pm »

Anyone who uses tabs is a filthy heathen. Deus vult.
Spaces is heresy. If someone suggested that we replace periods in sentences with "aaaa" we'd think they were crazy. 1 tab == 1 indent, the way God intended.
Logged

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #8804 on: January 16, 2016, 01:13:10 am »

https://www.shadertoy.com/view/4dy3Rz#

I made a shader thing!

It's kinda cool.

I still don't understand how people make fancy transforming 3D screeensavers out of nothing but shaders though.
It appears like channel1 is supposed to be a normal map according to your code, but you supplied a bump map instead, and it doesn't even seem related to the colour texture. So I changed your shader up a bit to read normals from the bump map differentials.

I blame the unrelatedness to it Shadertoy not letting you provide custom textures.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward
Pages: 1 ... 585 586 [587] 588 589 ... 796