Tell me Jow Forums, what aspect of computer programming is more beautiful than recursion?

Tell me Jow Forums, what aspect of computer programming is more beautiful than recursion?

Attached: recursion.png (358x180, 7K)

Other urls found in this thread:

google.github.io/dagger/producers.html
homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/baastad.pdf
en.wikipedia.org/wiki/Duff's_device
twitter.com/NSFWRedditImage

Error handling.

>Posts Javascript
Non TCO garbage. That's the opposite of beauty.

Attached: 1374580566292.jpg (344x209, 9K)

javascript is one of the best languages

Recursion in something other than Javascript.

programming something that works.

crossdressing memes

Indent your pajeetscript nigger

successful compilation with all flags and no error messages

an elegant solution
register n = (count + 7) / 8; /* count > 0 assumed */
switch (count % 8)
{
case 0: do { *to = *from++;
case 7: *to = *from++;
case 6: *to = *from++;
case 5: *to = *from++;
case 4: *to = *from++;
case 3: *to = *from++;
case 2: *to = *from++;
case 1: *to = *from++;
} while (--n > 0);
}

ripped from catb

That's seriously bad code on so many levels.

>what aspect of computer programming is more beautiful than recursion?
Loops & map
t. boomer

Monads

This, IO monad is particularly beautiful.
Recursion is also beautiful when dealing with acyclic graphs like binomial heaps.

Pointers

Kek, that's the first filter for brainlets.

the fuck is a monad

A portamento of money & gonads

computational context

I prefer looking at a well-crafted state-machine with minimal allocations.

>all of these retard answers

The most beautiful thing in programming is LISP's read-eval-print-loop

Attached: selection_006.png (655x458, 46K)

Variable Variables

Attached: variablevariables.jpg (333x536, 27K)

A functor with two natural transformations that form a monoid.

That strikes me as a security hole waiting to be exploited.

Recursion with TCO, delimited continuations, hygienic macros, monads, metaobject protocols.

The thing is, we don't know either.

Brainlets love recursion because it seems "beautiful"

I try to explain to them that it's just using the call stack as a stack data structure. They stare at me blankly, clearly not understanding, yet slightly angry.

Recursion is a great way to get stack overflow if you're doing anything too complex. I much prefer to just create a stack data structure, and use it. This tends to also create more readable code. For example, it becomes obvious that the algorithm makes use of a stack. Most brainlets never realize that is all that recursion is.

yeah it's a well documented vulnerability known as PHP.

nice onions overdose there

Attached: 51248680_french-onion-soup-2_6x4-hpr.jpg (2823x1882, 1.17M)

This

recursion is unnecessary and always less efficient than staying in the same scope.
>lets add call-stack limitations as a point of failure because i'm too retarded to code a simple fucking loop.

This. Not only is recursion generally inefficient, but it can be really dangerous in inexperienced hands. There's a reason why JPL bans it from mission critical code.

>I try to explain to them that it's just using the call stack as a stack data structure

Only if you're thinking in terms of von neumann machines. If you think in terms of lambda calculus, recursion is an elegant method of representing certain computations.

>Recursion is a great way to get stack overflow
What is TCO?

Nigger, you are creating a new array for every single recursion.

huh? what the fuck is this?
Adding a dollar sign gives you the variable defined before?

Attached: 1503248190109.jpg (480x454, 76K)

iteration

$a gives you Hello
$$a gives you $Hello that gives you World

recursion is shit

Google Producers

google.github.io/dagger/producers.html

Dollar operator takes a string and returns the content of the variable defined by that string. It's common in shitty interpeted languages where fucking everything is a dict with string keys.

Avoiding stackoverflows.

stack, stack is more beautiful than recursion

Javascript supports tail recursion in the standard since ES6. But the only mainstream browser that implements that part of the standard properly is safari on OSX and iOS.

Software architecture

>What is TCO?
Something that doesn't work with most meaningful recursive algorithms.

Compile time meta programming with side effects.

All of them

Reduction

Nah. Only a few small things that aren't perfect but absolutely not "bad". The first return i.e. should be aligned properly, also a few comments could help even though the code is pretty simple. Z
That said the complete idea is pretty bad, but what the hell, for Jow Forums this is impressive.

oh boy

closures

I'm talking about the use of recursion. It's creating a new array every time an element gets added.

functional composition

apply and eval

Isn't recursion inefficient? Our professor said to use iteration whenever possible.

Space inefficient

Can't you just split any function into multiple functions, splitting it at the points where it calls other functions, and then apply TCO to the resulting smaller functions, each of which will now end with a function call?

It uses stack. Loops don't.

Recursion in haskell> Recursion in any other language

FEXPRS

Call stack overflow

A monad is just a monoid in the category of endofunctors, what's are you, a brainlet?

An iterative solution. Are you trying to bait me? Because if you are it's not funny. Recursion is probably the dumbest thing to ever exist. You can almost always get a more optimised solution by using an iterative one, and not only that SAVE SOME DETODATDED WAM. And YES I AM A RAMLET

Attached: 1451126971394.png (618x618, 90K)

Sorting algorithms, obviously.

Half a diad

probably yes if you think about the problem enough, but seems messier than just calling (or even inlining) the functions
int a(){
int x = b1();
int y = b2();
c1(x,y);
return 2(x+y);
}

x isn't passed to b2's stack frame but you still need to put it where c1 expects it somehow

i also have aids

Attached: fiba.jpg (1266x420, 72K)

Liquid Types.

Proper vectorization.

Anything that doesn't flood the fucking stack, which you'd know would be the consequence if you weren't such a soifaggot who wants to program without knowing assembly basics

Attached: -.jpg (700x700, 60K)

Concurrency

Ah, I see what you mean. What I described will give you tail calls but not necessarily optimization.

console.log(range(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY));
console.log(range(10, 1));

Amateurish, like 99.9% of javascript code I've read.

Plus unnecessary method calls, a extra empty array at the end for no reason, etc. its just a very poorly written example.

a generalization of a burrito

Pattern matching.

>pythonlet detected

>If you think in terms of lambda calculus, recursion is an elegant method of representing certain computations.
The way it trees out?

I understood that reference

homoiconicity

you're all wrong

make your function async and it tcos in v8, chakra and whatever the fuck firecux uses,

The follow script returns Fibonacci numbers below the argument given and wont overflow your stacks. Thank me later!

#!/bin/sh

i=0
j=1
while [ $i -lt $1 ]; do
echo $i
t=$i
i=$((i+j))
j=$t
done

why would i need that

The Curry-Howard correspondence

>what is trampolining

I agree but
>using clisp

It was just an image I grabbed off Google. I was looking for a diagram I used to have of the REPL but couldn't find it.

I love intentional switch fallthrough

The part where you actually ship meaningful programs that have real users instead of obsessing over autistic shit and producing nothing of value

What the fuck is this language, and why the fuck is there two different code blocks using the same lines.

You are retarded

function* range(start, end, step) {
if (end == null) end = start, start = 0;
if (step== null) step = 1;
for (; start < end; start = start + step) yield start;
}

for (const i of range(5)) console.log(i); // 0, 1, 2, 3, 4

console.log([...range(1, 10)]);
Matches Python range behaviour

homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/baastad.pdf

That's Duff's device in C.

it's C. this is a trick that Tom Duff found when trying to optimize writing to a serial port. if i remember correctly, his goal was to do a jump similar to how he would have done it in assembly for the same task.

> what is a tail-recursive compiler

its an ugly quirky language called "c".

Wow, I didn't know you could do that to do loop unrolling. Even though it's probably useless nowadays since compilers got better than human to optimize C code.
But I have no idea how a C compiler can accept that. How is the AST supposed to look like here ?

Array indexing

Is recursion the same as pattern matching?

No, but you can write pattern matching programs using recursion.
Especially if what you're parsing is a tree.

There's a good explanation of it here that I think should answer your questions en.wikipedia.org/wiki/Duff's_device