1513: "Code Quality"

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

Moderators: Moderators General, Prelates, Magistrates

User avatar
sardia
Posts: 5812
Joined: Sat Apr 03, 2010 3:39 am UTC

1513: "Code Quality"

Postby sardia » Fri Apr 17, 2015 4:03 am UTC

Image
"I honestly didn't think you could even USE emoji in variable names. Or that there were so many different crying ones."

It's been a long time since I coded anything, but yea it always ends up a mess unless you were super anal retentive about it.

User avatar
Khaz
Posts: 72
Joined: Wed Sep 03, 2008 4:20 am UTC
Location: Ontario, Canada
Contact:

Re: 1513: "Code Quality"

Postby Khaz » Fri Apr 17, 2015 4:19 am UTC

I'm actually really intrigued by the last panel. Anyone feel like solving that problem?

For an arbitrary "transcript" of bytes of length N, if you repeatedly change a random byte and recompile, how many attempts will you expect it to take before it runs?

I guess you can get the worst case scenario by just taking a list of operations that can't crash the program and finding the probability of the transcript being composed entirely of them...

User avatar
rhomboidal
Posts: 760
Joined: Wed Jun 15, 2011 5:25 pm UTC
Contact:

Re: 1513: "Code Quality"

Postby rhomboidal » Fri Apr 17, 2015 4:21 am UTC

At least he thoroughly and properly commented his code with, "/* 0MG 0MG 0MG THIS IS SO AWFUL I KNOW */"

User avatar
slinches
Slinches get Stinches
Posts: 959
Joined: Tue Mar 26, 2013 4:23 am UTC

Re: 1513: "Code Quality"

Postby slinches » Fri Apr 17, 2015 4:24 am UTC

I read the second frame as "This is like being in a house built by a child using nothing but a hatchet and a picture of a horse"

I think it's better that way

User avatar
WanderingLinguist
Posts: 230
Joined: Tue May 22, 2012 5:14 pm UTC
Location: Seoul
Contact:

Re: 1513: "Code Quality"

Postby WanderingLinguist » Fri Apr 17, 2015 4:25 am UTC

Ugh, I don't know how I feel about this one. The implication that being self-taught leads to messy code bothers me. Maybe you can guess that I'm self-taught. But in all my years of programming, and working with many other engineers, I have yet to see a significant correlation between code quality and being self-taught. I've seen perfectly messy code from people with Ph.D's in computer science. When it comes to code quality, experience seem to be the major determining factor. Someone who has spent significant time working on a project with other engineers and dealing with other people's code is generally going to produce cleaner code, at least in my experience.

That said, the remaining three panels are hilarious.

MidSpeck
Posts: 1
Joined: Fri Apr 17, 2015 4:33 am UTC

Re: 1513: "Code Quality"

Postby MidSpeck » Fri Apr 17, 2015 4:36 am UTC

Regarding the alt text: it is possible to use emoji in some languages. For example, Swift. Search "swift emoji" for a nice example.

RogueCynic
Posts: 359
Joined: Sun Nov 22, 2009 10:23 pm UTC

Re: 1513: "Code Quality"

Postby RogueCynic » Fri Apr 17, 2015 4:45 am UTC

Code is like shit. It only smells if it isn't yours. Good comic though.
I am Lord Titanius Englesmith, Fancyman of Cornwood.
See 1 Kings 7:23 for pi.
If you put a prune in a juicer, what would you get?

Mirkwood
Posts: 70
Joined: Mon Dec 06, 2010 9:10 am UTC

Re: 1513: "Code Quality"

Postby Mirkwood » Fri Apr 17, 2015 5:12 am UTC

Khaz wrote:I'm actually really intrigued by the last panel. Anyone feel like solving that problem?

For an arbitrary "transcript" of bytes of length N, if you repeatedly change a random byte and recompile, how many attempts will you expect it to take before it runs?

I guess you can get the worst case scenario by just taking a list of operations that can't crash the program and finding the probability of the transcript being composed entirely of them...

Logic suggests the lower limit of probability for any attempt is 1/N, since changing the first byte to your language's comment symbol will validate whatever follows. Assuming single-character comment commands, of course.

User avatar
neoliminal
Posts: 626
Joined: Wed Feb 18, 2009 6:39 pm UTC

Re: 1513: "Code Quality"

Postby neoliminal » Fri Apr 17, 2015 5:41 am UTC

I've heard rumors of languages that, given valid ASCII, would run no matter what. That all input was valid and produced some kind of output.

Since I couldn't find such a language, I started writing one. I call it Garbage. The tagline is "Garbage in, Garbage out." because all valid programs which you input produce valid programs as output.
http://www.amazon.com/dp/B0073YYXRC
Read My Book. Cost less than coffee. Will probably keep you awake longer.
[hint, scary!]

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

Re: 1513: "Code Quality"

Postby commodorejohn » Fri Apr 17, 2015 5:49 am UTC

WanderingLinguist wrote:Ugh, I don't know how I feel about this one. The implication that being self-taught leads to messy code bothers me. Maybe you can guess that I'm self-taught. But in all my years of programming, and working with many other engineers, I have yet to see a significant correlation between code quality and being self-taught.

This. I've seen horrorshows by the formally-educated and clean, readable code by the self-taught (I'd like to think I fall into this category, though that's probably not for me to judge - I try for it, at least,) as well as the other way around. I've never observed a noticeable tendency for either group to fall more toward one side of the spectrum. I do think they tend to show different strengths and weaknesses generally (self-taught programmers seem to have a tendency to favor hacky, "clever" solutions where simpler, more straightforward ones would do the job just as well, while the formally-educated seem likelier to show counterproductive blind devotion to trendy techniques or technologies - particularly whatever was the Hot New Thing when they were in college,) but as for a significant correlation with general code quality? I'm not seeing it.

And of course there's the question of what "self-taught" even means in terms of programming, anyway. Are we talking "has never cracked a textbook and learned structured programming from QBASIC tutorial sites?" "Made it all the way through C++ For Dummies but only took gunsmithing at community college?" Or "owns every volume of The Art of Computer Programming?" Likewise, with what do we contrast it?
"'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.

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

Re: 1513: "Code Quality"

Postby commodorejohn » Fri Apr 17, 2015 5:52 am UTC

neoliminal wrote:I've heard rumors of languages that, given valid ASCII, would run no matter what. That all input was valid and produced some kind of output.

Since I couldn't find such a language, I started writing one.

I don't think it actually accepts every character in the ASCII set since it predates ASCII, but the canonical example of such a language is TECO. An example from the Wikipedia page, calculating pi to an arbitrary number of digits:

Code: Select all

GZ0J\UNQN"E 40UN ' BUH BUV HK
 QN< J BUQ QN*10/3UI
 QI< \+2*10+(QQ*QI)UA B L K QI*2-1UJ QA/QJUQ
 QA-(QQ*QJ)-2\ 10@I// -1%I >
 QQ/10UT QH+QT+48UW QW-58"E 48UW %V ' QV"N QV^T ' QWUV QQ-(QT*10)UH >
 QV^T @^A/
 /HKEX$$

Intuitive, no?
"'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
neoliminal
Posts: 626
Joined: Wed Feb 18, 2009 6:39 pm UTC

Re: 1513: "Code Quality"

Postby neoliminal » Fri Apr 17, 2015 5:56 am UTC

Intuitive? Meh, overrated. What it needs to do is take any input. So, for example, this sentence and produce output. Going to look it up now. Thanks for the heads up.

commodorejohn wrote:
neoliminal wrote:I've heard rumors of languages that, given valid ASCII, would run no matter what. That all input was valid and produced some kind of output.

Since I couldn't find such a language, I started writing one.

I don't think it actually accepts every character in the ASCII set since it predates ASCII, but the canonical example of such a language is TECO. An example from the Wikipedia page, calculating pi to an arbitrary number of digits:

Code: Select all

GZ0J\UNQN"E 40UN ' BUH BUV HK
 QN< J BUQ QN*10/3UI
 QI< \+2*10+(QQ*QI)UA B L K QI*2-1UJ QA/QJUQ
 QA-(QQ*QJ)-2\ 10@I// -1%I >
 QQ/10UT QH+QT+48UW QW-58"E 48UW %V ' QV"N QV^T ' QWUV QQ-(QT*10)UH >
 QV^T @^A/
 /HKEX$$

Intuitive, no?
http://www.amazon.com/dp/B0073YYXRC
Read My Book. Cost less than coffee. Will probably keep you awake longer.
[hint, scary!]

User avatar
Dr What
Posts: 69
Joined: Wed Dec 26, 2012 6:43 am UTC

Re: 1513: "Code Quality"

Postby Dr What » Fri Apr 17, 2015 6:10 am UTC

I CAN HAZ EMOJEEEEEES?

int :( , :cry: ;
printf("..\n");
scanf("%d", &:();
if ( :( == 2 )
printf(" :P \n");
else
{
for ( :cry: = 2 ; :cry: <= :( - 1 ; :cry:++ )
{
if ( :( % :cry: == 0 )
break;
}
if ( :cry: != :( )
printf(" :D \n");
else
printf(" :P \n");
}
return 0;
}

User avatar
Qaanol
The Cheshirest Catamount
Posts: 3035
Joined: Sat May 09, 2009 11:55 pm UTC

Re: 1513: "Code Quality"

Postby Qaanol » Fri Apr 17, 2015 6:20 am UTC

Probably worth mentioning that Swift not only allows emoji in variable names, but actually provides an example of it in the introductory documentation.
wee free kings

User avatar
Quercus
Posts: 1558
Joined: Thu Sep 19, 2013 12:22 pm UTC
Location: London, UK
Contact:

Re: 1513: "Code Quality"

Postby Quercus » Fri Apr 17, 2015 6:27 am UTC

"okay, I'll read a style guide"
"Don't you dare - you're our new secret weapon for this year's IOCCC"

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

Re: 1513: "Code Quality"

Postby Envelope Generator » Fri Apr 17, 2015 6:31 am UTC

neoliminal wrote:I've heard rumors of languages that, given valid ASCII, would run no matter what. That all input was valid and produced some kind of output.


I remember when I was a kid in the DOS era I would look at the exe files of games and, having no idea how programs are made, try to make my own by creating a mess of random ASCII characters, naming it .exe and running it. I mentioned this to an older programmer a few years ago and he remarked that if I'd named the file .com instead of .exe it'd somehow have been a valid program although I can't remember what the reason was.
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.

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

Re: 1513: "Code Quality"

Postby commodorejohn » Fri Apr 17, 2015 6:55 am UTC

The reason is that .COM files have no header or validation information - they're simply a binary dump of a program. DOS loads the entire file into a single 64KB segment starting at address 0x100 within that segment, then calls the procedure that it assumes must start at address 0x100. (This is a holdover from CP/M, which did the exact same thing.)
"'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.

ps.02
Posts: 378
Joined: Fri Apr 05, 2013 8:02 pm UTC

Re: 1513: "Code Quality"

Postby ps.02 » Fri Apr 17, 2015 7:03 am UTC

Envelope Generator wrote:I remember when I was a kid in the DOS era I would look at the exe files of games and, having no idea how programs are made, try to make my own by creating a mess of random ASCII characters, naming it .exe and running it. I mentioned this to an older programmer a few years ago and he remarked that if I'd named the file .com instead of .exe it'd somehow have been a valid program although I can't remember what the reason was.

Valid in the sense that MS-DOS would have at least tried to run it. Microsoft's .EXE format started with a structured header with fields dictating where the actual code was and how it would be run. If you just randomly type, the odds of getting something that MS-DOS would honor as a valid .EXE are vanishingly small. .COM, by contrast, was just a pile of executable code that got loaded into memory and launched from byte zero - no parsing or validation at all.

commodorejohn wrote:This. I've seen horrorshows by the formally-educated and clean, readable code by the self-taught (I'd like to think I fall into this category, though that's probably not for me to judge - I try for it, at least,) as well as the other way around. I've never observed a noticeable tendency for either group to fall more toward one side of the spectrum.

Yeah, this. I haven't noticed a correlation either. I also agree, as you say later, that it's hard to define "self-taught" in the first place. In my own case, I've had some actual computer programming education, but the majority of the programming knowledge and experience that I actually use is self-taught.

Also, in my younger days, if you had 2 programmers, one clean-cut and one with a ponytail, it would be the guy with the ponytail who was self-taught, not the clean-cut guy.

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

Re: 1513: "Code Quality"

Postby Envelope Generator » Fri Apr 17, 2015 8:08 am UTC

TECO looks wonderfully insane.
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.

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

Re: 1513: "Code Quality"

Postby Xenomortis » Fri Apr 17, 2015 8:12 am UTC

I think that this one strikes a little too close to home...
Image

User avatar
sfmans
Posts: 98
Joined: Mon Jun 23, 2014 9:09 am UTC
Location: High Peak, UK

Re: 1513: "Code Quality"

Postby sfmans » Fri Apr 17, 2015 8:22 am UTC

Qaanol wrote:Probably worth mentioning that Swift not only allows emoji in variable names, but actually provides an example of it in the introductory documentation.

Every last bit of excitement, interest and hope I had for Swift has just evaporated in that instant. If such a moronic decision made it onto the feature discussion agenda, let alone got formally proposed, let alone got passed, approved and implemented, that is insane; I think I'd rather spend the rest of my working life debugging Access database macros written by drunk blind illiterate gong scourers.

And hey, Randall, get out of our github.

DR6
Posts: 171
Joined: Thu Nov 01, 2012 1:44 pm UTC

Re: 1513: "Code Quality"

Postby DR6 » Fri Apr 17, 2015 8:55 am UTC

sfmans wrote:Every last bit of excitement, interest and hope I had for Swift has just evaporated in that instant. If such a moronic decision made it onto the feature discussion agenda, let alone got formally proposed, let alone got passed, approved and implemented, that is insane; I think I'd rather spend the rest of my working life debugging Access database macros written by drunk blind illiterate gong scourers.

And hey, Randall, get out of our github.


It's just a consequence of allowing Unicode. In that example, they were just saying "yes, you can actually use any unicode symbol"! Allowing Unicode in variable names is a sensible decision: lots of languages do it. I'm surprised to see so many people complaining about that: it's not like anyone is forcing you to use them, or like people were likely to think it's actually a good idea to use them. Not using Swift for allowing emojis is like not using Python for using # for comments instead of //. I don't know much about Swift, so I don't know if it's a good language of not, but if there's valid criticism of Swift, this isn't it.

Later they use another emoji in an example(a string, not a variable name) to show that the language handles unicode correctly, which is a good thing.

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

Re: 1513: "Code Quality"

Postby orthogon » Fri Apr 17, 2015 9:11 am UTC

You often get the opposite effect if you try to paste MATLAB code into an e-mail, or Skype, or IRC or whatever. A submatrix or vector can be indicated by, for example A(2:7,3:5), and you can omit one or both of the limits to indicate "first" or "last" as appropriate. Hence you often get stuff like A(3:4,:) which gets turned into A(3:4, :). It's kind of embarrassing in the midst of a learned discussion when your interlocutor thinks you've suddenly turned into a cutesy teenager.
xtifr wrote:... and orthogon merely sounds undecided.

Yu_p
Posts: 44
Joined: Wed Oct 12, 2011 9:00 am UTC

Re: 1513: "Code Quality"

Postby Yu_p » Fri Apr 17, 2015 9:40 am UTC

I wonder how much time is lost in numerical science in various fields, because many scientists never bother about software-development aspects, as long as they can get their short-term numbers. (May directly affect my PhD thesis...)

orthogon wrote:You often get the opposite effect if you try to paste MATLAB code into an e-mail, or Skype, or IRC or whatever. A submatrix or vector can be indicated by, for example A(2:7,3:5), and you can omit one or both of the limits to indicate "first" or "last" as appropriate. Hence you often get stuff like A(3:4,:) which gets turned into A(3:4, :). It's kind of embarrassing in the midst of a learned discussion when your interlocutor thinks you've suddenly turned into a cutesy teenager.


Skype additionally has introduced the feature that code between two * will be converted to bold-font. Unlike e.g. markdown or org-mode however, the formatting is even applied, if the * is standing alone or in the middle of a word. "a*b*c" and "a * b * c" will therefore become "abc" and "a b c" respectively. Skype ALSO has autocorrection enabled by default even for the desktop client and disabling it requires changing Windows 8's system-wide app-setting for autocorrection, which also may mess with code-input (though hopefully it doesn't mess with pasted code).

So yes, I can entirely relate to issues arising from formatting features in messengers, especially on notebooks/desktop systems where it doesn't even make sense (why not use Ctrl+B instead?), especially with Skype which doesn't even have a properly documented way to disable these features.

User avatar
Quercus
Posts: 1558
Joined: Thu Sep 19, 2013 12:22 pm UTC
Location: London, UK
Contact:

Re: 1513: "Code Quality"

Postby Quercus » Fri Apr 17, 2015 10:10 am UTC

orthogon wrote:You often get the opposite effect if you try to paste MATLAB code into an e-mail, or Skype, or IRC or whatever. A submatrix or vector can be indicated by, for example A(2:7,3:5), and you can omit one or both of the limits to indicate "first" or "last" as appropriate. Hence you often get stuff like A(3:4,:) which gets turned into A(3:4, :). It's kind of embarrassing in the midst of a learned discussion when your interlocutor thinks you've suddenly turned into a cutesy teenager.


On the Elite:Dangerous forums the game is often referred to as E:D. This renders as E :D, which I have to say I kind of like.


Yu_p wrote:I wonder how much time is lost in numerical science in various fields, because many scientists never bother about software-development aspects, as long as they can get their short-term numbers. (May directly affect my PhD thesis...)


Uh, me too. Exacerbated by the fact that a) I'm new to coding b) I'm the only one in my lab who codes c) I can't see a situation where I would/could ever reuse the code from this project even if it was written with re-usability in mind (which it isn't). I comfort myself with the fact that at least I know that what I am doing is awful, kludgey hacking.

User avatar
Yubtzock
Posts: 148
Joined: Sat Apr 18, 2009 7:37 pm UTC
Location: Breslau/Wrocław

Re: 1513: "Code Quality"

Postby Yubtzock » Fri Apr 17, 2015 10:18 am UTC

Emoji in variable/object names might not be such a bad idea for memorisation purposes.
Creating new ones might have an overhead so it's probably for ones that are going to be used a bit more often. Retyping them might be an issue, OTOH most dev environments have some auto-finish functionality for known names.

Point being: even the most descriptive name might not save me from delving into documentation (while bloating the code layout), but I might remember what that sad little face did due to a capability of a human mind to make face/picture/emotion associations.

...but it would be a bad idea for all the other reasons. Including arguments between the devs why a certain variable simply CAN NOT have this or that face.

Also, because the emoji used as the first one in each application would probably be T_T and that'd make programming feel sad.

User avatar
chalkie
Posts: 43
Joined: Wed Feb 24, 2010 10:03 am UTC
Location: River Trent, UK

Re: 1513: "Code Quality"

Postby chalkie » Fri Apr 17, 2015 10:52 am UTC

Damn - just tried emoji in VHDL and C#, neither seem to support it :(

Quercus wrote:On the Elite:Dangerous forums the game is often referred to as E:D. This renders as E :D, which I have to say I kind of like.


I wonder what the correlation between XKCD readers and Elite:Dangerous players is? (Using the sample set of people currently in my room, I get a coeffiecient of 1. (I am on my own though)).

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

Re: 1513: "Code Quality"

Postby orthogon » Fri Apr 17, 2015 11:29 am UTC

Interestingly, I hadn't heard or read the word emoji until perhaps a month ago, but now suddenly everyone is using it as though they'd always known it. I presume it was coined in Japanese some time ago - when and why did it suddenly make the leap into English? Google ngrams finds no instances at all, but admittedly only goes up to about 2010:

Spoiler:
emoticon.PNG
xtifr wrote:... and orthogon merely sounds undecided.

User avatar
Quercus
Posts: 1558
Joined: Thu Sep 19, 2013 12:22 pm UTC
Location: London, UK
Contact:

Re: 1513: "Code Quality"

Postby Quercus » Fri Apr 17, 2015 11:45 am UTC

orthogon wrote:Interestingly, I hadn't heard or read the word emoji until perhaps a month ago, but now suddenly everyone is using it as though they'd always known it. I presume it was coined in Japanese some time ago - when and why did it suddenly make the leap into English? Google ngrams finds no instances at all, but admittedly only goes up to about 2010:


Good video on the history of emoji from one of my favourite youtubers, Tom Scott. And he should know, he is one of the (reluctant) developers of (I kid you not) an emoji only messenger app. It started out as a joke down the pub, then they got overcommitted and made promises to people, and had to actually make the thing, which turned out to be a tiny bit more complicated than they expected. It's pretty funny.

User avatar
Flumble
Yes Man
Posts: 1944
Joined: Sun Aug 05, 2012 9:35 pm UTC

Re: 1513: "Code Quality"

Postby Flumble » Fri Apr 17, 2015 12:02 pm UTC

orthogon wrote:Interestingly, I hadn't heard or read the word emoji until perhaps a month ago, but now suddenly everyone is using it as though they'd always known it. I presume it was coined in Japanese some time ago - when and why did it suddenly make the leap into English? Google ngrams finds no instances at all, but admittedly only goes up to about 2010:

Spoiler:
emoticon.PNG

Interesting, I've seen emoji for the first time a couple of years ago. IIRC, it was because someone with an Apple product included "unknown" characters in their messages. It turned out that Apple's default font had symbols for the emoji part of unicode already, while Window's and Linux's fonts didn't/don't.
However, I haven't seen the word gain popularity ever since.

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

Re: 1513: "Code Quality"

Postby cellocgw » Fri Apr 17, 2015 12:28 pm UTC

Speaking of bad programming practices (and GOOMMATLABWTFR),
Why do so many people think it's a good idea to keep the MATLAB editor open and comment/uncomment sections of a script masquerading as a function as their method of changing the input arguments between runs?

It's insanely painful to figure out which blocks of commented code need to be un-commented as a group, not to mention which are intended for use and which are the cruft they look like.

Then again, Mathematica >> R >> MATLAB >> Excel >>MathCad
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

KarenRei
Posts: 265
Joined: Sat Jun 16, 2012 10:48 pm UTC

Re: 1513: "Code Quality"

Postby KarenRei » Fri Apr 17, 2015 12:34 pm UTC

DR6 wrote:It's just a consequence of allowing Unicode. In that example, they were just saying "yes, you can actually use any unicode symbol"! Allowing Unicode in variable names is a sensible decision: lots of languages do it. I'm surprised to see so many people complaining about that: it's not like anyone is forcing you to use them, or like people were likely to think it's actually a good idea to use them. Not using Swift for allowing emojis is like not using Python for using # for comments instead of //. I don't know much about Swift, so I don't know if it's a good language of not, but if there's valid criticism of Swift, this isn't it.


This. I know, to people in English speaking countries unicode is just an inconvenience. To everyone else, it's the difference between whether you can use your language or not in even your own personal development projects for your own personal use. It's yet another force trying to obliterate all other languages in favor of English. (yes, you can use transliterations to English character sets, but I've tried that aplenty and it just invites problems, from the coder forgetting to write the transliteration, getting confused between the need to transliterate in code but not in comments or filenames / makefiles, collisions in transliterated words, and so forth.)

And I know, the main reason many English-only speakers don't want unicode variable name support is out of fears that they'll open up a file and not understand any of it, or not be able to type any of it. Well, first off, that buys you nothing if the coder had to transliterate their language to ascii - even worse, the transliteration may ruin any chance Google Translate or online dictionaries would have given you to understand what they're trying to say. Secondly, if they're expecting it to be some international collaborative project, they'll write it in English if they're capable (and if they don't know or aren't comfortable with English, then don't pick on them over that fact). And third, is it really hard to do search-replace before you start messing with a piece of code if a character is too hard for you to type, or to use a unicode transliterator?

It's a small, rare inconvenience to you. It's a big, constant inconvenience to others.

KarenRei
Posts: 265
Joined: Sat Jun 16, 2012 10:48 pm UTC

Re: 1513: "Code Quality"

Postby KarenRei » Fri Apr 17, 2015 12:39 pm UTC

Khaz wrote:I'm actually really intrigued by the last panel. Anyone feel like solving that problem?

For an arbitrary "transcript" of bytes of length N, if you repeatedly change a random byte and recompile, how many attempts will you expect it to take before it runs?

I guess you can get the worst case scenario by just taking a list of operations that can't crash the program and finding the probability of the transcript being composed entirely of them...


If you just randomly change bytes you're looking at an NP-complete problem. You stand effectively zero chance of it working for even a short program. However, an evolutionary algorithm could probably manage it, with the changes being the insertion of valid tokens between words and the weighting factor being a "smart" weighting of compile-time errors (but not simply the number of errors - some types of errors don't even show up until you fix enough other, more fundamental errors, so you can reduce the error count from 1 and suddenly get 100 new ones, and that's still making progress)

I'd be very curious to see what the code comes out looking like :) Though I imagine a lot of it would just end up being variable declarations; perhaps you'd have to penalize variable declarations to keep the code interesting.

hdhale
Posts: 46
Joined: Fri Jul 30, 2010 5:09 pm UTC

Re: 1513: "Code Quality"

Postby hdhale » Fri Apr 17, 2015 1:33 pm UTC

My first question regarding any bit of code is: does it yield the results you want? If yes, then everything else is just about efficiency. Only Computer Science instructors give credit of code that looks pretty but doesn't work.

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

Re: 1513: "Code Quality"

Postby richP » Fri Apr 17, 2015 1:45 pm UTC

WanderingLinguist wrote:Ugh, I don't know how I feel about this one. The implication that being self-taught leads to messy code bothers me. Maybe you can guess that I'm self-taught. But in all my years of programming, and working with many other engineers, I have yet to see a significant correlation between code quality and being self-taught. I've seen perfectly messy code from people with Ph.D's in computer science. When it comes to code quality, experience seem to be the major determining factor. Someone who has spent significant time working on a project with other engineers and dealing with other people's code is generally going to produce cleaner code, at least in my experience.

That said, the remaining three panels are hilarious.

You are absolutely correct about experience as the biggest driver of good code. Remember, a PhD in computer science != a PhD in learning how to code.

That's not a knock on formal teaching, PhDs, or the CS field. CS is focused on the science of computers, so it's heavy on theory and analysis. When we look at another human's ability to code, we're focused on the art of coding.

Good coding is based a lot on things like consistency in naming conventions/indentation/etc. Good coders will also need to be able to effectively communicate with others on their team, the ability to comprehend requirements docs, write unit tests, and live with the project's rev control concept. A "good coder" doesn't necessarily understand how to prove their program using formal logic, and may not even be able to come up with an explanation of if their program is O(n) versus O(log(n)) or o-whatever.*

The formal CS side is much more focused on theory than application. A good computer scientist understands things like performance analysis, and a ton of abstract design concepts. If they have limited experience in actually writing code, then their code will tend to look messy.

A major project would need both skill sets, not necessarily in the same people. Ideally you'd have at least some knowledge from the art and from the science.

*granted, there are some CS concepts relating to code organization, data abstraction, etc. that qualify as "good code", and some of those can be self-taught. Conversely, at least some of art of coding should be picked up along the way through a CS program

CharlieP
Posts: 397
Joined: Mon Dec 17, 2012 10:22 am UTC
Location: Nottingham, UK

Re: 1513: "Code Quality"

Postby CharlieP » Fri Apr 17, 2015 1:47 pm UTC

orthogon wrote:Interestingly, I hadn't heard or read the word ________ until perhaps a month ago, but now suddenly everyone is using it as though they'd always known it.


This has happened worryingly many times in my life.
This is my signature. There are many like it, but this one is mine.

dp2
Posts: 345
Joined: Wed Aug 18, 2010 3:06 pm UTC

Re: 1513: "Code Quality"

Postby dp2 » Fri Apr 17, 2015 1:53 pm UTC

I don't think self-taught coders are necessarily messier, but that doesn't stop them from frequently saying this before a code review.

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

Re: 1513: "Code Quality"

Postby orthogon » Fri Apr 17, 2015 2:01 pm UTC

cellocgw wrote:Speaking of bad programming practices (and GOOMMATLABWTFR),
Why do so many people think it's a good idea to keep the MATLAB editor open and comment/uncomment sections of a script masquerading as a function as their method of changing the input arguments between runs?

It's insanely painful to figure out which blocks of commented code need to be un-commented as a group, not to mention which are intended for use and which are the cruft they look like.

Then again, Mathematica >> R >> MATLAB >> Excel >>MathCad

MATLAB does let you use %% to divide a script into sections that you can run individually, a bit like (i.e. they almost certainly borrowed the idea from) cells of a Mathematica notebook.

I use MATLAB, Mathematica and Excel and really think it's horses for courses - they all fall short of perfection in different ways.

Mathematica is pretty amazing for even existing, but it feels like a kind of hacked together AI and it annoys and impresses me in equal measure. Its behaviour is highly erratic: once, I had an expression that was symmetrical with regard to x and y: its "simplified" version had |x|2 but (y Conjugate[y]) instead of |y|2. Getting it to plot anything involves massive amounts of trial-and-error; most of the time you get empty axes and/or "foo is not a machine-sized real number at bar". You have to add and remove "Evaluate" until you get a result. Last time I used it, I had Plot [someFunction,..] and it wouldn't plot, but when I said myFunction=someFunction and plotted myFunction, it worked. This kind of weirdness happens every time I try to use it. I can almost always do a better job of simplifying something than it can, and at times I've resorted to doing it by hand then doing FullSimplify[originalFunction==mySimplifiedFunction] and seeing if it shakes down to "True".

I'm sure there are good reasons for all this, but the level of knowledge of its inner workings required to make it do anything in finite time seem far too high. And, for goodness sake, version 10 and there's still only one level of undo? This is 2015!

I also have a lot of trouble with the whole notebook concept, because you tend to end up executing the cells in an arbitrary order, going back and changing something and then re-running it. As a result, there's not a very good audit trail for how you got the output you did, and if you reload the notebook later there may be output that you can't replicate.

As I say, all the tools have their uses, and I admire the ambition behind Mathematica. But I politely disagree that the tools can be put in a fully ordered set like that.
xtifr wrote:... and orthogon merely sounds undecided.

clockworkbookreader
Posts: 31
Joined: Fri Feb 10, 2012 6:11 am UTC

Re: 1513: "Code Quality"

Postby clockworkbookreader » Fri Apr 17, 2015 2:02 pm UTC

RogueCynic wrote:Code is like shit. It only smells if it isn't yours. Good comic though.


Heh. This is true for any job, not just programming. If you didn't do the work and it gets the job done, don't bitch about the means.
In the event of pneumothorax, stab me with an 18g angiocath just above the second rib in the midclavicular line.
Thank you.

User avatar
Quercus
Posts: 1558
Joined: Thu Sep 19, 2013 12:22 pm UTC
Location: London, UK
Contact:

Re: 1513: "Code Quality"

Postby Quercus » Fri Apr 17, 2015 2:04 pm UTC

hdhale wrote:My first question regarding any bit of code is: does it yield the results you want? If yes, then everything else is just about efficiency. Only Computer Science instructors give credit of code that looks pretty but doesn't work.

I agree, with the caveat that bad but apparently functional code is sometimes worse than code which doesn't work at all. I'm thinking about code that works now, but relies on fragile hacks and thus will inevitably go up in smoke at some point; or code that works but is full of horrible security holes. At least if it doesn't work people aren't tempted to try and deploy/support it.


Return to “Individual XKCD Comic Threads”

Who is online

Users browsing this forum: Yahoo [Bot] and 41 guests