DEV Community

Cover image for Pitch me on Python
Ben Halpern
Ben Halpern

Posted on • Updated on

Pitch me on Python

Let's say I've never used Python before. Can all the Pythonistas out there give the run down of what the language does and why you prefer it? Feel free to touch on drawbacks as well.

Top comments (69)

Collapse
 
rhymes profile image
rhymes

Python has a worse package manager than Ruby's (as in there are multiple and none of them are stellar), other than that is great and does everything Ruby does more or less, with some bigger communities (especially on ML, data science) and probably equally sized communities on web dev (though fragmented around two or three major frameworks: Django, Flask and FastAPI probably).

Python is less DSL oriented and you can mostly ignore multiple inheritance. Even its most popular testing framework, pytest, works great with declarative dependency injection: a test function can declare which objects it needs and the framework will provide it to it.

Python modules are easier to grasp than Ruby modules as well (also because they're not exactly the same thing :D).

Also, Python async game is a bit further on than Ruby's, especially around the paradigm of structured concurrency, very useful to rein in the complicated logic of async programming but requires a bit of paradigm shift so it's probably underused still.

As you know, I enjoy both :D

Collapse
 
stevenally profile image
......

Django seems easier to learn than Rails.

Collapse
 
rhymes profile image
rhymes

that I don't know! They are very similar, one is MVC, the other one is MTV (Rails's controller actions are called views in Django and Rails views are templates in Django). They both have an ORM which requires some learning time. They both have lots of batteries included

Thread Thread
 
gigatt profile image
Evans✨

I just started my Django journey any tips??

Collapse
 
olney1 profile image
Ben

Flask is even easier.

Collapse
 
faraazahmad profile image
Syed Faraaz Ahmad • Edited

I learnt Ruby on Rails first, then few years later I learnt Django. I didnt like Django at all.

I'm not throwing shade at django, its just everyone has their preference

Collapse
 
valentinesean22 profile image
Valentine Sean Chanengeta • Edited

i once heard some companies like quora are using python as their backend language. what could be the reason of this choice since python has a reputation of being slow? the question goes for all medium to large companies using python backend frameworks.

Collapse
 
rhymes profile image
rhymes • Edited

In my experience the language is not often the primary cause for "slowness". After all the majority of web apps are I/O bound. It is true that in benchmarks is not the fastest but speed of language isn't usually the only reason you choose to "lock in" into a community (which you do after all if you decide to invest for many years building a company with a stack).

That said, Quora is 12 years old. Go, which is often used as a comparison for fast productive languages with a garbage collector, is 12 years old ;-)

Thread Thread
 
valentinesean22 profile image
Valentine Sean Chanengeta

ok, on that point of Go, is not it by that time Java was there and i hear many people arguing for it as fast, stable and suitable for writing large complex systems

Thread Thread
 
rhymes profile image
rhymes

Dunno, Java being the defaultt choice was one of the reasons why I started using Python in the first place :) Again, I don't think you can measure developer productivity just by "fast". Otherwise we'd only write in C or Java but we don't ;-)

Thread Thread
 
valentinesean22 profile image
Valentine Sean Chanengeta

thanks you

Collapse
 
mohamed99elsokary profile image
mohamed

Let's say django is working on a compiled Versione of ur code that way we can find beats something like laravel so easy
And get some good response times ok not as fast as node or go or even .net but when the response time is good there is not big difference between 80 and 120 ms after all they both are great
So we they aren't thinking in that point in matter of speed

Collapse
 
bascodes profile image
Bas Steins

Python is maybe one of the most versatile language out there. Now you can even do web frontends with it:

Collapse
 
lucidmach profile image
Nukala Suraj

JavaScript is maybe one of the most versatile languages out there. Now you can even do machine learning with it:
tensorflow.org/js

πŸ˜‚πŸ˜

Collapse
 
codingjlu profile image
codingjlu

But like why?? I'll understand if people try to Rustify JavaScript: it's faster, more efficient, and safer. But Python? Please, no. PyScript is just really really really ugh. I can't see how it'll be better than JavaScript anyways. Oof. Oof.

Collapse
 
jaradc profile image
jaradc

Totally disagree. Javascript syntax is ugly, making it pointlessly more difficult to learn. Python syntax is clean, logical (for the most part), elegant, structured, and is easy to learn for a complete beginner. Whoever says Javascript is a nice language has either learned coding through Javascript as their first language, or has a completely opposite brain from mine.

Thread Thread
 
codingjlu profile image
codingjlu

C++ was my first language. I love JavaScript for its versatility, in my opinion making it an insanely powerful language. There's no use trying to integrate Python everywhere; the syntax is simple, but so are its features. JavaScript was built for the web, and I think that's a spot no other technology should replace. Sure, maybe use WASM for some heavy computation or graphics, but DOM manipulation? Leave that to JS.

Collapse
 
k_penguin_sato profile image
K-Sato

Why not just use JS...?

Collapse
 
tusharsadhwani profile image
Tushar Sadhwani

Because JS is a badly designed language with many pitfalls?
TS is alright, but Python is still way better.

Thread Thread
 
codingjlu profile image
codingjlu

Wait, the "problem" TS solves is implementing static type checking, but there's no type checking in Python, so I'm not sure where you're coming from. Besides that, could you tell me some of the pitfalls you (or you've heard others) encounter when trying to JavaScript? What parts of it do you think are bad designed? I've worked with JS for a long time, and I love Rust, but I like JS even better. For me, Python is way down there next to PHP. And yes, JavaScript, in my opinion, is the best language out there (even ML).

Thread Thread
 
tusharsadhwani profile image
Tushar Sadhwani • Edited

Python has type checking support (in a way that Javascript is planning to add now, there was a TC39 proposal for it this year)

Consider properly trying python then I guess, don't know what else to say.

Ref: tshr.me/mypy

I guess Javascript also has a way to do type checking (jsdoc), but it's awful to write imo.
Apart from that, the weak typing (any data type can turn into strings if you use the wrong operator), the weird rules about how == works, and the baggage of es3 and older standards (eg. array.sort() doesn't do what you'd expect) is enough for me to hate the language as it is.

Thread Thread
 
codingjlu profile image
codingjlu • Edited

Well, I guess it comes to how experienced you are with each language. I've never had any problems with anything you mentioned in JavaScript, so it's probably specific to how much you learned (although I've seen SO posts where people completely crash everything). Sure, JavaScript has its quirks, but I've learned how to avoid the hectic ones and love the others. Python, on the other hand isn't the strange behavior, but more about its misuse (beginner usageβ€”someone made a brute force password guesser in Python), abuse, and overuse that makes me slightly despise it. For me, too, I've never struggled with the untyped language JavaScript, it works perfectly for me. Let me also ask, do you actually use mypy?

Thread Thread
 
tusharsadhwani profile image
Tushar Sadhwani

Javascript is much more misused (given that it's even more popular with beginners), you probably just haven't found the cases :P

I do use mypy, on every project I work on personally and at my workplace.

Thread Thread
 
codingjlu profile image
codingjlu

Okay, good for you.

Collapse
 
bobbyiliev profile image
Bobby Iliev

Saw this on Twitter today:

Collapse
 
olney1 profile image
Ben

Also webassembly work underway and Python in the browser: github.com/pyscript/pyscript

Collapse
 
cerchie profile image
Lucia Cerchie • Edited

It's very human-readable and was designed to handle data and mathematics well, if not at the speediest.

Collapse
 
po0q profile image
pO0q πŸ¦„

nice pitch!

Collapse
 
cerchie profile image
Lucia Cerchie

Thanks! I also forgot to mention that the community is supportive, and that's a big reason to learn a new language for me.

Thread Thread
 
po0q profile image
pO0q πŸ¦„

indeed

Collapse
 
ky1e_s profile image
Kyle Stephens
Collapse
 
pandademic profile image
Pandademic

classic!

Collapse
 
dhravya profile image
Dhravya

it's easy to learn and you can do pretty much everything with it. "it's a slow language", but the speed at which you can make stuff is worth it.

it's simple, user-friendly, easy to read, at this point, question should be "why NOT to learn python, anyway?"

Collapse
 
phlash profile image
Phil Ashby

Mature but very active ecosystem (see excellent teapot image hereabouts!) with sane versioned package repos and good package managment, gentle learning curve, excellent control plane language, effective (if not super efficient) data plane language although high-level expressivity through libraries like numpy and bindings to other tech like tensorflow can remove most of the performance challenges (look at how fast some of the python solutions are to advent of code 2021 for examples).

Plays well with 'as-a-service' things (vendor-supplied bindings to all popular cloud APIs), readily containerisable, the language of choice for tooling in multiple Linux distros (including Debian and derivatives) and likely to remain so (and thus remain relevant) for many years.

Fewer weird typing issues than Javascript (no need for a Tython equivalent to Typescript :), idiomatic ethos (peps.python.org/pep-0020/) with well maintained tutorials.

Neat Azure storage backup tools available (natch): github.com/phlash/azure-sync

Collapse
 
andrewbaisden profile image
Andrew Baisden

You can choose to become a white hat hacker or black hat hacker. Giving you serious street cred and you get to wear hoodies like Elliot Alderson in the series Mr Robot.

FYI white hat hackers are good guys and black hat hackers are bad guys.

Live your dream 😎

Collapse
 
aghost7 profile image
Jonathan Boudreau

IMO the type system in Python is probably the best out of Python, Typescript and sorbet (Ruby). The platform is very mature - you can find a library for almost anything you want.

Its pretty much the defacto language for operations work. There is an operator framework for Kubernetes, you can write ansible modules with it, standard library provides good file and subprocess modules, etc.

If you want to write a bit of Rust here and there, you can do so easily with pyo3. The language is very good at binding to lower level ones.

Since the standard library is much larger, there is less dependency churn compared to NodeJs.

Collapse
 
phlash profile image
Phil Ashby

Good point on the dependency churn, this also helps with security (of supply chain), and seems to be a result of the ethos, creating a managed change process (PEPs) that covers libraries as well as language.

Collapse
 
wiseai profile image
Mahmoud Harmouch • Edited

Feel free to check out the holy scriptures of the pythonic bible I have been writing.

Edit: Don't forget to slap that star button an odd number of times.
Join The Legion.

Collapse
 
jackokeeffe profile image
Jack O'Keeffe

Python is super easy to learn and has a ton of applications. For example, I've been writing HTTP requests to APIs in Java and it is way times easier in Python. Python also has great library support for beginners and pip is super easy to learn and install. Python's syntax is also relatively simple and is easy to read and understand with minimal to no knowledge of coding. OOP is also not too important to use in Python - as it's something that often scares away new developers.

Overall, it's a great langauge to start with if you are just learning progrmaming (I started with it myself) and it peaked my interest in learning other languages.

Collapse
 
n8chz profile image
Lorraine Lee

Python's use of indent level as syntax is widely copied, as evidenced by Coffesscript, HAML, and SLIM. The absence of block delimiters such as {} or begin end makes Python particularly VIM-friendly. I find it one of the fastest languages to edit.

Collapse
 
corentinbettiol profile image
Corentin Bettiol

Like C, but easier to read and way slower.

A new revolutionary package manager per ~month (pipenv, dephell, flit, pdm, pipx, pyflow, conda, poetry, hatch, curdling, edm, pipsi, ferry, ...)

Collapse
 
liviufromendtest profile image
Liviu Lupei

I just love the simple syntax of Python. And the fact that you can just write a few lines in any code editor and run it right away, without installing a ton of stuff.

Python is the JavaScript of non-web stuff.

Our Endtest engine is built with Python, and we wouldn't switch to any other language.

I wouldn't use Python for Web Development, because I'd have a hard time finding resources and questions on StackOverflow about that niche.

But if you're looking to interact with files, image editing, video, OCR, machine learning stuff, there's a huge community using Python for things like that.

Collapse
 
ademdj19 profile image
ademdj19

arent you tired of all semicolones, curley brackets, type declaration and hard syntax
try python it has iterators, sequences and the elements can be of whatever type
[ 1 , "i am an str" , False , Person("name",age=13)] can you believe this works