Coming from C, how should I learn Python? - Stack Overflow
Java vs python vs C++
Python developer here, want to learn Java
The same as for everybody else, see u/Automoderator's comment and take the MOOC.
Python is so fundamentally different to Java that you will have to relearn a lot of things, so it is best to start from scratch.
Even seemingly simple things are implemented differently in Python to Java, a simple for loop. In Java, it is a traditional for loop; in Python, it is basically a for-each loop.
Loops with else clauses. Great with their use cases. Not existing in Java.
Slicing, which is one of Python's greatest strengths, does not exist in Java. At least nowhere in a way that comes close to Python's capabilities.
Python can do OOP. Java has to do it. In Java, everything is in a class. Everything has to be in methods. In Python? Do what you want and what fits best.
Global variables? No-brainer in Python. Not existing in Java.
List comprehensions, generators, etc. Not existing or completely different in Java.
This goes on and on and on.
Don't get the above wrong, though. I am not dissing either language. Either is great. I like both languages very much. Still in the process of improving my Python skills, but my Java is pretty solid. I also had to basically start from scratch when learning Python despite being a professional programmer since more than three decades and despite having learnt, being fluent, and using over 10 different (some entirely different, domain specific) languages.
As a Python programmer, you are used to think in a very different way. I can see that myself already. You will get the feeling that Java is clumsy and verbose. And honestly, it is compared to Python. Yet, that is deliberate. It gives additional safety and stability. You will feel Java being more restrictive. Again, a deliberate and conscious decision.
More on reddit.comProfessor said learn Python and Java. Why?
Is this course really 100% online? Do I need to attend any classes in person?
How much math do I need to know to take this Specialization?
Can I take the course for free?
Videos
I knew C before I knew Python. No offence intended, but I don't think that your C knowledge is that big a deal. Unless you read very, very slowly, just set out to learn Python. It won't take that long to skim through the material you're familiar with, and it's not as if a Python tutorial aimed at C programmers will make you a better Python programmer - it might teach you things in a different order, is all, and raise some specific things that you would do in C but that you should not do in Python.
Strings in Python actually are somewhat different from strings in C, and they're used differently. I strongly recommend learning them "from scratch", rather than thinking about them in terms of their differences from C strings. For one thing, in Python 2 it's best not to use Python's "string" class to represent strings: there's a separate unicode string class and for practical Python apps (pretty much anything involving user data), you need that. (Python 3 fixes this, making the str class a unicode string). You need to establish a good working practice for unicode/byte data and decode/encode.
A common mistake when learning a second programming language, is to think "I know how to program, I just need to translate what I do in C into Python". No, you don't. While it's true that an algorithm can be basically the same in different languages, the natural way to do a particular thing can be completely different in different languages. You will write better Python code if you learn to use Python idiomatically, than if you try to write Python like a C programmer. Many of the "tricks" you know that make sense in C will be either pointless or counter-productive in Python. Conversely many things that you should do happily in a typical Python program, like allocating and freeing a lot of memory, are things that in C you've probably learned to think twice about. Partly because the typical C program has different restrictions from the typical Python program, and partly because you just have to write more code and think harder to get that kind of thing right in C than you do in Python.
If you're learning the language because you urgently need to program a system/platform which has Python but doesn't have C, then writing Python programs that work like C programs is a reasonable interim measure. But that probably doesn't apply to you, and even if it did it's not the ultimate goal.
One thing you might be interested to look at because of your C experience, is the Python/C API. Python is great for many things, but it doesn't result in the fastest possible computational core of scientific apps [neither does C, probably, but let's not go into FORTRAN for now ;-)]. So if you're aiming to continue with scientific programming through your move in Python, and your programs are typically memory-bus- and CPU-bound doing immense amounts of number-crunching (billions of ops), then you might like to know how to escape into C if you ever need to. Consider it a last resort, though.
You do need to understand Python reasonably well before the Python/C API makes much sense, though.
Oh yes, and if you want to understand OOP in general, remember later on to take a look at something like Java, Objective-C, C++, or D. Python isn't just an OO language, it's a dynamic OO language. You might not realise it from comparing just C with Python, but dynamic vs static types is a completely independent issue from the OOP-ness of Python. Python objects are like hashtables that allow you to attach new fields willy-nilly, but objects in many other OO languages store data in ways which are much more like a C struct.
I learned everything I know about Python from the official documentation: http://docs.python.org/
And it's free.
Hey y'all, I'll be needing to choose either one of Java, python, c++ or web programming for my second semester in electronics and communications but i have no idea where to start from
I've learnt all the basics of c programming in my first semester and i have to choose between the above mentioned for the second semester and it's really rattling my brain
Which of them would be better for a beginner to programming language and which would be most helpful in the future, if you'd have to say?
Thanks in advance!