4 ms·
Whenever my compiler comes up the first question tends to be why? I found that everyones "why" are specific. Some people want to know how many libraries exist,
by levodelellis 4y ago
Whenever my compiler comes up the first question tends to be why? I found that everyones "why" are specific. Some people want to know how many libraries exist, others want to know specifically how many high level (or low level) libraries there are for easy of use (or performance). Some want to know what's unique others want to know the goals. It's hard to know what people want so I'll do my best on answering questions
- duped 4y agoHow do you achieve automatic memory management without GC (including ARC)?
- levodelellis 4y agoWould you accept a short answer? The 'short' answer is the compiler tracks various things such as memory owner (for alloc) and lifetime (for constructors/destructors). The compiler enforces rules so it's clear (to the compiler) if the memory owner belongs to the caller function (for example ReadEntireFile), the parent function (itoa causes the calling function to pass in a hidden buffer for it to use) and if it's on the stack, heap or belongs to an object (class struct or array)
- duped 4y agoSo does that forbid mutually recursive functions, threading, and self referential data structures?
- levodelellis 4y agoYes self referential data structures are forbidden. No threading at the moment.
- alexisread 4y agoDoes this lang have an explicit effects system? Does the memory management work similar to PerceusRC in Koka, or is it more similar to ASAP?
- levodelellis 4y agoI'm not familiar with those
- exysle 4y agoCould you go into more detail? I am quit interested and would love to learn more.
- levodelellis 4y agoI'm not sure what details you want. The easy one to explain is itoa. Since 64bit ints can be at most 20 digits the function returns a fixed length array. Currently it's u8[21] because I've wanted an extra byte for null (for testing before I had print implemented). I'm not sure if I'll keep the extra byte, anyway since 21 bytes fits on the stack the caller function will allocate it on the stack so it doesn't need to copy it. But it doesn't have to be on the stack, if you write `obj.data = itoa(anInt)` the compiler will pass `obj.data` in. If it's a local variable then the compiler would have to decide if it should be on the stack or heap. Passing in a buffer gets rid of useless copies for the case where optimizers can't inline the function.
- necubi 4y agoI guess the broader question is how do you achieve automatic memory management without something like Automatic Reference Counting (like swift), the ownership/lifetime systems from rust, or the generic effect system of Pony? Ergonomically solving this problem is a major research area, so if you’ve found a solution to it’d be worth presenting that front and center.
- exysle 4y agoYes, I would like to emphasize the last point.
- levodelellis 4y agoAre you saying I should write a paper? I'm not sure how much it would help when a lot of it is intricate to the design of the language. I have no idea what the page limit of papers are and what the point would be besides for fun. I never had fun writing a paper either
- 4y ago