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
HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
Attempts to make programming "work" just like written english are the worst. How can someone experienced enough to design and implement their own programming language not see how that's a terrible idea?

Adbot
ADBOT LOVES YOU

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

vOv posted:

The dumbest implicit boolean conversion I ever saw was some Python HTML library that treats a node with no children as falsy.

:commissar:

HappyHippo posted:

Attempts to make programming "work" just like written english are the worst. How can someone experienced enough to design and implement their own programming language not see how that's a terrible idea?

SQL does OK. Opinions vary about AppleScript, but HyperCard is held in generally high regard.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

vOv posted:

The dumbest implicit boolean conversion I ever saw was some Python HTML library that treats a node with no children as falsy.

That sounds like a fairly standard "empty containers are falsy" kind of thing. Though if nodes are anything beyond merely containers then it becomes more problematic.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Subjunctive posted:

C99 has _Bool, which is a constrained integer -- casting a value to _Bool will always produce 0 or 1, which is not the case for casting to a general purpose integer.

Yeah, but that being a C99 extension matters. They didn't have that in the initial design, and you can't retroactively change it.

Subjunctive posted:

C and C++ also test truthiness of pointers differently from integers, since NULL may be a non-zero bit pattern on some architectures.

That's not "differently from integers". The integer rule is not comparison against a zero bit pattern, it's comparison against 0, which would matter on a target using a sign-magnitude representation. It's also an important difference for floats.

Steve French
Sep 8, 2003

vOv posted:

The dumbest implicit boolean conversion I ever saw was some Python HTML library that treats a node with no children as falsy.

to be honest, I don't view that as significantly worse than treating [], "", and 0 as falsy

:can:

vOv
Feb 8, 2014

TooMuchAbstraction posted:

That sounds like a fairly standard "empty containers are falsy" kind of thing. Though if nodes are anything beyond merely containers then it becomes more problematic.


Steve French posted:

to be honest, I don't view that as significantly worse than treating [], "", and 0 as falsy

:can:

The problem is that empty HTML nodes are very common for stuff like <img>, <meta>, and <script>. Although apparently they fixed it at some point.

Steve French
Sep 8, 2003

vOv posted:

The problem is that empty HTML nodes are very common for stuff like <img>, <meta>, and <script>. Although apparently they fixed it at some point.

turns out that empty arrays, empty strings, and the number zero are also pretty common!

eth0.n
Jun 1, 2012

M31 posted:

Give an error, I don't know. At least give a warning or something. Yes, the only difference between this and Java is essentially implicit versus explicit casting.

code:
class A {}

class B extends A {
    def foo() {
        println 'foo';
    }
}

A a = new B();
a.foo(); // print foo

a = new A();
a.foo(); // throws MissingMethodException at runtime
Why even bother with types at that point? It's not just this though, Groovy is full of implicit behaviour and weird DSL's at random places.

OK, yeah, but that's way weirder than your original example. An implicit cast on return is pretty normal and predictable. An implicit cast when you call a method through a reference is much less so.

Fergus Mac Roich
Nov 5, 2008

Soiled Meat

M31 posted:

Give an error, I don't know. At least give a warning or something. Yes, the only difference between this and Java is essentially implicit versus explicit casting.

code:
class A {}

class B extends A {
    def foo() {
        println 'foo';
    }
}

A a = new B();
a.foo(); // print foo

a = new A();
a.foo(); // throws MissingMethodException at runtime
Why even bother with types at that point? It's not just this though, Groovy is full of implicit behaviour and weird DSL's at random places.

This! That example is in the official documentation:
code:
// equivalent to: paint(wall).with(red, green).and(yellow)
paint wall with red, green and yellow
This is just terrible in every way.

I see what you're saying. This example is downright bizarre.


Steve French posted:

to be honest, I don't view that as significantly worse than treating [], "", and 0 as falsy

:can:

A node in a tree can still have meaning beyond its having children, though.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

rjmccall posted:

That's not "differently from integers". The integer rule is not comparison against a zero bit pattern, it's comparison against 0, which would matter on a target using a sign-magnitude representation. It's also an important difference for floats.

My point was that it's not the case that "everything is an integer" for purposes of truthiness, because you can have false values for which the same bit pattern interpreted as an integer would be considered true (not equal to 0).

Steve French
Sep 8, 2003

Fergus Mac Roich posted:

A node in a tree can still have meaning beyond its having children, though.

Sure, it's worse, my point is just that I think falsiness is generally a bad thing. The only things that should be considered false are false, and nil/null, if you absolutely must have nil/null as a thing.

sarehu
Apr 20, 2007

(call/cc call/cc)
Everything except true and false should result in a run time error.

Soricidus
Oct 21, 2010
freedom-hating statist shill

sarehu posted:

Everything except true and false should result in a run time error.

In boolean contexts, or just generally?

sarehu
Apr 20, 2007

(call/cc call/cc)
1 + 2
error: 1 is not true or false
2
error: 2 is not true or false
true == true
error: == is not true or false
true
error: is not the true true

Axiem
Oct 19, 2005

I want to leave my mind blank, but I'm terrified of what will happen if I do

sarehu posted:

Everything except true and false should result in a run time error.

Everything except the Boolean type as a conditional should result in a compile-time error.

Dylan16807
May 12, 2010

fleshweasel posted:

JavaScript's handling of truthiness is really interesting because the || and && operators actually return the arguments of whatever type you happen to have provided. That's why people can use || like
code:
var thing = maybeNull || defaultValue;
JS will return the first truthy argument it finds from left to right.

Honestly I use truthiness in my JS code...sue me. It's often enough that I want to know that a string is not null and also not empty. Since I write TypeScript, I at least know the goddamn thing is a string.

Zaxxon posted:

that's pretty common in dynamically typed languages. Ruby, Python (2.7 at least) and lua all do the same thing.

edit: by "the same thing" I mean the binary operators returning the values they were supplied with instead of coercing things to bools. Not having bizzare "truthy/falsy" rules.

Note C#'s weird way of doing it. It returns neither the value on either side nor a Boolean.

code:
// A || B
if(A) return A; else return A | B;

// A && B
if(A) return A & B; else return A;

Sedro
Dec 31, 2008

Dylan16807 posted:

Note C#'s weird way of doing it. It returns neither the value on either side nor a Boolean.

code:
// A || B
if(A) return A; else return A | B;

// A && B
if(A) return A & B; else return A;
I don't get it.

C# lets you indirectly overload || and && via true and false "operators", which are implicit conversions from your user-defined type to boolean

ErIog
Jul 11, 2001

:nsacloud:

Steve French posted:

to be honest, I don't view that as significantly worse than treating [], "", and 0 as falsy

:can:

Would you say that treating 0 as truthy is worse than treating it as falsey, though?

:getin: :can:

xzzy
Mar 5, 2009

I want my language to spit out 500 word essays about how it feels when evaluating my expression and justify relying on a gut feeling to produce the result.

raminasi
Jan 25, 2005

a last drink with no ice

xzzy posted:

I want my language to spit out 500 word essays about how it feels when evaluating my expression and justify relying on a gut feeling to produce the result.

Sounds like a possible INTERCAL extension.

Dylan16807
May 12, 2010

Sedro posted:

I don't get it.

C# lets you indirectly overload || and && via true and false "operators", which are implicit conversions from your user-defined type to boolean

Let's say you implement the true and false operators on your custom number type T.

T(6) && T(10) is not true or false or T(6) or T(10). It's T(2).

http://csharppad.com/gist/07f03054562c64e2e4ac

Dylan16807 fucked around with this message at 03:28 on Jan 16, 2016

Steve French
Sep 8, 2003

ErIog posted:

Would you say that treating 0 as truthy is worse than treating it as falsey, though?

:getin: :can:

No. In the pissing match between Ruby and Python, this is one of the things that I most firmly believe Ruby gets more right.

Flobbster
Feb 17, 2005

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

Axiem posted:

Everything except the Boolean type as a conditional should result in a compile-time error.

Everything except Subtract And Branch If Negative should result in a compile-time error :science:

Linear Zoetrope
Nov 28, 2011

A hero must cook
Everything except the unary one tape turing machine should be banned.

Pavlov
Oct 21, 2012

I've long been fascinated with how the alt-right develops elaborate and obscure dog whistles to try to communicate their meaning without having to say it out loud
Stepan Andreyevich Bandera being the most prominent example of that

Jsor posted:

Everything except the unary one tape turing machine should be banned.

Then you'll just have people arguing that those are technically linear bounded automata, because a turing machine technically has an infinite tape.

fritz
Jul 26, 2003

xzzy posted:

I want my language to spit out 500 word essays about how it feels when evaluating my expression and justify relying on a gut feeling to produce the result.

Compiler all sending a note to your grandma about how disappointed it is in you.

McGlockenshire
Dec 16, 2005

GOLLOCKS!

Subjunctive posted:

"0 but true"

Perl is the best language ever just because of the glorious poo poo you can pull.

code:
die unless "0 but true";

Carbon dioxide
Oct 9, 2012

Pavlov posted:

Then you'll just have people arguing that those are technically linear bounded automata, because a turing machine technically has an infinite tape.

Just glue the ends together and it's practically infinite.

qntm
Jun 17, 2009

xzzy posted:

I want my language to spit out 500 word essays about how it feels when evaluating my expression

Let me tell you about C++ templates.

FamDav
Mar 29, 2008

qntm posted:

Let me tell you about C++ templates.

It's not a real template error unless it doesn't fit in working memory

Pizzatime
Apr 1, 2011

code:
if (scene4_foreskin.y > 114)
{
	scene4_foreskin.y -= 2;
}
else
{
	scene4_foreskin.y = 114;
	if (scene4_omega.x < 0)
	{
		scene4_omega.x += 2;
	}
	else
	{
		scene4_omega.x = 0;
		if (scene4_roadkill.y < 0)
		{
			scene4_roadkill.y += 2;
		}
		else
		{
			scene4_roadkill.y = 0;
			if (scene4_down.x > 296)
			{
				scene4_down.x -= 2;
			}
			else
			{
				scene4_down.x = 296;
				if (scene4_sign.y > 67)
				{
					scene4_sign.y -= 2;
				}
				else
				{
					scene4_sign.y = 67;
					State = 14;
				}
			}
		}
	}
}


"I know what I'm doing."

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Wikipedia's tech is poo poo. Watch as a PNG file magically returns a application/x-www-form-urlencoded Content-Type!

https://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Cholesterol.svg/200px-Cholesterol.svg.png

iSurrender
Aug 25, 2005
Now with 22% more apathy!
code:
var thing = maybeNull || defaultValue;
C# introduced the ?? operator for this (in C#6, late 2014), so you can say what you mean instead of abusing weird behaviour in clever ways.

Dumlefudge
Feb 25, 2013

iSurrender posted:

code:
var thing = maybeNull || defaultValue;
C# introduced the ?? operator for this (in C#6, late 2014), so you can say what you mean instead of abusing weird behaviour in clever ways.

?? has existed in C# for a good while prior to C# 6. I think you may be mixing it up with the ?. operator

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

iSurrender posted:

code:

var thing = maybeNull || defaultValue;

C# introduced the ?? operator for this (in C#6, late 2014), so you can say what you mean instead of abusing weird behaviour in clever ways.





?? Has been around for years

C# 6 introduced ?. for shorthand null method chaining (bind with the arg being the lhs in the maybe monad)

But you could emulate it with a suitable class via linq

iSurrender
Aug 25, 2005
Now with 22% more apathy!

Dumlefudge posted:

?? has existed in C# for a good while prior to C# 6. I think you may be mixing it up with the ?. operator

Yep, my bad.

Steve French
Sep 8, 2003

iSurrender posted:

code:

var thing = maybeNull || defaultValue;

C# introduced the ?? operator for this (in C#6, late 2014), so you can say what you mean instead of abusing weird behaviour in clever ways.

They should have unintroduced null instead.

kitten smoothie
Dec 29, 2001

https://github.com/samshadwell/TrumpScript/blob/master/test/test_files/fizz_buzz.txt

code:
Make Donald have 15000000.
Nothing is 1000000 minus 1000000.
The fortune of Hillary is nothing.
As long as, Donald has more than Hillary; Do this:
If, Donald over 15000000 is nothing; Then: say "Fiorina Biden"!
Else if, Donald over 5000000 is nothing; Then: say "Fiorina"!
Else if, Donald over 3000000 is nothing; Then: say "Biden"!
Else: say Donald!
The fortune of Donald is, old Donald minus 1000000;
Amazing!
America is Great.
This isn't a horror, per se, this is pretty awesome.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Suspicious Dish posted:

Wikipedia's tech is poo poo. Watch as a PNG file magically returns a application/x-www-form-urlencoded Content-Type!

https://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Cholesterol.svg/200px-Cholesterol.svg.png

Their image viewer poo poo is so obviously some incompetent web astronaut's weird obsession. "Lets make every image format work on every browser" is a fine sentiment but all they've done is make them all half-work, including the ones that already worked just fine. It's also pointless now that there are only three major renderers, all of which have good support for most common formats.

Adbot
ADBOT LOVES YOU

Xarn
Jun 26, 2015
Found this in a homework friend needed help with.
code:
#define int unsigned
Allrig :suicide:

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