Updated June 20, 2023
Introduction to Learning Algorithms
The following article provides an outline for Learning Algorithms. So, before I start with my heavy artillery stuff about languages and their masks with algorithms, let us first know what algorithms are. You may have heard it in movies, especially movies like The Swordfish or any other wannabe hacking movie in which the hacker states something like if I go and change the algorithm and add blah blah and blah, then I will be able to hack into the CIA and stuff. But that’s pretty gibberish. There is no such thing as that. Learning Algorithms are not just meant for hacking.
First things first, Algorithms are just Data structures. They are a method or a way to do things, more likely to solve algorithms problems. Still confused; let me take this more simply. Think of Algorithms as formulae. Formulae that can help you carry on your task without much ado. Something like the following:
(a+b)2 = a2 +2ab + b2
But these are quite simple. Proper algorithms are much more helpful than just (a+b). These algorithms are used in banks, not just for security and stuff, but everywhere. Let’s say you open your account in a bank. You insert X amount of money in it and want to know the interest you would get.
The accountant in the bank would then just put the numbers as to the amount, the number of periods,s and the interest rate inside a box in software. The algorithms software runs and gives you the output. The algorithms calculated this output…the code already has the formulae for calculating interest. In our case for simple interest, it would be:
A = P (1 + rt)
A = Amount
P = Principal
R = Rate of Interest
T = Time or n
Now, most likely, you must have gotten an idea as to what algorithms are. Remember, if you are a beginner in programming, it doesn’t and never gets confused with functions and algorithms. Both are two different things. If you have any confusion, get them cleared and only then proceed further.
Languages, Math, and Algorithm
Few things to keep in mind that understanding algorithms math is the most important when you want to write better algorithms. Similar is the case with unbreakable or fool-proof algorithms. These learning algorithms, called unbreakable, are just pieces of code of pure mathematics that won’t solve the problem without the required parts. Let’s say, for example, a + b = 20
Let’s assume a is 5 here. Now, if I know that a is 5, this algorithm can be easily breakable. However, if I don’t even know what a is, then there is still a possibility that I can crack this algorithm. The way to crack it would be something like I would brute force it. Brute force means trying every possible combination. So what I would do is I would start guessing numbers like 1+19, 2+18, 3+17, 10+10, and so on. So, now either of the two things would happen.
The first probability is that since all the above combinations would give me the answer as 20, all of them could crack this algorithm. But, if the programmer has hard-coded it only to accept 5+15, all combinations would not work. But again, since I am trying all possible combinations, there would be a time when I would try 5+15, which would crack the algorithm.
Again, the programmer could try to keep the limited number of tries and much more security structure in between, but even for that, we have a lot of tools to bypass it.
Unbreakable Learning Algorithms or Myth?
So, the question is whether anything is termed an unbreakable algorithm or just a myth. The answer is both. I was recently reading some stuff on the internet, where I read a famous quote:
“Impossible only means that one has not tried all the solutions.”
Yeah. That’s how algorithms work. Let’s take the above case. Let’s assume there is another algorithm that goes as:
a + b + c + d + e + f = (-9)
Yes. This is how you write an unbreakable algorithm. The thing is, a decent computer with a good graphics card can easily crack this with oclhashcat. But that’s just an example. Here the combinations can be like anything. The answer is a Negative nine, which means that in a,b,c,d,e, and f, a few negative numbers are at least one large number getting subtracted by a small number.
This takes me back to our first algorithm examples of a + b = 20. Even here, there can be many more combinations like -1+21 or -29354+ 29374. Getting my point. So, the theory of unbreakable algorithms only goes as far as a human mind can think. Unbreakable algorithms are no myth. A well-written algorithm can take up to 2-3 or even more months to crack even by a computer, like that WPA2 encrypted stuff.
The thing is, one must have the patience to stay in mental peace until it gets solved. According to mathematics, no such algorithm cannot be cracked. It just needs someone to take an interest in it.
Best Languages to Write Algorithms
Frankly speaking, no specific language is officially superb for writing algorithms. Functional languages have the upper hand but are much superior in calculations and mathematics than object-oriented languages. However, I would just algorithms list a few of them which I find good enough to code mathematics in:
1. Python and Ruby
First and foremost, I would recommend High-level languages. High-level languages are easier to get on with. These languages are easier because, unlike C or any other low-level language, these languages are easier in terms of reading.
Even their syntax is so easy that a beginner would understand it without anyone teaching them. All the common data structures in these languages have abstractions. You can even build your own implemented versions and data structures upon data structures. These languages are typed dynamically.
But there is only one problem here it can be easier for a programmer to start with, but when they run tests, they may see lots of errors that they didn’t see before runtime, unlike other low-level languages.
2. C Language
C is precisely the opposite of Python here. You may get confused here because although C is a high-level language, some people consider it a low-level language due to its coding method. Even C is excellent in terms of abstraction here. If you are into algorithms, you may need to learn proper low-level languages like assembly at a later time, one or the other day.
The point is, if you know C very well, it would be quite easy to migrate from C or any similar type of language to assembly language. Memory management is also very good in C, which is very important for algorithms.
3. Java Program
A lot of people hate Java for being too verbose and strict. Even some people say that it lacks many features available in modern, sophisticated languages. But this does not point to be concerned.
Java, unlike Python, is not a dynamically typed language. It is a statically typed language and has loads of garbage collection. This means that Java will show errors during compiling and even before runtime. Compared to other high-level languages, Java has an extremely low memory leak that obviously can be fixed and has no segmentation faults.
4. C# and C++
C# is almost similar to Java. It is more like Java with the capabilities of the Modern Language. Some people like to use even C++. But it isn’t very easy. Some people use it because it is hard to understand, but once you crack it, people will seriously have difficulty understanding your algorithms, making them perfect for the job. C#, on the other hand, has garbage collection similar to that of Java.
Other functional languages like Haskell (Lisp Family) and Scala (based on Java) exist. You can read my other blogs, where I have written about how they work. Java, C, and C++ all run on one or the other virtual machine. At the same time, Ruby and Python are interpreters on their interpreter.
I prefer C# since it has all the modern capabilities, making porting to lower programming languages easier. In scientific terms, it has the properties of Java, Scala, C, and lower-level languages. If you want to start with algorithms, you could probably consider using visual studio community edition or Visual studio express. You would probably have to buy that, except that most of the stuff you want would be free in the case of Python.
Recommended Articles
Here are some articles that will help you to get more detail about the Programming Languages for learning Algorithms, so just go through the link.