Hey, I’m code_monkey_x.
I mostly write Python and JavaScript for practical stuff, but I’m trying to get better at Rust and OCaml. I like automation, small tools, parsers, and occasionally rewriting something three times just to understand the tradeoffs.
I’m here to learn, share small experiments, and find discussions that are more substantial than the usual social media noise.
Hey, I’m NightOwlDev.
I started with C and still use it when I want to understand what’s happening close to the machine. These days I also write Rust for side projects, mostly small CLI tools and experiments with networking.
I’m interested in low-level programming, Linux, debugging, and the kind of bugs that only show up late at night.
I am having a problem with loading .c files in ye olde Borland Turbo C for DOS 2.01. .C files will display properly if I load them in any other editor on earth, under any other operating system, but Turbo C seems to ignore line feeds(?) when loading that same file into it's IDE editor. It will throw out an error about the line being too long, etc.
Sincerely,
Getting a Bit Annoyed in Bermuda
Edit: Thanks all for your input. I found that if I loaded the file into an editor that would format it properly and then resaved it was fixed
Cheers!
Dynamic arrays, for instance std::vector in c++ are implemented based on the idea that if their size exceeds their capacity, the underlying array is reallocated to one that is twice the current capacity.
My question is, would this even be necessary given that at least in Linux, pages are allocated to a process on demand?
For instance, with a simple program like this:
#include <stdio.h>
#include <stdlib.h>
int main()
{
long size = (long)(64 * 4096 * 64) * 8;
long *arr = malloc(size);
for(long i=0; i < (size/32); i++)
{
arr[i] = i;
printf("%d\n", arr[i]);
}
printf("--->%p\n", arr);
while(1)
;
}
if size were equal to 64 * 4096 * 64, we can see via /proc/[PID]/maps that the heap section is about 4M(despite the malloc being for 16M) and with the size given in the program it is about 32M(despite the malloc being for 128M), illustrating on demand paging.
Considering that this implementation is probably not used widely, why is that? I figured one explanation would be the assumption of the system having on demand paging at all, which simply might not be the case, thus reducing portability, but what am I missing otherwise?
I wrote a small article around implementing Cartesian products, starting from Haskell’s sequence.
The article goes through a naive Haskell implementation, a more idiomatic list-comprehension version, native sequence, then versions using Data.Vector.Unboxed, mutable vectors, runST, unsafeFreeze to try a different memory representation.
The second half compares those designs with C implementations, mostly to look at what changes when the memory layout and allocation model are made explicit.
The most interesting result for me was that changing representation in Haskell reduced allocations a lot without automatically improving runtime. In some cases, fusion helped a bit (no temporary indices).
I’d be happy to get feedback on the Haskell side, especially the vector/ST implementations and whether there are more idiomatic or faster ways to express this.
Here is the article link:
https://julienlargetpiet.tech/articles/the-cartesian-product-disaster-tour-haskell-c-and-25gb-of-allocations.html
If you want to share any optimizations, you can do a PR at this repo:
https://github.com/julienlargetpiet/PerfLabs
It will be mentioned in the next article update.
PS: We now managed to find (currently) best version which is this one (in C) running at 160ms for 100k iterations to 55 lists here:
https://github.com/julienlargetpiet/PerfLabs/blob/main/CartesianProduct/contrib2/contrib2.c
I'm updating after trying some new Haskell impl, thanks everyone for the help and the intuition on where to dig !
Hi, I’m CosmicExplorer.
I’m into C, Rust, Linux, and mathematics. I like understanding systems from the bottom up, but I’m also interested in formal methods, programming language theory, and how we can make software more reliable.
I’m here to discover interesting projects, collect good resources, and discuss technical topics with people who care about details.
HOW BASED ARE PROTOTAXITES?
I mean seriously… giant mysterious tower-organisms dominating prehistoric landscapes?
For anyone unfamiliar, Prototaxites were massive life forms that lived hundreds of millions of years ago, with some specimens reaching around 8 meters (26 ft) tall. For a long time people argued about what they actually were giant algae, fungi, lichens, or something else entirely.
Imagine walking through an ancient world before forests as we know them existed… and seeing enormous pillar-like organisms rising from the ground.
They were looksmaxing long before us!
What makes them even cooler is that scientists are still debating aspects of their biology and ecology. Most evidence points toward a fungal or fungus-related identity, but the mystery itself is part of the appeal.
So I ask:
How based are Prototaxites on a scale from 1 to prehistoric eldritch tree?
Giant
Ancient
Weird
Still somewhat mysterious
Peak prehistoric lifeform or overrated fungal spaghetti tower?
Feel free to speculate!