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
nielsm
Jun 1, 2009



OddObserver posted:

... Though really, bringing back Pascal might actually not be a horrible idea, either (after adding a string type, of course).

Nobody would write ANSI standard Pascal today. Nobody sane, at least. Give the students FreePascal and have it use Object Pascal mode, I think that may even be default now.
As far as I remember, you then get a boilerplate like this:
code:
program foo;

var
  // variables declared here

begin
  // main program goes here
end.
If that doesn't make sense to someone beginning programming, they probably will never learn anyway. "Here's a program named 'foo', it has these variables, and the actual code begins here, ends here.".

But the more sane option is probably Haskell, a Lisp or an ML on first semester, and then Python on second. On third, throw C++ and Java at them simultaneously.

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->

Orzo posted:

Why? If you really don't know anything about programming, there are certain things you need to understand before method signatures, access modifiers, and argument lists. Have you ever tried to teach any programming to a complete newbie? The entrypoint signature can be overwhelming. Even many introductory books say 'we'll come back to this later, but for now you always need to have this block of code for your program to run.'

This is why we teach people to program with simpler languages with less conceptual overhead.

ToxicFrog
Apr 26, 2008


^^ Or should, anyways. Here we start students off on C because there's no money in the budget for the co-op and non-co-op students to take different courses in first year, and there's apparently no demand in the industry for anything but C and Java. :smithicide:

I see a lot of students in second year who can program in C badly but who can't really program - they get so bogged down in the overhead of learning C that they don't really learn any of the underlying concepts. There were similar issues when they started with Java.

A lot of the profs would rather move first year to Python, but it's never going to happen as long as the people running the co-op program have their heads up their arses.

ToxicFrog fucked around with this message at 16:25 on May 20, 2011

BigRedDot
Mar 6, 2008

Hughlander posted:

Didn't Dijkstra have a fairly famous interview where he said basically that when he was in industry he was writing OSes for an instruction set that wasn't fabbed yet and he had to do everything in his head / on pencil, and that's the way you should do it comma drat it?
I don't know about that, but on the first day of class he did state that he thought programmers would take more care, and would make fewer mistakes, if all programs first had to be chiseled[*] into stone before they were tested.

[*] He had a delightful accent, "chiseled" was pronounced "sizzled"

Zombywuf
Mar 29, 2008

ToxicFrog posted:

I see a lot of students in second year who can program in C badly but who can't really program - they get so bogged down in the overhead of learning C that they don't really learn any of the underlying concepts. There were similar issues when they started with Java.

The overhead of learning C, or the overhead of complex memory management that was taught to them before they were finished learning for loops?

RitualConfuser
Apr 22, 2008

Hughlander posted:

Didn't Dijkstra have a fairly famous interview where he said basically that when he was in industry he was writing OSes for an instruction set that wasn't fabbed yet and he had to do everything in his head / on pencil, and that's the way you should do it comma drat it?

I think he talks about something like that in this.

fishmech
Jul 16, 2006

by VideoGames
Salad Prong
Woz created and debugged by hand the first version of Apple II BASIC before getting actual chips to use, if that's what you're thinking of.

baquerd
Jul 2, 2007

by FactsAreUseless
The real horror is that I am disincentivized to fix this.

code:
String flag = (String)table.getValue(row, "Flag");
if (flag == null) {
  flag = "";
}

if (flag.trim().equalsIgnoreCase("Flagged") {
  flag = "YES";
} else if (flag.trim().equalsIgnoreCase("Not Flagged") {
  flag = "NO";
} else {
  flag = "NO";
}

if (flag.equals("NO") == false) {
 //...
}

raminasi
Jan 25, 2005

a last drink with no ice

OddObserver posted:

That people just starting out would have lots of difficulty getting it.

I don't know how familiar you are with SICP, but if you aren't: Its approach to teaching recursion is vastly different from any curriculum I've ever encountered elsewhere and it ends up being pretty intuitive.

Zombywuf posted:

The overhead of learning C, or the overhead of complex memory management that was taught to them before they were finished learning for loops?

C has a shitload of syntax before you touch malloc or even arrays. Hell, even learning how to create a C program is a Thing that takes up a lot more cognitive overhead than "here's a REPL."

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

fishmech posted:

Woz created and debugged by hand the first version of Apple II BASIC before getting actual chips to use, if that's what you're thinking of.

I heard he memorized the machinecode for Apple I BASIC, and before the Apple I had a tape drive he would just punch it in from a debug monitor.

fishmech
Jul 16, 2006

by VideoGames
Salad Prong
Wikipedia says: "It should also be noted that Wozniak did not have any software development tools for the 6502 processor other than an assembly language reference manual, and instead wrote out the software with pen and paper and then hand assembled the instructions into raw machine code for the 6502." and links to http://apple2history.org/history/ah03.html

wellwhoopdedooo
Nov 23, 2007

Pound Trooper!

fishmech posted:

Wikipedia says: "It should also be noted that Wozniak did not have any software development tools for the 6502 processor other than an assembly language reference manual, and instead wrote out the software with pen and paper and then hand assembled the instructions into raw machine code for the 6502." and links to http://apple2history.org/history/ah03.html

I'm not saying that's not impressive, because it is, but there's a slight difference between writing single-user software for an 8-bit, maybe 2 MHz processor and the multi-user, massively threaded, insanely complex software of today running on the multi-core within-an-order-of-magnitude-of-the-sun's-energy-density behemoths we have now.

Even if you could do something like that today, it would be a very, very dumb way to write software.

PalmTreeFun
Apr 25, 2010

*toot*

Mr.Radar posted:

But at the same time there are languages like Scheme and Python where you don't need to worry about those things at all. The real horror is teaching Java as a first language.

I would've given up on programming if Java or any C variant was my first language.

I started on DarkBASIC. :c00lbert:

I actually did. Not exactly a fantastic language overall, but it was great for sixth grade me because it was really easy to learn and let you dive right in to making games.

ToxicFrog
Apr 26, 2008


Zombywuf posted:

The overhead of learning C, or the overhead of complex memory management that was taught to them before they were finished learning for loops?

GrumpyDoctor beat me to it. C has a lot of up-front complexity compared to Scheme, Lua, or even Python, and is a lot harder to experiment with - even before you start talking about memory management. This is fine if you already have the fundamentals down, but if you're going into a first-year programming course, you probably don't.

The result of this is that the language gets in the way of the learning; you end up with a lot of people who know how to cobble together a program in C by regurgitating individual fragments of code, but don't actually understand what they're doing because they had to spend the entire semester learning C rather than learning how to program.

tef
May 30, 2004

-> some l-system crap ->
http://forrst.com/posts/Why_Cant_Programmers_Design_Software-gOg


(yes this a serious post by a serious person)

ninjeff
Jan 19, 2004

tef posted:

http://forrst.com/posts/Why_Cant_Programmers_Design_Software-gOg


(yes this a serious post by a serious person)

what's wrong with this, this is the best post

GROVER CURES HOUSE
Aug 26, 2007

Go on...

tef posted:

yes this a serious post by a serious person

nah

tef
May 30, 2004

-> some l-system crap ->

Broken Knees Club posted:

nah

yes

McGlockenshire
Dec 16, 2005

GOLLOCKS!
This is your brain on design patterns.

Any questions?

Zombywuf
Mar 29, 2008

drat, really wish I hadn't lost my fizzbuzz implementation in the great blade host crash.

Bozart
Oct 28, 2006

Give me the finger.

quote:

What if I told you that the answer to the FizzBuzz algorithm is only one line of code without any if and it looks like that
It is so simple! The correct answer to the question is to have a function that maps a number to a string, and call that function.

TasteMyHouse
Dec 21, 2006
I refuse to believe that isn't tongue in cheek.

tef
May 30, 2004

-> some l-system crap ->

TasteMyHouse posted:

I refuse to believe that isn't tongue in cheek.

Sorry, it is totally serious.

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


tef posted:

Sorry, it is totally serious.

quote:

As with every software engineering problem you don't really see the big picture if you are always in "low level" code. Another reason why you need to think in terms of objects

Wow. It really is.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
The solution to every problem is to over-engineer the gently caress out of it! Why do it in 9 lines of clear, readable code if you can abstract it into an unreadable monstrosity?

RitualConfuser
Apr 22, 2008

tef posted:

Sorry, it is totally serious.

Can't be. There's no mention of XML or even a basic Enterprise Service Transmogrifier. The solution obviously won't scale, isn't discoverable, and can't be consumed by all Enterprise users since it lacks an open standard. I propose that we start by forming a committee to draft an open FizzBuzz standard that will provide an open, standards based, alternative to all of these incompatible proprietary stovepipe FizzBuzz implementations that have been plaguing the Enterprise for some time. This standard will usher in a new era for FizzBuzz compatibility both within the SA community and the Enterprise as a whole.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
reminds me of that old 'object calisthenics' thing

http://binstock.blogspot.com/2008/04/perfecting-oos-small-classes-and-short.html

tef
May 30, 2004

-> some l-system crap ->

RitualConfuser posted:

Can't be. There's no mention of XML or even a basic Enterprise Service Transmogrifier. The solution obviously won't scale, isn't discoverable, and can't be consumed by all Enterprise users since it lacks an open standard. I propose that we start by forming a committee to draft an open FizzBuzz standard that will provide an open, standards based, alternative to all of these incompatible proprietary stovepipe FizzBuzz implementations that have been plaguing the Enterprise for some time. This standard will usher in a new era for FizzBuzz compatibility both within the SA community and the Enterprise as a whole.

no it is totally serious and not tongue in cheek. I wish it was.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
If it had XML, it would scale. XML scales like a boss.

tef
May 30, 2004

-> some l-system crap ->

Otto Skorzeny posted:

If it had XML, it would scale. XML scales like a boss.

I will suggest this to him next time I see him

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
How do you think he'd react to the video? Would Poe's law cause him to run with it?

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

tef posted:

no it is totally serious and not tongue in cheek. I wish it was.

That's as serious as a drunk clown playing with a rubber chicken.

Axel Rhodes Scholar
May 12, 2001

Courage Reactor

tef posted:

http://forrst.com/posts/Why_Cant_Programmers_Design_Software-gOg


(yes this a serious post by a serious person)

Tell him his answer is incomplete; the fizzbuzz problem is to print the fizzbuzz operation of numbers from 1 to 100, and he can't just punt on the design implications of traversing a range and applying an operation to the members of that range. First off, he's clearly missing a ContiguousIntegerRangeTraversal class (implements ContiguousRangeTraversal implements RangeTraversal implements Sequence) which he can traverse in various directions ( public Enum RangeTraversalDirections{ RangeTraversalForwards, RangeTraversalBackwards}).

Are you sure this is serious because I think this would be quite easy to do all day.

tef
May 30, 2004

-> some l-system crap ->

dazjw posted:

Are you sure this is serious

Yes

It's a staff pick, too

https://twitter.com/qnoid/status/40446929884299264

https://twitter.com/qnoid/status/66450115593904129

Zombywuf
Mar 29, 2008

He even cheats by using an if statement elsewhere.
code:
void fizz(int) {
  puts("fizz");
}
void buzz(int) {
  puts("buzz");
}
void fizzbuzz(int) {
  puts("fizzbuzz");
}
void number(int n) {
  printf("%d\n", n);
}
void (*handlers[15])(int) = {
  fizzbuzz, number, number, fizz, number,
  buzz, fizz, number, number, fizz,
  buzz, number, fizz, number, number
};
int main() {
  int i;
  for (i = 1; i <= 100; ++i)
    handlers[i % 15](i);
}

mjau
Aug 8, 2008
code:
#include <stdio.h>

int main ()
{
    int i;
    for (i = 1; i <= 100; ++i)
        printf("% 3d\n\0fizz\n\0buzz\n\0fizzbuzz\n"+(!(i%3)+2*!(i%5))*6, i);
    return 0;
}
:v:

mjau fucked around with this message at 15:31 on May 21, 2011

Zombywuf
Mar 29, 2008

Beautiful.

baquerd
Jul 2, 2007

by FactsAreUseless

Zombywuf posted:

Beautiful.

Definitely. Can a C guy break that apart? I assume it's some sort of way to reference the null terminated strings by memory address?

mr_jim
Oct 30, 2006

OUT OF THE DARK

baquerd posted:

Definitely. Can a C guy break that apart? I assume it's some sort of way to reference the null terminated strings by memory address?

Yeah, it's calculating the offset into the format string based on the loop index. Pretty neat. The trick is that in C, string literal arguments are actually character pointers. The "+(!(i%3)+2*!(i%5))*6" part adds an offset to the pointer.

The "!(i%3)" and "!(i%5)" become 0 if there is a remainder, and a 1 if there isn't. (Though I'm not sure if the 1 is guaranteed. Any non-zero value can be used for true.)

Adbot
ADBOT LOVES YOU

qntm
Jun 17, 2009
Wait, so

http://twitter.com/!/forrst/status/40425431857512448

says

quote:

Staff Pick: Can you write a FizzBuzz program without if/else/switch? http://t.co/RBecdHr

which links to

http://forrst.com/posts/Why_Cant_Programmers_Design_Software-gOg

which says, among a great many other things

code:
public boolean applies(int number) {
    return number % this.mod == 0;
}
code:
for (FizzBuzzOperation fizzbuzz : this.fizzbuzzes) {
    if(fizzbuzz.applies(number))
        return fizzbuzz;
}
?

So I guess the real challenge overcome here was to slightly obfuscate the location of the "if" statement!

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