Re: Preferred language for scheduler assignment?
by QM (Parson) on Nov 19, 2004 at 16:55 UTC
|
This problem would be straightforward in Perl. Whether it meets your requirements for efficiency depends on the criteria.
If the code just needs to be efficient (as in not wasteful), then Perl is probably better than C, etc. If it needs to run as fast as possible, then C might be your best bet. Considering that most of the time is spent executing other programs, I think it would be hard to tell the difference between comparable C and Perl implementations.
I would suggest looking at Time::HiRes (or Time::AutoRes); system or `` (backquotes) or qx//; reading and writing files (the <> operator, and print/printf); split and/or regular expressions (match operator m// or just //).
But if you're more comfortable in C than in Perl, C will be less hassle for you in the short term. If you have some time to learn, Use Perl!.
-QM
--
Quantum Mechanics: The dreams stuff is made of
| [reply] [d/l] [select] |
|
|
But if you're more comfortable in C than in Perl, C will be less hassle for you in the short term. If you have some time to learn, Use Perl!.
I have to second that. I like perl, I really do, but when I was in school I tried to use a language I did not know and it cost me. This comment is not about a language war but rather it is about using your time efficiently and meeting as many of your goals as you can.
It was an intro compiler course. The first assignment was a simple translator and we could use one of five languages (and lex libraries). I was most comfortable with C so I wrote about 1500 lines of code over a two day weekend. gdb was really handy for tracking through pointers in trees. I got a good grade on it.
Now the recommended language was python. I had never used python but the instructor recommeneded it and so did other students who knew it. I saw some of their programs were shorter than mine and I had spent a lot of time just writing linked list and tree code. So I tried python for the second program in the course.
The short version is I was busy with a paying job and school and the local undergrad club and now I was trying to write a compiler (which was new to me anyway) in a language I had never even written "hello world" in.
My assignment was late by a few days and was never completed. Up to that point I had used C, C++, Java, I don't know how many Assembly languages, LISP, Prolog and I'm sure a couple more but for the life of that compiler assignment I couldn't get python figured out in the time I had. (I still got a B-something in the course.)
My advice is don't take on too much. This course sounds like a Real Time Systems course. It's not on Perl or languages so focus your effort on the course content.
Afterwards most people are not going to notice that you learned a new language in a course and you can always learn it on your own time. Employers who ask to see your grades will likely notice if you did not pass a course and maybe you would prefer they see a higher grade. That said if you are asking this question you are likely bright and enjoy learning and will probably do just fine but my advice still remains as: don't complicate your assignments (or work projects) any more than you have to.
| [reply] |
|
|
| [reply] |
Re: Preferred language for scheduler assignment?
by davido (Cardinal) on Nov 19, 2004 at 17:03 UTC
|
Given that Priority Queues (heaps) are implemented by Heap::Simple, and Heap, the queuing portion of the task is mostly implemented for you already. You just have to handle the logic where order is only adjusted when something takes longer, but not when it takes shorter.
Reading in the flat files and splitting them into individual elements is also one of those things that Perl does easily.
And the Benchmark module, or Time::HiRes may be what you need for timing the execution of each entity.
So Perl definately provides the building blocks to you, through CPAN as well as built-in functionality. It starts you off a little further down the development road than C, for example, for a project like this.
That means that in programming efficiency, Perl is going to beat C on this particular type of project. But that doesn't mean it will be the winner based on execution speed. If raw speed is the goal, dust off your assembler and start bit-fiddling.
In amount of code, Perl is probably going to come out ahead; you're going to end up typing fewer lines of Perl to accomplish this than lines of C, especially since some of the groundwork is already done and available on CPAN.
As far as development efficiency, yes, Perl is starting you out further down the road toward "done", but if you don't know Perl, you have to also consider the learning curve.
| [reply] |
|
|
Given that Priority Queues (heaps) are implemented by Heap::Simple, and Heap, the queuing portion of the task is mostly implemented for you already.
The way I read the assignment, the instructor is looking for the students to create their own priority queue. The OP should run using Heap::* by the instructor to make sure that it is okay for the class. There is no point in using it if it will hurt the OP's grade.
Jason L. Froebe
Team Sybase member No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1
| [reply] |
Re: Preferred language for scheduler assignment?
by ikegami (Patriarch) on Nov 19, 2004 at 17:06 UTC
|
In this case, I think the prof wants you to use an efficient algorithm. I don't think Perl will be a problem. But really, go see your prof! Tell him/her you're interested in practicing your Perl, and ask him/her if he has any problems with you using Perl for this assignment. | [reply] |
|
|
| [reply] |
Re: Preferred language for scheduler assignment?
by trammell (Priest) on Nov 19, 2004 at 16:46 UTC
|
I'd argue that the "efficiency" of a program includes the time spent developing and maintaining the code.
Unfortunately, you're in school, and in my experience most CS professors have some little tin god or other they worship, so be prepared to sacrifice your grades if you think for yourself. | [reply] |