PDA

View Full Version : Pascal is a bloody brilliant language



jasonf
20-02-2007, 12:05 AM
I know, I'm stating the obvious, but something has just struck me..

and I know, I'm monologuing...


I've just spent the last hour thinking about how my tetris game is going to fit together, I've not written a line of real code, All I've done is build my class definitions. I'm going to have to pad them out later with the guts of the code, but at the moment, I'm in design mode. I may change the design, but right now, what's on the screen seems to work in my head, and I'm not going any further until I'm sure.

I work for a large IT company for my bread & butter so I'm no stranger to the design process, I've come from a pretty basic 'Hack it & See' approach to software development, but that was a long time ago, I've learned from many many mistakes and no longer rush in where angels fear to tread... ish... mostly.. sometimes.

My design doc for my game was written to get the basic idea for what I want to do out of my head and onto another medium where I can scrutinise it.., now, I feel that's been done, enough to get started anyway.. I get to the part where I'm designing classes.. When I'm done, I'll update the design doc and scrutinise it again, but at the moment, I need to see how things will work out..

This is where I think Pascals real strengths lie, and a lot of people miss this when jumping on the latest & greatest language band wagon.

I can see why Pascal is still taught in Uni, It's great for teaching codeaholics to step away from the immediate implementation and think about the structure. Some people may think that it's a terrible faff to have to do all this definition stuff up front, afterall, the compiler should be smart enough to figure out what needs to be compiled on it's own.. but that's not the point. The point is, it's way too easy to dive in and code.. too easy by far to rush in, write a load of classes then once you're elbow deep in language, you can't see the design for the bugs. The point is, you have to work it out properly.

Take VB.net for instance, it's a piece of cake to just write classes to solve problems, spend long enough without a design with all that OO power and you'll end up in a world of hurt.. I don't know about anyone else, but I can't hold an entire project's class structure in my head.. am I the only one?. I've fallen for this in VB before, I started writing a version of Chaos in VB, I knew the game mechanics very well, being a fan of the original game and started throwing the game together and I REALLY wanted it to be great. It began quite well, I'd got a bunch of classes to handle things , but very quickly the small faults in the design became big faults, which I had to code around. I'd not given myself the chance to look at the design at a higher level and think, "Is this the right way to do this?".. I could of course have written it all on paper and worked it out, but who enjoys doing that?
As a result, Chaos died.

The other thing is, pascal punishes the rush ahead mentality, especially if you've made a mistake. It's done it to me several times in the past. There you are, writing away.. you've got everything worked out.. you believe.. then something you didn't consider appears and bites you in the ass.. you have to rethink your entire design and hack out a lot of code. So, the next time, you take a bit more time over the definition stage and get it right. Some languages like VB make it easy to rethink and rehash the design, this can be good... if you've taken care of all the loose ends.. but what happens most of the time is, code gets left in there, bugs creep in, there's no overrall plan to tell you that X function is no longer needed or Y procedure has the wrong parameters. Basically, it becomes a mess.

So, It's midnight, I'm at the end of my monologue and hopefully, I've explained why I think Pascal is a brilliant language. I know, I'm stating the obvious, but sometimes... you have to walk outside and say.. Damn, the air smells sweet.

this monologue was sponsored by a rather cheeky little ros?© from Spain, so apologies if this sounds like a bucket full of drunken psuedo-knowldege.

rtf
21-02-2007, 06:50 AM
Well, that's basically the "static typing" argument. If you have to declare your variable types and match up your function parameters, you'll catch mistakes related to the type of the variable. All the low-level details are magnified so that you really have to take care of them. Plus a compiler can make faster code more easily with static types.

I'm in the dynamic type camp myself because I like writing code quickly, though. A well-made dynamic language lets you write quickly since you have less to think about. If you're done writing quickly, you have more time to test. And so on. If you know what you're doing this is good - if you don't, and it's a language like VB - not so good, maybe. There are lots of illogical things you can do with a lenient language, after all - that's why "goto" was mostly abolished.

But ultimately I use Pascal because I need the extra runtime speed. And when choosing from the static languages around, I found it more elegant than C/C++, and better supported than most alternatives. I looked at Digital Mars D for a while - that was a strong contender when I was choosing, but it didn't have great library support yet - and thinking back on it, it's as if it were evolving C++ to be more like Pascal. Might as well start from Pascal!

DGL-luke
07-03-2007, 03:05 PM
Yeah,

right now I'm into a bit of Python scripting, and when I create a class it just feels wrong I can't prototype it correctly... I initialize all properties I need in the constructor, but it just doesn't feel right.

3_of_8
07-03-2007, 03:21 PM
The thing I hate most about Delphi is that I always have to declare everything two times: In the interface and in the implementation. That's one thing I like more in C/Java.

But apart from that, Delphi is just cool. Sometimes I could just kill that bloody compiler, but it's alright.

savage
07-03-2007, 04:29 PM
The thing I hate most about Delphi is that I always have to declare everything two times: In the interface and in the implementation.

If you use class completion you can just press Ctrl+Shift+C after defining your class and it will create all the implementation stubs for you. This also works visa versa.

What I dislike about C#/C/Java is that the implementation is right next to the declaration.

3_of_8
07-03-2007, 05:04 PM
Well, it works if you have a professional or Turbo Delphi. I have neither.

WILL
07-03-2007, 05:08 PM
Or Lazarus. ;)

3_of_8
07-03-2007, 06:45 PM
I didn't like Lazarus. Don't ask me why.

cragwolf
07-03-2007, 11:41 PM
Pascal is certainly not easy on the old typing fingers (and wrists, and forearms, and shoulders ...) But on the other hand, it is very easy to read. I wouldn't call it a brilliant language (would like to reserve that for Haskell), but it is very solid and very effectively does the job that it sets out to do.

Another good thing about it is that its object-oriented offshoot, Object Pascal, retains the charm and elegance of the original. Can't say that about C (good language) and the monstrosity it spawned: C++ (argh!)

JSoftware
08-03-2007, 08:23 AM
Well, it works if you have a professional or Turbo Delphi. I have neither.
I used it since Delphi 5 pro.

I agree with savage. I think having a declaration without any code just makes the overview so much better on largescale project.

Without intellisense you wouldn't have a chance to code a program in VB.Net or C#

arthurprs
27-07-2007, 11:30 PM
Pascal are easy to learn, read.
It's also fast and portable.

In writing it is awesone too, simply keywords, (Delphi + cnwizard) simply make coding pascal as good as python.


*sorry my english

wodzu
28-07-2007, 02:15 PM
Pascal are easy to learn, read.
It's also fast and portable.

In writing it is awesone too, simply keywords, (Delphi + cnwizard) simply make coding pascal as good as python.


*sorry my english

Have you seen castalia? http://www.twodesk.com/ It is just amazing...(and I am saying that after seeing only 3 tutorial movies;)

sekelsenmat
05-08-2007, 07:00 PM
I didn't like Lazarus. Don't ask me why.

In that case Turbo Delphi Explorer can be downloaded for free.

sekelsenmat
05-08-2007, 07:02 PM
The thing I hate most about Delphi is that I always have to declare everything two times: In the interface and in the implementation. That's one thing I like more in C/Java.

This isn't true for C. In C you normally need to declare things on the .h file and also on the .c file. AFAIK this means declaring the same things two times