---
title: "Comment by Olivier Pons on \"I Built A SaaS Startup In 2 Months, Here's What I Learned.\" | Hashnode"
description: "&quot;I also find it super cool that I can pass a function that returns a function as a parameter to another function!&quot; This is why JavaScript is so hard t"
url: "https://hashnode.com/posts/i-built-a-saas-startup-in-2-months-heres-what-i-learned/6111d57a9584520c481f55fb/comment/6112b1c5c0623972de8a63bf"
---

[Discussion](https://hashnode.com/posts/i-built-a-saas-startup-in-2-months-heres-what-i-learned/6111d57a9584520c481f55fb)

Comment [I Built A SaaS Startup In 2 Months, Here's What I Learned.](https://hashnode.com/posts/i-built-a-saas-startup-in-2-months-heres-what-i-learned/6111d57a9584520c481f55fb)

[Olivier Pons](https://hashnode.com/@olivierpons)

[Aug 10, 2021](https://hashnode.com/posts/i-built-a-saas-startup-in-2-months-heres-what-i-learned/6111d57a9584520c481f55fb/comment/6112b1c5c0623972de8a63bf)

"I also find it super cool that I can pass a function that returns a function as a parameter to another function!"

This is why JavaScript is so hard to maintain. I can't even imagine how long that will take for another guy (even a JavaScript guru) to understand your code. It's very fun when you write it, it's hell when you have to maintain such code. And when you did not write this, you juste hate the developer who wrote this. So, no, IMHO, it's not super cool to be able to write complex things that will take hours for others to understand and debug when needed.

[Jarrod Watts](https://hashnode.com/@JarrodWatts)

[Aug 11, 2021](https://hashnode.com/posts/i-built-a-saas-startup-in-2-months-heres-what-i-learned/6111d57a9584520c481f55fb/comment/6112b1c5c0623972de8a63bf#reply-61132742c0623972de8a6ab6)

Definitely some valid feedback Olivier. I'm working on this solo at the moment, but I can imagine it could potentially be confusing to work on for someone else.

Although, this pattern isn't necessarily something unique to JavaScript (or Typescript in this scenario), this treatment of functions as first class entities is one of the principles of functional programming in general.

For some more information, this sentence refers to a function I wrote, which is meant to write data to Firestore for a social media profile. In a function called `writeSocialProfile`, which accepts a function `socialApiRequestFunction` as a parameter.

This enables me to run different functions depending on the social media platform I'm looking at.

Essentially it just says "run `getYoutubeProfile` if socialName is `youtube`", and repeat that for each social media in a switch statement.

It definitely might not be as clean to read for new devs to the project, but it has a few benefits that IMO make it worthwhile.

It sped up my workflow of adding new social media platforms to the app, as my workflow could simply be:

-   Write a new function `xyz` to get a user's profile from a new social media platform `abc`.
-   Write integration tests in Jest for this new isolated function (Jest was probably not ideal for this)
-   Once the tests pass, add a case in the existing switch statement, for this new function `xyz` to be returned when the value of `socialName` is `abc`

Definitely agree it might not be pretty to look at for people new to the codebase, but it made the flow a lot easier for me, with some added benefits of easy testing.

[Olivier Pons](https://hashnode.com/@olivierpons)

[Aug 11, 2021](https://hashnode.com/posts/i-built-a-saas-startup-in-2-months-heres-what-i-learned/6111d57a9584520c481f55fb/comment/6112b1c5c0623972de8a63bf#reply-6113941a756897544b106455)

[Jarrod Watts](https://hashnode.com/@JarrodWatts) With adequate comments this should be ok ;)

And you're right, all other languages I've used allow such things: C, C++, C#, Go, Java, Php and Python.

The problem is always: the limits of maintainability vs fast coding.

Because you always end up with debugging someone else's code, I've chosen Python as my language for my job: it's much harder (still possible unfortunately...) to write "hard-to-understand" code.
