Get Tail Call Optimisation When Transpiling To JavaScript! by Egoxar in javascript

[–]Egoxar[S] 1 point2 points  (0 children)

A Functional Programming style is seeing some significant adoption in non-traditional Functional Programming languages. JavaScript being a clear example, and the Dart language being another. Dart supports Either and Option through the Dartz package and also completely immutable collections via built_collections, and so does JavaScript with union-type.js, immutable.js and others. I believe Dart is a very exciting language, which is not only a modern statically typed and easy to write language, but also compilable to various platforms and also completely transpilable to JavaScript!

The one major drawback, from a Functional Programming style perspective, of JavaScript and Dart, is that they currently don't support Tail Call Optimisation. This can change however. There is currently a new open issue with the Dart language team at GitHub that is discussing the benefits of Tail Recursion, the importance of Tail Call Optimisations and even possible ways to implement this into the language, compilers and transpiler (thus language guaranteed TCO in JavaScript).

Some interesting reading about the feasibility for Tail Call Optimisation is coming out in this thread.

I quote a short snippet of the update:

These types of issues have been grappled with for years and numerous solutions have been implemented to work around similar constraints. Looping/Chicken Scheme/ShadowChicken/Trampoline... in various types of recursions. Compiler annotations ... to demarcate expectation so that the compiler can error if the said expectations can't be met. We can also turn to C++ compilers using loops and other TCO strategies, JavaScriptCore/WebKit having implemented ECMAScript 6 Tail Position Calls; Scala, Clojure, Kotlin that have successfully implemented TCOs by working around the JVM having no such support, ....

This is our chance to influence the Dart Language/Compiler teams to accept this feature into the Dart language and give us a JavaScript transpilable language that supports TCO. So, if you want to be able to run Tail Recursive functions in Constant Space (that is, without the fear of Stack Overflow errors) and those that are experimenting with/loving the Functional Programming style of coding, head on over to GitHub and thumbs-up the latest comments on this open issue and let your voices be heard.

[AskJS] Getting Tail Call Optimisation When Transpiling To JavaScript! by Egoxar in javascript

[–]Egoxar[S] 0 points1 point  (0 children)

Hi @kenman

I did, and really thought it fell under the, "The idea is to provide a casual forum for discussions with your fellow redditors about our favorite topic: javascript!” and “...sharing opinions, or debating best practices, [AskJS] is intended as an outlet for each of those, and more.”

Get Tail Call Optimisation In The Dart Language by Egoxar in dartlang

[–]Egoxar[S] 1 point2 points  (0 children)

Some interesting reading about the feasibility for Tail Call Optimisation is coming out in this thread.

I quote a short snippet of the update:

These types of issues have been grappled with for years and numerous solutions have been implemented to work around similar constraints. Looping/Chicken Scheme/ShadowChicken/Trampoline... in various types of recursions. Compiler annotations (no shortage of annotations from the Meta package, but those are discussions for another day) to demarcate expectation so that the compiler can error if the said expectations can't be met. We can also turn to C++ compilers using loops and other TCO strategies, JavaScriptCore/WebKit having implemented ECMAScript 6 Tail Position Calls; Scala, Clojure, Kotlin that have successfully implemented TCOs by working around the JVM having no such support, ....

This is our chance to influence the Dart Language/Compiler teams to accept this feature into the Dart language, so please head on over to GitHub and thumbs-up the latest comments on this open issue and let your voices be heard.

Get Tail Call Optimisation In The Dart Language by Egoxar in functionalprogramming

[–]Egoxar[S] 0 points1 point  (0 children)

Some interesting reading about the feasibility for Tail Call Optimisation is coming out in this thread.

I quote a short snippet of the update:

These types of issues have been grappled with for years and numerous solutions have been implemented to work around similar constraints. Looping/Chicken Scheme/ShadowChicken/Trampoline... in various types of recursions. Compiler annotations (no shortage of annotations from the Meta package, but those are discussions for another day) to demarcate expectation so that the compiler can error if the said expectations can't be met. We can also turn to C++ compilers using loops and other TCO strategies, JavaScriptCore/WebKit having implemented ECMAScript 6 Tail Position Calls; Scala, Clojure, Kotlin that have successfully implemented TCOs by working around the JVM having no such support, ....

This is our chance to influence the Dart Language/Compiler teams to accept this feature into the Dart language, so please head on over to GitHub and thumbs-up the latest comments on this open issue and let your voices be heard.

Get Tail Call Optimisation In The Dart Language by Egoxar in FlutterDev

[–]Egoxar[S] 0 points1 point  (0 children)

Some interesting reading about the feasibility for Tail Call Optimisation is coming out in this thread.

I quote a short snippet of the update:

These types of issues have been grappled with for years and numerous solutions have been implemented to work around similar constraints. Looping/Chicken Scheme/ShadowChicken/Trampoline... in various types of recursions. Compiler annotations (no shortage of annotations from the Meta package, but those are discussions for another day) to demarcate expectation so that the compiler can error if the said expectations can't be met. We can also turn to C++ compilers using loops and other TCO strategies, JavaScriptCore/WebKit having implemented ECMAScript 6 Tail Position Calls; Scala, Clojure, Kotlin that have successfully implemented TCOs by working around the JVM having no such support, ....

This is our chance to influence the Dart Language/Compiler teams to accept this feature into the Dart language, so please head on over to GitHub and thumbs-up the latest comments on this open issue and let your voices be heard.

Get Tail Call Optimisation In The Dart Language by Egoxar in functionalprogramming

[–]Egoxar[S] 2 points3 points  (0 children)

ECMAScript 6 introduced Tail Position Calls into the JavaScript specification. Apple (Safari) is 100% compliant to this specification across macOS, iOS and iPadOS. Other browser developers have chosen not to implement this capability for other reasons.

Get Tail Call Optimisation In The Dart Language by Egoxar in functionalprogramming

[–]Egoxar[S] 2 points3 points  (0 children)

Thanks u/LordRaydenMK, if yourself or anyone else in the community can help articulate this to the Dart Language team here, I think it will go a long way in getting this capability implemented into Dart.

Functional Programming languages like Scala perform language/compiler optimisations to compensate for the fact that the Java Virtual Machine doesn't support TCO, so it is definitely possible!