Tail Call Optimization: The Musical!!

youtube.com/watch?v=EnDknmMXxFY

Hmm.. maybe women really are equal to men when it comes to programming.

Attached: Screenshot_2019-06-03_07-49-13.png (794x398, 204.82K)

Other urls found in this thread:

youtube.com/watch?v=EnDknmMXxFY
youtube.com/watch?v=-PX0BV9hGZY
play.rust-lang.org/?gist=668034293aee6ec0dc870999e243c641
gnu.org/software/guix/
gnu.org/software/shepherd/
gnu.org/software/guile/libraries/
blog.cloudflare.com/how-stacks-are-handled-in-go/
twitter.com/SFWRedditGifs

my pp is hard?

Or you just write a loop instead kek.
Women know no shame.

This. Recursion is a meme perpetuated by functional programmers.

> youtube.com/watch?v=EnDknmMXxFY
Video is unavailable. But I cannot imagine it being more cringe than Stallman's St. Ignucious act.

t. brainlets who can't into recursion and keep blowing the call stack

This.

all recursion can be rewritten as iteration, but not all iteration can be written as recursion. Doing this makes memory usage explicit, guarantees caching and reuse of results, and allows depth first search to be easily supplanted by breadth first or any other order. Iteration is strictly superior, bar making it harder for brainlets like you to understand.

function calls are slow. most good compilers turn recursive messes into loops. generally unless you are a nigger loops are superior.

dont think this is how it works

I wish i had a girlfriend. The more retarded the better but not too retarded I think these girls are at the perfect level.

based

This.

This.

There is no difference between recursion and a loop once compiled, retard but recursion requires the compiler to recognize your retarded writing style for a loop.
There isn't anything hard to understand about returning the function call.

You're still a faggot.

I want to see an example, because I can't imagine such a case. I write all my scheme programs with recursion instead of loops and it works in the same way.

But you know LISP-like language interpreters do just that thing? They don't call a function there, but they interpret this as a loop. Basically look how a compiler works.
With tail calls you can do both recursion and iteration, whereas with your poor loops, you can do just iteration.

!!Con 2019- Tail Call Optimization: The Musical!! by Anjana Vakil ...

new link
youtube.com/watch?v=-PX0BV9hGZY

Comments are disabled for this video.

FORTRAN programmer from 1972 just discovered Zig Forums without updating his programming knowledge first

Show me an example please.


Yes, compilers do optimization, no shit. That's like saying you should manually unroll loops because that's what a compiler will do to your loop anyway. You don't unroll loops manually because that breaks the semantics of what you are doing. Same with recursion, if your problem is elegantly expressed as tail-called recursion then use recursion.

function calls are slow. they will always be slow. You can trick yourself into thinking they arent slow by using inlining and compiler trickery but they will always be slow. context switching will always be slow.

most real code before it is released the programmers themselves turn recursive messes into loops and dont have the compiler do it. recursion just allows your nigger mind to comprehend what is happening. also dont think about recursion once you start programming anything low level.

Yes, in C because otherwise you'll blow the sstack and literally cause RCE vulns [search "stack clash" for the latest hype about rediscovering this problem from the 60's]

C is slow you stupid fucking LARPer

FIX UR SHIT FUCKING NIGGER ADMINS. LITERALLY WORSE THAN REDDIT TUBE

C is slow? how am i a larper you are the nigger thats swimming in the middle of the ocean with no idea whats below you. Just because when you are creating hello world in java in your CS 101 class you didint need to worry about whats below doesnt mean you shouldnt know.

Your brain is slow. Interpreters do not interpret tail calls like calling a function, but like a loop.
What code, who? If they're C programmers, it's understandable, but in LISP everything is written by recursion. I'm sorry that your language isn't optimized and it overflows the stack every time you make a linearly recursive function.

i found the real larper
real programs that people actually use.

Fixed it for you.

oh you are a troll, you are just pretending to be retarded.

(((globals)))

You won't find one, because the person who wrote that is an idiot me. what you will find, is that anything but trivial recursion would be better written as iteration in languages that support it. functional languages generally have a number of functional operators like map and reduce, because writing these operations from plain recursion is too confusing. imperative languages get along fine with just for and while loops, the two of which can perform any iterative operation without being overly confusing.


Every imperative language I know has limits on stack depth. If you want a stack that grows, allocate one and use that (yes, that means using iteration. get used to it)


click on the captcha until you get an easy one.


false.
once you've rewritten your code to make the tail call explicit, you would be better off wrapping the whole thing in a while loop and making the iteration explicit as well.

Good programmers use recursion or loops depending on circumstance.

Write Ackerman's function using iteration. I fucking dare you

play.rust-lang.org/?gist=668034293aee6ec0dc870999e243c641
fn ackermann_iterative(m: u32, mut n: u32) -> u32 { let mut stack = vec!(m); while let Some(m) = stack.pop() { if m == 0 { n += 1; } else if n == 0 { n = 1; stack.push(m - 1); } else { n -= 1; stack.push(m - 1); stack.push(m); } } n}

You did it.

BTFO tbh.

Attached: alex jones laughing.jpg (1400x1538, 232.86K)

Okay, now write it in a language that people use

Oh yes, I can really feel my brain dissolving after having implemented those.
(define (map proc . items) (define (iter acc remaining) (if (null? items) acc (iter (cons (proc (car remaining))) (cdr remaining)))) (reverse! (iter '() items)))(define (reduce initial proc items) (define (iter acc remaining) (if (null? remaining) acc (iter (proc acc (car remaining)) (cdr remaining)))) (iter initial items))

There is nothing confusing about map or reduce, those are first-chapter beginner's exercises in SICP. The reason they are included is because they are so frequently used that it would make no sense not to have them included.

wtf
Nobody actually writes programs in this language, right? It's just a bunch of LARPers jerking each other off because >muh homoiconicity, right?

The point is that writing the equivalent of map with a for loop is not confusing. Writing the equivalent of reduce with a for loop, ie an accumulation, is also not confusing. Mix them together, add logging or early exit or anything else and it still isn't confusing. Writing the equivalent of map using recursion is confusing, as is reduce, and I notice that your demonstration used "iter" (ie a for loop) for both.

Wrong.
gnu.org/software/guix/
gnu.org/software/shepherd/
gnu.org/software/guile/libraries/
After one month of programming in a LISP dialect ))) stop being problematic.
Programmers using languages with C-like syntax have small brains indeed.

Every recursion can be expressed as a loop and every loop can be expressed as recursion, I don't understand what you are getting at. The iter in my code is just another function I defined, which I can tail-recursively, it is not part of the language. I could have called it bash-the-fash for all it matters.


Programming in Lisp made me realize that syntax is just unnecessary bloat that obscures the view. The (((parentheses))) just vanish from view mentally and my editor balances them automatically anyway.

lol
This is your brain on (((LISP))). Utter braindamage.

>Programming in Lisp made me realize that syntax is just unnecessary bloat that obscures the view. The (((parentheses))) just vanish from view mentally and my editor balances them automatically anyway.
This. It is funny, but they actually vanish, brain removes them in some way.
I've never had something like this with languages using C-like syntax. LISP really changes the way you think.

Unbased.

You lose.
Shame because I'm pro recursion.

The Indian has better showmanship than the Jewess. That was a surprise seeing as how the Jews run showbiz.

I hate seeing females, it makesbme want to die.

That was I joke, I know C is used for real things, kernel I'm using is written in C, but it doesn't change the fact Scheme is sometimes used for real things too, for example GNU Guix or the Shepherd.
C is a popular language indeed, but it doesn't necessarily mean it is perfect and better than everything else. Windows is widely used for real things too, and it doesn't make the OS the best.
There are many reasons C is popular, probably one of these is that UNIX used it. D in my opinion is designed better than both C and C++, and it isn't popular and widely used somehow. Also check out JS - a language written in ten days is now widely used and people try to make it a real thing like with nodejs. They wan't to program back-end in such a buggy language. It doesn't make JS good.
I have used JS, Scheme and C++ and In my opinion Scheme has the best design out of these.

I have a couple of questions
a) are the Guix shill and Lisptard the same person
b) is he mentally ill

No
I'm not, but it depends who are you talking about. There's one multicsfag blaming Unix for Windows' faults. There are many of us and we're not a hive mind yet.

It's the best desktop OS with the most applications and a modern compositor even through it's source code dates back to QDOS.
Look Wayland has just arrived and you still have to make applications for it. It won't magically make things good by receiving everything XWayland.

Don't misunderstand.
What I'm saying is that it's not a good desktop OS for the average consumer at the moment, I'm not say that that can't be changed.

bumperoo

I _am_ used to it you dickfuck, but it's fucking retarded. If you want speed, use assembly. If you want solid code, use SML like a white man and don't do workarounds to implement recursive functions, which are one of the most basic and common techniques in programming (unless all you do all day is DSP and do multiply-add ops).

couldn't watch for more than 15 seconds

Go is an imperative language with automatically growable stacks, but no tail call optimization.

blog.cloudflare.com/how-stacks-are-handled-in-go/

And yes, if the tail call happens to be to the same function, a compiler can easily optimize this away to a GOTO. But if the tail call calls another function, then you have some fun times. You can achieve in a compiler/transpiler that compiles into C or Java by using trampolines, but that sucks performance-wise. I am actually tempted into compiling into Go instead...

Scheme has both tail call optimization and growable stacks.

Recursion can always do what an iteration does. But not as fast, for the most part. If you code in C, or C++, or Java, or JS, you have to use custom stacks because you can run out of stack pretty quickly...

The mark of the brainlet.

Don't say that, the "average consumer" uses his OS as a hardware compatibility layer to launch the real OS called the "web browser".

unbased and braindamaged