1024programmer Java Which of C, C++, MATLAB, Python and Go is more suitable for writing algorithms? -Python Tutorial

Which of C, C++, MATLAB, Python and Go is more suitable for writing algorithms? -Python Tutorial

Programming background: I am not a computer-related major. I am majoring in basic subjects such as mathematics and physics. I have just studied C language by myself and finished reading C primer plus. I have a preliminary understanding of the entire language, but I don’t have much programming experience. I have only briefly looked at the contents of classes and inheritance and the ideas of OOP in C++, but I haven’t gotten started yet. You will need to learn matlab soon because it will be used in numerical calculations and data visualization. I have no contact with python and Go language at all.
The main purpose of learning programming at present is not to do projects, find a job, or write papers, but to write programs to implement algorithms when learning algorithms using the book “Introduction to Algorithms”, or to model and analyze some interesting things. For algorithms, what I care about is not the specific implementation details, but the ideas and mathematical principles behind them.
I heard that when writing algorithms in C/C++, they spend a lot of time processing and implementing related details, while writing algorithms in Java and python can focus more on the connotation of the algorithm itself. Is this indeed the case?
If python or Go are more suitable for writing algorithms, may I ask what kind of books or materials are suitable for people with a background like me to get started with these languages?
If C/C++ is more suitable for writing algorithms than other languages, what are the specific differences between C and C++ in this regard? Do I need to learn additional C++, or should I continue to further develop my C language skills?
This is my first time asking a question on Zhihu, thank you!

Reply content:

The main purpose of learning programming at present is not to do projects, find a job, or write papers, but to write programs to implement algorithms when learning algorithms using the book “Introduction to Algorithms”, or to model and analyze some interesting things. For algorithms, what I care about is not the specific implementation details, but the ideas and mathematical principles behind them.

Your request itself is contradictory

One of the core goals of studying “Introduction to Algorithms” is to establish a comprehensive understanding and feeling of the complexity of algorithms. This of course must be done in an easy-to-understand language. Experiments are better on performance modeling/prediction systems, such as C/C++, which are “purely passive” highly predictable systems where the runtime does little or no additional operations. If you choose a system with managed Memory/IO, and the literal O(1) operation turns out to be sometimes not O(1) behind the scenes, aren’t you asking for trouble?

Would you like to be interested in Event modeling and analysis is the domain of mathematics or other disciplines. Of course, it is better to use advanced tools at this time. Apart from anything else, if you are just doing an integer numerical calculation, you also have to consider whether the value will overflow if the value is too large. These machine-level problems are not a waste of time.

[I heard that when writing algorithms in C/C++, they spend a lot of time processing and implementing related details, while writing algorithms in Java and python can focus more on the connotation of the algorithm itself. Is this indeed the case? 】

Wrong. You can use C++ without dealing with implementation details, no one forces you to do so.

Data structures and algorithms are generic in nature. You either use C++ templates or Python’s dynamic typing. Both C and go will make you feel very hard to do. However, the current IDEs for debugging C++ are much better than python. If you already know C++, then use C++.

Just to learn algorithms, C++/Java/C# is the most suitable.

First of all, a language without generics may not be difficult to use. Our company’s current server code is almost all Go, but without generics, it is difficult to use when writing general code. I implemented half of the “Algorithm” in Go and transplanted Haskell’s Parsec library. Most of these codes are actually used in my team’s projects. It’s not necessarily how proficient you are in Go, but I am quite familiar with how many pitfalls it has in language functions. Without generics, it would be too confusing to implement the algorithm. Can you cover all numerical types such as float32/float64/int8/int16/int32/int64/int? If you are just implementing it based on a limited set of data types and problem areas, it is good to use go. Its environment is easy to configure and does not rely much on IDE, but it is still relatively friendly to IDE. It has natural integration of test, fast compilation, simple model, and easy learning. It is easy. It can be said that it is the most similar to a dynamic scripting language among the static compiled languages ​​I have used, and is the most suitable for rapid development of micro-tools.

Secondly, languages ​​​​such as Python/Ruby are not suitable for practicing algorithm implementation. They are too “advanced”. For example, when using Python, it is difficult to avoid its built-in containers List and Dict. These things encapsulate too many things and are easily disturbed during the learning process. In addition, without static type control, some knowledge will be lost during the learning process. It doesn’t mean that you won’t be able to take care of yourself for the rest of your life, but it does require additional learning.

In my experience, if you want to learn algorithms, C++/C#/Java is still a better choice. Their generics are relatively mature and can establish relatively complete knowledge concepts during learning. You can find some better IDEs to use. I personally don’t use IDEs very much at work, but when learning algorithms, a good IDE can help you track the running process of the code and make it easier to do performance analysis. In this way You can use a dynamic, intuitive, and vivid perspective to understand and observe the algorithm. This is very helpful for learning.

If it is just a tool for learning knowledge in a specific field, C++ is actually not very difficult. The main difficulty of C++ lies inAn outstanding coder.
Matlab is officially a super calculator with low learning costs and is very friendly for implementing generalized algorithms. The production efficiency is very high. It also comes with IDE and debugging tools. Debug is not bad, and there is also simulink. Waiting for a very powerful tool.
So matlab is recommended first.
In addition, for students who have room for learning, it is very good to master C++/Java or choose a common programming language based on related backgrounds (such as machine learning students, learn Python).
Of course, if you are already a senior C++/Java language user, then you naturally do not have to go back and learn matlab

For simply learning algorithms, Matlab is the best. Combined with Matlab’s visualization tools, the algorithm process can be easier to understand. Moreover, for basic subject majors, you need to invest in Matlab anyway, so why not start now.

I don’t agree with the use of C/C++ learning algorithms, especially if the poster is not a computer major. Writing algorithms in C involves too many programming skills and matters unrelated to the algorithm. Memory management alone is very troublesome, not to mention various pointer operations that cannot be circumvented. If you implement the algorithm in C++, the advantage over C is multiple generics. Without generics, the algorithm cannot be universal, but the purpose of the original poster is to learn the algorithm, not to implement a universal algorithm of industrial quality (stl has long been implemented). So generics is a concept that only increases the learning curve. There is no need to touch it. What if we just use float32 as the algorithm to implement it?

According to my concept, C and C++ are used to write algorithms, while matlab and python are used to use algorithms.

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/which-of-c-c-matlab-python-and-go-is-more-suitable-for-writing-algorithms-python-tutorial/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索