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
Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

Beardless Woman posted:

And this guy's code is actually in production.
So what if it is? The code you posted apparently works; it's the broken code you should worry about first. People shouldn't feel obligated to use every redundant feature of a language.

Gazpacho fucked around with this message at 09:51 on Apr 12, 2009

Adbot
ADBOT LOVES YOU

Flobbster
Feb 17, 2005

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

Gazpacho posted:

So what if it is? The code you posted apparently works; it's the broken code you should worry about first. People shouldn't feel obligated to use every redundant feature of a language.

The "not" operator is a redundant feature? :v:

ehnus
Apr 16, 2003

Now you're thinking with portals!

Flobbster posted:

The "not" operator is a redundant feature? :v:

No, but "unless" certainly is.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

ehnus posted:

No, but "unless" certainly is.

What's the difference? Isn't "unless(statement)" identical to "if (!(statement))"?

e: Come to think of it, isn't "if" redundant if you have goto? And "else" is sure overrated hey? I just jump right there. Surely we don't need for loops if we have while loops. Why have a break statement when you can just use a flag?

When does "arbitrary" cross into "quite helpful" for you? Especially if it boils down to the same instructions in the end.

pokeyman fucked around with this message at 19:03 on Apr 12, 2009

TheSleeper
Feb 20, 2003

pokeyman posted:

What's the difference? Isn't "unless(statement)" identical to "if (!(statement))"?

e: Come to think of it, isn't "if" redundant if you have goto? And "else" is sure overrated hey? I just jump right there. Surely we don't need for loops if we have while loops. Why have a break statement when you can just use a flag?

When does "arbitrary" cross into "quite helpful" for you? Especially if it boils down to the same instructions in the end.

If is a conditional jump, goto has no condition.

POKEMAN SAM
Jul 8, 2004

pokeyman posted:

e: Come to think of it, isn't "if" redundant if you have goto?

How would you conditionally branch with goto?

shrughes
Oct 11, 2008

(call/cc call/cc)

Ugg boots posted:

How would you conditionally branch with goto?

Put function pointers in a two-element array and index the array with a boolean.

Of course, that has nothing to do with goto. But I think there's some gcc feature that would let you do that with goto. Don't bytecode interpreters use that nowadays?

POKEMAN SAM
Jul 8, 2004

shrughes posted:

Put function pointers in a two-element array and index the array with a boolean.

Of course, that has nothing to do with goto. But I think there's some gcc feature that would let you do that with goto. Don't bytecode interpreters use that nowadays?

Pfft, function pointers are such a redundant feature :downswords:

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

Ugg boots posted:

How would you conditionally branch with goto?

Short-circuiting boolean operators.

shrughes
Oct 11, 2008

(call/cc call/cc)

ShoulderDaemon posted:

Short-circuiting boolean operators.

Does that really work?

http://codepad.org/iKriru3l

Edit: Oh, but obviously not really with goto... Durr

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"
Every operation on a computer except for "Subtract and Branch if Less Than or Equal to Zero" is redundant, so it seems arbitrary beyond that to say "well this operation isn't redundant but this one is".

Lonely Wolf
Jan 20, 2003

Will hawk false idols for heaps and heaps of dough.

Flobbster posted:

Every operation on a computer except for "Subtract and Branch if Less Than or Equal to Zero" is redundant, so it seems arbitrary beyond that to say "well this operation isn't redundant but this one is".

That operation is redundant if your computer is omniscient :mad:

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
I don't see the point of arguing whether Perl has redundant features. Larry Wall admits it and is proud of it.

Once upon a time in the 1990s, I wrote a fair amount of Perl code where I tried to be as concise as the language allowed, and a guy who had to maintain it later told me "WTF?" I don't write Perl like that anymore.

Gazpacho fucked around with this message at 20:26 on Apr 12, 2009

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Gazpacho posted:

I don't see the point of arguing whether Perl has redundant features. Larry Wall admits it and is proud of it.

Wasn't arguing about Perl redundancy, more that being pedantic about redundancy in coding leaves you with a tiny set of nonredundant operations and most likely unreadable code. But I'm done.

Regarding conditional goto: I meant to say branch, sorry. Branch/if and goto/break. Y'all got my point: higher-level constructs like if boil down to low-level constructs like branch, so they're redundant, but surely we find value in them, etc. etc. I don't think Beardless Woman found value in an empty code block, as he expected a not or an unless, so he posted it here. That's all.

ehnus
Apr 16, 2003

Now you're thinking with portals!

pokeyman posted:

What's the difference? Isn't "unless(statement)" identical to "if (!(statement))"?

e: Come to think of it, isn't "if" redundant if you have goto? And "else" is sure overrated hey? I just jump right there. Surely we don't need for loops if we have while loops. Why have a break statement when you can just use a flag?

When does "arbitrary" cross into "quite helpful" for you? Especially if it boils down to the same instructions in the end.


Sorry to break it to you but "unless" is redundant as it does the same thing as using if with a negated condition but saves no typing and some (like myself) might even say it does nothing to improve code clarity or comprehension.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

ehnus posted:

Sorry to break it to you but "unless" is redundant as it does the same thing as using if with a negated condition but saves no typing and some (like myself) might even say it does nothing to improve code clarity or comprehension.

"If not (whatever) do this" is less clear to you than "unless (whatever) do this"? I mean, one of them is a common English construct.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

ehnus posted:

Sorry to break it to you but "unless" is redundant as it does the same thing as using if with a negated condition but saves no typing and some (like myself) might even say it does nothing to improve code clarity or comprehension.

code:
if !something_false do hurf; // 1

if not something_false do durf; // 2

unless something_false do hurfdedurf; // 3
Numbers two and three are clearer to me than number one (goddamn exclamation point is easy to miss, especially with parentheses thrown in), and the third reads ever so slightly more naturally to me than the second. Maybe you save a fraction of a second by not typing an extra, count them, 3 characters (in statement one); if that's your goal, good for you? (Personally, having to twist up then back to hit the 1 key slows me down as much as typing 'ess'.) At worst, there is no difference when I read the code, so what do I care? Do you honestly find yourself struggling to read any of the above three statements?

Calling something "redundant" doesn't imply it's a worthless feature; we've covered this. Stop using that as a crutch, and just explain your opinion.

pokeyman fucked around with this message at 23:10 on Apr 12, 2009

Kelson
Jan 23, 2005

pokeyman posted:

code:
if !something_false do hurf; // 1

if not something_false do durf; // 2

unless something_false do hurfdedurf; // 3
Numbers two and three are clearer to me than number one (goddamn exclamation point is easy to miss, especially with parentheses thrown in), and the third reads ever so slightly more naturally to me than the second. Maybe you save a fraction of a second by not typing an extra, count them, 3 characters (in statement one); if that's your goal, good for you? (Personally, having to twist up then back to hit the 1 key slows me down as much as typing 'ess'.) At worst, there is no difference when I read the code, so what do I care? Do you honestly find yourself struggling to read any of the above three statements?

Calling something "redundant" doesn't imply it's a worthless feature; we've covered this. Stop using that as a crutch, and just explain your opinion.

#3 trips me up and I'd have issue with it if I ran into it, but that's because I don't normally see/use them. It just isn't as clear to me as "if !A then B" to say "unless A do B". Heck, just typing that one and re-reading trips me up linguistically, it should be "do B unless A".

edit: Although "do B unless A" looks a lot like "do B until A" which makes it even worse!

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
I understand that everyone has their own sense of code aesthetics, I just wouldn't use it as the basis for calling something a coding horror when my solution is not really much better in production.

ehnus
Apr 16, 2003

Now you're thinking with portals!

Ryouga Inverse posted:

"If not (whatever) do this" is less clear to you than "unless (whatever) do this"? I mean, one of them is a common English construct.


There are many common natural language constructs that have no business whatsoever belonging in a programming environment. In my case I find "unless" somewhat foreign (and less clear than if-not) because I'm largely steeped in C#/C++.

If you can't figure out how to negate a boolean expression and require keywords like "unless" in your language then you probably aren't going to be a successful programmer.


pokeyman posted:


Calling something "redundant" doesn't imply it's a worthless feature; we've covered this. Stop using that as a crutch, and just explain your opinion.

It's simple - redundancy breeds inconsistency and inconsistency leads to incomprehensible code bases. Probably the worst example of this is Perl because there are so many ways to express the same functionality. Each programmer has their own idea of what they like, one may use "if (!condition) { blat }", another "blat if (!condition)", a third may use "unless (condition) { blat }", and a fourth "blat unless (condition)".

When I'm working in an area of code that other people are working on and I come across something that isn't what I would think as idiomatic my mind is divorced from finding out what's going on in the code temporarily to figure out why the pattern was chosen. This is where coding standards come into play -- they help enforce consistent styles and practices so that people only really need to think about the problem at hand rather than why certain syntactic elements in the code were chosen. But if your coding standard dictates which of the conditional styles above are to be used then you've eliminated the need to have the alternate methods at all. If this is the case then redundancy has lead to these language extensions being worthless.

ymgve
Jan 2, 2004


:dukedog:
Offensive Clock

Flobbster posted:

"Subtract and Branch if Less Than or Equal to Zero"

Is this actually enough for a computer to be Turing complete?

ehnus
Apr 16, 2003

Now you're thinking with portals!

ymgve posted:

Is this actually enough for a computer to be Turing complete?

Yes.

Zhentar
Sep 28, 2003

Brilliant Master Genius

Gazpacho posted:

I understand that everyone has their own sense of code aesthetics, I just wouldn't use it as the basis for calling something a coding horror when my solution is not really much better in production.

The horror is not the original programmer's failure to use negation, so much as the comment suggesting that the original programmer is unaware that negation is even possible.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

ymgve posted:

Is this actually enough for a computer to be Turing complete?

Note that you do need either memory cells to be unbounded or an unbounded number of cells. Models with bounded memory are never Turing-equivalent.

j4cbo
Nov 1, 2004
huh?

rjmccall posted:

Note that you do need either memory cells to be unbounded or an unbounded number of cells. Models with bounded memory are never Turing-equivalent.

You need the cells themselves to be unbounded, since there's no way to refer to an unbounded number of cells with a value of bounded range.

For what it's worth, even C isn't Turing complete unless you let "char" be an unbounded value (i.e. any natural or integer, rather than -128 to 127 or some such). This is because the size of any pointer must be a multiple of the size of a single char, and if pointers are of finite dimension, then you can only reach a bounded number of memory addresses.

Functional languages, like SML, OCaml, Haskell, and Lisp/Scheme, are generally Turing-complete without any extra weirdness. Their implementations usually aren't, of course.

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

j4cbo posted:

For what it's worth, even C isn't Turing complete...

The C standard defines recursion, wouldn't that qualify it as being Turing complete (for values of "Turing complete" that incorporate resource limits) despite the data-width issues?

Avenging Dentist
Oct 1, 2005

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

j4cbo posted:

This is because the size of any pointer must be a multiple of the size of a single char, and if pointers are of finite dimension

The first part of this does not imply the second part.

j4cbo
Nov 1, 2004
huh?

Avenging Dentist posted:

The first part of this does not imply the second part.

The sizeof operator result "is an integer" according to the spec, so it can't be infinity. Or is that not what you meant?

ymgve
Jan 2, 2004


:dukedog:
Offensive Clock
This is all just theoretical bickering, though. To me it is "turing complete enough" if you can make a compiler for language xxx in C, and you can make a compiler for C in language xxx.

Avenging Dentist
Oct 1, 2005

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

j4cbo posted:

The sizeof operator result "is an integer" according to the spec, so it can't be infinity. Or is that not what you meant?

"Integer" in the ISO standard is understood to refer to the integral types in the language, which make no explicit mandate that the values be finite. It's being pedantic, but so are you. (It would be stupid, for instance, for sizeof to return an integer larger than can be represented by the available integral types, so just "is an element of Z" isn't what the standard is referring to. Besides that, the grammar rules for integer constants clearly allow constants of infinite length.)

Incidentally, a conforming implementation of ISO C can have unbounded char values if it wants. The standard says nothing whatsoever about the size of a byte, and in fact goes out of its way to provide for systems where a byte is not 8 bits.

Avenging Dentist fucked around with this message at 04:46 on Apr 13, 2009

j4cbo
Nov 1, 2004
huh?

Avenging Dentist posted:

"Integer" in the ISO standard is understood to refer to the integral types in the language, which make no explicit mandate that the values be finite. It's being pedantic, but so are you. (It would be stupid, for instance, for sizeof to return an integer larger than can be represented by the available integral types, so just "is an element of Z" isn't what the standard is referring to. Besides that, the grammar rules for integer constants clearly allow constants of infinite length.)

Incidentally, a conforming implementation of ISO C can have unbounded char values if it wants. The standard says nothing whatsoever about the size of a byte, and in fact goes out of its way to provide for systems where a byte is not 8 bits.

Infinite and unbounded (arbitrarily large) aren't the same thing. And yes, of course I'm being pedantic. :)

That latter bit was my point - it's fine by the spec for char to be unbounded, and in fact is required for the language to be "actually" Turing-complete.

Avenging Dentist
Oct 1, 2005

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

j4cbo posted:

Infinite and unbounded (arbitrarily large) aren't the same thing. And yes, of course I'm being pedantic. :)

If you have infinite space (required for TC) you can define a decimal integer literal equal to aleph-0 (by way of writing a decimal expansion with aleph-0 digits). I mean, that's part of the basis of the proof that R is uncountable.

floWenoL
Oct 23, 2002

j4cbo posted:

That latter bit was my point - it's fine by the spec for char to be unbounded, and in fact is required for the language to be "actually" Turing-complete.

Unless the spec also bounds stack space (which I don't think it does, given that it doesn't even mandate a stack), the boundedness of pointer size does not mean that C is not Turing-complete. You can "cheat" and use the unbounded stack to do whatever you want (e.g., implement the lambda calculus).

floWenoL fucked around with this message at 05:10 on Apr 13, 2009

shrughes
Oct 11, 2008

(call/cc call/cc)
Unless somebody points to a piece of standard that says otherwise, there's no reason a char can't be bounded between -128 and 127 while sizeof(int) == 4 where there is no bound on the possible value an int may contain.

Edit: The reason was that you'd be limited to having 2^n distinct int values at any given time without being limited to having 2^n distinct ints.

But if you're limited to having at most 2^n distinct ints, then that might violate some other rule of the language.

shrughes fucked around with this message at 05:20 on Apr 13, 2009

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
C is Turing-complete. Turing-completeness does not require that an unbounded amount of memory be simultaneously addressable; after all, that is not true of Turing machines themselves.

j4cbo posted:

You need the cells themselves to be unbounded, since there's no way to refer to an unbounded number of cells with a value of bounded range.

With a single value, no, but that's not what I said.

EDIT: of course that's inapropos if you're assuming a single-instruction machine without indirect addressing, which you might be, since I suppose that's what I was directly responding to.

rjmccall fucked around with this message at 05:59 on Apr 13, 2009

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

rjmccall posted:

C is Turing-complete. Turing-completeness does not require that an unbounded amount of memory be simultaneously addressable; after all, that is not true of Turing machines themselves.

I think it depends on the definition of Turing Complete you use. In the strictest sense, a Universal Turing machine requires an unbounded tape and any resource-limited machine cannot fit that definition.

That said, most people use the looser definition where any language that would be Turing Complete when run on some theoretical unbounded machine is considered TC.

Dijkstracula
Mar 18, 2003

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

But we're talking about languages, independent of any real-life machines. It's what the grammar can express that we're interested in, and not technicalities like sizeof(void*) or memory addressibility.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

TRex EaterofCars posted:

I think it depends on the definition of Turing Complete you use. In the strictest sense, a Universal Turing machine requires an unbounded tape and any resource-limited machine cannot fit that definition.

Unbounded, not infinite. If you formalize C as running on a theoretical machine with finite memory, then yes, your statement is correct; but if you formalize it as running on a machine with the full capabilities of, say, an IBM PC AT, then its space is theoretically unbounded, because if it runs out of space locally it can pause execution and say "Insert a new disk in drive A:".

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

rjmccall posted:

Unbounded, not infinite. If you formalize C as running on a theoretical machine with finite memory, then yes, your statement is correct; but if you formalize it as running on a machine with the full capabilities of, say, an IBM PC AT, then its space is theoretically unbounded, because if it runs out of space locally it can pause execution and say "Insert a new disk in drive A:".

Yes but you'd run out of matter eventually. I feel dirty for how pedantic this is getting :(

Adbot
ADBOT LOVES YOU

necrobobsledder
Mar 21, 2005
Lay down your soul to the gods rock 'n roll
Nap Ghost

Dijkstracula posted:

But we're talking about languages, independent of any real-life machines. It's what the grammar can express that we're interested in, and not technicalities like sizeof(void*) or memory addressibility.
That's the real crux of the problem. No real computer is a true Turing machine, so we shouldn't be using pure theoretical terms to describe Turing Completeness for real machines by the principle of transitivity. For example, if a language spec does not allow infinite revisions or extensions, I'd say it's pretty much not Turing complete.

Regardless, none of this helps me get porn to my computer faster and is thus meaningless.

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