DEV Community

Cover image for Pitch me on Python

Pitch me on Python

Ben Halpern on May 11, 2022

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.

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
 
spo0q profile image
spO0q 🐒

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
 
spo0q profile image
spO0q 🐒

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
 
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
 
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
 
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
 
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
 
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
 
nuclearzzet profile image
Nik

Python is a modern object oriented programming language, it primarily focuses on web development, ml, ai, automation, it has a not so great package manager, simple syntax, easier to understand and use, I primarily use python for web development using django, but some times flask, it has a large community, so there is someone to help you out with anything

Collapse
 
the3rdc profile image
Cody Crumrine

Big strength #1) Python has several good libraries that will let you write functions in Python that actually execute compiled on a GPU. This is a big reason why it's so popular in Machine Learning. Python itself is super inefficient (like most loosely typed interpreted languages) but it let's you run code in a more efficient way for something like a neural net.

2) pandas and numpy

Collapse
 
the3rdc profile image
Cody Crumrine

lol markdown made my #2 a header

Collapse
 
n8chz profile image
Lorraine Lee

It's said that VisiCalc was the killer app for Apple II. Numpy is the killer app for Python. Conceptually, the things in Numpy are more or less to be found in APL and MATLAB, but Python is friendly and accessible, so why wouldn't it be your go to for array crunching?

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
 
sirseanofloxley profile image
Sean Allin Newell

Here's my pitch:

Good Python reads like prose, it's self documenting and does what it says on the tin. It has a friendly community and a great set of documentation and excellent libraries that make common tasks a breeze. It's easy to jump in a repl to quickly trst some things, transfer to a unit test and then production code within an hour or 30 minutes or less.

Collapse
 
mellen profile image
Matt Ellen-Tsivintzeli

I use python every day, a lot. I can't tell you if it's better than any other scripting language, but it is good and easy to use.

Package management is better than npm, but that's the only comparison I can make

If you like class based object orient programming, it has that, and its syntax is nice and concise.

You can also use it procedurally, no need for a wrapper class.

It's duck typing means unit testing is easy.

Monkey patching is probably to be avoided, due to how unpredictable it can make things.

It's implemented on multiple architectures, as well as in multiple frameworks (Jython and IronPython spring to mind), so you can run it on most systems as well as embed it in applications as a way to script the app.

There are so many libraries built in as well as third party, so if you need to do something in python there's almost certainly someone who has an example you can crib from.

I would say its main downsides are it can seem a little slow (although I don't usually notice), and it's Global Interpreter Lock means you can never leverage the advantages of a multithreaded environment.

Collapse
 
gjorgivarelov profile image
gjorgivarelov

To craft a meaningful personalized offer to you in this way, assuming you agree everything is relative, you'll have to reveal more about the reason you are interested in Python. Have you used some other programming language before? What do you plan to achieve with Python? Python can be the greatest language you've ever written code in, its syntax might appeal to you, you may be tempted to use it for absolutely every coding project landing at your desk and then...
Screwdrivers are made for dealing with screws, gardening tools are for the garden, wrench is for plumbing. I am not saying you can't use a screwdriver for plumbing but every tool has a set of problems it can address.
Why I love Python? I started learning Java first. It was a time when you'd have to dig through Java's APIs to find a data collection object to go beyond the built-in array. And Java's API was already an overgrown jungle. Python on the other hand already has data collection objects built-in and ready to use. Dictionaries, tuples, lists.
Python's math, statistics and machine learning libraries- another reason to love Python, along with the Anaconda project that brings all of them together in a convenient and easy to use interface that is just inviting itself for quick prototype testing and for a student of Python that is a lot of help.
Python's API- easy to search through for modules you might need in a convenient web interface, along with explanations of what each module does and examples of its usage. In all honesty, I don't know if Java progressed in terms of the search usability of its APIs since Oracle overtook it, I saw what Java in the past looked like, how Python nowadays look like, and am not turning back just based on improved search through API.
You may come back and argue that language X beats Python in a segment that I mention above, fine, I just laid out the case for Python. I am interested in machine learning and Python just has everything I need now and as I progress with my self-study I'll probably be covered well by what Python provides.

Collapse
 
moopet profile image
Ben Sinclair

PEP20, i.e. a really early entry to the Python proposals, is the Zen of Python

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

That can apply to any language, but in Python it can be used as a way to critique code someone's trying to get merged, and people shouldn't complain about you being picky.

Collapse
 
aturki profile image
Ali Turki

Python is a mature language
Has a low learning curve
Comes with batteries included
Has an impressive standard library
Easy to setup across multiple environments (and available by default on most systems)

Collapse
 
sanjaybabu profile image
C K Sanjay Babu

Pros :
Very high level language. Syntax very close to the english language.
Zero boilerplate
Easy to learn and get started.
One of the best send most loyal communities around.
Tons and tons of library support

Cons:
Not the fastest.

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

Collapse
 
fen1499 profile image
Fen

Easy to learn, hard to master. You can do all sorts of things with.

Very good for heavy math of data processing, Numpy and Pandas are able to keep your code as readable and as efficient as possible.

Collapse
 
stealthmusic profile image
Jan Wedel • Edited
  • My main language is Java but I’ve build my personal blog/CMS with Django and it’s very very easy to learn but yet very powerful to achieve complicated features.
  • There is a huge number of packages available for all kinds of tasks.
  • I personally would not use it for professional applications due to the lack of static typing. You just have to test a lot more for things that usually a compiler would catch. But I could totally understand why people do this.
Collapse
 
drsensor profile image
૮༼⚆︿⚆༽つ
  • Although Julia is better (no GIL), Python still the "King of Data Scientist"
  • Great for IaC (Infrastructure as Code). I use pulumi + pyinfra for doing orchestration
  • Many old references will say Python has the worst dependency manager but recently it got better and on par with JS package manager. If you start a new project, you might want to use combination of Pipenv/Poetry + pyenv
Collapse
 
amirtds profile image
AMIR TADRISI

AND You can run python in browser
wasmeditor.com

Collapse
 
dumboprogrammer profile image
Tawhid

Hmm,Pyhton is a... Human readable dynamic garbage collected interpreted not very fast versatile simplified syntax intended(no semicolons) abstract OOP language

Collapse
 
pcjmfranken profile image
Peter Franken

It's slow so you can take your time and never feel rushed on the job!

Only joking of course, it's not that slow 😉

Collapse
 
ifierygod profile image
Goran Kortjie

You are not allowed to do python.
--Parents

Collapse
 
unfor19 profile image
Meir Gabay

Easy :mic_drop:

Collapse
 
leob profile image
leob

I don't see the point, unless you do data science or stuff like that ... for web development I think it's decidedly non-mainstream, and increasingly so.

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

Following

Collapse
 
dendihandian profile image
Dendi Handian

I run venv in Anaconda, but if you prefer more in-project venv like Composer or NPM, try Poetry.

Collapse
 
olney1 profile image
Ben

You forgot a word in that sentence.

It does everything brilliantly.
Only slower :)

Collapse
 
codingjlu profile image
codingjlu • Edited

One-second pitch: No. Thirty-second pitch: Noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo[redacted].

Collapse
 
simeg profile image
Simon Egersand 🎈

The logo. Everyone knows if the logo is cool, you should use it.

🙃

Collapse
 
unsungnovelty profile image
Nikhil

You write it and it runs it! :D

Collapse
 
athulmuralidhar profile image
Athul Muralidhar

easy to prototype - hard to scale to complex projects