How JS made the programmer I am now

Riky Perdana
12 min readMay 1, 2024
Photo by Anthony Tori on Unsplash

I’m sorry if this isn’t my typical article posts like before, where I show you some new inventions to solve real problems. In this article I’ll show you little to no codes, snippets, nor mathematical problems. It’s merely a reflection for reminding myself in the future how I got here — a self taught programmer — in the first place. You may skip this one if you don’t really care, but if you do read through, probably you could get something that sticks. I don’t have a plan of how to structure this writing like the professional does, just think of me having a face-to-face talk with you directly, as a brother. Let me lead with few questions:

Why bother being a programmer?

In Indonesia, it’s typical for any second year highschool students to be assigned to "social science major" when their grades didn’t met the requirements for "natural science major". Parents were so eager to get their children to pass all the requirements — which weren’t that high — so these children could access better chance of getting into University majors where "natural science major" background is required. Let’s spill the names, like medical major, engineering, architecture, physicists, even nurseries. These majors were as cool as it sounds, no wonder the parents would struggle by any means to help — or get — their children in it.

But unfortunately not all children are bright enough to meet their parent’s expectations, for some of us were quite "slow". Yeah, this is an unironic confession. The embarassment of being ranked 36th out of 36 students after first year final exam is no joke. There’s nothing funny seeing my mom being handed out the reports only after all other parents were dismissed. So, getting her child into natural science major is out of the question, from that day and on. This boy got to go through life with the so called "well-designed" education system, getting choked with history, nationalism, and geography lessons, while he can only imagine what science experiments were the kids in the opposite class having fun with.

The same academic pattern went on up 'til recently when I finally got my Ph.D from prestigious university that made me academically well established in social science domain, yeah, I’m a lecturer now. Yet this boy still had the envy of what’re the natural science boys were doing in their lab. But, long long ago I did branched my self out of the social science customary where we’re supposed to be inclined exclusively in social science. The closest thing we do in the realm of math are statistics softwares where we ought to infer a hypothesis and test it by the collected data. But I didn’t stop with IBM SPSS. The very first book that deserve all my thanks was "How to create websites with Joomla (CD included)", that’s it. Kids nowadays took everything for granted as tutorials are abundant and freely available, they don’t feel the amazement of learning bleeding edge skills like web development in 2006, even at that time Google was nowhere like they’re now. I can still recall the excitement of making my html page appear on my Internet Explorer, successfully installed Joomla CMS and Drupal, changed the templates, modify the plugins, I believe it was a God-like power.

Throughout the undergraduate years in Economy major, I secretely learn about web development like HTML, CSS, jQuery (not JS). Oftenly after class breaks, I pay visit to Computer Science major to look for more, being thirsty. But only left to disappoint, after knowing that their classes mostly teaches Visual Basic, .NET Framework, Delphi, Ms. Access for database, even Fortran is a must for every students. The fanciest class they have is Adobe Flash: Action Script. One particular community, outside the classes, shown how they use PHP, finally something relatable. That’s when my world extended yet again to Laravel, Zen Framework, NginX. I no longer use Joomla, but dared to create a content management system (CMS) of my own which is obviously crap.

Years after years honing my PHP skills in secrecy while studying in economy major, I was graduated. Few months after graduation I tried to build my portofolio in MySpace and Friendster (Facebook was almost unheard of), claiming that I’m an experienced web developer. Few job interviews rejected me with "Unfortunately..." for my claim as a web developer didn’t match my title, and require that they’re must be from computer science major. But my luck didn’t stop there, a month after failing tech job interviews — which I didn’t actually deserve — there was a request for a project, create an online store for baby apparels. The site was nothing fancy, just few pages of product categories, slapped with product images and the prices, and let the admin manage the post updates through forms and tables, stored in MySQL. It worked, and I earned my first money and the first thing I bought with that money is Playstation 2. And slowly build my local reputation as a lone web developer. Well, who would’ve thought it’d work?

Why I got interested in it?

Being a lone developer is not an easy endeavour, but not without its own advantages. If you apply for computer science major, you’d have all the privilege of studying all aspects of programming from your peers, lecturers, communities, and get the foundations of programming which could make you a better programmer one day. Being a self taught developer instead gives you one major advantage, freedom, something many people took for granted. You’re not being told to pass linear algebra or discrete math classes before being allowed to touch coding. If the classroom present you with problems where you ought to solve it in certain ways, you don’t mess around by being creative solving it by any other ways unless you don’t mind getting C- for pissing off the lecturer. Outside of the classroom you won’t be handed out with problems, you ought to find one or create yourself, that’s what we call projects.

You can choose to join hackathons, completing Kaggle challenges, or build a start-up yourself with your friends, or even alone. This kind of challenge could range from easy like building wedding guests app, to an entire enterprise resource planning information system. At classroom, you’re given lessons first before facing real challenges. An auto-didact or self-taught developer challenge the world first, then get all the lessons after, oftentimes the hard way. As an example, I learnt about time complexity and big O notation just after I ponder on why does computing matrix inverse of 10 sized matrix took 10 times the duration of computing the inverse of 9 sized matrix, and so on downward. When you’re stuck with a problem, you have no colleagues or lecturers to consult to. The best backups within your reach are developers forums and Stack Overflow. And if none of them helps, fold your sleeves up because there’s only you left.

Not that I hate having few companies, I’d love to. But once I found potential candidates, they turned out to be either too inexperienced, like "Hey, can we change all the workstations here to Windows 7? I don’t do Linux shits". Or they’re too professional like "I don’t code, I’m a system analyst. Even one that actually clicks has paradigmatic difference to mine, like he strictly goes OOP while I love the elegance of functional paradigm. That’s when I settled my self with "I’m my own best company". I know this is wrong and you’d better not venture this path.

What it gave me so far?

So what this poor lone developer achieved so far? Well, nothing much other than the freedom and ability to craft my own solutions for any kinds of technical coding problems I face. If you have free time and cared to look what I made, feel free to check my GitHub page. You’d find how my repositories express my thoughts and believe throughout the codes. Ranging from basic CRUD boilerplate, automatic form generator for hierarchical data, an entire integrated hospital information system, to the last directed graph path finding algorithm. All of them follows one credo,

"If you think that a pair of problem and the answer are representable in function, then it should be done function wise".

A programmer with imperative mind would be inclined to think of any problems should be done imperatively. So does the OOP programmers with their SOLID principles. But a programmer with functional paradigm will tend to think of any problem as a set of functions that requires inputs and yield the desired output. The secret sauce lies inside the function body. We’re free to use any means in the body to get reliable results, as long as we don’t mutate anything outside the function itself. But if you could ditch for loop and conditional statements throughout the process, the function could be as pure as it could get. That’s why purely functional functions tend to be simpler than the other counterparts. I’m not trying to sell out the functional paradigm here that it should claim the throne of the best paradigm, but merely as an eye opener for those who haven’t bat an eye in functional paradigm.

Please take time scouring as many tutorial sites regarding of factorial function. I don’t know what you’d find out there, but throughout the first three pages of Google search results, I bear witness to how procedural, imperative, and OOP programmers design their respective solutions. They extensively used for loops, conditional statements, variables and even classes just to get the result. But the functional way only require this one line.

factorial = n => n === 1 ? 1 : n * factorial(n - 1)
// ^ give me any integer
// ^ is the given integer finally equal to 1?
// ^ if yes then just return 1
// ^ if not then multiply this integer...
// ^ by a factorial of smaller integer by 1

Did you see something peculiar there? Yes, a function that call itself, over and over again, until it satisfy certain condition and fold all the results up to the surface and gives you the final result. No for loops nor conditional statements involved. It’s so simple that it barely demands any documentation. I don’t mean to berate the other paradigms here as they’re good at many other fields such as operating systems to game developments. They even show their strength in the age of AI development. But if efficiency, simplicity, and even code aesthetic is among your concerns, then functional paradigm surely worth a try.

I am no expert in other fields like desktop app development, operating system, or even game development. There must be justifications for using OOP or Procedural paradigm on their respective fields. But as long as it in the realm of web development, I can safely say that I found no challenges that couldn’t be handled by functional paradigm. If you care to look at my Github repositories or my Glitch projects, you’d find that I’ve developed every apps exclusively in functional paradigm. An entirely integrated hospital information system, consists of home-made libraries like autoForm, autoTable, and mithril, where each of them are made from smaller functions. No matter how small or big the functions are, they always have few things in common, extensive use of native array methods (map, filter, find, and reduce), ternary operator, short circuits, and arrow functions. Once you get a good grasp of how each of those weapons work, then you’d never ever look back at for loops and conditional statements again. You’ll think less of codes that works like a set of explicit commands, and begin to think of everything as declarative functions which when given the materials, shall give you the desired product.

You may wonder, if a pure function does nothing but transforming — a clone of — an input to desired output without mutating anything outside of it, then how should we create an useful app where certain information has to be stored somewhere either temporarily or permanently. A function that alter something outside of itself is called impure function, and this is perfectly normal as long as you know what each impure functions responsible for. Like a function that is dedicated to insert something new into the database, a function that meant to update the content of an object stored in a variable, or function that render something onto the screen. Throughout my codes I extensively use these three forms of impure functions, and when something went off, I’d immediately know what caused it and which function to look for, as reported on the console error logs. The simpler the codes, the less it prone to errors.

Why you should care too?

I’ve spilled everything I got, show you examples, and even points you out to check my repositories. I don’t know how much — or less — interested you are in functional paradigm after this, but I did all my best to ensure you that it works, not only they’re effective, efficient, they’re also aesthetic. After embracing functional programming for some years — I did and so you will — and you’ll realize that the epitome of functional programming lies in recursion. I cannot overstate the superiority of recursion in solving various problems that has any resemblance to recursion. No matter what you’ll use your coding skills for, the ability to see a recursive pattern in a problem and the guts to make a recursive solution will almost certainly give you the most elegant solution.

Javascript as a language didn’t gain it’s popularity for being multi-paradigm, other than to know about jQuery for altering any html codes on the browser. With the raise of virtual dom libraries and single page applications, we’ve moved far from the age of jQuery and give JS more respect to handle the entire frontend which were usually pre-rendered server-side.

Have a deep understanding of functional paradigm will also make you less dependant on external libraries, or what we call dependencies. Why bother importing a bloated library which does nothing but leftpadding a string, checking if an integer is odd or even, or make a random unique characters? You could do all of that by making your own made functions in single line each. Have a peek on my simrs repo, you’d find only a few libraries required like express for server, mongo for database, bcrypt for password encryption, lodash for utilities and some minors which would be a hassle to self-write. Less dependencies will also make your apps less prone to errors brought by any of them. And this is the best part, JS as a language which were born client-side does its best job in the browser. That’s why most of my apps are client-oriented while the server-side responsible for nothing other than serving database interaction (create, read, update, and delete). Even apps that doesn’t interact with any database shall work perfectly client-side only.

For my frontend framework I chose Mithril, I owe this library so much, it defined the way I think of what frontend means and could be. People are free to boast about React, Vue, Angular or everything else, but once you know how Mithril is different from them all, you’ll never look back. Mithril framework perfectly aligned with functional paradigm where none of my frontend codes require for loops nor conditional statements. For styling, Bulma CSS is my best choice, why? Because this library doesn’t involve any javascript that might override yours, every components are purely CSS, elegant.

And the last one I’d like to introduce you is Glitch platform. Any newbies whom just moved from other languages like PHP, Ruby, or Python would find setting up the first hello world in expressJS quite daunting. How many tutorials out there instructing you how to install nodeJS in windows or mac, serving the first hello world requires at least a hundred lines of server-sided codes not including the npm packages. The node modules meme where it could be heavier than a spinning black hole is partly due to those behavior of lavishly overusing packages. In Glitch, you could clone any projects in few clicks and, modify it to your heart’s content, and run it live. It’s ensured to stay awake while you’re tinkering with it, and shall wake the instance up whenever someone else visits your projects.

Final take

Why bother publishing all my works publicly on Github, Glitch, and Medium like this? It doesn’t make money for me, nor fame (judging by the amount of claps or subscribers). Even the Joker suggested that “If you’re good at something, never do it for free”. Though I admire the character say much, I must go against that ideology. I believe that what’s good should be shared with everyone else regardless of what we’ll earn from it. I do hope that long after we’re gone, buried deep beneath the ground, the next generation would find something amazing in our works, make something good out of it, regardless they know our name or not. So Medium, don’t you dare removing my posts as they are the only proof of my existence. I write, therefore I am.

--

--