Posts

Showing posts with the label language

Yet another take on recursion

Recursion is often one of the hardest things to "get" in programming, so when you have your "aha" moment, it's that much more amazing. Conceptually, it's not that hard to see, but how do you actually program one such?  First, realize that " recursion is a method of solving a problem where the solution depends on solutions to smaller instances of the same problem." Let us try something simple. Let's say... I want you to sum up the elements of an arbitrary array, let's call it arr. It can have any number of elements, and each element is an integer. For the purpose of this exercise, let's just say it's [1,2,3,4], but it can be any integer, and the array can be any valid size. And I want to you use recursion, not loop (no for or while or such statements).  Now, remember the definition: "solving a problem where the solution depends on the solutions to smaller instances of the same problem".  Let's call this function rsum (...

There is no such thing as "best (programming) language"...

One of the most often asked questions on /r/learnprogramming is "what is the best (programming language / framework / toolkit) to learn?" The proper answer is "the language you know best that can do the job". But many new to programming don't have a job to do. Instead, they want an answer that will basically, predict the future, i.e. what should they learn NOW, so they can be employable or be happy LATER. Sorry, that's not gonna happen. And obviously anyone who said "study this" is a lying SOB. And since everyone's programming journey is a bit different, everybody's answer will be different, and most will simply give the answer of the language they are most proficient in, assuming that his own journey can be recreated by anyone. Rather unlikely. Almost everyone can drive a car, not everyone can RACE a car (successfully) for a living. Same with programming. Almost everyone can program a little. Macro recording, simple scripting...