New beginner's help -- learn which programming language to enrich my knowledge?

In summary: I recommend "Effective C++" by Scott Meyers and "An Introduction to C++ Programming" by Bjarne Stroustrup.In summary,This physics undergraduate is thinking about learning programming language in order to enrich his knowledge. He recommends C++, Python, and Matlab for different reasons.
  • #1
christliang
8
1
I am a physics undergraduate and is going to pursue a physics Ph.D. degree from 2015 Fall.

I am thinking about learning some programming language to enrich my knowledge. Also, I hope this kind of skill could enlarge the scope of my future career. Please give me some advice on which language should I start from.

THX.
 
Technology news on Phys.org
  • #2
There are numerous threads on the subject, simply search "which language".

The bottom line is that it doesn't matter. Choose C, Fortran, Python, or whichever else for which you can find a compiler and a good book to learn from.
 
  • Like
Likes shade rahmawati
  • #3
First learn Matlab then you have a lot of choice.
I personally use C++ for intensive computing. You have good library, Boost, STD, QT for graphics, OpenCV for computer vision... You can build powerful and reusable code with template méta-programming. You can use assembler code, SIMD intruction for parallélisation (SSSE3 is very usefull for intensive computing).
I know less Fortran and Python. Java is good only for multi-platform, don't use it for math.
 
  • Like
Likes FactChecker
  • #4
For engineering / math / ... type students and engineers, Matlab is popular software tool due to it's ineractive ability to solve mathematical problems without going much into actual programming, You can pick up what programming you need over time. To learn programming as opposed to using a high level tool like Matlab, the language doesn't matter that much, but I would suggest finding out what the current graduate students are using at your school and use what they use.
 
  • Like
Likes FactChecker
  • #5
I second the Matlab recommendation for physics and engineering applications. Also check out Simulink. It is a diagramming tool for simulations that is also made by Mathworks and is well integrated with Matlab. Both have extensive libraries for application areas.
 
  • #6
Thanks all. I know learned a little about MATLAB and C++ before. For C++, could you please recommend some textbooks which is clear written and easily followed. I find many textbooks are not aimed to beginners, so they are very hard to read.

Thx.
 
  • #7
christliang said:
For C++, could you please recommend some textbooks which is clear written and easily followed.
You could just start off with simple programs, like copying a file (read a file and write to another file). Perhaps a sort program that generates an array or vector of random integers and using std::sort to sort the integers. A program to find primes via sieve method.

Here's a link to a very old learning exersice that includes some basic concepts of programming, although dealing with the limitation on branching is more of a puzzle aspect than a programming method.

simple programming training puzzle
 
  • #8
rcgldr said:
You could just start off with simple programs, like copying a file (read a file and write to another file). Perhaps a sort program that generates an array or vector of random integers and using std::sort to sort the integers. A program to find primes via sieve method.

Here's a link to a very old learning exersice that includes some basic concepts of programming, although dealing with the limitation on branching is more of a puzzle aspect than a programming method.

simple programming training puzzle
OK. I think it may be a good way to start. You know, there are many textbooks in my native language(Chinese) that only describe the concepts and do not use many words to show the details of some simple programs. So, I hope you can write some names of books.
 
  • #9
I recommend Python, its easy to grasp and understand. However if you believe yourself to be reasonably adept I would look into JavaScript :)
 
  • Like
Likes camila
  • #10
I would strongly suggest starting out with Python, which is simple as well as enlightening about topics encountered in most other languages. Once you learn Python, MATLAB will be easy to learn. Try NOT to start with C. It is an excellent language ( my favorite) without doubt, but not the best starting language. I have come across quite a few people who ran away from programming because they started with C
 
  • Like
Likes camila
  • #11
sarvesh0303 said:
I would strongly suggest starting out with Python, which is simple as well as enlightening about topics encountered in most other languages. Once you learn Python, MATLAB will be easy to learn. Try NOT to start with C. It is an excellent language ( my favorite) without doubt, but not the best starting language. I have come across quite a few people who ran away from programming because they started with C

Yes, it true... I tried to learn C one year before, but it really didn't leave me a deep impression...

Ok, I think maybe python is a good language for a beginner like me.
 
  • Like
Likes camila
  • #12
christliang said:
For C++, could you please recommend some textbooks which is clear written and easily followed. I find many textbooks are not aimed to beginners, so they are very hard to read.

I've never seen this book myself, but it has good reviews on stackoverflow and amazon.com, and I have some of Stroustrup's other books which are very well written. He is the original inventor of C++ and is probably the leading authority on it. Unlike his other books, this one is intended for people with no programming experience.

https://www.amazon.com/dp/0321992784/?tag=pfamazon01-20
 
Last edited by a moderator:
  • #13
C is hard to learn because functionnal programming is not really intuitive. C++ is oriented object, If you understand oriented object programming, you will define the diferrent concept needed for your project, then you can write it. Python is a new but very popular programming langage, i like it, there is a lot of libs for matrix computing, MATLAB like. BUT it depend of your personnal objective. I repeat, if it's for intensive computing you don't have the choise C++ or Fortran.
 
  • #14
jtbell said:
I've never seen this book myself, but it has good reviews on stackoverflow and amazon.com, and I have some of Stroustrup's other books which are very well written. He is the original inventor of C++ and is probably the leading authority on it. Unlike his other books, this one is intended for people with no programming experience.

https://www.amazon.com/dp/0321992784/?tag=pfamazon01-20
^This. This is easily the best programming book I've seen. I think, however, that Python is a better language for a new programmer, and I'd recommend the MIT OCW 6.00 course from Fall 2008 http://ocw.mit.edu/courses/electric...o-computer-science-and-programming-fall-2008/
It's got video lectures, assignments, readings for various subjects, and it will really guide you at applying your newly acquired programming knowledge into math/physics problems. Good luck
 
Last edited by a moderator:
  • #15
kroni said:
C++ is oriented object

C++ supports object-oriented programming, but it does not require you to write programs in an object-oriented style by defining your own classes of objects, member functions, etc. You can go a long way just using some of the pre-defined classes that are part of the standard library (e.g. iostreams, strings and vectors) which requires learning only a bit of "extra" syntax.
 
  • #16
kroni said:
I repeat, if it's for intensive computing you don't have the choise C++ or Fortran.
When it comes to intensive computing the trend goes more and more towards cloud based solutions. (e.g. Google's compute engine). That means whenever you need to do some lengthy computations you just upload your code and run it on their servers. You can rent as much computing time as you need and run it in parallel on as many servers as you want and of course you can use any language you want, including matlab. And since computing time is quite cheap, the language you use only matters if you have to do really huge amounts of calculations.
 
  • #17
in my major, ocean engineering, we use fortran and MATLAB mostly.
such as Princeton Ocean Model (POM), etc.
good luck!
 
  • #18
When it comes to intensive computing the trend goes more and more towards cloud based solutions. (e.g. Google's compute engine). That means whenever you need to do some lengthy computations you just upload your code and run it on their servers. You can rent as much computing time as you need and run it in parallel on as many servers as you want and of course you can use any language you want, including matlab. And since computing time is quite cheap, the language you use only matters if you have to do really huge amounts of calculations.

You can't say that ! Computing power is not a solution to intensive computing, i think that Cloud Computing must be used as last solution. Recently i traduce a MATLAB program in C++, I use SIMD instruction, OpenMP, Intel Compiler (Linking optimisation, automatic profiling and code optimisation). I work on cache miss, "if" bad prédiction, data structure optimisation and look up table. I gain a factor 17000 on time execution. So the MATLAB code work on 4 hours when mine compute in 1 seconds. It's an extrem example but i personnaly think that before use GPU or Cloud Computing, you must ultra-optimise the algorithme, the code, the compilation.
 
  • #19
I said the language doesn't matter (for moderate amounts of computations). I never said anything about the algorithm. Of course you should use a good algorithm. And I think that cloud computing can be a great solution. Not in all cases but sometimes it is the best option. What happens if after all your ultra optimizations you program still takes weeks to solve a problem? With cloud computing you are able to rent the power of 1000s of CPUs for a short time. Sometimes you simply need a huge amount of processing power.
 
  • #20
I suggest Python because it is easy to learn and is used with physics quite often. For example look at Blender and Sunpy( on Github). There is also a lot of help available for Python.
I started with Java, but later on I realized that is not the language I was looking for. I also tried C but that is in my opinion to complicated to start with, because of pointers etc. I also suggest to try C++. C++ is also easy to learn and suitable for many purposes.
 

Related to New beginner's help -- learn which programming language to enrich my knowledge?

1. What is the best programming language for beginners?

There is no one "best" programming language for beginners. It ultimately depends on your personal interests and goals. However, some popular languages for beginners include Python, Java, and JavaScript.

2. What language should I learn first?

Again, this depends on your goals and interests. If you are interested in web development, learning HTML and CSS would be a good place to start. If you want to develop mobile apps, learning Java or Swift would be beneficial.

3. How do I choose which language to learn?

Consider what you want to achieve with programming. Do you want to create websites, mobile apps, or work with data? Research the languages used for those specific purposes and choose the one that aligns with your goals.

4. Is it better to learn multiple languages or focus on one?

It is generally recommended to focus on one language at a time, especially for beginners. Once you have a solid understanding of one language, it will be easier to learn others. However, if you have specific goals that require knowledge of multiple languages, then it may be beneficial to learn them concurrently.

5. How long does it take to learn a programming language?

The amount of time it takes to learn a programming language varies for each individual. Some factors that may affect this include your prior experience with coding, the complexity of the language, and the amount of time you dedicate to learning. With consistent practice, you can expect to have a basic understanding of a language within a few months.

Similar threads

  • Programming and Computer Science
Replies
8
Views
918
  • Programming and Computer Science
Replies
15
Views
1K
  • Programming and Computer Science
12
Replies
397
Views
14K
  • Programming and Computer Science
Replies
11
Views
1K
  • Programming and Computer Science
4
Replies
107
Views
5K
  • Programming and Computer Science
Replies
16
Views
1K
  • Programming and Computer Science
Replies
16
Views
2K
  • Programming and Computer Science
Replies
9
Views
1K
  • Programming and Computer Science
2
Replies
69
Views
4K
  • Programming and Computer Science
Replies
6
Views
1K
Back
Top