You are viewing a single comment's thread from:

RE: Algorithms and Codewars

in Programming & Dev3 years ago (edited)

Hello @aristak,

I think you can learn algorithms in any language, but scripting (dynamically typed) languages have the disadvantage when it comes to clean code, and whenever you learn something new you should strive to code it as cleanly as possible in order to re-read it multiple times and play with it in small variations and see what that small change impacts.

The reason for the need for clean code is two-fold: when learning algorithms you will inevitably learn and create structures that if not well designed can have performance pitfalls, and the second reason is that when developing algorithms you will most likely need to change something in the heart of it after a while, and reading scripting languages is always more difficult.

That being said you can have a clean code structure using any language.

When it comes to algorithm performance, the answer is also two-fold: the libraries that come out of the box from the framework you are using might have slight performance differences, but usually, the algorithms implemented are the same. For example for sorting an array, usually, every framework has quick-sort implemented behind the scenes. The second thing that you need to keep in mind is that scripting languages are interpreted at runtime, while strongly typed languages are compiled into native or intermediate code that is highly optimized and close to the native code. So if you google for language execution speed lists you will always see C and C++ at the top because they are compiled to native code, then probably something like C# and Java (maybe not the java from 15 years ago :D), and after that languages like JavaScript, PHP and Python

Hope this helps and maybe this should have been a post and not a comment :D

Keep in mind that there is a third component, and that is fun. Use whatever language is most comfortable and fun for you.

Sort:  

Thank you, @dotnetguru 😁. Now I know why I didn't see Lua in the top languages respect of the execution speed. ¿Does that happen because Lua hasn't built-in concept of classes, since Lua is an object-oriented language?

Not really, it's more because it's a scripting language and not a compiling one...

Now I understand better. Thank you ^^