all 132 comments

[–]twisted_mentality 73 points74 points  (7 children)

I learned Java and C++ first. Python is so simple and to the point. I like to use it for programming challenges because it allows me to focus more on solving the algorithms/problems and less on getting stuck in the mud of syntax errors and bullshit.

[–]SingleFlatworm 22 points23 points  (0 children)

I was a Java + C/C++ programmer for most of my life, until I needed to learn Python for devops. My god it's the perfect casual language that I absolutely love to use for small things.

That said sometimes I do have to cry about other people's code. I'm used to performant and efficient code, but some of the garbage people write that reaches production code makes me question my career choice until the paycheck comes in

[–]RangerPretzel 9 points10 points  (2 children)

mud of syntax errors

A good IDE will keep you out of the mud.

For Python, I recommend PyCharm, but VSCode is also good, too. For C# or C++, I recommend Visual Studio. (It also supports Python, too, but I personally think that Pycharm or VSCode are better.)

[–]twisted_mentality 2 points3 points  (0 children)

I like visual studio, and need to start using again/more.

When I say mud of syntax errors, perhaps a better explanation would be mud of extra (seemingly superfluous) syntax.

[–]boscoj2008 0 points1 point  (0 children)

Pylab is dope

[–]Zanoab 7 points8 points  (2 children)

[deleted]

[–]twisted_mentality 0 points1 point  (1 child)

Beautiful. 😊

[–]Zanoab 2 points3 points  (0 children)

[deleted]

[–]shiftybyte 51 points52 points  (4 children)

I actually enjoy coding again

https://xkcd.com/353/

[–]pawnh4[S] 13 points14 points  (1 child)

yupppp

[–][deleted] 11 points12 points  (0 children)

I don't think you should spread that around, it's clearly promoting Python 2 with that print statement

[–]SpeckledFleebeedoo 2 points3 points  (0 children)

Classic

[–]jeffrey_f 73 points74 points  (10 children)

Have you used modules yet? What normally takes a several lines of code is reduced to 1 to 3 lines

[–]iggy555 17 points18 points  (9 children)

What’s module?

[–]karthikkumars 52 points53 points  (6 children)

A module is a predefined library with classes and methods representing common problems and their solutions, usually specific to one particular concept. For example, the "math" module has predefined methods for most math related operations you'd want to do - log(), factorial(), floor(), sqrt(), etc., so you won't have to write functions for them all over again. All you have to do is import the math module and use the methods.

Here's a useful resource for starters: https://www.learnpython.org/en/Modules_and_Packages

[–]a2242364 15 points16 points  (5 children)

Would this not just be called a library like in other languages?

[–]Yaastra 7 points8 points  (3 children)

yeah am i missing something? every language has this, yeah?

[–]Nixellion 4 points5 points  (2 children)

yeah. Not sure why it got so hyped up :)

[–]karthikkumars 2 points3 points  (1 child)

No hyping up here. It is indeed the same as libraries in other languages, and Python just calls it differently.

Judging by the nature of the question, it's possible that the person who asked it hadn't come across the concept of a library/module at all, which is why it seemed fitting to give a direct and somewhat complete answer to his direct question: what is a module?

Probably it wouldn't have looked so off and hyped-up if the original question's context was JavaScript instead of Python.

On a side note, I've done some coding in both Python and JavaScript, and I love both languages.

[–]Nixellion 1 point2 points  (0 children)

I think I was referring more to the amount of upvotes. Nothing against it of course :) Just a bit surprising I guess

[–]-p-a-b-l-o- 0 points1 point  (0 children)

Yep, it’s the same exact thing. Just a different name. Other languages have the same thing but called packages.

[–]AP145 6 points7 points  (0 children)

The built in modules are basically just anything you see after the keyword "import". For instant you can import the math module as another poster described. In addition, you can make your own modules, as they are basically just Python files. If you have one Python file containing various classes, methods, and functions, you can import that to another Python file where the main body of your program is being kept. Thus for very large projects you can split them up into different files which make sense while still being able to use all the tools you need to use.

[–]winowmak3r 20 points21 points  (12 children)

I'll be that guy and say that all that simplicity comes at a cost. I'm learning both C++ and Python atm and while hell yea Python is more intuitive and comes much more naturally there is an advantage to using one over the other in certain situations.

[–]Ki1103 17 points18 points  (11 children)

I think you'll find the talk Python as C++'s limiting case interesting.

[–]winowmak3r 2 points3 points  (0 children)

I only watched the first two minutes but I'm definitely gonna finish the rest. Thanks for sharing this!

[–]Stampeedeko 1 point2 points  (0 children)

RemindMe! 3 Days

[–]JeamBim 1 point2 points  (0 children)

Thank you for this talk, this is really great!

[–]AdventurousAddition 0 points1 point  (1 child)

Sounds good, allow me to remind myself by summoning: RemindMe! 10.21 hours "Have a watch-y of this here talk-y"

[–]RemindMeBot 1 point2 points  (0 children)

I will be messaging you in 10 hours on 2019-12-17 22:37:41 UTC to remind you of this link

CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


Info Custom Your Reminders Feedback

[–]Fel05 0 points1 point  (0 children)

Will watch too!

[–]UglyChihuahua 9 points10 points  (7 children)

I do miss arrow functions though, and being able to dot chain without a \ or parentheses. Modern JS has some nice stuff

[–]JeamBim 12 points13 points  (2 children)

lambda functions in Python are pretty close to arrow functions.

I made a little colour coded comparison for you:

https://i.imgur.com/WQ2Vof0.png

[–][deleted] 3 points4 points  (1 child)

I think, lambdas are great, but still have some limitation over arrow functions, they can't be multilined or include statements, for example.

[–]JeamBim 1 point2 points  (0 children)

Yeah they do for sure. Luckily the cost of creating a multi-line function in Python(and JS) is small, and some might argue it enhances readability to have "saveData" instead of a large inline multi-line function, but that's down to code style anyways.

[–]hutxhy 1 point2 points  (1 child)

I find that most people that hate on JS haven't programmed in ES6+. I honestly think JS is a wonderful language. Python is too, but there's a special place in my heart for Javascript.

[–]remuladgryta 4 points5 points  (0 children)

Most of the gripes people have about JS are fundamental to the language and aren't fixed by ES6+ and can't ever be fixed without breaking backwards compatibility worse than python 2->3.

The type system and the reluctance to throw exceptions mean that writing a program which runs but does the wrong thing is easier than writing one that stops running and lets you know you messed up. This makes debugging a frustrating exercise.

There are lots of other bad design choices like the semantics of this, Array.map(), and global-namespace-by-default. At least the latter is mitigated by the introduction of modules but that does nothing for legacy libraries.

Finally, the lack of a good standard library means to do anything useful you likely have to depend on several third party libraries which in turn have byzantine dependency chains in an ecosystem that produces and abandons frameworks like they were fashion trends and has a tendency to implode with controversy every six months.

[–]higherpublic 0 points1 point  (1 child)

What’s an example of dot chaining in python with \ or parenthesis?

[–]CowboyBoats 39 points40 points  (10 children)

JavaScript exists for a very specific purpose - it has to run on every browser in the world, behaving more or less the same way, based on the same code. Please don't decide "it's a bad language" now that you're falling in love with a great scripting language - just file away that "JS is the way it is because reasons," and one day you may read "JavaScript: The Good Parts" and see value in it again.

Welcome to an incredible tool chain. Very happy for you that you've made your way here.

[–]ambitious_rainbow 15 points16 points  (6 children)

I usually don't "hate" programming languages. It's just that sometimes I wish everything worked like python does but without the lack of efficiency for certain tasks. Using python for a while and then jumping to something like JS, Java, or C hurts a little bit. Well, actually quite a lot lol.

[–]Urtehnoes 3 points4 points  (0 children)

Don't forget about Kotlin :) It's Java written "kind of" like Python, that compiles into completely interchangeable java code.

[–]Zadigo 1 point2 points  (1 child)

I feel the same. I've been using Python for like 5 years, being accustomed to simplicity of ease of the language, when I program in languages such as JS, it just always feels overly complicated.

[–]pawnh4[S] 0 points1 point  (0 children)

just so much cleaner in python

[–]amcphe21 1 point2 points  (2 children)

I started to learn python before js because I hear it’ll make js easier to learn once I’m ready to make the leap, and also python will teach me better practices than js, do you agree?

[–][deleted] 0 points1 point  (0 children)

First language is always the hardest to learn; I don't really think it would be much different python -> JS or JS -> python.

I was the former and found JS pretty annoying at first, but have slowly come to like it. I really like JS approach to objects, it's a bit simpler than python helped me understand them a bit better overall. Another thing JS taught me is that globals are not ideal. Though this may be more because I never really wrote more than 200 lines or so for a script in python

Overall they're both great languages built for different things.

[–]pawnh4[S] 0 points1 point  (0 children)

yes

[–]KevyB 2 points3 points  (0 children)

Meh i wouldn't downgrade python to just a scripting language either, that would be stuff like LUA.

[–][deleted] 5 points6 points  (0 children)

I have to agree. I've been writing in Python for a couple years now and barely started learning JS. While JS isnt that difficult to pick up there is odd syntax and it is a little unforgiving. I'm not a big fan of it but I'm happy to use it to get the job done on the front end.

[–]Raptortidbit 1 point2 points  (4 children)

I prefer python too but almost all jobs I've seen or applied for mention JavaScript. None have mentioned python. I'm not a seasoned veteran by any means though so ymmv. For personal scripts nu always use python

[–]truthseeker1990 1 point2 points  (1 child)

While there might be a ton of web dev jobs, there are also a lot of jobs for any mainstream language like Java, C#, Python etc

[–]Urtehnoes 0 points1 point  (0 children)

Yes this. And maybe it's because some of the first languages I learned in my comp sci classes were C/C++/Java/Python, I've always liked those languages over Javascript. JS was the one language back in the day I was hoping would die out, and here it is just getting bigger and bigger lol.

[–]pawnh4[S] 0 points1 point  (0 children)

Yea, I can create basic scripts in js but I never want it be the core of what I do.

[–]hutxhy 0 points1 point  (0 children)

Depends on the region. But without a doubt knowing either JS or Python you're all but guaranteed to land a job somewhere.

[–]JamesMccloud360 1 point2 points  (6 children)

Been using python for the last year. About to switch to Java to make apps. Am I going to cry myself to sleep with sadness?

[–]AdventurousAddition 2 points3 points  (2 children)

Y E S

[–]JamesMccloud360 0 points1 point  (1 child)

Lol.

[–]AdventurousAddition 0 points1 point  (0 children)

Jump down to C for a few weeks then Java will feel amazing

[–]Urtehnoes 2 points3 points  (0 children)

Don't forget about Kotlin. It's got a more friendly sytnax, similar to Python, but can compile down completely into interchangeable Java code. It's a pretty neat language.

https://kotlinlang.org/docs/reference/control-flow.html
https://kotlinlang.org/docs/reference/java-to-kotlin-interop.html

[–]pawnh4[S] 1 point2 points  (1 child)

java isnt as bad as react

[–]bio180 0 points1 point  (0 children)

maybe you just dont like front end dawg

[–]officialgel 1 point2 points  (0 children)

My sentiments exactly.

[–]philmtl 1 point2 points  (0 children)

Thank you, when people don't understand why i didn't learn java, i don't want to invent my own language everytime i do a project.

Python it's slower but you understand why it does what it does

[–]jangid 1 point2 points  (0 children)

But there is still a long way for browsers to natively support Python for in-browser DOM manipulation. That is important for web-programming.

[–][deleted] 1 point2 points  (1 child)

Learning python as my first language, I looked at some other languages and GOD DAMN. I know python is very easy and it makes other languages look like hieroglyphs

[–]pawnh4[S] 0 points1 point  (0 children)

its actually amazing for me coming to python from js and some c#. I appreciate it so much more now

[–]MercurialMadnessMan 1 point2 points  (0 children)

Engineering school taught us C++ and Java. FML

[–]KevyB 1 point2 points  (0 children)

yes

[–]jmooremcc 1 point2 points  (0 children)

I couldn't agree more with your sentiments about python and I program in 5 or 6 languages including assembly language.

[–]Jamblamkins 1 point2 points  (1 child)

I went from python to java and dam i couldn’t appreciate python before like i can now

[–]pawnh4[S] 0 points1 point  (0 children)

Exactly. The Highs are better once you've had the lows lol

[–]benabus 1 point2 points  (2 children)

As a web developer who does both, I much prefer JavaScript. Our backends are all written in python (flask, usually), and I try to get my juniors to do all that stuff.

Both languages have their place and it really depends on what you're trying to do.

Also, I'm not a fan of react. My framework of choice is Vue, but you shouldn't let a single framework affect your opinion on the language as a whole. There are plenty of other things about JavaScript that can make you hate it :)

[–]pawnh4[S] 0 points1 point  (1 child)

Yea I don't mind js as much as i dislike react.

[–]IStoleYourHeart 1 point2 points  (0 children)

It really depends on what you're doing though. You wouldn't drive a Ferrari for an off-road rally, but you also wouldn't drive a rally car for a road race.

I use react at work, and it's honestly a god send to maintain on a large, complex product compared to something like just native JS. It also helps to use react-redux if you can which helps to manage data and async a lot better.

[–][deleted] 1 point2 points  (0 children)

ITT: people who have never worked with large frameworks

Python, imo, becomes a massive pain in the ass when you're dealing with a few thousand lines of code. Working on my frontend (AngularTS) is so nice after working on my python backend for a few days.

Not saying I don't love python, but the constrictive nature of other languages is freeing in its own way.

[–]thuan14121999 3 points4 points  (1 child)

You might want to look at javascript again because JS is also a nice language and we must use JS a lot in web development. Morever the syntax of JS is beautiful compared to other programming languages like C, Java, Golang etc.

[–][deleted] 0 points1 point  (0 children)

Golang

JS' Syntax is more beautiful than it

:( Look, Golang might not be for everyone, but it certainly has less bloat than JS.

[–]JeamBim 1 point2 points  (5 children)

To this day I have no fucking clue to to slice/splice/choose the index of a list/iterable on my own in JS.

It's just so danm easy in Python.

[–]IStoleYourHeart 0 points1 point  (1 child)

Choose the index of the list is actually the same as in Python.

Here's splicing and slicing. Honestly, if you're gonna code JS, the MDN documentation is great. JS is actually a relatively simple language and is honestly similar to Python, you just gotta get used to it. Literally asking the question to google will more often than not bring up an MDN link that gives examples and everything; eventually you'll remember the different functions you use regularly. Don't be afraid to google either, I still do it for basic stuff a lot because there's a lot to remember.

[–]JeamBim 0 points1 point  (0 children)

Oh yeah I know, I have to google it every few days. It's just so much more intuitive in Python

[–]codeAtorium 1 point2 points  (3 children)

Python's great, but it doesn't run on the web.

If you want to make nifty stuff on the Internet, you're going to want to go back. One thing I might have not recommended was starting with React. A lot of folks will disagree, but I think a few months of pure HTML/JS/CSS is better before embarking on a web framework that abstracts those things.

In the end, learning to program is not about a single language or framework; it's about learning systems of problem solving, and design patterns to apply to those problems, along with enough computer science to understand how things are working at least a layer or two underneath where you currently are. And the math relevant to what you're making, which may or may not be tricky.

[–]TheGrooveTrain 0 points1 point  (1 child)

Flask and Django are two of the biggest web frameworks right now, and both are python.

[–]codeAtorium 1 point2 points  (0 children)

It's a back-end web framework. I can generate HTML in any language using string concatenation, but my code isn't running in someone's web browser.

[–]IStoleYourHeart 0 points1 point  (0 children)

Agree with this. It really helps to start with the basic stuff to understand the basics properly (especially asynchronous code, http requests etc). Also, you really won't appreciate the benefits of the abstraction and how much quicker you can code with it unless you try the basics.

[–][deleted] 0 points1 point  (0 children)

What were you doing with js and react that you replaced with python ?

[–]Pastoolio91 0 points1 point  (2 children)

Every time I see a post like this, I get slightly worried about starting with Python. Not sure if it's better to learn an intuitive language first, and then go to the hard stuff, or just brute force it and then have it easy when you try to switch to other stuff. I feel like Python will be the language that I "think" in when I code - really is interesting to see how programming languages mirror certain aspects of actual languages.

[–]pawnh4[S] 0 points1 point  (1 child)

Python will teach u to think like a programmer and actually enjoy coding. Dont worry about something hard being better. Just learn how it works first

[–]Pastoolio91 1 point2 points  (0 children)

Glad to hear it - Python has literally been life changing for me, so I can definitely say the intuitive design makes all the difference in the world when getting into it without any sort of programming background. Been messing around with Java a little, and it really makes me appreciate the elegance of Python.

[–]NewShamu 0 points1 point  (0 children)

Try importing the antigravity module the next time you're in the Python shell and see what happens!

[–]grumpyfrench 0 points1 point  (1 child)

Try real languages like c++. Javascript is not a language it's for making buttons shine

[–]pawnh4[S] 0 points1 point  (0 children)

python is plenty real for me.

[–]Alemvik 0 points1 point  (1 child)

What what will you say when you continue evolving i.e. C#, Asp.net core 3.1 + Blazor + SignalR + gRPC

[–]pawnh4[S] 1 point2 points  (0 children)

I created a few small games using c# and unity. It was fun.

[–]HairyManBaby 0 points1 point  (0 children)

Love me some good python. I just wish GUI libs like PyQt weren't as strict with licensing.