1537: "Types"

This forum is for the individual discussion thread that goes with each new comic.

Moderators: Moderators General, Prelates, Magistrates

User avatar
Echo244
Posts: 511
Joined: Wed May 20, 2015 9:49 am UTC
Location: Ping! Ping! Ping! Ping!

1537: "Types"

Postby Echo244 » Fri Jun 12, 2015 11:51 am UTC

Image

Title='colors.rgb("blue") yields "#0000FF". colors.rgb("yellowish blue") yields NaN. colors.sort() yields "rainbow";'.

I love the Floor function... but more than that, I'm hoping it has a garbage collection system I can run on Floor(), as my flat could really use that...
Unstoppable force of nature. That means she/her/hers.
Has committed an act of treason.

Polixenes
Posts: 24
Joined: Thu Mar 29, 2012 5:35 pm UTC

Re: 1537: "Types"

Postby Polixenes » Fri Jun 12, 2015 11:59 am UTC

I should be used to not understanding an XKCD by now, but never have I been so far from even a glimmer.

User avatar
rdnetto
Posts: 9
Joined: Fri Nov 13, 2009 5:54 am UTC

Re: 1537: "Types"

Postby rdnetto » Fri Jun 12, 2015 12:07 pm UTC

Is it just me, or does this remind other people of Javascript?

User avatar
Echo244
Posts: 511
Joined: Wed May 20, 2015 9:49 am UTC
Location: Ping! Ping! Ping! Ping!

Re: 1537: "Types"

Postby Echo244 » Fri Jun 12, 2015 12:11 pm UTC

Yeah, something Javascript-y but picking up quirks from other places too, I think...

Every time I try to decide which of these is my favourite, I understand a new one... 3-4, 5, 9, 10 and 13 are delightful, but 11-14 is probably my favourite.

(Shall we leave a job for explainxkcd, or go through them here?)
Unstoppable force of nature. That means she/her/hers.
Has committed an act of treason.

motiz88
Posts: 6
Joined: Mon Nov 19, 2012 6:40 pm UTC

Re: 1537: "Types"

Postby motiz88 » Fri Jun 12, 2015 12:13 pm UTC

Oh man, nerd sniped. I caught myself *this* close to coding a transpiler from this to JavaScript. Though I don't get all of the examples (shall we say "the spec"?) yet.
Oddly enough (and re: @rdnetto), my first instinct upon seeing this comic was that it was about JavaScript. Or, come to think about it, Perl (qntm.org).

Wooloomooloo
Posts: 128
Joined: Wed Mar 16, 2011 8:05 am UTC

Re: 1537: "Types"

Postby Wooloomooloo » Fri Jun 12, 2015 12:18 pm UTC

Neat, but definitely not an Adams-complete language unless it can do this:

Code: Select all

[14]> ?
   => 42

TheEngineer
Posts: 43
Joined: Wed Nov 24, 2010 2:40 pm UTC

Re: 1537: "Types"

Postby TheEngineer » Fri Jun 12, 2015 12:27 pm UTC

rdnetto wrote:Is it just me, or does this remind other people of Javascript?

I was thinking the same. Made me think of of Gary Bernhardt's talk at Codemash 2012.

User avatar
cellocgw
Posts: 1888
Joined: Sat Jun 21, 2008 7:40 pm UTC

Re: 1537: "Types"

Postby cellocgw » Fri Jun 12, 2015 12:29 pm UTC

Dunno what he's going to name this language, but I'm going to recommend "LOLbrainCATSfuck"
https://app.box.com/witthoftresume
Former OTTer
Vote cellocgw for President 2020. #ScienceintheWhiteHouse http://cellocgw.wordpress.com
"The Planck length is 3.81779e-33 picas." -- keithl
" Earth weighs almost exactly π milliJupiters" -- what-if #146, note 7

YetAnotherGeek
Posts: 1
Joined: Mon Apr 07, 2014 6:49 am UTC

Re: 1537: "Types"

Postby YetAnotherGeek » Fri Jun 12, 2015 12:38 pm UTC

I am closely awaiting an implementation of the language :D.

rmsgrey
Posts: 3357
Joined: Wed Nov 16, 2011 6:35 pm UTC

Re: 1537: "Types"

Postby rmsgrey » Fri Jun 12, 2015 12:52 pm UTC

I disagree with 5 - surely it should be: " ' + ' "

JediMaster012
Posts: 14
Joined: Wed Jun 01, 2011 11:56 am UTC

Re: 1537: "Types"

Postby JediMaster012 » Fri Jun 12, 2015 1:07 pm UTC

rmsgrey wrote:I disagree with 5 - surely it should be: " ' + ' "

#5 looks "correct" to me.

Here's my interpretation:

Instead of "" + "", as most languages would parse it, the comic is saying that it is parsed as follows:

""+""

In other words, instead of adding two empty strings and returning an empty string, the first double-quote signifies the start of a string that does not close until the final double-quote.

In Ruby, and many other languages, I would have to escape the inner double-quotes as follows:

Code: Select all

"\"+\""

Or

Code: Select all

'"+"'

User avatar
Locoluis
Posts: 98
Joined: Mon Dec 11, 2006 7:30 pm UTC
Location: Santiago, Chile
Contact:

Re: 1537: "Types"

Postby Locoluis » Fri Jun 12, 2015 1:14 pm UTC

At first I thought it was a quick jab towards Python (which is quite strong-typed, BTW). Now I'm not so sure.

Being careless about data types is sloppy programming, and I don't think it's a good thing when programming languages are too lenient about it.

If you really need to do something that defies common sense, you should explicitly perform all steps required to avoid ambiguity. This is not something that should be as simple as pears + apples.

Sure, it may be annoying if you keep getting stupid errors about incompatible data types, but it's a price you should pay if you want your code to be reliable.
Sueños del Sur - A webcomic about four siblings, their family, friends, adventures and dreams.
http://sds.lgm.cl/

User avatar
FrobozzWizard
Posts: 61
Joined: Wed Feb 02, 2011 2:01 pm UTC

Re: 1537: "Types"

Postby FrobozzWizard » Fri Jun 12, 2015 1:26 pm UTC

rdnetto wrote:Is it just me, or does this remind other people of Javascript?


Up until the use of the [1,2,3] syntax, it reminded me of PHP's ridiculous type rules. And yes, as someone mentioned, it looks vaguely like mangled Python as well.

User avatar
Xenomortis
Not actually a special flower.
Posts: 1420
Joined: Thu Oct 11, 2012 8:47 am UTC

Re: 1537: "Types"

Postby Xenomortis » Fri Jun 12, 2015 1:28 pm UTC

Still more predictable than PHP.
Image

User avatar
orthogon
Posts: 2879
Joined: Thu May 17, 2012 7:52 am UTC
Location: The Airy 1830 ellipsoid

Re: 1537: "Types"

Postby orthogon » Fri Jun 12, 2015 1:39 pm UTC

JediMaster012 wrote:
rmsgrey wrote:I disagree with 5 - surely it should be: " ' + ' "

#5 looks "correct" to me.

Here's my interpretation:

Instead of "" + "", as most languages would parse it, the comic is saying that it is parsed as follows:

""+""

In other words, instead of adding two empty strings and returning an empty string, the first double-quote signifies the start of a string that does not close until the final double-quote.

In Ruby, and many other languages, I would have to escape the inner double-quotes as follows:

Code: Select all

"\"+\""

Or

Code: Select all

'"+"'

Oh, I see. I had a different take on it: In Sinclair BASIC you could use a pair of double quotes within a string to represent a literal double quote, so

Code: Select all

PRINT """Hello,"" said Jane, ""You must be John!"""

would yield

Code: Select all

"Hello," said Jane, "You must be John!"

You're almost certainly right though. Randall isn't old enough or British enough to do a Sinclair BASIC gag (unless the same syntax is used in other BASICs).
xtifr wrote:... and orthogon merely sounds undecided.

rmsgrey
Posts: 3357
Joined: Wed Nov 16, 2011 6:35 pm UTC

Re: 1537: "Types"

Postby rmsgrey » Fri Jun 12, 2015 1:40 pm UTC

JediMaster012 wrote:
rmsgrey wrote:I disagree with 5 - surely it should be: " ' + ' "

#5 looks "correct" to me.

Here's my interpretation:

Instead of "" + "", as most languages would parse it, the comic is saying that it is parsed as follows:

""+""

In other words, instead of adding two empty strings and returning an empty string, the first double-quote signifies the start of a string that does not close until the final double-quote.

In Ruby, and many other languages, I would have to escape the inner double-quotes as follows:

Code: Select all

"\"+\""

Or

Code: Select all

'"+"'


Standard English grammar is to modify the inner quotes rather than the outer

User avatar
Echo244
Posts: 511
Joined: Wed May 20, 2015 9:49 am UTC
Location: Ping! Ping! Ping! Ping!

Re: 1537: "Types"

Postby Echo244 » Fri Jun 12, 2015 2:02 pm UTC

But in... well, whatever language this is, you'd want to alter the way of representing the string to the compiler, rather than its content, yes?
Unstoppable force of nature. That means she/her/hers.
Has committed an act of treason.

Unclevertitle
Posts: 34
Joined: Fri Oct 01, 2010 4:20 am UTC

Re: 1537: "Types"

Postby Unclevertitle » Fri Jun 12, 2015 2:09 pm UTC

I got a kick out of [5], parsing quotes like parentheses, lol.

This would be perhaps the most whimsical language, while also the most infuriating.

richP
Posts: 176
Joined: Wed Aug 17, 2011 3:28 pm UTC

Re: 1537: "Types"

Postby richP » Fri Jun 12, 2015 2:31 pm UTC

cpan install Data::Types::xkcd?

Echo244's alt-text is better than the original.

User avatar
orthogon
Posts: 2879
Joined: Thu May 17, 2012 7:52 am UTC
Location: The Airy 1830 ellipsoid

Re: 1537: "Types"

Postby orthogon » Fri Jun 12, 2015 3:28 pm UTC

Shouldn't 2/0=inf?

(Sorry if that's the joke, but I don't think so; I think it's just a setup for NaP. 0/0 would be a better way of getting NaN.)

NaNs are like the plague, they infect everything they touch. There are different types of NaN, including quiet and signalling varieties. Personally, Peshwari NaNs are my favourite.
xtifr wrote:... and orthogon merely sounds undecided.

Bounty
Posts: 41
Joined: Mon Apr 23, 2012 10:38 pm UTC

Re: 1537: "Types"

Postby Bounty » Fri Jun 12, 2015 3:31 pm UTC

I don't think there's a single language to blame here, and we know Randalls not 'monolingual' when it comes to coding. He's just poking foibles at the entire Set.

The only one I'm still not quite Groking is #5, ... Never mind, just got it...

Favorite is still #10 though, as XKCD is funniest when it shatters the 4th wall.

User avatar
orthogon
Posts: 2879
Joined: Thu May 17, 2012 7:52 am UTC
Location: The Airy 1830 ellipsoid

Re: 1537: "Types"

Postby orthogon » Fri Jun 12, 2015 3:52 pm UTC

(returns from explainxkcd.com) Hmm, in that case, shouldn't [11] be 2+=2? It could have returned 4 (or possibly 2, I can't remember if += returns the old or new value).
xtifr wrote:... and orthogon merely sounds undecided.

commodorejohn
Posts: 1074
Joined: Thu Dec 10, 2009 6:21 pm UTC
Location: Placerville, CA
Contact:

Re: 1537: "Types"

Postby commodorejohn » Fri Jun 12, 2015 5:14 pm UTC

TheEngineer wrote:
rdnetto wrote:Is it just me, or does this remind other people of Javascript?

I was thinking the same. Made me think of of Gary Bernhardt's talk at Codemash 2012.

I came here to make sure this got mentioned, because it is beautiful.
"'Legacy code' often differs from its suggested alternative by actually working and scaling."
- Bjarne Stroustrup
www.commodorejohn.com - in case you were wondering, which you probably weren't.

User avatar
Quizatzhaderac
Posts: 1530
Joined: Sun Oct 19, 2008 5:28 pm UTC
Location: Space Florida

Re: 1537: "Types"

Postby Quizatzhaderac » Fri Jun 12, 2015 5:18 pm UTC

[0]> zero = {}
=> {"null"}
[1]> one = {zero}
=> {"zero"}
[2]> two = {one,zero}
=> {0,"{zero}",null}
[3]> three = {two,zero}
=> {{0,"{zero}",null}, zero, this}
The thing about recursion problems is that they tend to contain other recursion problems.

User avatar
Steve the Pocket
Posts: 682
Joined: Mon Apr 23, 2007 4:02 am UTC
Location: Going downtuuu in a Luleelurah!

Re: 1537: "Types"

Postby Steve the Pocket » Fri Jun 12, 2015 6:15 pm UTC

colors.sort() returning "rainbow" sounds like an awesome (and entirely plausible) Easter egg.
cephalopod9 wrote:Only on Xkcd can you start a topic involving Hitler and people spend the better part of half a dozen pages arguing about the quality of Operating Systems.

Baige.

User avatar
Coyoty
Posts: 195
Joined: Wed Jun 06, 2012 5:56 pm UTC

Re: 1537: "Types"

Postby Coyoty » Fri Jun 12, 2015 6:20 pm UTC

So when God divides by zero, He's NaPping?

User avatar
Envelope Generator
Posts: 582
Joined: Sat Mar 03, 2012 8:07 am UTC
Location: pareidolia

Re: 1537: "Types"

Postby Envelope Generator » Fri Jun 12, 2015 6:25 pm UTC

Yay, I can't remember the last time there was a bonerfied (pronounced bo-NERFied) coding strip on XKCD.
I'm going to step off the LEM now... here we are, Pismo Beach and all the clams we can eat

eSOANEM wrote:If Fonzie's on the order of 100 zeptokelvin, I think he has bigger problems than difracting through doors.

Stealth Tomato
Posts: 6
Joined: Fri Sep 30, 2011 7:09 pm UTC

Re: 1537: "Types"

Postby Stealth Tomato » Fri Jun 12, 2015 6:40 pm UTC

JediMaster012 wrote:Instead of "" + "", as most languages would parse it, the comic is saying that it is parsed as follows:

""+""

In other words, instead of adding two empty strings and returning an empty string, the first double-quote signifies the start of a string that does not close until the final double-quote.


It appears that in this language, double-quotes are greedy - it will take the last quotation mark on the line and assume that to be the end of the quoted string. This is, of course, potentially disastrous to string math and any function that takes multiple strings as parameters.

igorlugosi
Posts: 1
Joined: Fri Jun 12, 2015 6:44 pm UTC

Re: 1537: "Types"

Postby igorlugosi » Fri Jun 12, 2015 6:46 pm UTC

Ha ha, line 11 changes the value of 2 FOREVER!

User avatar
Djehutynakht
Posts: 1546
Joined: Thu Feb 10, 2011 1:37 am UTC

Re: 1537: "Types"

Postby Djehutynakht » Fri Jun 12, 2015 8:03 pm UTC

I am so hopelessly lost.

User avatar
Eternal Density
Posts: 5544
Joined: Thu Oct 02, 2008 12:37 am UTC
Contact:

Re: 1537: "Types"

Postby Eternal Density » Fri Jun 12, 2015 8:39 pm UTC

This is very silly. Nor sure what makes this language great.
How is the object model? Are functions first class objects? Can they be manipulated in equally silly ways? I hope so.
Play the game of Time! castle.chirpingmustard.com Hotdog Vending Supplier But what is this?
In the Marvel vs. DC film-making war, we're all winners.

User avatar
Locoluis
Posts: 98
Joined: Mon Dec 11, 2006 7:30 pm UTC
Location: Santiago, Chile
Contact:

Re: 1537: "Types"

Postby Locoluis » Fri Jun 12, 2015 10:22 pm UTC

Unclevertitle wrote:I got a kick out of [5], parsing quotes like parentheses, lol.


Now that you mention it, there's a language that behaves sort of like that: LOGO.

This is a word: "Hello
This is another one: 5
This is yet another onethe same as above: "5

This is a list containing two words: [Hello world]
This list contains one item: [5]

Code: Select all

? PRINT EQUALP 5 "5
true
? PRINT [5]
5
? PRINT "5
5
? PRINT EQUALP "5 [5]
false
? PRINT EQUALP "5 FIRST [5]
true
? PRINT SUM "5 "2
7
? PRINT SUM [5] "2
SUM doesn't like [5] as input
? PRINT SENTENCE [5] "2
5 2
? PRINT LIST "5 "2
5 2
? PRINT WORD "5 "2
52
? MAKE "RADIUS 2
? MAKE "PI PRODUCT 2 (RADARCTAN 0 1)
? PRINT QUOTIENT (PRODUCT 4 :PI POWER :RADIUS 3) 3
33.5103216382911
Sueños del Sur - A webcomic about four siblings, their family, friends, adventures and dreams.
http://sds.lgm.cl/

Markus__1
Posts: 36
Joined: Wed Apr 20, 2011 6:42 pm UTC

Re: 1537: "Types"

Postby Markus__1 » Fri Jun 12, 2015 10:43 pm UTC

Wooloomooloo wrote:Neat, but definitely not an Adams-complete language unless it can do this:

Code: Select all

[14]> ?
   => 42


But is surely can only do

Code: Select all

[14]> ?
   => 44
:wink:

User avatar
Pfhorrest
Posts: 4607
Joined: Fri Oct 30, 2009 6:11 am UTC
Contact:

Re: 1537: "Types"

Postby Pfhorrest » Fri Jun 12, 2015 11:18 pm UTC

Can anyone explain why lines 13 and 14 are out of order? I feel like I get most of these but not that one.

EDIT: Wait, nevermind, that's just a continuation of the joke on lines 11 and "14".

For those as lost as I was: line 11 is interpreted "as increase the value of the variable 2 by 2". Thus, 2 is henceforth equal to 4.

What should have been line 12 is then line "14".

Line 13 remains unaffected.
Forrest Cameranesi, Geek of All Trades
"I am Sam. Sam I am. I do not like trolls, flames, or spam."
The Codex Quaerendae (my philosophy) - The Chronicles of Quelouva (my fiction)

User avatar
addams
Posts: 9866
Joined: Sun Sep 12, 2010 4:44 am UTC
Location: Oregon Coast: 97444

Re: 1537: "Types"

Postby addams » Sat Jun 13, 2015 1:18 am UTC

TheEngineer wrote:
rdnetto wrote:Is it just me, or does this remind other people of Javascript?

I was thinking the same. Made me think of of Gary Bernhardt's talk at Codemash 2012.

That helped.
Thanks.
Life is, just, an exchange of electrons; It is up to us to give it meaning.

We are all in The Gutter.
Some of us see The Gutter.
Some of us see The Stars.
by mr. Oscar Wilde.

Those that want to Know; Know.
Those that do not Know; Don't tell them.
They do terrible things to people that Tell Them.

sotanaht
Posts: 203
Joined: Sat Nov 27, 2010 2:14 am UTC

Re: 1537: "Types"

Postby sotanaht » Sat Jun 13, 2015 1:55 am UTC

TheEngineer wrote:
rdnetto wrote:Is it just me, or does this remind other people of Javascript?

I was thinking the same. Made me think of of Gary Bernhardt's talk at Codemash 2012.


Most of those actually make sense though. Not in a "this is obviously how code should work" sort of way, but in a "I can understand the thinking behind why this is happening".

This comic though? Not so much.

jlunder
Posts: 2
Joined: Sat Jun 13, 2015 4:07 am UTC

Re: 1537: "Types"

Postby jlunder » Sat Jun 13, 2015 4:16 am UTC

So #8, 3/2 and 1/2 are exactly representable in binary floating point... so I infer that the VM for the language is ternary or something else? For maximum obtuseness.

jlunder
Posts: 2
Joined: Sat Jun 13, 2015 4:07 am UTC

Re: 1537: "Types"

Postby jlunder » Sat Jun 13, 2015 4:18 am UTC

So #8, 3/2 and 1/2 are exactly representable in binary floating point... so I guess the language specifies ternary or some other? For maximum obtuseness :)

User avatar
alvinhochun
Posts: 54
Joined: Wed Nov 14, 2012 3:07 pm UTC

Re: 1537: "Types"

Postby alvinhochun » Sat Jun 13, 2015 7:02 am UTC

Code: Select all

(2/0) == NaN

Code: Select all

(2/0)+2 == NaN + 2 == (Na) + (N + 2) == NaP


`+` have higher precedence than ``!

User avatar
orthogon
Posts: 2879
Joined: Thu May 17, 2012 7:52 am UTC
Location: The Airy 1830 ellipsoid

Re: 1537: "Types"

Postby orthogon » Sat Jun 13, 2015 9:05 am UTC

alvinhochun wrote:

Code: Select all

(2/0) == NaN

Code: Select all

(2/0)+2 == NaN + 2 == (Na) + (N + 2) == NaP

In that case

Code: Select all

[63]> (2/0-N)^16
"Batman!"
xtifr wrote:... and orthogon merely sounds undecided.


Return to “Individual XKCD Comic Threads”

Who is online

Users browsing this forum: moody7277 and 20 guests