Python or C++ for ChemE Major: Which is Most Useful?

In summary: I've heard that it can be a bit of a pain, but that you eventually get used to it.I haven't used it -- I'm more familiar with the paradigm of rewriting parts of your python program in C/C++...I've heard that it can be a bit of a pain, but that you eventually get used to it.In summary, the poster wants to learn Python in order to do something with it, but is worried about the difficulty of learning it as a first language. They mention that C++ is a good option, but that Python is also a powerful language. They also mention that it's important to start with a language that is easy to learn, and that C++ is not the best
  • #1
Null_
231
0
I'm a chemE major, entering my sophomore year. I have used python in physics classes, but that was minimal experience.

I want to begin learning a language this summer; I have no other prior experience. My main interest is cryptography, but I don't think this will amount to anything other than a hobby. I'm not interested in games or apps.

I am thinking of learning Python because I have experience with it and because it's a simple language. However, many of my comp sci friends bash on it and tell me to learn C or C++.

Which language would be the most useful? I want to be able to use it to accomplish something (maybe in a future job), but I am not going to be a computer programmer.
 
Technology news on Phys.org
  • #3
It won't be overwhelming? I dabbled with it for a few hours about a month ago and don't even remember now how to print "hello world." I'll probably try to spend an hour a day working with whatever language I choose.
 
  • #4
Both are great languages. I started with Python, but C++ will have you at a lower level. It's probably harder to move from Python to C++.

At my uni. most engineering students have to learn C++.

I'd give the C++ tutorial on this site a shot.

Once you learn how to programming, learning a new language is essentially a matter of learning syntax. The choice of language depends on the task at hand.
 
  • #5
Okay, thanks. I'll give C++ a go for a month and see how far I get.

I find what you say about learning syntax to be inspirational. I suppose it would be better to just jump in the deep end and learn how to swim with C++ than wear those little floaties in the kiddie pool with Python. :)
 
  • #6
I wouldn’t consign Python to the kiddie end of the pool. Python is a great language, and I use it daily. It's extremely powerful and great for rapid development.

Python and C++ are different beasts. C++ is compiled, Python is interpreted. They are both versatile. C++ is good for when you need to operate at a lower level, but it can be a kludge. Python and plain C are elegant, but if code execution is a factor Python may be too slow, and C requires time spent of memory management and the like.

Whitespace is significant in Python, which puts a lot of programmers off, but it's really not a big issue as you should be indenting your code anyway. Both C++ and Python come with large libraries.
 
  • #7
Interesting. Thanks for the insight. I hear many jokes about "import [...]" with Python which is why I made the statement. However, I think I'll stick with the original recommendation and learn C++ first, then Python later if I find the need for it.
 
  • #8
Given the opening poster's motives, I have great difficulty imagining how C++ would have any benefit over Python.


Even for general programming, python is a strong language. As a person who writes high performance code, I would even write most of a finished product in python if it worked on all of my target platforms. Writing an entire program in C++ is premature optimization.
 
  • #10
Now I'm just confused. I suppose I'll wait just a little longer until I decide. The MIT OCW looks nice as I would have a guide to follow. Hmmm..decisions, decisions...
 
  • #11
Welcome to the programming-language wars. :wink:

Just pick one or the other (flip a coin if necessary), and start learning. While the rest of us are arguing over which one you should learn, you can go a long way with either one.
 
  • #12
I just started programming a couple months ago and dabbled with C++ and Python. I really don't see how anyone can learn C++ as a first language. Python is going much faster in my learning experience, mainly because I don't have to worry about syntax as much.

I plan on only focusing on Python until I feel proficient enough to explore other languages. With that said, is there any program that converts or translates Python code into C++?
 
  • #13
DrummingAtom said:
I just started programming a couple months ago and dabbled with C++ and Python. I really don't see how anyone can learn C++ as a first language. Python is going much faster in my learning experience, mainly because I don't have to worry about syntax as much.

I plan on only focusing on Python until I feel proficient enough to explore other languages. With that said, is there any program that converts or translates Python code into C++?
There is Cython.

I haven't used it -- I'm more familiar with the paradigm of rewriting parts of your python program in C/C++ in a fashion that can be invoked from python, e.g. using the ctypes module. But that's mainly because it's the method I'm familiar with, so I can't offer an evaluation of the alternatives.
 
  • #14
Okay, I'm giving python a go.

I've run into a slight annoyance (error on my part probably):

Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> a,b=0,1
>>> while b<100:
a,b=b,b+a
print (b)


1
2
3
5
8
13
21
34
55
89
144
>>>

As you can see, my small program does print; however, when I try to run the program (after saving), I get an invalid syntax error popup message, and the 2 in Python 3.2 is highlighted in a peachy red color. What is the cause of this?
 
  • #15
Why not learn Lisp? :biggrin: Most beautiful language in existence...
 
  • #16
Null_ said:
Okay, I'm giving python a go.

I've run into a slight annoyance (error on my part probably):



As you can see, my small program does print; however, when I try to run the program (after saving), I get an invalid syntax error popup message, and the 2 in Python 3.2 is highlighted in a peachy red color. What is the cause of this?

Does it look something like this in the file?
Code:
a,b=0,1
while b<100:
    a,b=b,b+a
    print b
 
  • #17
Cython is an option; I'm only vaguely familiar with it, but the Python wrapper for libfreenect uses it.

Null_, can you post the exact code you try to save and get the syntax error on?
 
  • #18
I did indent as you did, but I found the problem.
In physics class, we had been using VIDLE with VPython, so I was expecting IDLE to work the same way. I just downloaded VIDLE and it works fine now. Is there any disadvantage to vidle? I really like being able to click and edit the code.
 
  • #19
Vidle is less common, so I'd recommend writing code that works under the standard Python interreter if you want to share code. For personal use, whatever floats your boat.

I personally write my code in gedit and run it from python in bash.
 
  • #20
You should definitely learn python first. The important part of programming is to learn algorithms and paradigms. The only major thing you'll learn from C++ development that you won't learn from python is RAII and pointers. You do not need the raw performance of C++ for what you are learning, and you will proceed quicker and learn faster with python.
 
  • #21
Honestly, it would be to your advantage to learn both. Python is such a functional language and c++ is used all over the place. The cool thing is that you can use them both together.
 

Related to Python or C++ for ChemE Major: Which is Most Useful?

1. Which language is more commonly used in the field of chemical engineering?

Python is generally more commonly used in the field of chemical engineering due to its versatility and ease of use for data analysis and modeling.

2. Can both Python and C++ be used for chemical engineering applications?

Yes, both languages can be used for chemical engineering applications. However, Python may be more suitable for data analysis and C++ for more complex and computationally intensive tasks.

3. Is one language more efficient than the other for chemical engineering tasks?

It depends on the specific task and the programmer's expertise. Generally, C++ may be more efficient for tasks that require high performance and complex computations, while Python may be more efficient for data analysis and visualization.

4. Which language is better for beginners in chemical engineering?

Python is generally considered to be a more beginner-friendly language due to its simpler syntax and readability. However, both languages require time and practice to master.

5. Are there any advantages to learning both Python and C++ for a chemical engineering major?

Yes, there are several advantages to learning both languages. Python can be used for quick data analysis and visualization, while C++ can be used for more complex simulations and models. Having knowledge of both languages can also make you a more versatile and competitive candidate in the job market.

Similar threads

  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
17
Views
1K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
9
Views
1K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
12
Replies
397
Views
14K
  • Programming and Computer Science
Replies
3
Views
474
  • Programming and Computer Science
Replies
16
Views
2K
  • Programming and Computer Science
Replies
14
Views
5K
Back
Top