Answers.Body: <p>Matlab may be a good option to get started with the implementation of genetic algorithms, given that there a lot of pre-defined functions.</p>
  
  <p>See e.g. <a href="https://www.mathworks.com/discovery/genetic-algorithm.html" rel="nofollow noreferrer">https://www.mathworks.com/discovery/genetic-algorithm.html</a> and <a href="https://www.mathworks.com/help/gads/examples/coding-and-minimizing-a-fitness-function-using-the-genetic-algorithm.html" rel="nofollow noreferrer">https://www.mathworks.com/help/gads/examples/coding-and-minimizing-a-fitness-function-using-the-genetic-algorithm.html</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-21T11:00:00.263Z
Answers.LastActivityDate: 2020-02-09T14:51:57.713Z
Answers.LastEditDate: 2020-02-09T14:51:57.713Z
Answers.UserDisplayName: Ayoub EL MAJJODI
Answers.Body: <p>There is no "best language" for any problem. There are too many variables to consider, even when advising a single person with a single project plan.</p>
  
  <p>If the choice is between Python and C++, I would generally advise:</p>
  
  <ul>
  <li><p>If you want to implement from scratch and learn how the algorithm works, use Python with numeric/accelerated libraries such as NumPy or PyTorch. Python script is quicker to prototype and try different ideas, due to loose variable typing and built-in high-level structures such as <code>dict</code> and <code>list</code>.</p></li>
  <li><p>If you want to write core, efficient libraries, then C++ will out-perform Python, but writing these will take longer. There are plenty of C++ libraries available (e.g. TensorFlow is available with a C++ API), but the community around them is less focused than with Python toolkits.</p></li>
  </ul>
  
  <p>You can also combine both approaches and write specific libraries in C or C++ to improve performance at any time.</p>
  
  <p>With Genetic Algorithms, the speed bottleneck is most often population assessment - e.g. running the environment simulation to get a fitness measure for each individual - and not the GA itself. So if you have a specific problem or problem domain in mind, may want to orient your choice around a language that already has support for the kind of environments where you want to run your GA. GAs usually benefit greatly from parallelisation, so if you are aiming for something ambitious you will want to look into GPU support and/or distributed computing toolkits.</p>
  
  <p>Most researchers/hobbyists working in AI-related fields end up using multiple languages over time. You may end up with a favourite language environment, which might be Python, Julia, Java, C++, C, C#, Lua, LISP, Prolog, Matlab/Octave, R . . . but you will end up needing a smattering of other languages, and usually skills with specific toolkits such as TensorFlow, Scikit-Learn, Hadoop etc in order to complete projects. </p>
  
  <p>Don't be afraid that you will "waste time" learning in one language initially then needing to transfer to another. Your learning of algorithms will be transferable, and your first attempts will most likely not be that re-usable as library code anyway, so you are going to re-implement your ideas, perhaps many times. My first simulated annealing project was written in Fortran 77 . . . 20 years later I dug that knowledge up again and implemented in Ruby/C - nowadays I work in Python for the AI/hobby stuff even though my professional career sees me working mostly in Ruby.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-21T09:00:59.283Z
Answers.LastActivityDate: 2018-10-21T09:16:04.990Z
Answers.LastEditDate: 2018-10-21T09:16:04.990Z
Answers.UserDisplayName: Neil Slater
Body: <p>What is the best and easiest programming language to learn to implement genetic algorithms? C++ or Python, or any other?</p>
  
Tags: <comparison><genetic-algorithms><programming-languages><genetic-programming>
Title: What is the best programming language to learn to implement genetic algorithms?
UserDisplayName: Rahul R
ThreadText: # What is the best programming language to learn to implement genetic algorithms?
  
  (Asked by: username_0 on 2018-10-21)
  
  What is the best and easiest programming language to learn to implement genetic algorithms? C++ or Python, or any other?
  
  **Tags:** comparison, genetic-algorithms, programming-languages, genetic-programming
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-10-21. Score: -2 | Accepted answer
  
  Matlab may be a good option to get started with the implementation of genetic algorithms, given that there a lot of pre-defined functions.
  
  See e.g. <https://www.mathworks.com/discovery/genetic-algorithm.html> and <https://www.mathworks.com/help/gads/examples/coding-and-minimizing-a-fitness-function-using-the-genetic-algorithm.html>.
  
  
  ---
  
  ### Answer by username_2 on 2018-10-21. Score: 5
  
  There is no "best language" for any problem. There are too many variables to consider, even when advising a single person with a single project plan.
  
  If the choice is between Python and C++, I would generally advise:
  
  * If you want to implement from scratch and learn how the algorithm works, use Python with numeric/accelerated libraries such as NumPy or PyTorch. Python script is quicker to prototype and try different ideas, due to loose variable typing and built-in high-level structures such as `dict` and `list`.
  * If you want to write core, efficient libraries, then C++ will out-perform Python, but writing these will take longer. There are plenty of C++ libraries available (e.g. TensorFlow is available with a C++ API), but the community around them is less focused than with Python toolkits.
  
  You can also combine both approaches and write specific libraries in C or C++ to improve performance at any time.
  
  With Genetic Algorithms, the speed bottleneck is most often population assessment - e.g. running the environment simulation to get a fitness measure for each individual - and not the GA itself. So if you have a specific problem or problem domain in mind, may want to orient your choice around a language that already has support for the kind of environments where you want to run your GA. GAs usually benefit greatly from parallelisation, so if you are aiming for something ambitious you will want to look into GPU support and/or distributed computing toolkits.
  
  Most researchers/hobbyists working in AI-related fields end up using multiple languages over time. You may end up with a favourite language environment, which might be Python, Julia, Java, C++, C, C#, Lua, LISP, Prolog, Matlab/Octave, R . . . but you will end up needing a smattering of other languages, and usually skills with specific toolkits such as TensorFlow, Scikit-Learn, Hadoop etc in order to complete projects.
  
  Don't be afraid that you will "waste time" learning in one language initially then needing to transfer to another. Your learning of algorithms will be transferable, and your first attempts will most likely not be that re-usable as library code anyway, so you are going to re-implement your ideas, perhaps many times. My first simulated annealing project was written in Fortran 77 . . . 20 years later I dug that knowledge up again and implemented in Ruby/C - nowadays I work in Python for the AI/hobby stuff even though my professional career sees me working mostly in Ruby.
  
  
  ---
  
  