Answers.Body: <p>There are a few advantages of interpreted languages (compared to compiled languages)</p>
  
  <ul>
  <li>platform independence (you only need the interpreter for your platform, even though this is not true if e.g. your interpreted language is only a <a href="https://en.wikipedia.org/wiki/Wrapper_library" rel="nofollow noreferrer">wrapper library</a> around a library written in another programming language)</li>
  <li>dynamic typing (no need to specify the types of the variables)</li>
  <li>dynamic scoping (e.g. you can access variables in other scopes)</li>
  <li>automatic memory management (but there are compiled languages, like Java, that also have a garbage collector)</li>
  <li>Rapid prototyping (for various reasons, including dynamic typing), hence software can be written more quickly</li>
  </ul>
  
  <p>Hence, the main advantages of an interpreted language compared to a compiled language are <em>flexibility</em> and <em>dynamism</em>. Given that AI is still an evolving field, these characteristics are widely appreciated.</p>
  
  <p>There is also at least one disadvantage of interpreted languages (compared to compiled languages)</p>
  
  <ul>
  <li>Slower running times compared to compiled languages, which, once compiled, are quite fast, because they are often compiled to a code that is quickly executable by the machine or virtual machine</li>
  </ul>
  
  <p>Python and R are widely used in data science and artificial intelligence because of the advantages above, which possibly contributed to the rapid growth of the communities around them and the development of software libraries.</p>
  
  <p>However, note that the core of the most common machine learning libraries today, including TensorFlow and PyTorch, is written in a compiled language like C and C++. In the specific case of TensorFlow, Python is just a wrapper library. Consequently, under the hood, the code is not executed by the Python interpreter, but first compiled, which implies that, when you're using e.g. TensorFlow, your code will run (more or less) as fast as if you were using a compiled language like C. A similar argument can be made for libraries like NumPy, where Python is just a wrapper library.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-22T17:56:56.043Z
Answers.Text: is there any good reason why python may not be compiled to be as fast as C?
Answers.UserDisplayName: user8426627
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-22T18:52:55.550Z
Answers.Text: @user8426627 Python code can be first compiled to an intermediate code (called bytecode). See e.g. https://stackoverflow.com/q/471191/3924118. So, Python is both a compiled and interpreted language (like Java). There's also a version of Python that is only compiled [Cython](https://en.wikipedia.org/wiki/Cython), which should give you C-like performance, but this is not the official distribution of Python. If you decide that you want a compiled language, then the language might lose flexibility in certain aspects, because you want to optimize towards the specific architecture (or OS).
Answers.UserDisplayName: nbro
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-22T13:51:46.040Z
Answers.LastActivityDate: 2019-06-22T19:02:34.507Z
Answers.LastEditDate: 2019-06-22T19:02:34.507Z
Answers.UserDisplayName: nbro
Body: <p>One of if not the most popular programming language for data science and AI today is Python, with R being a frequently cited runner-up. However, both of them are interpreted languages, which do not execute as fast as compiled languages. Why is that the case? The main advantage of AI over humans is in computing speed, and with real world AI applications today handling big data, execution time will already increase considerably as it is. Why aren't compiled languages preferred for this very reason?</p>
  
  <p>Sure, the key argument and strength going for Python is its vast range of third party libraries available for AI, like scikit etc. but such communities can take root and grow anywhere under the right circumstances. Why did this community end up growing around Python and not a faster, equally common compiled language like C++, C# or Java?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-22T14:04:23.297Z
Comments.Text: This question is highly related to https://ai.stackexchange.com/q/3494/2444 and https://ai.stackexchange.com/q/7205/2444. Maybe they are all duplicates.
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-23T18:21:39.983Z
Comments.Text: I know that some companies prototype several solutions in Python and then translate the best one in Java.
Comments.UserDisplayName: dcolazin
Tags: <programming-languages>
Title: Why aren't compiled languages as popular as Python in AI?
UserDisplayName: thegreatjedi
ThreadText: # Why aren't compiled languages as popular as Python in AI?
  
  (Asked by: username_0 on 2019-06-22)
  
  One of if not the most popular programming language for data science and AI today is Python, with R being a frequently cited runner-up. However, both of them are interpreted languages, which do not execute as fast as compiled languages. Why is that the case? The main advantage of AI over humans is in computing speed, and with real world AI applications today handling big data, execution time will already increase considerably as it is. Why aren't compiled languages preferred for this very reason?
  
  Sure, the key argument and strength going for Python is its vast range of third party libraries available for AI, like scikit etc. but such communities can take root and grow anywhere under the right circumstances. Why did this community end up growing around Python and not a faster, equally common compiled language like C++, C# or Java?
  
  **Tags:** programming-languages
  > **Comments:**
  > **username_1**: This question is highly related to https://ai.stackexchange.com/q/3494/2444 and https://ai.stackexchange.com/q/7205/2444. Maybe they are all duplicates.  
  > **username_2**: I know that some companies prototype several solutions in Python and then translate the best one in Java.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-06-22. Score: 2
  
  There are a few advantages of interpreted languages (compared to compiled languages)
  
  * platform independence (you only need the interpreter for your platform, even though this is not true if e.g. your interpreted language is only a [wrapper library](https://en.wikipedia.org/wiki/Wrapper_library) around a library written in another programming language)
  * dynamic typing (no need to specify the types of the variables)
  * dynamic scoping (e.g. you can access variables in other scopes)
  * automatic memory management (but there are compiled languages, like Java, that also have a garbage collector)
  * Rapid prototyping (for various reasons, including dynamic typing), hence software can be written more quickly
  
  Hence, the main advantages of an interpreted language compared to a compiled language are *flexibility* and *dynamism*. Given that AI is still an evolving field, these characteristics are widely appreciated.
  
  There is also at least one disadvantage of interpreted languages (compared to compiled languages)
  
  * Slower running times compared to compiled languages, which, once compiled, are quite fast, because they are often compiled to a code that is quickly executable by the machine or virtual machine
  
  Python and R are widely used in data science and artificial intelligence because of the advantages above, which possibly contributed to the rapid growth of the communities around them and the development of software libraries.
  
  However, note that the core of the most common machine learning libraries today, including TensorFlow and PyTorch, is written in a compiled language like C and C++. In the specific case of TensorFlow, Python is just a wrapper library. Consequently, under the hood, the code is not executed by the Python interpreter, but first compiled, which implies that, when you're using e.g. TensorFlow, your code will run (more or less) as fast as if you were using a compiled language like C. A similar argument can be made for libraries like NumPy, where Python is just a wrapper library.
  
  > **Comments:**
  > **username_3**: is there any good reason why python may not be compiled to be as fast as C?  
  > **username_1**: @user8426627 Python code can be first compiled to an intermediate code (called bytecode). See e.g. https://stackoverflow.com/q/471191/3924118. So, Python is both a compiled and interpreted language (like Java). There's also a version of Python that is only compiled [Cython](https://en.wikipedia.org/wiki/Cython), which should give you C-like performance, but this is not the official distribution of Python. If you decide that you want a compiled language, then the language might lose flexibility in certain aspects, because you want to optimize towards the specific architecture (or OS).  
  
  ---
  
  