Computer Science Teacher
Computer Science Teacher - Thoughts and Information from Alfred Thompson

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Object Oriented Programming is Dead

    • 10 Comments

    OOPtombstone

    OK perhaps not dead but Robert Harper, a professor at Carnegie Mellon University, says(Teaching FP to freshmen) that object oriented programming and design is “unsuitable for a modern CS curriculum.” More of the quote in context is:

    "Object-oriented programming is eliminated entirely from the introductory curriculum, because it is both anti-modular and anti-parallel by its very nature, and hence unsuitable for a modern CS curriculum."

    As you might imagine there is some dissent in the comments. When I posted this link to my Facebook page there were some 16 comments, mostly in disagreement, in a short period of time. One person, who hires people for industry responded with “I'm tired of interviewing interns who know Haskell but can't code up strlen() in C. ” But as Robert Harper says in a reply to a comment on his post “Our goal at Carnegie is provide students with an education, not training.” What does that mean anyway? Is there a conflict between industry and academia? Academics often believe that “There are plenty of opportunities for them to learn the old ways, and to pick up industry practices on the fly” while industry hiring managers lament the fact, as one VP told me, that it takes an average of a year and a half to turn a recent college hire from a good school into a fully productive software developer. Is is any wonder that many companies prefer not to hire people right out of college?

    I’ve seen programming paradigms come and go. I started programming as industry (and academia) were adopting structured programming. That was a big advance at the time but required some changes in the way people thought and designed code. Later I lived through the long, slow and at times even more painful transition to objected oriented programming. Are we entering the age of functional programming? Perhaps. But perhaps not to the exclusion of other paradigms.

    We do have new needs today. While first structured and later OOP developed to support the needs of larger programs and larger teams of developers as well as the needs of dealing with more data today the key new issue is parallelism. One of the design goals behind the development of F# (a functional language that is built into Visual Studio) is parallelism and making it easier to spread work across multiple processors. Clearly that is where we have to go to continue to be able to take advantage of the newest hardware. But does that mean OOP can become optional or that we can wait for students to learn it after college? That I am not so ready to buy.

    Even at the peak of OOP mania I have maintained that not everything has to be an object and that a mix of paradigms would/did/does work. I think that is still going to be the case even as functional programming grows in usage and popularity. But will old style programming completely go away? I don’t think so.Will objects go away? Not a chance.  I think universities, especially those who provide an “education not training” do their students a disservice if they ignore the reality of what is currently in the field. The handwriting is on the wall and functional programming is going to continue to grow in importance. But ignoring OOP now is not doing anyone any favors. Just my 2 cents.



  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Monte Carlo Simulation – Slot Machines

    • 0 Comments

    Random numbers are fun. Really they are. They are at the heart of gambling for sure but they are also a key part of what is called a Monte Carlo Simulation. These simulations are used for all sorts of scientific, financial, engineering and other simulations. They are an attempt to figure the effects of chance, of random reactions, to a formula/algorithm or plan. As such they are an important tool in many fields. But of course Monte Carlo refers to the famous casino so its association with gambling is pretty much unavoidable. This even though the term originated with a group of nuclear researchers that included the computer pioneer John von Neumann. And as it turns out I have a couple of gambling simulations in mind that I think make interesting projects.

    The first was inspired by this slot machine simulator that I found as a result of a Tweet on Twitter.

    image

    It’s pretty fancy and clearly some serious research went into it. Just for fun I decided to create a very simple version of a slot machine simulation. I didn’t do much research so it’s not as scientific but it was fun to do. The form is below and you can see that I used textboxes to allow the user to specify the starting amount, how much to bet on each spin and how many spins to do. The payoff rate I hard coded in but could easily be another variable the user could set. The payoffs is determined by an other random number and could be a lot more fancy. Probably should be.

     

    image

       1: private void button1_Click(object sender, EventArgs e)
       2:       {
       3:           int bankRoll = Int16.Parse( this.textBox1.Text);
       4:           int bet = Int16.Parse(this.textBox2.Text);
       5:           int cnt = Int16.Parse(this.textBox3.Text);
       6:           Random r = new Random();
       7:           for (int i = 0; i < cnt && bankRoll >= bet; i++)
       8:           {
       9:               if (r.Next(100) > 90)
      10:               {
      11:                   bankRoll += r.Next(100);
      12:               }
      13:               else
      14:                   bankRoll -= bet;
      15:           }
      16:           this.label1.Text = bankRoll.ToString();
      17:       }

    Making this better is an exercise for the student. I hope to write this up in some more detail at a future date but I’m on vacation so it will wait. But there are a couple of things I do like about it. One is that I get to use a more complex terminating clause than we often see in an early student project. It allows for some discussion about the roll of negative numbers in loops. Do you allow them? It depends on the application doesn’t it? Slot machines typically do not grant credit. And of course there are those random numbers to look at so you can get into all sorts of discussions about random numbers, statistics and streaks. Why do you sometimes win? Good stuff.

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Hacking Vs. Programming

    • 6 Comments

    What is the difference between Hacking and programming? One opinion I have heard expressed is that a hacker can put a lot of code together in a hurry but if a change is needed the code has to be completely rewritten. A programmer may take a little longer but if changes are needed they are more quickly and easily installed without the need for a complete rewrite. One source I heard attributed an observation like this to Maggie Johnson of Google. It rings true to me though. Hacking is usually described as “quick and dirty.” You though a bunch of code together and make it up as you go along. Some hackers are quite brilliant and can do amazing things in incredibly short periods of time. And then they move to the next thing. Or perhaps they stay with the same thing because no one else can understand it well enough to fix it, modify it or improve it. Job security? Perhaps but not a good thing for the people who use, or importantly pay for, the software.

    I do a little hacking – that is to say toss something together in a short period of time without a lot of planning – from time to time. I’m not a genius though and typically this ends poorly. The performance is poor, the maintainability is poor, and no one else wants to use it. This may make be biased against this way of doing things I guess. I prefer to program – to think things out, to plan, to proceed in an organized fashion. I saw the difference made clear to me my first year of teaching (a long time ago). I was working on a little game programming of my own and decided to show it to some of my students. As I explained how I had set things up around a number of constants that is hoped would make the program more easily expandable one of the students turned to another and said “Look at that. He’s just starting and already he is planning for additions.” That is one of the real keys, in my opinion, to real programming.

    I was a major in Systems Analysis in college. This was during a time when computer science majors were rare and software engineering majors rarer still. But one of the things my professors drilled into our heads was that programs had to be maintainable and extensible. We were taught from day one that programs are not finished but, in a sense, abandoned. More likely at some point you declare victory and more on. But others will maintain these programs and expand them and adapt them. Making their lives easier is a good thing. Think of the Golden Rule – program was you would want the programmers whose code you are modifying to have programmed. I think that is how it is written. Smile

    The hackers get a lot of attention these days. These are the basketball players who make the slam dunk that makes it to the highlight reel. But basketball games are won by teams of players executing on the basics – the solid play well executed, the dribble, the layup, the pass that gets the ball to the star. In the long run we need more real programmers to make solid, dependable programs that don’t have be be rewritten from scratch when a change is needed.



Page 2 of 618 (1,853 items) 12345»