Page 1 of 1

please upgrade your FreePascal compiler

Posted: Tue Jun 13, 2006 12:18 pm
by bisma
I found that UVA uses FreePascal (FPC) v.2.0.0 as the pascal compiler. Since now FPC has upgrade to v.2.0.2 which contains tons of bugs fixed, I recommend UVA to upgrade FPC as well.

I also have some suggestions for FPC users here...

1. FPC is very slow on I/O operation. That's why in some cases, pascal solutions got TLE. Actually it's not about language issues. Because basically FPC and gcc is very close on compiled code speed. The slowness is becaused FPC only allocates 256 bytes for I/O buffer by default. Compare it to gcc which allocates 4 KB for I/O buffer. Because of this, obviously, C's I/O will be faster by a large factor. To overcome this buffer limit, we need to override the default FPC buffer allocation. Here's the example:

Code: Select all

program Test;
const
  MaxBuf = 4 * 1024;  // 4KB buffer
var
  I: Integer;
  BufRead, BufWrite: array[0..MaxBuf-1] of Char;
begin
  SetTextBuf(Input, BufRead, MaxBuf);
  SetTextBuf(Output, BufWrite, MaxBuf);
  repeat
    Readln(I);
    if I = 0 then Break;
    Writeln(I);
  until False;
  Flush(Output);
end.
With this "optimization", your pascal program will perform about 4-5 times faster on I/O operation.

2. About editor or IDE for FPC. Though FPC provides text-based IDE that looks like Turbo Pascal 7 IDE, but for some people, especially Delphi people, that default text-IDE is not good enough. Delphians demand GUI IDE with great editor and easy debugging feature. Actually, there's a Delphi-like IDE for FPC. It's called Lazarus (http://www.lazarus.freepascal.org) that now become de-facto FPC IDE, both for GUI and console programming. As like FPC, Lazarus is also available natively on most platforms that supported by FPC (win32, linux, bsd, mac-os, etc running upon win32 widget, gtk1, gtk2, qt, carbon, etc). Lazarus is almost like Delphi, most Delphi features are also available in Lazarus. So, it's time to "write once, compile everywhere" using FPC and Lazarus. :)

Here's the screenshot Lazarus running on MacOS X...

Image

And I also have a question... why FPC and pascal is no longer allowed in world finals contest? Are there any technical reasons for this decision? Because I don't think it's fair since pascal as language is still very popular on many countries, especially on educational field. And it's too bad to know that ACM-ICPI 2006 is using (Borland) Kylix instead of FPC/Lazarus as pascal compiler/IDE. And the worst is... pascal is no longer supported on the next ACM-ICPI event. :(

Thank you.

---
PS: I've submitted a same topic on Pascal forum, but I think it is more apropriate to post here. I'm sorry for this mistake, and I hope someone would remove my post on Pascal forum. Thank you.

Posted: Wed Jun 14, 2006 12:31 am
by Carlos
Thanks a lot for your point of view. The comment level overpasses me, but I'll try to give my point of view:

- I agree we should upgrade the compiler. Unfortunatelly, we had several problems in the past relating that: some codes were AC before the upgrade, and CE after it. That's the reason we'll leave it as it in by the moment. As we'll change to the new system, we've thought about installing several versions of every compiler and let the user select what version he wants to use. That way this kind of errors will be avoided. Of course you'll be able to select "most recent version" for users that don't care about it (like me) :P

- About I/O operations, I didn't know that. You should say it somewhere in the forum. Isn't there a Pascal subforum? That will help new users a lot.

- About the editor for FPC....I'm the kind of person who uses vi for programming, so I won't give my opinion on that :P

- Nevetheless, I'll give my (PERSONAL, SINCE WE HAVE NO CONTACT WITH ACM/ICPC STUFF) opinion about the last issue: removing pascal from ACM/ICPC. I think it's the best they could ever do. They should only allow one language (I don't matter which one, but since C/C++ is quite standarized and well known, it could be the right one). Why? Because if there are several programming languages some users might have advantages over the other users. ACM/ICPC is and algorithm contest, if you can use a high level library who can solve the problem, what do we need to compete for? The other possibility is to turn it into a real programming contest, but that would mean allowing quite other languages. In my school, people are pretty brilliant, but since they program in fortran they can never compete in ACM/ICPC. Also, cobol is well known between computer engeneering students. And basic/visual basic is the programming language used by someone who has learnt on his own. Java is used by telecom engeneers...as you can see, there are too many elections to just choose a little between them. As I said before, if I should select an universal language, that would be C/C++. Not Pascal (delphi), not Java, not Fortran (not even F2003).

Anyway, I'll leave this topic open, so that other users can give their opinion about that.

Posted: Wed Jun 14, 2006 6:04 am
by bisma
Unfortunatelly, we had several problems in the past relating that: some codes were AC before the upgrade, and CE after it.
Of course, that'd be the consequences. New version is not always fully compatible with the previous one, no matter they try to be backward compatible. And this is not only pascal problem, all compilers have the some problem. :)
Isn't there a Pascal subforum? That will help new users a lot.
I did, please read my PS. And actually this (I/O operation) is a very common mistake done by lots of pascal programmers. :)
I'm the kind of person who uses vi for programming
Then it's not for you, obviously. :)
ACM/ICPC is and algorithm contest, if you can use a high level library who can solve the problem, what do we need to compete for?
I'm sorry to be disagree with you. I think for this kind of event (algorithm contest), the most suitable language is Pascal. It's a language that implement clear and clean way of programming, that's why pascal is used mostly on educational field. Unlike C/C++ or Java, Pascal does not require any external library to do complex algorithm, default standard libraries are more than enough. If external or high level library is completely prohibited, then pascal still allow you build a program using your own custom functions/procedures. Compare it to C/C++ or Java that always requires #include directives, even for a simple program.

So, I think it'll be more fair if the language of choice in ACM/ICPC event is Pascal. Anyway, I don't think ACM/ICPC decides to remove pascal from the contest is based on the same reason as we discuss here. I think it's because they lacks of information about good and free pascal compiler which has good ability to compete with gcc and java. They don't think gpc is good enough, and that's why they choose Kylix, a commercial troublefull pascal compiler for Linux from Borland. I wish they knew about FPC and Lazarus. :( I'm sure if they really know about FPC and Lazarus, they'll use it for the (next) contest. :)

For more information about FPC and Lazarus, please visit...
- FreePascal at http://www.freepascal.org
- Lazarus at http://www.lazarus.freepascal.org

Posted: Wed Jun 14, 2006 6:45 am
by mf
Unlike C/C++ or Java, Pascal does not require any external library to do complex algorithm, default standard libraries are more than enough. If external or high level library is completely prohibited, then pascal still allow you build a program using your own custom functions/procedures. Compare it to C/C++ or Java that always requires #include directives, even for a simple program.
You're wrong here. Pascal does have some standard library, even your own code uses ReadLn, WriteLn, SetTextBuf and Flush.
You didn't write these routines, did you?

And actually, the following is a perfectly valid C/C++ code, and it doesn't use any #include.

Code: Select all

int printf(const char *, ...);
int main() { printf("Hi there\n"); return 0; }
printf is part of C standard library, and it basically has the same purpose as Pascal's Write/WriteLn. It's just that in order to use it, you have to tell the C compiler that it exists, either by an #include or a explicit declaration as done above. In Pascal, AFAIK, Write/WriteLn are part of unit System, which is included by default.
I think for this kind of event (algorithm contest), the most suitable language is Pascal. It's a language that implement clear and clean way of programming
You can write clean programs in almost any programming language, it more depends on you, than your programming language.

Posted: Wed Jun 14, 2006 11:57 pm
by Carlos
bisma wrote: I'm sorry to be disagree with you. I think for this kind of event (algorithm contest), the most suitable language is Pascal. It's a language that implement clear and clean way of programming, that's why pascal is used mostly on educational field. Unlike C/C++ or Java, Pascal does not require any external library to do complex algorithm, default standard libraries are more than enough. If external or high level library is completely prohibited, then pascal still allow you build a program using your own custom functions/procedures. Compare it to C/C++ or Java that always requires #include directives, even for a simple program.
I don't quite agree with you. I think every language has some standard libraries that can be used by the programmer. Maybe in pascal you don't have to explicitely declare them, but they are still there. In C you have to explicitely include them...but it's a line at the beggining of the program, the rest of it is similar. I prefered C because everything looks simpler on it. I/O operation are clearer, variables and pointer handling is more intuitive...and it's known by most of the people who participates in acm. Also, Pascal is obsolete. I've never heard about any project in any enterprise in my sector (spacecraft) starting a project in Pascal.
bisma wrote:So, I think it'll be more fair if the language of choice in ACM/ICPC event is Pascal. Anyway, I don't think ACM/ICPC decides to remove pascal from the contest is based on the same reason as we discuss here. I think it's because they lacks of information about good and free pascal compiler which has good ability to compete with gcc and java. They don't think gpc is good enough, and that's why they choose Kylix, a commercial troublefull pascal compiler for Linux from Borland. I wish they knew about FPC and Lazarus. :( I'm sure if they really know about FPC and Lazarus, they'll use it for the (next) contest. :)
I don't think they reject Pascal because of a compiler or a gui. I think they just want to get rid of something that 10% of the people uses, and that takes them 50% of the time to manage. It's a simple demand/offer rule. If they got paid about keeping pascal I think they'd keep it :P

Posted: Thu Jun 15, 2006 7:01 am
by bisma
I think every language has some standard libraries that can be used by the programmer. Maybe in pascal you don't have to explicitely declare them, but they are still there.
Agree. What I meant is... with no external unit (explicit unit declarations) involved, we still able to create a program with complex algorithm using pascal. With this compiler internal libraries, we could prevent any usage of high-level un-aunthenticate libraries. Programmer just simply use it and if there's non-provided functions they need then they can write them by their own.
I prefered C because everything looks simpler on it. I/O operation are clearer, variables and pointer handling is more intuitive...
I disagree with this. "Simpler" is very much relative. C/C++ programmer would say C/C++ is simpler, as pascal programmers would say the same thing. The reason why pascal is still mostly used for educational purpose is because pascal is admitted as a simple, clean, clear, and readable progamming language. You may deny this but the fact still show you that. :)
Also, Pascal is obsolete. I've never heard about any project in any enterprise in my sector (spacecraft) starting a project in Pascal.
This is TOTALLY wrong! Never been used in spacecraft project is NEVER means that Pascal is obsolete. And it also does not mean that pascal cannot be used in spacecraft projects. Your statement is a very naive conclusion! This is a typical C/C++ programmer statement about pascal, by the way. :P

Pascal is ALWAYS enhanced with new features and technologies (.Net, 64-bit, multicore, etc, just to mention a few). And THERE ARE PLENTY of enterprise projects build using pascal (using various pascal compilers) which are still active and alive. The statement that pascal is obsolete or dead and never been used in any serious projects is simply a Myth(tm). You never knew it because you never want to know about it.
I think they just want to get rid of something that 10% of the people uses, and that takes them 50% of the time to manage. It's a simple demand/offer rule.
Oh really? According to this statistic (http://acm.uva.es/problemset/statsjudge.php), Java users are never more than 10%! Then why they didn't get Java out of the contest? So, your demand/offer rule doesn't make sense at all. Did SUN pay (or give something) to get Java still on the contest?

Algorithm contest should be only about algorithm, not about language. We all know that any algorithms can be implemented in any programming languages, though the complexity to apply can be vary. That's why I think that removing pascal (or other languages) from the contest is unfair. "Algorithm <> C"(tm). Instead, they should add other languages so other programmers also can compete in the contest and shows the advantages (and the disadvantages) of other languages, besides C/C++. If this is too difficult, then at least, keep the three most used languages (C/C++, pascal, and java) still exist on the contest. :)

Alright, we can discuss about this topic for years and will never come to a conclusion. So, I think we could stop this here. But, I do hope that my suggestion will come to consideration. :)

Thank you.

Posted: Thu Jun 15, 2006 8:35 pm
by Carlos
just some remarks:

- Java isn't used in VOJ because Java compiler is very restricted, and doesn't work as it should. That's why people using JAva move to C++.

- Pascal isn't used in most of the schools I know. Apart from informatics, where they see most of the manguages, including pascal, I don't know nay other chool where they teach pascal.

- I'm not a C/C++ programmer. Actually, I'm a Fortran programmer who had to move to C to compete in ACM. Actually, ot wasn't a great effort, that's why I think that it's easier to move to an universal programming language than to make them install every single version of every compiler in the world (of course, i'm exagerating, but you get the idea :P)



I also hope that this discussion helkped anyone, even if they didn't participate.