News for hackers. Stuff that matters.
Re:Stack safety for free? by gumby on Monday December 06, 2021 @11:44AM (#29462017)
I’ve been writing recursive code “in the real world” for almost 40 years and your statement seems unrealistic to me.
Re:Stack safety for free? by auggierose on Monday December 06, 2021 @12:16PM (#29462536)
Good for you. I've been writing code for only about 30 years, so maybe you are onto something.

Personally though, I am fed up with abstractions that cannot be used when I really need them. Those abstractions are not really abstractions. They are gimmicks.

So yeah, I had to go through thousands of lines of code and convert it to trampolined code to make it run on my input. I got lucky once, and I could just increase the stacksize to be large enough. That's often not possible.

So these days, I only use recursion if a) it's just exploratory code or b) I know that the environment can support a recursion depth adequate for a computer with 64GB Ram or more.

To finish my rant, if you really think my statement is unrealistic, then you don't the fuck know what you are talking about.

Actually, not finished yet. Anyone building recursion into their language, and not making sure that recursion can use up all the memory available if so needed, is just not doing their job properly.

Re:Stack safety for free? by astrobe_ on Monday December 06, 2021 @01:47PM (#29463894)
> Personally though, I am fed up with abstractions that cannot be used when I really need them

Abstractions are often leaky [1], this has been known for 20 years. Deal with it?

> Actually, not finished yet. Anyone building recursion into their language, and not making sure that recursion can use up all the memory available if so needed, is just not doing their job properly.

You don't "build recursion into [a] language", that's a direct consequence of having any form of subroutine call. You don't have to do anything except maybe making sure the function "sees itself", if you have lexical scoping. Even assembly language has recursion. Which makes recursion... Not an abstraction at all.

[1] https://en.wikipedia.org/wiki/Leaky_abstraction

Re:Stack safety for free? by auggierose on Monday December 06, 2021 @05:25PM (#29466508)
Leaky abstractions are for people who are too lazy to think. And computing is full of them.

And of course you build it into the language. It might happen to you by accident, but if you kill somebody by accident, it is still manslaughter. Well, maybe not if your name is Alec Baldwin.

Look at Apple Metal and the version of C++ they use for it. Try to make a recursive call there. Good luck.

Re:Stack safety for free? by astrobe_ on Tuesday December 07, 2021 @01:56PM (#29476686)
> Leaky abstractions are for people who are too lazy to think

Worthless blanket statement.

> Look at Apple Metal and the version of C++ they use for it.

That's a very specific case of a shader compiler that is disguised as C++. It has a terrifying list of restrictions (for a C++ programmer), and I would say that recursive calls are the least of your problems there.

Obviously, it is not a design failure but a set of hard constrains that lead to those restrictions. Of course they would give you recursion happily if they could. People who can do that sort of compiler are not idiots.

It just shows that you understand little about languages. Yet you think you are in position to comment on language implementers' and designers' jobs. Say hello to Dunning and Kruger.

Re:Stack safety for free? by auggierose on Tuesday December 07, 2021 @05:15PM (#29478913)
My example shows that recursion is a design choice. It doesn't "just happen to you".

But you are right. You can implement recursion properly by just implementing function calls properly, and making sure that you are not limited by an arbitrary and usually small stack size. It's just that if you don't have recursion, you usually don't have a need for deep stack sizes either.

By the way, citing tropes like "leaky abstraction" and "Dunning and Kruger" is exactly the kind of lazy thinking I am talking about.