SilasBarta comments on Open Thread: March 2010, part 2 - Less Wrong

4 Post author: RobinZ 11 March 2010 05:25PM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (334)

You are viewing a single comment's thread. Show more comments above.

Comment author: cousin_it 12 March 2010 12:18:52PM *  3 points [-]

Programming is different from medicine. All the good programmers I know have learned their craft on the job. Silas doesn't have to wait and learn without getting paid, his current skill level is already in demand.

But that's tangential. More importantly, whenever I hear the word "maintainability" I feel like "uh oh, they wanna sell me some doctrinaire bullshit". Maintainability is one of those things everyone has a different idea of. In my opinion you should just try to solve each problem in the most natural manner, and maintainability will happen automatically.

Allow me to illustrate with an example. One of my recent projects was a user interface for IPTV set-top boxes. Lots and lots of stuff like "my account", "channels I've subscribed to", et cetera. Now, the natural way to solve this problem is to have a separate file (a "page") for each screen that the user sees, and ignore small amounts of code duplication between pages. If you get this right, it's pretty much irrelevant how crappily each individual page is coded, because it's only five friggin' kilobytes and a maintenance programmer will easily find and change any functionality they want. On the other hand, if you get this wrong... and it's really fucking distressing how many experienced programmers manage to get this wrong... making a Framework with a big Architecture that separates each page into small reusable chunks, perfectly Factored, with shiny and impeccable code... maintenance tasks become hell. And so it is with other kinds of projects too, in fact with most projects I've faced in my life. Focus on finding the stupid, straightforward, natural solution, and it will be maintainable with no effort.

Comment author: SilasBarta 17 March 2010 04:49:58PM 1 point [-]

Sorry for not reading the follow-up discussion earlier.

Silas doesn't have to wait and learn without getting paid, his current skill level is already in demand.

What do you mean by this? How can I be hired for programming based on just what I have now? Who hires people at my level, and how would they know whether I'm lying about my abilities? (Yes, I know, interviews, but to they have to thin the field first.) Is there some major job finding trick I'm missing?

My degree isn't in comp sci (it's in mech. engineering and I work in structural), and my education in C++ is just high school AP courses and occasional times when I need automation.

Also, I've looked at the requests on e.g. rent-a-coder and they're universally things I can't get to a working .exe (though of course could write the underlying algorithms for).

Comment author: thomblake 17 March 2010 05:46:48PM 3 points [-]

Is there some major job finding trick I'm missing?

The best 'trick' for job-finding is to get one from someone you know. I'm not sure what you can do with that.

Generally speaking, there are a lot of people who aren't good at thinking but have training in programming, and comparatively not a lot of people who are good at thinking but not good at programming, and the latter are more valuable than the former. If I were looking for someone entry-level for webdev (and I'm not), I'd be likely to hire you over a random person with a master's degree in computer science and some experience with webdev.

Comment author: SilasBarta 17 March 2010 07:27:51PM 1 point [-]

The best 'trick' for job-finding is to get one from someone you know. I'm not sure what you can do with that.

Heh, that's what I figured, and that's my weak point. (At least you didn't say, "Pff, just find one on the internet!" as some have been known to do.)

If I were looking for someone entry-level for webdev (and I'm not), I'd be likely to hire you over a random person with a master's degree in computer science and some experience with webdev.

Thanks. I don't doubt people would hire me if they knew me, but there is a barrier to overcome.

Comment author: Morendil 17 March 2010 05:55:26PM 2 points [-]

I'm sorry to be the one to break the news to you, but the IT industry has appallingly low standards for hiring.

For instance, you may be able to get a programming job without at any point being asked to produce a code portfolio or to program in front of an interviewer.

I'd still be keen, by the way, to help you through a specific example that's giving you trouble compiling. I believe that when smart people get confused by things which their designers ought to have made simple, it's an opportunity to learn about improving similar designs.

Comment author: bogus 18 March 2010 05:51:26PM *  12 points [-]

A quick solution to the FizzBuzz quiz:

HAI
CAN HAS STDIO?
I HAS A VAR
IM IN YR LOOP
UP VAR!!1
IZ VAR LEFTOVER 15 LIEK 0?
YARLY VISIBLE "FizzBuzz"
NOWAI IZ VAR LEFTOVER 3 LIEK 0?
YARLY VISIBLE "Fizz"
NOWAI IZ VAR LEFTOVER 5 LIEK 0?
YARLY VISIBLE "Buzz"
NOWAI VISIBLE VAR
KTHX
IZ VAR NOT SMALR THAN 100? KTHXBYE
IM OUTTA YR LOOP
KTHXBYE
Comment author: AdeleneDawner 18 March 2010 05:57:49PM *  2 points [-]

*in ur LessWrong, upvotin' ur memez*

Comment author: Morendil 18 March 2010 05:56:44PM *  1 point [-]

For the first time here I'm having a Buridan moment - I don't know whether to upvote or downvote the above.

Comment author: AdeleneDawner 18 March 2010 06:33:21PM 1 point [-]

It might help to note that dialects - and I don't see any reason not to consider both the various kinds of 'netspeak and the various programming languages as such, in most cases of human-to-human interaction - are almost exclusively used as methods of signaling cultural affiliation. In this case, I parsed Bogus' use of 'netspeak as primarily an avoidance of affiliation with formal programming culture (which tends to linger even when programs are set out in standard English, in my experience), and secondarily a way of bringing in the emotional affect of the highly-social 'netspeak culture.

It is 'mammal stuff', but it seems to be appropriate in this instance, to me.

Comment author: Morendil 18 March 2010 06:35:54PM *  0 points [-]

Thanks. I was mostly kidding, but I appreciate the extra perspective.

(Signalling my own affiliation as a true geek, I actually attempted to download a LOLCODE interpreter and run it on the above, but the ones I could get my hands on seem to be broken. I would upvote it if I could run it, and it gave the right answer.)

Comment author: AdeleneDawner 18 March 2010 06:49:26PM *  2 points [-]

integer var

while(1)

{

++var

if (var % 15 == 0)

output "FizzBuz"

else if (var % 3 == 0)

output "Fizz"

else if (var % 5 ==0)

output "Buzz"

else

output var

if !(var<100)

return

}

Looks right to me, though I wound up reformatting the loop a little. That's most likely a result of me being in the habit of using for loops for everything, and forgetting the proper formatting for other kinds, rather than being an actual flaw in the code - I'm willing to give bogus the benefit of the doubt about it, in any case.

Comment author: gregconen 18 March 2010 07:14:20PM 1 point [-]

Pretty much. Both you and bogus apparently forget to put an initial value into var (unless your language of choice automatically initializes them as 0).

Using while(1) with a conditional return is a little bizarre, when you can just go while(var<100).

Of course, my own draft used if(var % 3 == 0 && var % 5 == 0) instead of the more reasonable x%15.

Comment author: AdeleneDawner 18 March 2010 07:25:56PM 1 point [-]

Pretty much. Both you and bogus apparently forget to put an initial value into var (unless your language of choice automatically initializes them as 0).

Mine does, but I'm aware that it's good coding practice to specify anyway. I was maintaining his choice.

Using while(1) with a conditional return is a little bizarre, when you can just go while(var<100).

Yep, but I don't remember how else to signify an intrinsically infinite loop, and bogus' code seems to use an explicit return (which I wanted to keep for accuracy's sake) rather than checking the variable as part of the loop.

My method of choice would be for(var=0; var<100; ++var){} (using LSL format), which skips both explicitly returning and explicitly incrementing the variable.

Comment author: JGWeissman 19 March 2010 03:48:57AM 2 points [-]

Jeff Atwood also makes this meta point about blogging about fizzbuzz:

Evidently writing about the FizzBuzz problem on a programming blog results in a nigh-irresistible urge to code up a solution. The comments here, on Digg, and on Reddit-- nearly a thousand in total-- are filled with hastily coded solutions to FizzBuzz. Developers are nothing if not compulsive problem solvers.

It certainly wasn't my intention, but a large portion of the audience interpreted FizzBuzz as a challenge. I suppose it's like walking into Guitar Center and yelling 'most guitarists can't play Stairway to Heaven!'* You might be shooting for a rational discussion of Stairway to Heaven as a way to measure minimum levels of guitar competence.

But what you'll get, instead, is a blazing guitarpocalypse.

Somehow, the other responses to this comment reminded me of that.

Comment author: RobinZ 19 March 2010 03:53:22AM 0 points [-]

Somehow, I believe this is my fault for having mentioned trying it myself, and for that, I apologize.

Comment author: wedrifid 19 March 2010 03:29:55AM *  1 point [-]

If all you have is regex s/.+/nail/

until(m/j{100}/){s/(j*)$/\1\n\1j/};
s/^(j{15})*$/fizzbuzz/gm;
s/^(j{3})*$/fizz/gm;
s/^(j{5})*$/buzz/gm;
s/^(j+)$/length($1)/gme;
print;

Warning: Do not try this (or any other perl coding) at home!

Comment author: wnoise 18 March 2010 11:40:20PM *  1 point [-]
main = putStr . unlines $ fizzbuzz 100
fizzbuzz m = map f [1..m] where
f n | n `mod` 15 == 0 = "FizzBuzz"
f n | n `mod` 3 == 0 = "Fizz"
f n | n `mod` 5 == 0 = "Buzz"
f n = show n
Comment author: ata 19 March 2010 03:42:40AM *  0 points [-]

I think anyone who applies to a programming job and can't write this (in whatever language) deserves something worse than being politely turned down.

for i in range(1, 101):
if i % 15 == 0: print 'fizzbuzz'
elif i % 3 == 0: print 'fizz'
elif i % 5 == 0: print 'buzz'
else: print i
Comment author: RobinZ 18 March 2010 02:30:14PM 0 points [-]

I tested myself with MATLAB (which makes it quite easy) out of some unnecessary curiosity - it took me about seven minutes, a fair part of which was debugging.

I feel rather ashamed of that, actually.

Comment author: RobinZ 18 March 2010 11:53:36PM *  0 points [-]

As everyone else seems to be posting their code:

% FizzBuzz - print all numbers from 1 to 100, replacing multiples of 3 with
% "fizz", multiples of 5 with "buzz", and multiples of 3 and 5 with
% "fizzbuzz".
clear
clc
for i = 1:100
fb = '';
if length(find(factor(i)==3)) > 0
fb = [fb 'fizz'];
end
if length(find(factor(i)==5)) > 0
fb = [fb 'buzz'];
end
if length(fb) > 0
fprintf([fb '\n'])
else
fprintf('%5.0f\n', i)
end
end

A better program (by which I mean "faster", not "clearer" or "easier to modify" or "easier to maintain") would replace the tests with something less intensive - for example, incrementing two counters (one for 3 and one for 5) and zeroing them when they hit their respective desired factors.

Comment author: Morendil 18 March 2010 02:56:00PM 0 points [-]

I feel rather ashamed of that, actually.

I wouldn't be; I'd take it as (anecdotal) evidence that the craft of programming is systematically undertaught. By which I mean, the tiny, nano-level rules of how best to interact with this strange medium that is code.

(Recently added to my growing backlog of possibly-top-level-post-worthy topics is "how and why programming may be a usefull skill for rationalists to pick up"...)

Comment author: RobinZ 18 March 2010 03:24:58PM *  1 point [-]

I have to admit, I was looking up functions in the docs, too - I would have been a bit faster working in pseudocode on paper.

Edit: Also, my training is in engineering, not comp. sci. - the programming curriculum at my school consists of one MATLAB course.

(Recently added to my growing backlog of possibly-top-level-post-worthy topics is "how and why programming may be a usefull skill for rationalists to pick up"...)

Querying my brain for cached thoughts:

  1. Programming encourages clear thinking - like evolution, it is immune to rationalization.

  2. Thinking in terms of algorithms, rather than problem-answer pairs, and the former generalize.