DEV Community

loading...
Cover image for Why I use python

Why I use python

codemonkey51 profile image Codemonkey51 ・2 min read

If you have read my posts on replit you might know that I mainly use python3 and used to use python 2.7. Today I will talk about the story of why I used python 2.7, and why I transferred to python3, along with pros and cons of each.

I started with python2.7, because that was the class I took. It looked like a nice programming language, and was easy to use once I learned the fundamentals. So here are the pros and cons:

Pros Cons
Easy to learn Missing support for new features
Easy to use It has essentially been back-porting python 3 features
Simple No more official support

Eventually for whatever reason I switched to python3, and the only different thing I noticed at the time was that print became a function. It was a simple change with a great reason behind it, but it made a lot of things possible. Of course there were more changes that I can notice now, but back then I wasn't as good with python as I am today. So here are the pros and cons:

Pros Cons
Easy to learn Took some time to relearn how to quickly Code in it
Easy to use
Simple
More powerful
Great docs!

For python3 there aren't that many cons, and the one con that I could think of was short term and only affected people who had only coded in python2.7 before.

I chose python over other languages becuase:

  • JavaScript has weird type behavior
  • Java & C & C++ are statically typed, while I prefer dynamic languages, also you can use python typing with mypy to kind of statically type python
  • bash scripting is not really a language

As a side note, it can also be easily coded with, with projects like brython, and replit

Discussion (9)

pic
Editor guide
Collapse
barbaroja19 profile image
barbaroja19

I really wish that my first class in programming was in Python. We used Visual Basic instead which has a much smaller use case.

If you really love Python though I would encourage you to learn some C programming, as one of the main compilers for Python is written in C. It may open the door to a deeper understanding of the language.

Also I can't recommend bash enough. Not only does it allow you to work more efficiently in *nix environments, it is really useful for working with personal and enterprise servers.

Just my two cents!

Collapse
stevepryde profile image
Steve Pryde

Just going to add another 2c to the mix.

I learned C fairly early in my coding journey (started with BASIC - long before visual basic was a thing, which might show my age, then moved to Pascal and then C) and I found the "C for dummies" book pretty helpful at the time.

I regard C as one of the most important languages to know/understand but never use. It teaches you so much about memory management and how computers work and even when using other languages just being aware of when memory is being allocated helps a lot. C makes this kind of thing second nature.
However these days I think the only real reason to actually use C is for embedded programming with low power hardware.

As for bash, almost every time I've used it to just whip up a little shell script I end up regretting it later as the complexity inevitably grows. Python or perl are installed almost everywhere nowadays or if they're not then it's easy to install them (maybe that's the part to use bash for). Bash is good for bootstrapping something or a quick download here or there but anything more complicated than that and you'll have basically something only you can maintain (and in 6 months you'll come back and wish you'd used something else). I still use it occasionally but it just feels so nasty and prone to easy mistakes. Maybe with a good linter it might be better.

Collapse
barbaroja19 profile image
barbaroja19

Great points! If you're just scripting Python is definitely more scalable. However, BASH is absolutely indespensible if you're regularly working with enterprise servers.

Collapse
codemonkey51 profile image
Codemonkey51 Author

Hi, I have looked at C before just a bit, maybe I'll re-visit it.

About the bash thing, I should clarify bash scripts are great, but I find it hard to write really complex bash scripts, so in that case I prefer to use something like python instead.

Collapse
barbaroja19 profile image
barbaroja19

Fair enough! They can be very complicated and Python is an excellent alternative. The cross platform capabilities are much greater with Python as well.

Thread Thread
codemonkey51 profile image
Codemonkey51 Author

Yea, I would bash for simple stuff like an install script, or just for a list of commands I would like to execute without typing them out one at a time. But python is much more consistent, because you know exactly how it will execute, even in weird environments (where some bash commands different/ aren't there)

Collapse
elipie profile image
Eli

you are on repl too? How many people are there here?? probably a lot

Collapse
codemonkey51 profile image
Codemonkey51 Author

Why hello there, yes there are, and coder100 basically just made many more ppl come now with his latest post: repl.it/talk/share/Devto-API/87142

Collapse
jdog787 profile image
JDOG787

lol yeah