Introduction to 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 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 in a simpler way. Think of Algorithms as formulae’s. 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 useful than just (a+b). These algorithms are used in banks, but 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 amount of interest you would get.
The accountant in the bank would then just put the numbers as to the amount, the number of period and interest rate inside a box in a software. The algorithms software runs and gives you the output. Now, this output was calculated by the algorithms…the piece of code that 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. Just, one thing to keep in mind if you are a beginner in programming, that doesn’t and never gets confused with functions and algorithms. Both are two different things. If you have any confusion, just 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 which are called unbreakable are just pieces of code of pure mathematics which won’t solve the problem without the required parts. Let’s say for example: a + b = 20
4.5 (5,374 ratings)
View Course
Let’s assume a is 5 here. Now, here if I know that a is 5, then this algorithm can be easily breakable. But 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 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 to only accept 5+15, then all combinations would not work. But again, since I am trying all of the possible combinations, there would be a time when I would try 5+15 and that 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 Algorithm or Myth?
So, the question is whether there is anything termed as an unbreakable algorithm or is it 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 which 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, there can be a few numbers which are negative, 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 a lot 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 of. 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, there is no such algorithm which cannot be cracked. It just needs someone to actually take an interest in it.
Best Languages to Write Algorithms
Frankly speaking, there is officially no specific language which is superb for writing algorithms. Functional languages have an upper hand however, the reason being they are much more superior in terms of calculations and mathematics than other object-oriented languages. But 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 most easier to get on with. The reason why these languages are easier is because, unlike C or any other low-level language, these languages are easier in terms of reading.
Even their syntax is so easy, that just a pure 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 build data structures upon data structures. These languages are typed dynamically.
But there is only one problem here that it can be easier for a programmer to start with, but when they run tests, they may see lots of errors which they didn’t see before runtime, unlike other low-level languages.
2. C Language
C is exactly the opposite of Python here. You may even get confused here because although C is a high-level language some people even consider it as a low-level language due to its way of coding. Even C is very good in terms of abstraction here. If you are into algorithms, you may at a later time one or the other day need to learn proper low-level languages like the assembly.
Point being, 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 and this is very important for algorithms.
3. Java Program
A lot of people actually hate Java for being too verbose and strict. Even some people say that it lacks lots of features that are available in modern sophisticated languages. But this does not actually point to be concerned of.
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 actually show errors during compiling and even before runtime. And as compared to other high-level languages, Java has an extremely low memory leak which 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 is extremely unnecessarily complicated. Some people use it because since it is hard to understand, but once you manage to crack it, people will seriously have a tough time to understand your algorithms which makes it perfect for the job. C#, on the other hand, has garbage collection similar to that of Java.
There are also other functional languages like Haskell (Lisp Family), and Scala (based on Java). You can read my other blogs on them where I have written in detail about how they work and stuff. Java, C, and C++ all run on one or the other virtual machine. Whereas Ruby and Python are interpreters on their interpreter.
If you ask me, I would prefer C#, since it has all the modern capabilities and also would make it easier to port to lower programming languages. In scientific terms, it has the properties of Java, Scala, C, and lower level languages. If you are just wanting 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 in the case of python, most of the stuff you want would be free.
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.