Live data from Hacker News

Ask HN: Anyone else use FreePascal as their low level language?

news.ycombinator.com

31–40 of 58 posts

Re: Ask HN: Anyone else use FreePascal as their low level language?

#32

If you consider Go as a low level language, you might want to try C# which can be as low level as Go while having a lot of high level features. NativeAOT compiler allows you to statically link native libraries or create native shared libraries (.dll/.dylib/.so) that can be consumed from other languages. It's kind of 2-in-1 language, but the ecosystem is primarily focused on the high level part, so you can only depend…

You can get very low-level in C# but at the point you start using unsafe the nature of the language changes very suddenly.

Unsafe C# is the most unsafe language I've ever worked with. Really terrifying stuff.

Re: Ask HN: Anyone else use FreePascal as their low level language?

#33
I've been enjoying writing a Gameboy emulator in Odin - it interfaces nicely with C libraries (I've been using SDL and its been much easier to set up than with C++)

Tooling it a bit lacking, but the language is simple enough you can get away with using a semi-broken LSP.

The language feels light and expressive, and has generally gotten out of my way - the only thing I've been really craving is closures.

You might not like it because it has errors as return values like Rust/Go, however there are some directives/macros/keywords such as `or_return` which work a lot like `?` in Rust.

Re: Ask HN: Anyone else use FreePascal as their low level language?

#34

Interesting fact: lately I've been benchmarking few things around and I have found out that the same algorithms in JavaScript tend to outperform C in O0. Why does that relate to your post? Because if you're going lower level for performance you may actually find your assumptions to not hold true unless a good compiler optimization phase is involved.

The OP made their reasons clear and performance wasn't part of it.

Re: Ask HN: Anyone else use FreePascal as their low level language?

#36
post #16

Pascal is not a low level language - quite the opposite. That being said, various implementations provide low level facilities, including turbo pascal back in the days , and free pascal which I did use in the early 2000s. If I were you, if you like fpc, I’d actually look into Ada ( the OO part is a bit odd granted but works ). You’ll get extremely high control over low level stuff ( it’s used in the embedded world )…

> Pascal is not a low level language - quite the opposite. Why do you say that? Back in the 80s and early 90s it was the primary competitor to C, and in an alternate universe we might have ended up using Pascal decedents instead of C decedents. For example the original Mac Toolbox was first written in Pascal: https://apple.fandom.com/wiki/Macintosh_Toolbox The original Mac API were all native Pascal: https://wiki.fre…

I learned to program in VAX Pascal, and didn't learn VAX C until later. I always found Pascal more intuitive, especially for string handling than C, and combined with the VAX/VMS System library and Runtime Libraries was able to build quite complex systems in Pascal. I found out later, after I joined DEC, that VAX Pascal was a popular Systems Programming language for a while.

Re: Ask HN: Anyone else use FreePascal as their low level language?

#37
post #26

The paper "C is not a low level language as we are not programming a PDP11" (something like that anyway) made a good point that C is only fast on a multi core machine because c fans work hard at keeping the laurel. What does a low level language look like when you have 8 cores? Conversely what would a high level language look like for (low level) verilog and FPGAs?

The referred paper C isn't a low level language - your computer isn't a fast PDP11 [1] was not really addressing multicore parallelism. It was discussing instruction-level parallelism , which is done within an execution thread and is achieved by speculative and out-of-order execution of instructions that do not have sequential dependency on previous instructions. [1] https://queue.acm.org/detail.cfm?id=3212479

The article does go into cache coherency which is very much intertwined with multicore parallellism:

> The cache coherency protocol is one of the hardest parts of a modern CPU to make both fast and correct. Most of the complexity involved comes from supporting a language in which data is expected to be both shared and mutable as a matter of course.

I feel like we live in a world where everyone works very hard to pretend that C is our best low-level language, when in reality an APL-like purely functional array language would be a better candidate.

Re: Ask HN: Anyone else use FreePascal as their low level language?

#38
post #23

If you like go, modern pascal is basically that with less curly braces. The other way around is true, too. There’s zero technical reasons to not use pascal. Popularity, library availability, programmer availability and LLM quality of responses may be, but the technical foundation is there and has been for at least a decade (if not since turbo pascal from early nineties.)

What about memory safety? Go uses garbage collection but FreePascal doesn't and is essentially as unsafe as C++, from what I understand.

Re: Ask HN: Anyone else use FreePascal as their low level language?

#39
One of the languages taught in high school in South Africa is Object Pascal (via Borland Delphi), so this is actually the first programming language I learned.

I think Object Pascal is quite a nice language, it feels like OO without a whole bunch of messy package protected Java nonsense.

Re: Ask HN: Anyone else use FreePascal as their low level language?

#40
post #21
post #2

FP is an interesting language. In my opinion, it is somewhat problematic that different language concepts (Delphi, etc.) have been more or less merged into FP, resulting in redundant object models, for example. Pascal as a language also has various historical legacy issues (dangling else, block overhead, global namespace, etc.), which Wirth corrected in Modula and Oberon. The compiler is huge and apparently difficult…

> In my opinion, it is somewhat problematic that different language concepts (Delphi, etc.) have been more or less merged into FP, resulting in redundant object models, for example. That was not an FP invention, though. Delphi already did it - they kept the Apple's Object Pascal constructs from Turbo Pascal, and then bolted a whole new object system in parallel. FP inherited that mess and has to maintain it for backw…

> it has been around for almost 30 years now, so it's very mature.

The compiler is insanely large and complex, more than the sum of the implemented languages would suggest. I can't imagine that anyone still has a complete understanding of it. See e.g. https://github.com/rochus-keller/FreePascal/blob/master/Read....

Post reply on HN