So does learning Python lead well into learning C++? Does Python have the ability to make full use of GPU functions like 3D collision detection? One of the projects I want to do is a CNC machine simulator with collision detection. Commercial versions cost $10K and up per seat. Way back when, I wrote a CNC code backplotter, which interprets CNC code and draws lines where the tool will go. In theory it shouldn't be too much more difficult to add 3D models for machine components and move them around, but then I need to ask the GPU if they're colliding.
I think Python will give you a good grasp on object-oriented programming and modern programming paradigms, which can be used as a basis for learning C++. The language you probably want for programming GPUs is something like OpenCL, which is a C-like language but there are third-party APIs for using it with Python and such. In any case, I think you might be a little ambitious at the moment. I don't know how fast you learn, but you'll have to decide between being able to make things quickly and being able to make powerful things. You will not be able to make interesting things in C++ with just a few lines of code. Actually, this might be a good question for @seebs, who has worked on C as a language and might have a better understanding of how it compares to Basic and how to learn it.
I learned in C++ without ever diving into object-oriented anything, and I have to say I think I'm a better programmer for it. Memory management is a pain in the ass, but that makes it a very useful skill.
I never really got used to memory management; mathematicians change scope so often that the idea of explicitly freeing things up is like explicitly pronouncing your commas when you talk: you can do it, sure, but you don't unless you're making a point.
I tend not to use new/delete a lot. Sometimes it's hard to avoid, but usually references and stack-created objects do the job.
Yeah but then you have to mess with pointers. :D I understand them pretty well now but they did give me a bit of a headache when I first started... and then there was the time I had to explain to my incredibly experienced programmer dad why I was using a pointer to a pointer to a character...... It was a pointer to a string, which is made up of characters in C, so. There's a reason I prefer C++ over C, object-oriented programming just makes more sense to people. Usually. But it often comes at the cost of speed. Ech okay, here's the benefits and drawbacks I can think of to C and C++. You're going to have to ask someone else about Python, I don't know it very well. Benefits: Memory management-Like I said, useful skill. Programs are applied mathematics. You can't really get completely away from memory management, though there are definitely languages that make it easier than C & C++. Mix between functional and object-oriented-I like this because C taught me the absolute basics and lays out how programs are compiled much more clearly, but object-oriented programming scratches that ordering itch in my brain. Ability for detailed object structures-So C just has structs and pointers, and Java has constructors (create an object) and destructors (destroy an object) and abstract classes (...actually you might want to save that for later), but C++ has constructors, destructors, abstract classes, implicit copy constructors that actually copy members instead of the object's address, overloaded operators where you can make the operators (+,-,= etc.) unique to the object, a form of initialization where you can specify the values that are put into the object before it's put together, and yeah. I have yet to encounter a language that I like as much as C++ for exactly this reason. Code written in C is generally faster than code written in other languages. Object-oriented languages are easier for humans to understand, but less like what a computer speaks, so you usually end up with something that just doesn't interface as well. Drawbacks: Memory management A lot to learn to even just cover the basic semantics of the language(s), and a lot you can do with it on top of that. Bug-prone. Because of the freedom it gives you it can be very easy to make mistakes. If you do go object-oriented in C++ 4 above still applies. As far as compilers go, it really depends on your system. There's a C compiler for Windows, Mac and Linux but I can say from experience that the C compiler for Windows is a pain because Microsoft decided not to support any standard of C beyond the very basics of the first standard. So if you want to use something beyond that, it's more or less a game of darts as to whether or not it'll work. Not sure about C++, as much as I love the language I haven't worked with it as much.
No - I avoid new/delete and use references and stack because there are no pointers when using them. Pointers are usually a bad thing :) EDIT: and speed differences between C and C++ can be eliminated in time critical sections. Don't use exceptions, use references to pass data around (reduces copying objects without the risk that pointers add). Avoid new object construction in time critical areas. ...
You can't avoid pointers if you're, for example, reading out of a buffer. If you use stuff from the C++ library to do those operations, you're still using pointers, you're just not seeing them. It depends on what you're doing. I reject the notion that a basic part of the language is inherently good or bad.
It's the not seeing them part that is important. If you use std::string, for example, YOU have an object, not a pointer to worry about. Underneath, the string object used new to create the buffer - but that is not the problem with pointers. The problem with pointers is forgetting to delete, or double delete, or using an invalid one. By using the string class YOU can't make that mistake. The pointer itself is not the issue. Pointers aren't bad - failing to manage them is. Using objects that manage the pointers for you is one way to avoid that issue. EDIT: even using references doesn't remove pointers - they are usually implemented as pointers under the hood. But the compiler will force you to use them correctly, where it won't do that with a raw pointer.
Yup. I've been using C++ for 18 years as a contractor (going from one kind of thing to another). I think my biggest reason for avoiding new/delete (without going nuts - there is no feature that is useless, just some that are risky to use) is how often I see people use pointers WRONG and introduce bugs that don't show up for a LONG time after.
And that's why I don't use C/C++. No pointers, no risk of pointers. Anyway, in terms of Python versus C/C++: Python has: Pros: 1: No memory management issues; Python takes care of all of that for you. 2: Python is much better at object-oriented stuff than C++, considering that Python was designed with object-oriented programming in mind rather than C++'s sort of tacking object-oriented stuff on top of C. 3: Quick to learn, mostly-human-readable syntax and semantics. 4: Good for file read/write stuff, apparently. Python is popular in data crunching. Cons: 1: No memory management abilities; Python takes care of all of that for you. 2: Slow compared to C/C++; Python has a bunch of overhead to make it more human-readable. 3: Easy to get yourself in trouble on a higher level of abstraction than C's type of trouble, in that it will compile and run more easily but compared to C code that compiles and runs, it probably less robust against user error and scaling issues. 4: Uses indentation as part of its syntax. Seriously, this is absolutely dreadful, and is the main source of not-completely-human-readable. Python can do functional just as well as C. It's not Haskell, but few things are.
Almost everything I have ever worked on has been "this has to work faster! No you can't use assembly language!" so combination of C and C++. Haven't had time to look into Python.
Also, another thing that may or may not be of interest if CNC machine stuff is the goal: Python has built-in arbitrary precision integer arithmetic; C/C++ needs third-party libraries. There are a bunch out there, so you have choices, but they may not all be as robust as C itself. I don't know how most CNC people handle this.
What's CNC? Most of what I do is virtual world simulations, image analysis, and hardware control (currently, next gen iLasik laser system for eye surgery - it's fun).
Computer Numerical Control for machine tools. Like automated lathes and stuff like that. So I guess the hardware control stuff; I don't know how much overlap there is. I'd guess that the eye-surgery systems are probably pretty big on the precision stuff, or at least I hope they are. Not sure how much emphasis on speed there is in CNC.
Speed is important - firing a laser takes a lot of control (micrometer precision) (gas system measurements, Energy Meter measurements, adjust the controls) and in between each firing have to analyze the images from 4 different cameras (3 at 1024x1024, 1 at 640x480) to be sure the laser hit the right place, then based on that analysis reposition the laser via three motors (X, Y, Z axis) for the next shot, and the target speed is 44 firings per second. We do have the advantage of offloading the exact movements of the motors by giving the controller board "current position, desired position" numbers and let it do the actual fine control.
Well... yes but then that means you're also using arbitrary precision integer arithmetic every time, doesn't it? Also @ADigitalMagician told me about this: Python stores the integers up to a certain limit as pointers, so when you type in the literal Python makes that a pointer of the relevant type. This becomes an issue when you try to compare something beyond the limit to something below it.