Live data from Hacker News

A guided intro to the Free Pascal language

getlazarus.org

81–90 of 102 posts

Re: A guided intro to the Free Pascal language

#81

I used to be a hard Delphi/Pascal guy and still think it is much better than C for it's strong typing and overall "squareness". But I'd have a hard time going back to it nowadays. The 'var' section, magic "Result" variable and begin/end pairs are just from another age. Programming languages have advanced _a lot_ since Pascal was created. It's core principles remain valid (safety by default, readability, flexibility).…

" The 'var' section, magic "Result" variable and begin/end pairs are just from another age...Programming languages have advanced _a lot_ since Pascal was created. " I understand why some programmers dislike Pascal's syntax, but C and C++ are also old and still popular (including for new projects). Syntax and semantics are closely entwined but C and C++ syntax still influence "modern" languages.

Nim has a result variable, it's very handy.

Re: A guided intro to the Free Pascal language

#82
post #73
post #65

Earlier quoted context omitted.

I learned programming at school in Pascal and didn't have troubles with memory safety. FreePascal/Delphi has good standard library to work with strings and dynamic arrays and objects, and as long as you follow very simple convention with TObject.Create() and TObject.Free; you won't have memory safety problems. I didn't really have a need to work with pointers and do pointer math in Pascal, because language itself pro…

> as long as you follow very simple convention with TObject.Create() and TObject.Free; you won't have memory safety problems Is this the same as how in C, as long as you follow very simple convention with malloc() and free() you won't have memory safety problems?

not only that, Object pascal has very nice way of separating code and avoiding globals, and variables were constrained within certain scope. Each module is compiled independently and no macro hell.

if you were to pass reference around, then compiler would warn about potentially dangerous Free.

I don't remember ever seeing Pascal code where you received raw pointer and then directly casted it to your object type for example. Pascal has very powerful and expressive type system

Re: A guided intro to the Free Pascal language

#83
post #29

Earlier quoted context omitted.

Embarcadero insane pricing of Delphi is the reason I haven't continued beyond my old version Xe2. I guess they are making hay while the sun shines with the locked-in customers.

Do they have the yellow-on-blue syntax highlighting trademarked or something? I've looked for vim and vscode color schemes to match the original turbo c++ but to no avail. I remember borland builder had a setting to switch back to it.

Probably no one else saw interest to do it? I do remember seeing something similar for emacs.

Re: A guided intro to the Free Pascal language

#84
post #29

Earlier quoted context omitted.

Embarcadero insane pricing of Delphi is the reason I haven't continued beyond my old version Xe2. I guess they are making hay while the sun shines with the locked-in customers.

Do they have the yellow-on-blue syntax highlighting trademarked or something? I've looked for vim and vscode color schemes to match the original turbo c++ but to no avail. I remember borland builder had a setting to switch back to it.

I've definitely used turbo c vim themes in the past. a quick Google search brings up https://github.com/caglartoklu/borlandp.vim and some others

Re: A guided intro to the Free Pascal language

#85
post #3

Pascal killed my interest in programming for a while as it was force fed in both high school and earlier collage years. Reflecting back, it was the pessimistic approach to teaching of just pushing math problems via programming.

Pascal is great as a teaching language because of its simple syntax. It is also a pre-OO language, so you don't need to spend time explaining what classes and objects are. For an introductory programming course it is a very good language.

BASIC is a great teaching language.

Pascal is way too verbose and boilerplate-ly compared to that.

Re: A guided intro to the Free Pascal language

#86
There are some things that Lazarus/Free Pascal does right:

- It has the most sane strings you'll ever see, you don't have to allocate them, and they can hold gigabytes of text.

- You'll never confuse equality tests = with assignment :=

- It's case insensitive

- It doesn't do macros

- It is one of the fastest compilers available

- It is one of the best GUI builders available

Things it doesn't do right

- Begin/End seems verbose to some people

- Other "standard" pascal systems gave it a bad name

- Historically, Borland et al, priced people out of their products and killed off a loyal use base.

Re: A guided intro to the Free Pascal language

#87

Is there a way to use the Lazarus libraries, but write code in C++, like with C++ Builder?

> Is there a way to use the Lazarus libraries, but write code in C++, like with C++ Builder?

I write lazarus programs, and link to my lib**.so files which are all written in C. Works very well.

Re: A guided intro to the Free Pascal language

#88

Don't download the bundled Free Pascal and Lazarus distributions from this site, they're very outdated. Just get the normal releases from the actual Free Pascal and Lazarus sites which are linked at the top of the page. Lazarus comes with Free Pascal bundled by default anyways, so you don't need to grab the compiler separately if using Lazarus.

I downloaded Lazarus from its release page on Github and after installing it didn’t work, saying it needed extra binaries that it couldn’t find. Now I have to see what it’s talking about, what to install, etc. Kind of a hassle.

Re: A guided intro to the Free Pascal language

#89
post #80
post #51

Note for people who don't know much about FreePascal. It is a full-featured and very fast compiler. The resulting program is a rival for the best output of C/CPP compilers. It can be used in the style of simpler languages like Go and is almost as safe as Rust in a much faster manner. It has a great but old-looking IDE, Lazarus. It has been under active development for decades and is used for proper projects like: htt…

I don't believe you regarding "as safe as Rust." It's been a minute since I've messed with FreePascal, but as far as I know and can ascertain at a glance, it lacks any true modelling of memory safety to even match Go, and certainly not memory ownership to match Rust. It is surely possible to write correct programs in Pascal, and maybe even easier than C, but it would not be accurate to describe it as "as safe as Rust…

That's reasonable to not believe me, but can you enlighten me with more samples? If you mean managing pointers in Pascal, you can code in a style of high-level language like JS and never see a pointer to manage, thanks to managed records, objects, strings, and arrays. And if you are doing low-level stuff that needs getmem, alloc, and pointers, you better know what you are doing with your memory; otherwise, what is the point of writing these low-level codes? speed and control. Furthermore, pointers are typed and managed at compile time, with plenty of hints and warnings to show you the correct behaviour.

I stand by what I said about speed: I've been comparing the resulting code of GCC or Clang and FPC for years, and if you know what you're doing, the resulting speed will be almost the same. Sure, Clang does some quirky things, but at the end of the day, I've never seen a piece of code written by the same person in both languages (the result of one mind with one style of code) that resulted in a different speed. To be fair, GCC or Clang are a step ahead because they are the result of millions of dollars in corporate support, but my response was to emphasize that the speed is not what people remember from decades ago. As a sample, you can try the Dadroit tool, I linked, I am on the team, and you can compare a result of Pascal with similar tools.

And I agree with you. Don't get me wrong; despite my passionate response about Pascal, I am not saying that Pascal is a one-to-one replacement for new languages; my thesis is that you have most of the cool stuff you hear in this old language too, just without the hype, to encourage people to give it a try and not repeat the old "Pascal is old."

Re: A guided intro to the Free Pascal language

#90

Don't download the bundled Free Pascal and Lazarus distributions from this site, they're very outdated. Just get the normal releases from the actual Free Pascal and Lazarus sites which are linked at the top of the page. Lazarus comes with Free Pascal bundled by default anyways, so you don't need to grab the compiler separately if using Lazarus.

I downloaded Lazarus from its release page on Github and after installing it didn’t work, saying it needed extra binaries that it couldn’t find. Now I have to see what it’s talking about, what to install, etc. Kind of a hassle.

fpcupdeluxe will automate the process of installing a working Lazarus/FPC environment. You can just click through, as the defaults are fine.

https://wiki.lazarus.freepascal.org/fpcupdeluxe

Post reply on HN