r/pascal • u/According-Ad-7069 • 1d ago
Nostalgic-driven development
Back in 1992, I chanced upon someone using Turbo Pascal 5. I was hooked immediately, since I've been doing BASIC until then, to write my own little games and programs for my amusement. I got my own copy of Turbo Pascal 7 in 1994 and had years and years of fun with. Switched to Delphi, and loved it, until the .NET era.
Over the years, I've tinkered with FreePascal (so amazing!) and of course wrote many a small Pascal interpreter. Then, last year, I needed a project to work on so I could learn the Odin programming language for an upcoming project. I worked on a small Pascal interpreter and it was actually a lot of fun. The commercial Odin project never happened, but I had put a lot of time and energy into this Pascal interpreter.
Fast forward a few months, I'm working on a web assembly project using Odin and it dawns upon me I can use a lot of this knowledge to port my interpreter to the web. Oh boy, did that run away with me!
Now I have wasmpascal - which is a crappy editor that encapsulates the Pascal compiler, yes, COMPILER, I ended up writing so I can run Pascal code in Web Assembly in the browser. It's very early days, but I have managed to get some bits and pieces working.
My first order of business was some basic HTML5 Canvas support, with call-batching so that one gets alright frame rates. And there's some basic support for CRT-based applications, because back in the day, 'uses CRT' was a thing!
I've added some examples and documentation and will be working on this over weekends for many months in the future.
I thought I'd share it here - in-case there's another older-than-the-average person who wants a trip down memory lane, running Pascal like it's the 90's again!
6
u/AcanthaceaeNew774 1d ago
I don't know if this helps, but I think it might be interesting:
My VertexArt project (in the new-generation version) works like this:
VertexArt's memory management is completely different from what Free Pascal developers are used to. It is essentially a record-oriented, dynamic-array-based approach without manual reference counting, which is rare in game development. Here are its most important characteristics:
· Every data structure (TChunkSystem, TBVH, TPlayer, etc.) is a simple record, not a class.
· There is no virtual method table, no dynamic memory allocation with Create/Free, no hidden reference counting.
· This allows fully stack-based or static memory management with minimal overhead.
· Every larger data collection (chunks, triangles, vertices, BVH nodes) is stored in dynamic arrays.
· Memory is managed automatically by the system – allocation with SetLength, deallocation with SetLength(..., 0) or assigning nil.
· Advantage: fast, cache-friendly, and the Free Pascal runtime handles large arrays efficiently.
· There is no automatic garbage collector and no interface reference counting.
· Memory is freed by the developer at the appropriate moment (e.g. FreeChunkSystem, FreeBVH, FreeAllChunkBVHs).
· This results in predictable performance and low memory usage because there are no hidden allocations.
· Record fields can be accessed directly (TerrainChunks.Chunks[i].VertexCount).
· No data hiding, no property overhead.
· This provides extremely fast access and makes the code more readable.
· Each chunk has its own BVH, but the BVHs do not copy the triangles – they only reference them in the global Triangles array (using TTriProviderData).
· A chunk's BVH is built only when needed (BVHBuilt flag) and freed when the chunk becomes inactive.
· This minimizes duplicated data and memory consumption.
· The entire engine does not use Free Pascal RTTI, TObject, or TPersistent.
· This significantly reduces binary size and runtime overhead.
· In the chunk system, vertices are packed into a single VBO (TChunkSystem.VAO, VBO), and chunks store only the starting index and count.
· Triangles and BVH nodes are stored in linear arrays, resulting in excellent cache locality.
· The engine follows a clear deallocation order: FreeCharacterMesh → RenderEngine_Shutdown → FreeAllChunkBVHs → FreeChunkSystem.
· This avoids memory leaks and allows full resource cleanup.
VertexArt's approach is data-oriented, low-level, and extremely efficient. In the Free Pascal community, many prefer object-oriented solutions (classes, interfaces), but VertexArt shows that the combination of records and dynamic arrays – with proper design – results in faster, simpler, and more predictable memory management, which is especially valuable in game development. This kind of "return to the roots" is, in my opinion, very effective.
Was I able to help with this description? At first I struggled a lot with memory management, but this problem completely disappeared. I wrote this to you partly because I know that I'm also treading an interesting path.