Matlab is very good to start programming simple CFD codes. Then, according to the progress you achieve, you have to consider Fortran or C++. This latter is required if you want to program subroutine for OpenFOAM.
Fortran is an ancient language and it doesn't have a lot of the functionality and support that c or c++ has. That being said, it is an efficient low level programming language that is still popular with CFD enthusiasts
It strongly depends on what you mean by "CFD Coding and optimization"...
If you would like to make a research stuff like implement new equation or just check the mesh/discretization, the convergence of meshless method, or anything like this in some very simple geometry with many available numerical/analytical solutions for comparison, then use something like matlab or better python.
If you would like to write your own efficient solver, then use C++ (it is fast and allows to easily combine with GPU stuff like CUDA).
If you are in the middle of this, then look at some well-known, well established and well tested opensource existing software - you can develop and contribute to this. E.g.:
The choice of language mainly depends upon your nature of work. Although Fortran is an old language it is more efficient and fast in the case of parallel computing. I think MATLAB has more options and built-in functions than the described language in the question.
Wouldn't really call MATLAB a programming language. The massively parallelized codes use FORTRAN and C++. However, if you are really going to write your own free standing code - you may want to consider CUDA or something that runs on GPUs rather than CPUs.
As optimization problems and CFD problems are usually time-consuming, I recommend you using Fortran or C++. Their codes can be parallelized. They are both faster than MATLAB.
Python front ends like those developed in these projects
https://fenicsproject.org/
https://firedrakeproject.org/
are becoming increasingly popular and combine some MATLAB-like features with greater computational efficiency due to the wide range of optimized libraries they employ.
Personally, to check the concepts or implementing some new methods which I want in my project, I use MATLAB/Python first to get to the bottom of it asap.
Once things are sorted I keep some outputs as checkpoints while writing a good robust object oriented and scalable C++ code where I verify each checkpoints with MATLAB outputs.
However, this is beginner level. Once you are acquainted to C++, I am sure you can directly dive into and write a good code.
There is another thing I want to point out that at what scale are you working on. If the simulation is simpler of like an hour to iterate then I won't consider to go to C++. But if it requires scaling, parallelization etc I will definitely consider C++ anyday over any other language.
If you are a fan of Ansys Fluent, and you want to run simulations in Cfd field, you need to use a C program to integrate only short programs, like matlab with comsol. Or you can move to Ansys Fluent 2021 which is full of new options and I don't think you will need a program there.
For coding I think OpenFOAM is popular nowadays and is preferred especially for multiphase systems. I personally use ANSYS Fluent and it is quite UDF-friendly although I don't do it.
As a newbie to CFD coding, MATLAB may be a good starting point. But to engage in coding of coupled PDEs like full Navier-Stokes equations, you need FORTRAN or C++ as rightly suggested by other referred researchers on here. Hopefully, you can become another renowned Code Developer/Software Engineer in no distant time if only you will pay the price through hardwork and resilience.
The best programming language for Computational Fluid Dynamics (CFD) coding and modeling can depend on several factors, including the specific requirements of the project, performance needs, and the user’s familiarity with the language. Commonly used languages in CFD include:
C++: It is widely used for CFD due to its performance and object-oriented features. C++ allows for high levels of abstraction while still being able to write low-level code for performance-critical applications.
Python: Python is popular for its simplicity and readability, making it a good choice for prototyping and teaching. With libraries like NumPy and SciPy, Python is used for scripting and automating CFD simulations. However, it may not be as performant as compiled languages.
Fortran: Historically, Fortran has been used extensively in scientific computing and CFD due to its efficiency in handling array operations and numerical computation. Modern Fortran is still used in many legacy codes and for high-performance computing tasks.
MATLAB: MATLAB is an interpreted language that is often used for numerical analysis and algorithm development. It’s particularly useful for visualization and has built-in functions for CFD-related tasks.
Each language has its own strengths and weaknesses, and the choice may also be influenced by the existing ecosystem, such as available libraries and community support. For high-performance and large-scale simulations, compiled languages like C++ and Fortran are often preferred. For smaller projects or educational purposes, Python or MATLAB might be more suitable due to their ease of use and extensive libraries. Ultimately, the “best” language will depend on the specific use case and the user’s proficiency with the language. It’s also common to use a combination of languages, such as using Python for setting up simulations and C++ for the performance-critical parts of the code.