• not a robot (unregistered)

    "I hope none of these students are using Windows" - likewise

  • gcc (unregistered)

    This is the ultimate "useless use of cat" scenario. Kudos to the professor!

  • maurizio (unregistered)

    Beautiful !

    May be in original research project the file came out from something more complex than a cat ?

  • b.a.freeman (unregistered)

    and what happens if dog is your tool of choice?

  • Sandman (unregistered)

    Just cus you have a degree doesn't mean you're good at it

  • Techpaul (unregistered)

    Could be like some exam questions I see where no matter what the language the exam question is it was written in Pascal FIRST, so all arrays must have data starting at 1 index, yes they have to offset their indexes for C, C#, Python, Ruby, Java...

    Then don't get me started on not knowing how to use globals !!!! Yes globals are defined, then passed as parameters to functions that are declared with parameters of SAME name and reference the same name in the function.

  • kktkkr (unregistered)

    Well, they could solve that by supplying some supplementary tools with the parser code, namely a cat binary for Windows users. (With a full installation of Cygwin attached to it.)

  • gnasher729 (unregistered) in reply to Techpaul

    In Pascal, arrays can have any subrange of the integers as their range, like -1000:1000 or 1900:2000 or 0:1000 or whatever you want. No reason at all why an array would have to start at index 1.

  • Martin (unregistered)

    In my humble opinion, what if the professor was trying to show their students the java's ability to execute a OS command? In school not everytime you'll see an optimized code, it depends of what the professor is trying to achieve at that time.

    Regards

  • Herby (unregistered)

    Someone needs to rewrite 'cat' so it recognizes that when it has no arguments, it is a useless program, and with only one argument it makes sense only if standard output is to an interactive device (I may be simplifying here).

    It would output an error "You are a stupid idiot. Learn how to program."

    Wishful thinking in many cases, and way too much logic for such a simple program. Then again look at the complexity of the 'true' or 'false' program, the mind boggles...

  • Chris (unregistered)

    The parsing code seems to have an error too. It reads a line before the loop and then inside the loop it throws that line away and reads the next line. I guess it's ok if the first line is a header or something.

  • Martin (unregistered) in reply to Herby

    Hi Herby: I understand your point. But what about if that's the catch of the code? The article says about the instructor: "He had more to say, but no one was paying attention".

    If I was the teacher and I feel that no one's paying me attention I can use some gotchas in the code to see if students is looking and understanding de codes. If no one looks it or even understsand the code's flow, then I'll blame them lol ;) .

    P.S. I'm a evil teacher, hopefully never became an instructor LOL!

  • Ulysses (unregistered)

    RE: Windows and HTML comments. Code blue! We have haters in aisle 5!

  • Leep (unregistered)

    My guess is that the code was written by someone who came into "programming" from the command-line script world. It's perfectly normal to cat a file and pipe it through grep and pipe that through ... in the bash/DOS world. I've known script wizards that were unbelievably good at doing just about anything in a cmd/bat/sh/... script. And they were almost always more than willing to send me an example of how to do it in a command-line script when I was researching how to do something in C#. :)

  • TimothyB (unregistered) in reply to Ulysses

    You just wait until it's the year of the Linux desktop! (or laptop in this case)

  • Lazerbaems (unregistered)

    I wish there was a Gordon Ramsay of Code that would go around and yell at people on TV for being muppets about their code and then there would be an episode with this professor and he's all arrogant but then Ramsay of Code puts him in his place and tells him his research project is doomed to fail if he continues on like this and then the profressor cries but tries to hide it from the camera after one of his students that's barely making grades meet bakes a fantastic beef wellington I mean algorithm

  • Gerry (unregistered) in reply to gnasher729

    Or of any ordinal type, e.g. enums, boolean:

    Array[enum1..enumN] of string; Array[False..True] of string; or Array[OrdinalType] as a shortcut

    Array[Boolean] of string;

    Array[EnumType] of Char; etc

  • Donald T. (unregistered)

    If you look in our windows, Bill C. and I have pussy on our laptops. Eunuchs have cat instead. We win.

  • Jistuce (unregistered) in reply to TimothyB

    If we are still running Windows when the sun burns out, we DESERVE Linux on the desktop.

  • löchlein deluxe (unregistered) in reply to Sandman

    Well, programming is not a useful skill for a fairly large part of the CS ecosystem. Every line of code you're writing, you're not writing a grant proposal or paper. (Maybe I'm overly cynic, but even teaching is not a useful skill in the university ecosystem.)

  • KI (unregistered) in reply to Martin

    Duh!

    It is clearly program demonstrating binding of java and external compiler/transformer/etc tool. While "cat" is clearly just placeholder. Needing such bindings in real world happens every now and then.

    For error handling, well, since it is plain study program that is also likely intentional. Also most likely program is originally written by some student earlier ad part of some research. I have had myself sometimes pleasure to deal with such research apps written by ignorant students.

  • Martin (unregistered)

    Greetings KI

    Yes, I totally agree with you. Some time ago I was in need to execute an external command to process several files because using a library required the the company spend some $$ to buy it, instead, executing a process from the custom app was easier because we already had such application.

    My point was that Herby explained that cat was doing nothing, the code has a bug, my point is that the instructor maybe was trying to say "Guys, the code is ready to be downloaded with a file example, but beware that the code has a bug when reading the file, your homework consist in identify the bug and tomorrow we review it " (I had this kind of homework too when I was at college),.

    Anyways, this article was too funny :)

    Kind regards guys.

  • Martin (unregistered) in reply to KI

    Greetings KI

    Yes, I totally agree with you. Some time ago I was in need to execute an external command to process several files because using a library required the the company spend some $$ to buy it, instead, executing a process from the custom app was easier because we already had such application.

    My point was that Herby explained that cat was doing nothing, the code has a bug, my point is that the instructor maybe was trying to say "Guys, the code is ready to be downloaded with a file example, but beware that the code has a bug, your homework consist in identify the bug and tomorrow we review it " (I had this kind of homework too when I was at college),.

    Anyways, this article was too funny :)

    Kind regards

  • dn3s (unregistered)

    I can relate; I love cats! sometimes I'll just throw a bunch of cats into a shell pipeline just because I love cats so much! $ cat file.txt | cat | cat | cat | grep something | cat | cat

  • Research Student (unregistered) in reply to Leep

    My guess is that the code was written by someone who came into "programming" from the command-line script world. <

    Yes, (in spite of sanitation), it's still right there in the article: "In fact, this code started life as part of a research project conducted by multiple members of the CS department’s faculty."

    This is what scripts look like when they start life as something incidental to the main project, and aren't owned by anybody, but can't change because they are used by everybody.

  • Dieter H (unregistered) in reply to Martin

    No. Programming professors are hacks almost by definition. Coming from a developer who has taught many university students how to program, and in that process having to deal with the ridiculous platforms and required utilities enforced by the professor himself. I'm sure there are exceptions to the rule, but I haven't seen any.

    If I'd have to hire a programmer, I'd probably avoid the risk and pick someone without a formal education in IT; better to study it at home.

  • Martin (unregistered) in reply to Dieter H

    Hi Dieter:

    In my experience I had the opportunity to work with guys without formal IT education and let me tell you that I was gladly surprised :) but not always are the same.

    From my very personal point of view, the difference between a person with IT education and one without it, is the way to solve the issue, avoiding at the same time issues like XSS, SQL-injection. I remembered that some years ago I worked making modifications for a web application made by a Oncologist that knows development, but when I reviewed the webapp code I found a lot of security concerns (one example of the several security concerns was that the DB processing was made using javascript inside the front-end). Persons with formal IT education are more intuitive in that kind of issues (of course, they are exceptions).

    Regards

  • Martin (unregistered) in reply to Dieter H

    Please, allow me to try again without gibberish:

    The difference between someone with an IT education and another one without it, is that the first understand better the programming logic, the processes involved and understand the skills to develop an application, as well as the security concerns involved. The other persons only knows the "language" itself, I mean, understand the language, but don't have the skills and logic to develop applications (something like know a couple of words in french vs someone that can speak in french).

    Hope this clarifies.

  • PWolff (nodebb) in reply to Martin

    Like Google Tran's Later knows millions of French words ...

  • Mark Jacobs (unregistered)

    Java is bad enough with regards execution speed. When you mess up the code so much that it becomes woefully inefficient, people are just not going to use your programs! The fact that this is a lecturer in programming, makes me shudder for the future IoT. Someone get me off this planet!

  • owlstead (unregistered) in reply to Mark Jacobs

    Execution speed - nobody should care. Using cat is unlikely to form a major problem and can easily be replaced. Code that cannot be maintained and is not fail fast (if it correctly fails at all), now there's a problem. And it certainly is in that piece of crap code.

  • jay (unregistered)

    Every now and then I write some long and convoluted piece of code because it's the only way I see to get the job done. Then some time later I come back to it and realize, Hey, I could have done that with two lines of code! Sometimes because there's some handy-dandy function in the library that does exactly what I need and I didn't know about it before, sometimes because I was just brain dead and did things the hard way.

    I wonder if that's what happened here. The teacher didn't know how to read a file in Java, but he knew how to create a process and execute a command and read the output stream. In this case, I think I'd be saying to myself, There MUST be a function in the library to do this, I just need to find it. But maybe he searched and couldn't find it, or something.

Leave a comment on “Grumpy Cat”

Log In or post as a guest

Replying to comment #:

« Return to Article