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

  • Thread starter Thread starter Null_
  • Start date Start date
  • Tags Tags
    C++ Python
AI Thread Summary
The discussion centers around the choice of programming languages for a chemical engineering major with minimal coding experience, particularly in relation to interests in cryptography. The individual is considering learning Python due to prior exposure and its simplicity, but is receiving pressure from peers to learn C or C++. While C++ is noted for its lower-level capabilities and is commonly taught in engineering programs, many contributors argue that Python is more accessible for beginners and offers rapid development advantages. The conversation highlights the differences between the two languages, such as Python being interpreted and C++ being compiled, and emphasizes that both languages have extensive libraries. There is a consensus that learning programming fundamentals is more important than the specific language chosen, and many suggest starting with Python before potentially transitioning to C++. The discussion also touches on practical issues like syntax errors encountered while coding and the use of different coding environments. Ultimately, participants encourage the original poster to choose one language and start learning, as both Python and C++ can be valuable tools in their future career.
Null_
Messages
227
Reaction score
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
C++ without a doubt
 
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.
 
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.
 
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. :)
 
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.
 
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.
 
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.
 

Similar threads

Back
Top