Did you ever ask ChatGPT how it was programmed? Or which programming language might be useful when you are about to create or test new AI application features? Let’s discover which programming languages are the most popular and in which scenario for AI.
When you usually have a question, you ask Google. But nowadays, you might also ask ChatGPT for a response. Depending on the knowledge cutoff (= latest data added before the model was trained) of the large language model (LLM) you will receive different answers. Here is the latest answer of ChatGPT-4 with the knowledge cutoff in December 2023
ChatGPT did a great job as all these languages are very useful for specific AI developments. However, it depends on the context, methods and use-case which programming language to choose. “It depends” is the usual answers in IT projects such as this one.
First and foremost, ask yourself: What do you want to achieve? What is the targeted outcome? And based on that answer, choose your tools such as programming languages, libraries and software-stack.
Do you or does your team have already pre-knowledge in this programming language or software? Are there already some stable libraries available which you can leverage? I am an advocate of learning new things, but always think twice if learning a new programming language or software tool is the right way to go.
Always have in mind: Applying AI means that you are applying various techniques and methods from
statistics and mathematics which are initially independent from any tech stack.
How you are applying your chosen algorithms to your data is up to you. Programming languages and specific libraries are tools which help you to achieve this outcome.
Here is my take on useful programming languages for AI, sorted by its main advantage. For each programming language you see a sample code how each language is intelligently reading and outputting a CSV-file.
Simplicity: Python
As ChatGPT already correctly answered, Python is the undisputed champion when it comes to AI, mainly because of its simplicity. Fun fact: ChatGPT is also mainly written in Python.
Python is easy to learn, has a large community and is highly extensible. Nowadays, many AI frameworks, (vector) databases, Cloud-APIs, etc. support an SDK in Python. When going with Python for any task, a library usually exists for it.
Within the last years many data scientist, data engineers & data analysts started to use Python more often. When comparing the largest data platforms, you usually see support for Python and SQL.
Notable libraries: PyTorch, TensorFlow, Keras, Sci-kit learn, Numpy, Pandas, Polars, Jupyter, Matplotlib, openCV, spaCy
Performance: C++
The main limitation of Python is computational speed. This is where C++ comes into play, which is a compiler-based programming language and especially used for computationally intensive tasks like AI workloads.
Did you know, many AI Python libraries are using C++ code under the hood because of the better performance. So, you provide the input parameters within your Python environment, but the actual compute task is executed by C++ code for example. With this hybrid-approach, users can achieve their task using Python and not C++, which is more difficult to learn.
If execution speed, latency and performance is a top priority, go for C++, but expect a steeper learning curve compared to Python.
Notable libraries: PyTorch, TensorFlow, mlpack, Caffe, OpenNN
Full-Stack: JavaScript
JavaScript is one of the most popular programming languages nowadays. You can execute JavaScript code on the client-side (in the browser) and on the server-side (e.g. with Node.js) which makes it a “full stack” programming language.
If you would like to add AI features to your JavaScript application, you can do that natively. Seamlessly integrate an interactive web-based user-interface, leverage the GPU on the client- and server-side, and implement near real-time interaction with web services.
Screenshot from the OpenAI docs: REST API, Python and JavaScript (Node.js)
are supported to interact with ChatGPT.
However, JavaScript is not suited for intense AI workloads and lacks extensive data science and machine learning libraries. There are also constraints when executing workloads in the browser.
Notable libraries: TensorFlow.js, Brain.js, D3.js, Synaptic.js
Data Analysis: R
In such a list, R cannot be missed. The interpreter-based programming language R was specifically created for statistics in 1993 and is still widely used especially in scientific domains.
R has a native command line interface and is mostly used for data manipulation, calculation and graphical display. It features many extension packages which can be used for machine learning, statistical analysis and many other statistical and mathematical methods.
While R is a favorite among many statisticians, it can be difficult to learn for beginners in this topic area. Also, R is not suitable for production environments.
Notable libraries: tidyverse (dplyr, ggplot2), XGBoost, Gmodels, H2O
Enterprise-level applications: Java
As in the introductory stated, with a programming language you are applying the techniques and methods from statistics and mathematics. So, when you work on a Java-based applications and you are skilled in Java, there are also many libraries which you can leverage to create neural networks or do data preprocessing tasks.
Should you learn Java if you would like to primarily learn and apply machine learning or data analysis? Probably no. Java has a steeper learning curve and not as many extensive libraries like Python.
Java will not replace Python when it comes to AI. However, it can be useful for enterprise-level applications and if you are seeking for scalability and performance.
Notable libraries: Deeplearning4j, Deep Java Library, Apache OpenNLP
The emerging star?: Julia
Have you ever heard of the programming language Julia? When released in 2012 by a small team of programmers, the promise sounds interesting: As general as Python, as fast as the programming language C, as statistics-friendly as R, etc. (find more in their blog post here: https://julialang.org/blog/2012/02/why-we-created-julia/).
It seems that the team delivered. Julia has been downloaded over 45 million times and registered over 10,000 Julia packages for community use. Also, larger corporations are leveraging this newer programming language.
Compared to Python (interpreter- based), Julia uses a JIT (just in time) compilation and is therefore executed faster. Julia features a built-in package manager, is a dynamically typed programming language like JavaScript, and the syntax is better to understand compared to C/C++.
While Julia provides many advantages, Python with its extensive machine learning and data science libraries might be just enough for many AI workloads – in terms of execution and delivery speed.
If there are no libraries for your task, you need to write the code from scratch, which adds extra time.
Julia dropped out of the top 20 in the TIOBE index and is currently on the 34th place (April 2024). In the end, time will tell if Julia can find its way. For now, it might be worth to check it out.
Notable libraries: Flux, Pluto, Makie, MLJ, Tensorflow
This list should provide you a first direction when it comes to programming with AI workloads and is not complete.
Other notable programming languages such as Lisp, C#, Golang, Scala, Prolog & others also have its place in this space. It all comes down to each specific project, use-case and team/skillset.
Feel free to add more languages or other AI libraries below which you’ve already used in your project. Tell us how it went!
Whether you’re just getting started or are looking to enhance your skills in programmability with AI, check out the below learning resources:
Share: