Funny/sad. It’s easy to imagine a world where programming is a second language and we can all wield computers as flexible tools and not pre-built channels. So much emphasis and reward-structure for “process efficiency.”
I remember reading this randomly during my first year undergrad CS. I got a bit sweaty. What if I can’t do the FizzBuzz? Sure enough it worked under 10 mins, with beginner Python knowledge. I remember too needing a second iteration to add in the (var % 3) && (var % 5) condition, which I had forgotten on my first attempt. I still rarely get a program to run after first writing it without any debugging. Programming is an interactive process that takes time! Qualification tests should take that into account.
I do also feel that (some part of) programming/development has become more abstract and frankly, easier. With all the frameworks and high-level languages available, it’s possible to produce a simple front-end web app without knowing about the existence of the modulo operator. However, that doesn’t excuse job applicants from learning the basics of algorithmic reasoning, data structures & math. They will be needed sooner or later.
I mean... this is from >10 years ago. Having just interviewed a few engineers last year and the year before I can say that I didn't encounter a single applicant who couldn't do significantly more complex things than the ones mentioned here.
I don't know Perl but it's easy enough to follow along for the most part. I'm curious though, what does this do?
$|++;
Also, sorry about the formatting issues! It's cool to see people posting code here. We should update the formatting guide to include code blocks. Fenced code blocks are supported and are definitely the easiest way. Indenting 4 spaces also triggers it but it's a pain to edit.
It's not really too important in this program, it would act well without it, even if the output is redirected to a file or piped through another command, such as "less" which I used while testing the program. Perl programmers often put it in defensively when writing something that is going to be redirected into a file or a pipe, it avoids surprises when characters get written into a buffer instead of the device you want, then thousands of characters later, it all suddenly appears.
Things like this can act weird in some circumstances:
./foo.pl > log_file.txt &
tail -f log_file.txt
Unix/Linux commands, if you're a Windows-only person, they'll seem unfamiliar, sorry I don't know your background.
In the example program, the output is all written to the file before you can even type in the tail command, but in a program that runs for hours or days, the file and the output of the tail command will make the output appear to come sporadically as the buffer flushes even if data is written more often.
Here's pretty much the canonical article about it:
Perl can be that way. Some people call it a write-only language because of that. I try to make my Perl easy to read, but sometimes something like $|++ sneaks in without a comment to explain it.
Some Perl can be totally unintelligible to anyone but the author, sometimes even the author can't figure it out a few years later. I really, really try to avoid that. It does lead to some interesting things like the Perl poetry contests. I couldn't find as much of that as I wanted with a quick search, but I did find some good ones.
The vast divide between those who can program and those who cannot program is well known. I assumed anyone applying for a job as a programmer had already crossed this chasm. Apparently this is not a reasonable assumption to make.
This is particularly hard for smaller companies that hire a software engineer but don't have a big IT group. It's much harder for the business users/managers to catch this sort of thing - and it is very costly not to.
"Wow. Just wow." sums it up pretty well. I am astounded.
Won’t it be easier to catch this if they don’t have a big IT group? Inadequacies would pop up and would be very noticeable if there aren’t many people to manage.
Yes and no. In my own experience we were building a pricing tool for wholesale distributors. We do this stuff in excel and calculators but it is a rules based system with some judgement involved. We knew if we built a program we could do more of it and sell it as a product. We hired a programmer. The problem was there wasn't anyone to filter the BS. So a 'programmer' can tell you that blah blah blah blah blah and that's why things are delayed/behind etc. And you don't know the difference, you hired a programmer because you're not an expert on the software your a subject matter expert. Six months later with very little to show for it we started looking again. We lucked out with our second hire. We kept the first hire for another year before we realized he wasn't ever going to deliver anything. I've always thought we just had a bad apple (in programming, he was a great person otherwise)- reading this article made me think that maybe the problem is more wide spread.
Classic article! Here's a solution using PostgreSQL to mix things up. Two nice features of doing it this way are that you can add any number of params in the VALUES clause and the divisor and word literals are only each specified once in the expression. No magic numbers, variables or statements. I love SQL!
SELECT
array_to_string(
array_agg(word),
'',
number::text
)
FROM
generate_series(
1,
100
) AS number
LEFT JOIN (
VALUES
(3, 'Fizz'),
(5, 'Buzz')
) AS param (
divisor,
word
) ON
number % divisor = 0
GROUP BY
number
ORDER BY
number;
Almost as fast as typing it in. Not the fewest possible lines, nor the most elegant, but super fast and easy.
At my past job there were only of us who coded, so we didn't need to hire anyone else to do so, but finding people with even the most trivial Unix admin skills was just as hard as finding a real programmer is for the author of the article.
Copy and paste:
<cfloop index="i" from="1" to="100">
<cfoutput>#i#</cfoutput>
<cfif i mod 3 eq 0 and i mod 5 eq 0>FizzBuzz
<cfelseif i mod 3 eq 0>Fizz
<cfelseif i mod 5 eq 0>Buzz
</cfif>
<br>
</cfloop>
Funny/sad. It’s easy to imagine a world where programming is a second language and we can all wield computers as flexible tools and not pre-built channels. So much emphasis and reward-structure for “process efficiency.”
OpenAI has made some pretty amazing advances when it comes to code generation by way of natural language input:
https://www.youtube.com/watch?time_continue=98&v=fZSFNUT6iY8&feature=emb_logo
I remember reading this randomly during my first year undergrad CS. I got a bit sweaty. What if I can’t do the FizzBuzz? Sure enough it worked under 10 mins, with beginner Python knowledge. I remember too needing a second iteration to add in the
(var % 3) && (var % 5)
condition, which I had forgotten on my first attempt. I still rarely get a program to run after first writing it without any debugging. Programming is an interactive process that takes time! Qualification tests should take that into account.I do also feel that (some part of) programming/development has become more abstract and frankly, easier. With all the frameworks and high-level languages available, it’s possible to produce a simple front-end web app without knowing about the existence of the modulo operator. However, that doesn’t excuse job applicants from learning the basics of algorithmic reasoning, data structures & math. They will be needed sooner or later.
I mean... this is from >10 years ago. Having just interviewed a few engineers last year and the year before I can say that I didn't encounter a single applicant who couldn't do significantly more complex things than the ones mentioned here.
Sorry about the formatting on the last post, line got run together, here it is with extra spaces hopefully easier to read:
#!/usr/bin/perl -w
use strict;
use warnings;
$|++;
my ($ktr);
for ($ktr = 1; $ktr <= 100; $ktr++)
}
I don't know Perl but it's easy enough to follow along for the most part. I'm curious though, what does this do?
Also, sorry about the formatting issues! It's cool to see people posting code here. We should update the formatting guide to include code blocks. Fenced code blocks are supported and are definitely the easiest way. Indenting 4 spaces also triggers it but it's a pain to edit.
https://www.markdownguide.org/extended-syntax/#fenced-code-blocks
It's not really too important in this program, it would act well without it, even if the output is redirected to a file or piped through another command, such as "less" which I used while testing the program. Perl programmers often put it in defensively when writing something that is going to be redirected into a file or a pipe, it avoids surprises when characters get written into a buffer instead of the device you want, then thousands of characters later, it all suddenly appears.
Things like this can act weird in some circumstances:
./foo.pl > log_file.txt &
tail -f log_file.txt
Unix/Linux commands, if you're a Windows-only person, they'll seem unfamiliar, sorry I don't know your background.
In the example program, the output is all written to the file before you can even type in the tail command, but in a program that runs for hours or days, the file and the output of the tail command will make the output appear to come sporadically as the buffer flushes even if data is written more often.
Here's pretty much the canonical article about it:
https://perl.plover.com/FAQs/Buffering.html
Very interesting, thanks for the explanation! Never would have guessed that in a million years. Such cryptic syntax.
Perl can be that way. Some people call it a write-only language because of that. I try to make my Perl easy to read, but sometimes something like $|++ sneaks in without a comment to explain it.
Some Perl can be totally unintelligible to anyone but the author, sometimes even the author can't figure it out a few years later. I really, really try to avoid that. It does lead to some interesting things like the Perl poetry contests. I couldn't find as much of that as I wanted with a quick search, but I did find some good ones.
Stuff like this:
https://www.perlmonks.org/index.pl?node_id=111157
Wow. Just wow.
This is particularly hard for smaller companies that hire a software engineer but don't have a big IT group. It's much harder for the business users/managers to catch this sort of thing - and it is very costly not to.
"Wow. Just wow." sums it up pretty well. I am astounded.
Won’t it be easier to catch this if they don’t have a big IT group? Inadequacies would pop up and would be very noticeable if there aren’t many people to manage.
Yes and no. In my own experience we were building a pricing tool for wholesale distributors. We do this stuff in excel and calculators but it is a rules based system with some judgement involved. We knew if we built a program we could do more of it and sell it as a product. We hired a programmer. The problem was there wasn't anyone to filter the BS. So a 'programmer' can tell you that blah blah blah blah blah and that's why things are delayed/behind etc. And you don't know the difference, you hired a programmer because you're not an expert on the software your a subject matter expert. Six months later with very little to show for it we started looking again. We lucked out with our second hire. We kept the first hire for another year before we realized he wasn't ever going to deliver anything. I've always thought we just had a bad apple (in programming, he was a great person otherwise)- reading this article made me think that maybe the problem is more wide spread.
Excellent points. It's easy to see how this can happen at a small company. Reminds me of George Costanza's quote about mechanics:
Classic article! Here's a solution using PostgreSQL to mix things up. Two nice features of doing it this way are that you can add any number of params in the VALUES clause and the divisor and word literals are only each specified once in the expression. No magic numbers, variables or statements. I love SQL!
http://sqlfiddle.com/#!17/9eecb/55585
Sorry about the totally messed up formatting, it looks good until I save it, then...
#!/usr/bin/perl -w
use strict; use warnings;
$|++;
my ($ktr);
for ($ktr = 1; $ktr <= 100; $ktr++) { if ($ktr % 3 == 0) { print "Fizz"; } if ($ktr % 5 == 0) { print "Buzz"; } if (($ktr % 3) && ($ktr % 5)) { print $ktr; } print "\n"; }
Almost as fast as typing it in. Not the fewest possible lines, nor the most elegant, but super fast and easy.
At my past job there were only of us who coded, so we didn't need to hire anyone else to do so, but finding people with even the most trivial Unix admin skills was just as hard as finding a real programmer is for the author of the article.
Go to: https://trycf.com/
Copy and paste: <cfloop index="i" from="1" to="100"> <cfoutput>#i#</cfoutput> <cfif i mod 3 eq 0 and i mod 5 eq 0>FizzBuzz <cfelseif i mod 3 eq 0>Fizz <cfelseif i mod 5 eq 0>Buzz </cfif> <br> </cfloop>
:)
Applicable to life beyond programming too. Loved it.