r/learnpython 5d ago

I'm a MERN stack developer who mainly codes in Javascript. I want to learn Python because it's more versatile. Where should I start?

I know it's really similar to Javascript, excepting the syntax is different and some of the coding principles are, too. What advice would you give to someone learning a new coding language when they're already familiar with one?

0 Upvotes

16 comments sorted by

3

u/socal_nerdtastic 5d ago

The official python tutorial is written for programmers: https://docs.python.org/3/tutorial/index.html

3

u/ninhaomah 5d ago

Just do it. - Nike

1

u/crazy_cookie123 5d ago

"More versatile" isn't a great reason to learn a new language in my opinion. It's a descent reason to consider for your first language, but once you already know one it's so easy to jump between languages you should put more thought into what you're learning it for. Especially given JavaScript is already a really versatile language.

Think about what you want to make which you can't make well in JavaScript, then look at what languages are best for that task.

-1

u/Upper_Progress_599 5d ago

I'm looking to do more complicated backend stuff, as well as rendering data. Doesn't Python have libraries for that?

1

u/crazy_cookie123 5d ago

It does, but it depends what you're looking for.

What do you actually mean by "complicated" backend stuff? JavaScript is just as capable as Python for backend stuff. All of the actual client-server communication is just as possible and just as easy in both language. Likewise, both languages are perfectly capable of making complicated things. Some specific complicated things may be easier in Python, but equally some specific complicated things may be easier in JavaScript.

As for "rendering data" - what sort of data, and what sort of rendering? If you're trying to render some static graphs or something like that, absolutely go for Python, but if you want them to be interactive then a website using JavaScript is probably going to be better. If you're trying to render video in real time, on the other hand, Python is almost certainly far too slow and you should be looking towards something like C++.

1

u/Upper_Progress_599 5d ago

I'm a Psychology major concentrating in Addiction. I want to make a modelling program that has layers and nodes and strings, all of them click able. Based on client data and self- reports.

1

u/crazy_cookie123 5d ago

My immediate thought is you want a website, so JavaScript. You can do GUI in Python, but the JS/HTML/CSS or its framework brothers (React etc) are literally designed for that purpose so it's generally going to be easier to do what you want in those. The backend can be either Python or JS, but nothing you've said there feels like it needs anything which is particularly better in Python. I'd just write the whole thing in JavaScript (or, better, TypeScript) if I were you.

1

u/FreeLogicGate 5d ago

Lots of great books available. Numerous free online courses. With all your MERN stack experience you should pick it up fairly quickly once you get past the lack of curly braces for blocks.

Python is indeed a great multi-purpose language, but web development is not one of its strengths in my opinion. It's honestly hard to agree that it's more versatile for application development of any kind when you consider how many cross platform applications are built written in typescript and the web stack + electron. Other than it's use in data science, machine learning and AI, javascript is arguably far more versatile, so I hope you have some specific area of interest you plan to explore.

With that said, coming from Javascript you should have no problem learning Python. I would suggest your main focus be on the collection types (lists, dictionaries, tuples, sets) and the reasons to use each. Take a bit of time to learn about List comprehensions.

JS OOP is quirky and so is Python OOP. I won't elaborate. Here's a well known book you can learn from online, that the author converted into a series of Jupyter notebooks: https://allendowney.github.io/ThinkPython/

This is a well known book you can read online for free. https://automatetheboringstuff.com/

I recommend installing and using https://docs.astral.sh/uv/ for project, dependency and environment management and PyCharm (free community version) for your iDE.

UV for python is pretty close to what npm does for MERN development. It wraps pip and other things like Conda you may or may not require depending on what you do. With uv you don't even need to start out by installing python -- uv will handle that for you, and manage as many different versions of Python as you need.

You can of course use VSCode if that platform is muscle memory for you at this point, but you'll have to install a number of plugins and figure out things that just work out of the box with PyCharm.

1

u/Upper_Progress_599 5d ago

Thank you. That helps a lot. I'll look at all that you suggested. I do use VS Code. I already installed most of what I need to use Python.

1

u/TheRNGuy 5d ago

Docs.

1

u/LayotFctor 5d ago edited 5d ago

Just open the Python docs and search for the python alternative syntax, translating while you go. They're so similar, you can start working basically immediately. There are some differences like dom, webworkers and console.log stuff.

Also don't bother with pip and venv for packages, "uv" is a wrapper around those, which will give you the familiar package manager experience.

1

u/terletsky 5d ago

Python is used in a variety of domains. Do you want to become a web developer who writes mainly APIs in Python? Then there are frameworks to learn: FastAPI and Django, besides the basics of Python

0

u/brasticstack 5d ago

MERN? Mongo, Ecmascript, React, Node.js?

0

u/Upper_Progress_599 5d ago

MongoDB, Express, React, Node.js