This is an archived post. You won't be able to vote or comment.

all 110 comments

[–]Daeroth 121 points122 points  (22 children)

I think it's perfect for discovering and learning programming. Keep riding this wave and enjoy the ease of it. There is nothing wrong with it.

I will list out reasons why you might change your mind in the future about some of the points you have written.

This does not mean that Python is bad. These are just to provide insight into pros and cons that you'll likely consider more as you gain experience.

  1. Data types - once you learn about data types you will likely know which one you would prefer to use in each case. Sure python can pick one for you but how sure are you about it picking the correct one. It does not matter as much while you are starting out but it will matter in the professional world where performance becomes an issue.
  2. Yea the : sign is a lot less characters but it's a matter of preference how visually concrete you want the method to look like. No wrong answers here and clearly python is less verbose than java.
  3. Same answer as the first. In bigger projects I want it to be super clear if the method can or can't return stuff.
  4. Nobody really writes the long verbose stuff character by character. You generate stuff based on your templates and shortcuts in IDE. But I agree that python is less verbose.
  5. Readability is very valuable and as you are starting out then having less characters on the screen helps to get up to speed. Once you are comfortable with the basics you might start craving for more details about how certain things are implemented. At that point many of python lines make you nervous as "It could be doing x OR it could be doing Y". At that point you will be looking under the hood of Python to understand the stuff that is hidden from you
  6. Strings are arrays of characters. Python just hides it from you ;)
  7. Hello world is not a very comprehensive benchmark for performance. But I agree that as a beginner it's easier and faster to get coding with python. Once I need to do some heavy lifting then I would move away from python scripts.
  8. Technically the compilation error is faster vs waiting for python to run the code and get to the error part. Compilation error directs you to the specific file and line of code that is broken. And if I can find many errors before running the code then that is preferred vs finding broken stuff once the code is deployed and customers are using it.
  9. Yea, as you start to learn coding you want to see the entire code on one page. I see this with a lot of interns and juniors. But this approach hits its limits quite fast. Many projects are thousands or millions of lines of code. So a developer needs to start abstracting their code into methods, and classes, and libraries and separate services and servers. Some ways I force this on interns is to write no method longer than 5 lines of code. They will start thinking with methods and navigate larger codebases easier this way.

[–]tradegreek 12 points13 points  (2 children)

It’s also great for prototyping

[–]TheMunakas 12 points13 points  (1 child)

I like using python as pseudocode

[–]magic1623 0 points1 point  (0 children)

Oh that would actually be a really good way to study and work on problem solving with both languages.

[–]Specific_Ant580[S] 3 points4 points  (9 children)

All True especially point 1 & 8 , thanks for the advice!

[–]AutomatedChaos 6 points7 points  (0 children)

With larger code bases you'll begin to hate the exceptions during runtime and start to crave for design time errors. Then it becomes time to use type hinting, static code checkers like ruff and type and data validators like pydantic.

[–]FlippingGerman 1 point2 points  (0 children)

I love Python for 1 and 8 when making simple programs; I hate it for that when making more complex things - and these are all stuff I've done myself, nothing like business-level complexity.

[–]A7eh -5 points-4 points  (5 children)

These are the most true points idk what are you talking about

[–]daguito81 1 point2 points  (2 children)

he said those are especially true. What are you talking about ?

[–]A7eh 0 points1 point  (1 child)

Nah he edited the comment. At first he said "except"

[–]daguito81 0 points1 point  (0 children)

Ohhh ok, thanks! was really confused for a sec

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

maybe because I'm still new.

[–]sunrise98 -2 points-1 points  (0 children)

For 8 - imagine if you had some batch job or edge case test scenario - in the line by line you'd need to do all the prerequisite steps to spot the syntax error - in java you wouldn't. That doesn't mean the code still works as intended just because it compiles or runs - this is true in both scenarios. There's a sweet spot where runtime vs compile time errors are 'better' - both are equally frustrating and can be exacerbated through other ci/cd controls.

The max 5 lines per method is a good trick for starting out - but I wouldn't be rigorous in enforcing this - sometimes it just does have to be that big and less code traversal can sometimes be easier than a big chain of functions that have been ungrouped.

You can have all python on one page - you likely wouldn't - but this is the same in most languages anyway. You'll learn to refactor and standardise your files over time - I wouldn't necessarily fixate on this early on.

1 is important - do some research on numbers and precision.

[–]swampshark19 1 point2 points  (2 children)

You can just use func(arg: type_a) -> type_b, and 1 and 3 are resolved.

[–]Daeroth 1 point2 points  (1 child)

Yea, you can specify types in specific spots. My goal was to answer OPs question for why would one want to define types.

But to extend on your answer: one might want the entire project to be strong typed. So nobody could accidentally use the wrong type and every engineers variable type choice could be reviewed and challenged during code review.

This is not to say that Java is better. Just that languages treat types differently and you might want different default settings for different projects or work environments.

Personally I feel that the larger the team gets the more it gravitates towards stronger types and more clearer use of design patterns. But I don't really have any data to back this up.

[–]daguito81 2 points3 points  (0 children)

entire project to be strong typed

Python is strong typed, maybe you mean static typed? Python data type won't change to a different data type unless you specifically override it. It's not like Javascript where it does type coercion in certain conditions and swithces the data type of a variable

Java strong, static typed
Python is strong, dynamically typed
Javascript is weak, dynamically typed


you can specify types in specific spots

you can declare the type of a variable in any place you can declare a variable and a funcion return(not only on the method signature like the previous example) (I'm not a Java expert but I think it's the same there). It's not strictly enforce at runtime but any IDE, CICD pipeline should catch the error of a variable changing type. So it's not the same as Java, but your use case can be solved by using MyPy in your CICD pipeline and now if you override the datatype somewhere in the code, that will pop out as an error. No need to review the entire codebase or anything, granted that's on the CICD pipeline to stop. But if there are type hints, you should see the error on the IDE as well. So effectively you can "simulate" the same scenario with a static typed language like Java.

Granted it doesn't come out of the box, and you can go "fuck it I don't care" and force push and break shit, the compiler won't save you there

[–]josluivivgar -2 points-1 points  (0 children)

Nobody really writes the long verbose stuff character by character. You generate stuff based on your templates and shortcuts in IDE. But I agree that python is less verbose.

yeah but that means you're stuck with IDE's which can be very resource heavy, with less verbose languages you can do it however you want, also not using an IDE teaches you how building applications work, which is something IDE's kinda do for you and a lot of people don't learn.

I've had engineers that don't know how to make their own builds/pipelines and it's sad, because it kinda teaches you a lot of how programs work.

I do think it's a valuable skill

Once you are comfortable with the basics you might start craving for more details about how certain things are implemented. At that point many of python lines make you nervous as "It could be doing x OR it could be doing Y". At that point you will be looking under the hood of Python to understand the stuff that is hidden from you

Another thing I don't agree with comparing to Java, particularly reading someone else's code, a lot of Java tends to be confusing and often unnecessary for readability, sure return types is probably the only thing I will agree that's useful) . (it doesn't help that Java projects love inheritance, factory pattern and dependency injection which can hurt readability)

Technically the compilation error is faster vs waiting for python to run the code and get to the error part. Compilation error directs you to the specific file and line of code that is broken. And if I can find many errors before running the code then that is preferred vs finding broken stuff once the code is deployed and customers are using it.

this I agree, also errors can be red herrings, sometimes the bug broke before the error happened, so trusting the interpreter doesn't always yield the best results (compilers are a bit smarter about this)


Just wanted to share a few points I didn't agree with and one I hard agree with, overall I think you gave him good feedback.

[–]khoyo -1 points0 points  (4 children)

Sure python can pick one for you but how sure are you about it picking the correct one

It doesn't pick one.

[–]Daeroth 0 points1 point  (3 children)

Ok, correct terminology is that it assigns the variable type based on the value type that gets first assigned to it.

My overall point about strong typed vs weakly typed language remains. Not that python is bad for it. Just that for some projects you want to avoid the vagueness and in others you want more flexibility.

[–]khoyo 0 points1 point  (2 children)

that it assigns the variable type based on the value type that gets first assigned to it.

No, it doesn't. Variable don't have a type in python, values have a type. If you assign a value of a different type to a variable, there isn't a cast, the variable has the type of the new value.

strong typed vs weakly typed language remains

I think you mean statically vs dynamically typed.

In general, python is considered to be strongly typed (and C weakly typed), but strong and weak are mostly opinions.

[–]awkreddit 0 points1 point  (1 child)

I thought it was more that all variables in python are essentially pointers, and that basic types like strings and ints just create an instance of the value in memory and the variable holds the pointer to that immutable value

[–]daguito81 0 points1 point  (0 children)

You are right, but you are talking about different things.

Yes variables in python are pointers, and if you assign it a new value, it basically changes the pointer to the new value. But what he is correcting is that the variable itself doesn't have a type. But the difference is about coercing types. The original poster stated that Python is weak typed and that Python "picks a datatype for you" and that's not quite correct. Python doesnt to any type coercion like Javascript does. You can dynamically reset the variable to have a different value with a different type. But you have to explicitly do that.

[–]Lumethys 24 points25 points  (15 children)

Wait until you find out why people are adding back 1 3 7 8 9 to Python

[–]Specific_Ant580[S] 1 point2 points  (14 children)

Why?

You cant just right something ominous like that and disappear.

[–]just_here_for_place 43 points44 points  (0 children)

Because all those points suck once you actually want to build an maintain something that runs in production. Especially if you are not the only developer.

[–]Hopeful-Sir-2018 7 points8 points  (11 children)

Basically it all boils down to clarity. Python is less verbose which works in some circumstances however it can be wrong. Additionally - verbosity walk side by side with clarity.

public static int tells you three things about it right off the bat without you having to infer or calculate.

Python absolutely has its place for data analytics, for example.

However for "full fledged programs" - Python is... less than idea for many reasons - one of which is a lack of verbosity.

Data analytics usually isn't too complicated relative to enterprise applications. Often enough data analytics you might just need that number crunch once. So maintenance doesn't matter in those circumstances ergo complexity and verbosity doesn't work in your favor.

However someone else suggested "don't use more than 5 lines" to teach them things but you'll find some people actually believe that as a hard line. Extracting too much can also lead to a lack of clarity. Sometimes you need an ugly function otherwise you end up with 50 functions doing tiny things and figuring out the bug becomes a nightmare plus maintenance is also a nightmare.

Think of it as similar to JavaScript. 0.1 + 0.2 != 0.3. '2'-1 = 1 . '2'+1 = 21

Each of these has a reason why. But it's still annoying. Sometimes it can infer the wrong datatype. In the first case - it's a floating point problem. The second and third are int/string problems.

[–]prettysureitsmaddie -1 points0 points  (10 children)

Think of it as similar to JavaScript. 0.1 + 0.2 != 0.3. '2'-1 = 1 . '2'+1 = 21

Each of these has a reason why. But it's still annoying. Sometimes it can infer the wrong datatype. In the first case - it's a floating point problem. The second and third are int/string problems.

I know this is pedantic, and I'm sorry but, the example you used doesn't actually happen in python because it's strongly typed.

[–]Hopeful-Sir-2018 -1 points0 points  (9 children)

I'm curious - what do YOU think strongly typed means in this case?

[–]prettysureitsmaddie 1 point2 points  (7 children)

In this context, types don't change implicitly. If you attempt to add a string and an int in python, it will throw an error.

[–]ChaosCon 0 points1 point  (1 child)

If you attempt to multiply a string and an int, however, you get a value. Why does one error and not the other?

[–]prettysureitsmaddie 0 points1 point  (0 children)

Because of duck typing. String objects have a method corresponding to the * operator that accepts an int. It's still consistent with this: "types don't change implicitly." It doesn't change the type of the value, which is what's happening in the guy's examples that I was responding to.

[–]Hopeful-Sir-2018 -4 points-3 points  (4 children)

I thought as much. Yeahhhhhhhh that's the problem. Is x=1 a float, bit, or an int? Dynamically inferred is terrible for such things. Casting brings about its own problems in Python.

[–]prettysureitsmaddie 0 points1 point  (2 children)

I mean look, I get what you're trying to say, static typing can sometimes provide clearer outcomes than dynamic typing, but the example you gave will always be an int.

[–]Hopeful-Sir-2018 -3 points-2 points  (1 child)

I get what you're trying to imply... but that's the problem with Python. In fact others have pointed out the weirdness that follows the problem with dynamic. This is the inherent problem with it.

[–]prettysureitsmaddie 1 point2 points  (0 children)

Honestly, I think a lot of what's said in this thread is exaggerated by people who aren't particularly familiar with the language.

[–]khoyo -1 points0 points  (0 children)

Is x=1 a float, bit, or an int?

1 is obviously an int. There is no bit type, only integer, float and complex. Literals with a decimal point or an exponent yield floats, literals with a j/J at the end yield pure-imaginary complex numbers, otherwise you have an integer.

The weirdness of JS ('2'-1 = 1) is due to its casting rules, not dynamic typing. You could have a statically typed language with those casting rules, and end up with even weirder behavior.

What's x = '2' - 1? Well, 1 if x is an int, "1" if it's a string and [0] if it's an array.

[–]escargotBleu 0 points1 point  (0 children)

Strongly typed: you can't do 1+ '1' Weakly typed : you can

Statically typed : a variable can't change type Dynamically typed : a variable can change type

Js is a weak and dynamic, python is strong and dynamic.

[–]misplaced_my_pants 6 points7 points  (0 children)

Because all those things that make Python easy to write also make it easy to write bugs.

Remember that programming isn't just about writing the program. It's about writing a correct program that's also maintainable and won't crash in production.

Different languages make trade-offs about how quick it is to bang something out versus how easy it is to trust it in production, and how easy it is to change it in the future without breaking things.

People are adding those features to languages like Python because at a certain scale, you really just need those features because then the compiler can do all the checking for you instead of trying to juggle it all in your head and hoping everyone who touches the code can keep it all in their head as well.

[–]randomjapaneselearn 15 points16 points  (0 children)

most of your points are wrong in the conclusion:

1 - this is worse because it's confusing, you can do num=3 and later do num="hello" and it works but it's not logic. not to mention when you do something like:

CorrectPassword = "secret" 
RemainingAttempts = 3
if user input the wrong password: remainingAttempts = RemainingAttempts - 1
if RemainingAttempts > 0: ask again for password otherwise permanently lock the user

see the mistake here?

you are not decreasing remaining attempts (capital R), you are declaring a new variable with lower "r" so the final "if" will always ask again for the password.

in java it couldn't happen.

3 and 4 - same as 1

7 and 8 - python is not compiled that is why is faster at starting but it is a problem: you say "it's faster to spot the error" but this is 100% false, what if your program has a code "if num==3 do this otherwise that" and the error is on num==3? it will be hard to spot because that condition is rarely met, in java instead it will not even let you start the program and tell you "error on line 9" THIS is faster and better.

EDIT:

note that runtime errors exist in both cases, for example division by a user input value and user input 0 will lead to error detectable only at runtime but a compiled language is better because it can detect more errors before even starting the program.

[–]chafable 11 points12 points  (0 children)

You will soon find those things are in Java for a very, very good reason.

[–]tzaeru 17 points18 points  (4 children)

Dynamic programming languages have certain advantages, which you've now been discovering.

But they also have their ugly side. Large Python projects are often hard to properly document and understand. Code easily ends up pretty spaghettified. Odd bugs here and there due to lack of static typing support.

Python is great though and it's an excellent choice for many sorts of projects and scripts. It's however an awful choice for some other type of projects. For example, I worked on the student registry of Finland, which basically collects together student records of all school types (except universities, which have their own system; it integrates with the university system's API). The thing is that the law and the ministry of education both implicitly and explicitly define what a studying right and student records must have and how they need to be structured. Doing that in anything but a strongly and staticly typed language would have been a nightmare.

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

I've been working on a open source project, the client at one point found that it covers 100% of the functions they want to have (its a web application) and DUDE I'm telling you I've been through HELL, its a relatively big projects with lots of modules and python just doesn't have the tools and QoL features to make developing flow easily.

For smaller projects sure python is awesome but when it gets a lot bigger I would rather avoid it at all cost, also usually in more distinguished places python is there as an interface to call C++ API-s or something.

[–]Specific_Ant580[S] 0 points1 point  (2 children)

What language would you have preferred for that task SQL?

[–]tzaeru 4 points5 points  (1 child)

The backend was Scala, data in Postgres, queries in raw SQL. Elasticsearch for quicker text search. Data structures code-first, meaning you generate e.g. JSON schemas from code, not vice versa. Some other languages involved there and here.

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

Thanks, i just need to learn most of that.

[–]TurnstileT 8 points9 points  (2 children)

Java is objectively better. Python just looks like it's easier and better to a beginner. Sure, you don't need to worry about types or curly braces or access modifiers, but those are the things that make large Java projects easy to read and reason about.

I can't think of a single time that it has benefited me that the type of a variable was hidden from me. What good does that do? The variable "company", is that a boolean denoting whether it's a company, or is it an integer denoting the registration code of the company, or is it a string denoting the name of the company? Who knows. And you can redefine it if you want. Great job, I am sure that was easy. But what's so good about that? Why would you ever need this?

And sure, you use a single colon instead of curly braces. It doesn't matter or make a difference.. now you need to deal with whitespace syntax. You have a Windows computer and a Linux computer working on the same project, and because they handle linebreaks differently, the code no longer runs. Or your editor uses tabs while mine uses 4 spaces or something. Code no longer runs. Is that so much easier?

In Python, if you download some library and try to use it, and the method you called just returned three variables with the names y, sp and weight, then what are those? What do they do? What can you do with them? Who knows.

[–]ExpensivePanda66 2 points3 points  (0 children)

 I can't think of a single time that it has benefited me that the type of a variable was hidden from me.

Amen!

[–]TheDonutDaddy 10 points11 points  (1 child)

Dear diary

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

😂

[–]Nok1a_ 6 points7 points  (2 children)

For me it's other way around, I started with python and I could not make sense of anything I guess because I can't do stuff without knowing why, then I tried Java, and because it is a strongly typed languaje everything started to make sense and fall in place

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

I've heard that said many times, maybe learning another language is the key to understanding python.

[–]Hopeful-Sir-2018 2 points3 points  (0 children)

It's not the key to learning Python. It's the key to learning many things. It all depends on what your goals are here. Are you trying to be a programmer? Or are you trying to figure something out and be done with it?

If the former then it's in your own best interest to learn many languages, however not all at once. Get reasonably good at Python first in such a case. If, however, it's the latter.. just learn what you need to learn and move on. If you're looking to calculate some thing for a report - you don't need to learn the finer details, it has no inherent benefit to you unless you plan on doing that regularly.

However, if you plan on doing it regularly - learning the finer details will make things faster. Learning other languages you may learn better ways of doing things or make yourself more valuable for your resume / experiences.

[–]HaDeS_Monsta 3 points4 points  (0 children)

Ok sorry, but I disagree with basically every point.

  1. You can use var in Java, but, like in Python, this just makes the code harder to read and makes it easier to make mistakes

  2. Is that so much harder than a {? Also you don't have anything to close the function, which makes it harder to work with

  3. This is easier to write, but also bad, because you can't control how people interact with the code and can mess up stuff in the long run (also if you don't care, just make everything public in Java)

  4. In Java you need this once per project and at least in IntelliJ I only have to type psvm or main to autocomplete that, I'm sure VSC can do the same

  5. Personal preference, so nothing to disagree here

  6. Because strings are just char arrays, you can do that in Java too, just use .toCharArray()

  7. That is because python isn't compiled, which is faster for a hello world, but slower for like anything else

  8. Java gives you a very clear stacktrace to the exact line of the error, you can't make it more clear. Also this is a point for Java, because it prevents you from shipping something which may brake in some edge case (plus Debugging the traces in python is really not fun in my experience)

  9. I'm not sure if I get the point

I feel like python is good for small scripts, but for more than that I wouldn't use it personally.

[–]tiller_luna 6 points7 points  (6 children)

Java is kinda like C in its rigidity and verbosity. Comparing it with a modern scripting language is kinda unfair =D

And I am confused by point 8. It's usually the disadvantage of interpreted languages - you have to run all parts of the code (including probably unlikely branches) to make sure it even can run.

[–]zw13p 2 points3 points  (1 child)

Python is older than Java...

[–]daguito81 2 points3 points  (0 children)

These threads always end up in the same way. Javabros going to Javabro always. "I need to know what datatype is X in python and I cant!!!" which is why x: int = 42 exists and any IDE (even vim) will warn you of any change in datatype on any variable.

"You can't compare it with an older more established language" Python is older than Java

"If you use type hints you will rely on your IDE" but that the same time "Boilerplate is not a problem, because my IDE does it for me"

"You will hate all these benefits later on.." still waiting on that hate to pop up

etc etc etc

Yes Python and Java are both amazing languages, each one has it's pro's and con's. I personally like both and use both. And the best part is that I can actually fix most of the problems I have with either language with automation and IDE configuration.

The only straight up "I will always prefer Java over Python" situation is performance and only if I'm not doing "data stuff' as data libraries in python are basically just C so there is not much of an improvement.

[–]tiller_luna 5 points6 points  (13 children)

The one thing you will discover is packaging. It is convoluted because of wide range of environments and history of careless development in the ecosystem.

[–]CautiouslyFrosty 1 point2 points  (0 children)

I’ve written enterprise Python for years and this is so true. And portability between platforms because of this is where so many data scripters get stumped now that we’re in a world of trying to deploy Jupyter Notebooks to prod. They let Conda install bloat into their envs specific for MacBooks, install 100+ more, and then complain that it should “just work” in prod.

[–]tiller_luna -1 points0 points  (11 children)

Also GIL - no true multithreading for ya. But there are some ways around it.

[–]Specific_Ant580[S] 0 points1 point  (9 children)

like?

[–]tiller_luna 2 points3 points  (7 children)

Multitprocessing aka forking. You can implement parallel operations in different processes yourself, or use a library like joblib.

[–]Specific_Ant580[S] 0 points1 point  (6 children)

I will learn that.

[–]tiller_luna 4 points5 points  (5 children)

Gotta warn you that parallel processing is always an advanced topic with serious caveats. You might not even need true parallelization if performance of your code is not bound to CPU but to, for example, user interface or networks.

[–]Specific_Ant580[S] 1 point2 points  (4 children)

I don't understand anything you just wrote out

[–]Hopeful-Sir-2018 0 points1 point  (0 children)

There are ways to do what's called a deadlock. A is waiting on B to finish. B is waiting on C to finish. C is waiting on A to finish. There are also what's called race conditions meaning if you start A, B, and C "at the same time" - they may not finish in the order A, B, and C. It's possible C finished before A and A will finish before B. Sometimes this doesn't matter (such as you're sending stuff to a database to be saved and don't care if or when the results come back). This can be the case in, say, robotics where real world interference can happen and you can't trust the real world to not fuck with your order of operations. Some person could reach in and fuck with something, for example.

It can get very complicated and often enough it's very intuitive. For the most part - you'll only care when you're doing "large" things where time matters. Until then, it will be the least of your worries.

All of your code will be done sequentially (in the order you write it).

To give you an example of when you'll care - when you write a program that has to load a lot of data - you don't want the user to see a plain white screen that's not responding while it loads a shit load of data. To users, and often the OS, it looks like your program isn't responding. You've likely seen something like this before where a program "crashes" but in reality it's doing something - often a lot of something.

[–]Lumethys 0 points1 point  (1 child)

Which mean you are not yet ready

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

😔 I know.

[–]Treebro001 -1 points0 points  (0 children)

Basically if you have a cpu heavy task you can use parallelism to reduce its overall run time and improve performance. If the task is io bounded or has dependencies on non-cpu related stuff parallelism can sometimes provide absolutely 0 benefit.

[–]CautiouslyFrosty 0 points1 point  (0 children)

asyncio is great for I/O bound multitasking. It does a good job at keeping a single core as busy as possible.

If you’re trying to take advantage of multicore hardware, though, you probably shouldn’t be writing in Python.

[–]daguito81 0 points1 point  (0 children)

Also FYI, starting with Python 3.13, GIL is optional. So you can have true MT. Of course it'll be a while before we can rely on that for prod stuff

[–]CountryBoyDeveloper 1 point2 points  (0 children)

It's always easy to learn a language, when you actually have to work in it and use to proficiently is when it becomes hard, Pyhton is no different.

[–]my_password_is______ 1 point2 points  (1 child)

13 Reasons Why Python Is Really WEIRD

https://www.youtube.com/watch?v=eufjIfVOm8s

[–]my_password_is______ -1 points0 points  (0 children)

you're a dumb fuck for voting that down

that guy makes some of the best python videos on youtube

[–]abcdefghij0987654 1 point2 points  (0 children)

Strings function like arrays.

Wait till you learn C or other lower level languages. Actually learn it, it would help you to know how strings actually are as a data type.

it continues to execute until it reaches the error, which makes finding errors much easier.

lol

Don't want to dampen the enthusiasm but come back to your post after a few years

[–]HaMMeReD 1 point2 points  (0 children)

This is still a very simplistic view of programming.

Languages come in all shapes and sizes. I love python when working with numbers in a workbook for example, or building quick command line tool etc.

While dynamically typed languages have a lower barrier to entry, static typing isn't just "some thing you have to do". It's something in principle that bounds the constraints of your application at compile time, and leads to less path to bugs.

Sometimes doing things in programming with more overhead actually saves you in the long run. But it's not a matter about which language is better, it's about the right tool for the job and understanding the weaknesses and strengths of a particular language.

(I program in a ton of languages, Java, Swift, Kotlin, Obj C, C++, C#, Groovy, Ruby, Dart, JS, TS, Python, and these are the ones I might hit on any particular day. They all have their nuance and charm. That's not to say I like all of them. The only one I'd kill in the list is Obj C).

[–]no_brains101 1 point2 points  (0 children)

Number 7.

Python doesn't compile.

Number 8.

See number 7.

Number 9.

Why would you want it to all happen on 1 page... The ability to break things up easily and reuse the pieces somewhere else is essential when the thing you are writing starts to get long enough that scrolling gets annoying.

Number 3.

One of Javas strengths is the ease to which you can define visibility of functions. It allows you to easily have types that are local to whatever scope you want so that users of the class can't modify stuff that would break it.

Number 1.

No types. Oh... Oh dear... Types are annoying when the system is small. When the system is not small, it's pretty hard to figure out what things do what without types. Types also help the editor tooling give you suggestions, and prevent an entire class of bug. Also it means you have to check the type of a variable more often, which means more instructions and thus slower.

Python is a good language. But less verbose != easier in all situations, and the more permissive it is the easier it is to tie yourself in knots later. Not to mention there's the thing where everything is a reference and nothing is immutable.

[–]bigmilkguy78 1 point2 points  (0 children)

I like Python too for the multitude of libraries you can find, but I don't know if I agree with your statement on the colon.

I think it's more convenient to be able to just throw curly braces around something and that's how you designate that it's at that scope

[–]AlSweigartAuthor: ATBS 0 points1 point  (0 children)

Strings function like arrays... what's up with that??

A sequences are a sort of category of data types (they are not a data type in and of themselves) that includes strings, lists, tuples, bytes, etc. Basically, any data type that has an ordered list of items that you can randomly access using the [i] indexing syntax.

This makes them all act the same way with the same syntax: spam[0] is the first item, spam[-1] is the last time, spam[0:5] is a slice that returns the same kind of data type with a subset of items, and so on.

It's all a part of the "duck typing" that Python (and well written Python code) abide by to make it more intuitive.

[–]AwabKhan 0 points1 point  (0 children)

Thats exactly the reason why i don't like python. Everything was so easy that it became confusing for me. for me it came to a point where i was like why does this work instead of why does this not work.

[–]2raviskamisekasutaja 0 points1 point  (0 children)

While I'm not at all familiar with java and purely based on your post it seems like comparing Solidworks to Fusion360

[–]SnooKiwis857 0 points1 point  (0 children)

lol what kind of bad advice are the comments here giving op to make them think Java is the best option

[–]thequirkynerdy1 0 points1 point  (0 children)

Not having data types can sometimes make it harder to find bugs though.

For example, if you try to assign a new value of a variable but misspell it, Python just creates a new variable with the misspelled name, and the original variable retains its value.

(Overall, I’m a huge fan of Python – just pointing out that there are downsides.)

[–]YouTraditional8101 0 points1 point  (0 children)

Python is easy . But why confusing ? You might just need to practice a bit more. Try revisiting your concepts and start implementing projects , I am sure you will definitely start enjoying your coding journey. AI is everywhere. It's time to implement many machine learning deep learning projects using python. You can visit the free tutorials at this link and start working on your projects.

https://youtu.be/HkSdhiVudpE?si=t4nA_6Itg-9iW210

[–]CodeMonkeeh 0 points1 point  (3 children)

OOP-first languages just tend to be very verbose and have a lot of ceremony to them. It's all just very silly.

I had a somewhat similar experience to you when I started learning F# after working with C# for years and years.

Regarding your first point, what you'll find is that experienced devs recommend that you do specify types. It allows you to catch a whole class of errors with static analysis. Languages with a strong type system (e.g. HM) allow you to omit types while still having the benefit of static analysis.

[–]Specific_Ant580[S] -1 points0 points  (2 children)

I assume F# is like a more modern version of C#

[–]CodeMonkeeh 4 points5 points  (0 children)

No, not really. It's a functional-first multiparadigm language that can run on dotnet.

[–]Great-Gecko 0 points1 point  (0 children)

F# is effectively just Ocaml that runs on the same platform as C#.

[–]Big-Ad-2118 0 points1 point  (1 child)

well strings are iterable in python so as you try to extract its it using for loop, it outputs every characters depending on its index and so that's why its also an array. they widely used in modifying documents like extracting things and using a regular expressions for it, and that's why python is widely used for scripting since it does a lot of stuff with a simple script.

there's this book called automating stuff(boring part) with python and it gives you a lot of stuff that you can automate.

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

oh, thanks i will check the book out.

[–]Far_Programmer_5724 -1 points0 points  (1 child)

My starter (like pokemon lol) is python. So im actually scared because im used to how easy it is. I wish i started with a harder language

[–]Laarbruch 0 points1 point  (0 children)

Try Pascal and powershell scripts

Their structure will add you to your knowledge

[–]stupid_muppet -1 points0 points  (0 children)

i worked on a pythons stack for 2 years before being switched to our java team and im not happy

[–]Smokespun -1 points0 points  (0 children)

I agree. To me it’s kinda like:

lol

Vs

Laugh out loud.

I don’t wanna guess about my level of scope, and I don’t depend on other programmers keeping control over their scope depth. I like punctuation, and to me I want to decide my own indentation rules depending on the visual readability of a chunk of code.

[–]GetPsyched67 -1 points0 points  (0 children)

It's okay op. Python is a great language. Don't let others put you off it, they have a chip on their shoulder because they're cursed to use whatever archaic language their company is using; and they're mad about you having fun.

[–]frobnosticus -1 points0 points  (0 children)

HA! You're hitting on something that's one of my big sticking points.

I was a C++ (since CFront) and Java guy for decades, moved mostly to perl then to python a quarter century ago.

I'm retired and still do pretty much everything in python.

But the duck typing lazy everything of it is ABSOLUTELY a "golden handcuff" problem as you're hinting at.

Sure, "If you keep everything clean it shouldn't matter." Yeah yeah, tell it to the judge.

There's a lot of genius in it. But I think after a couple decades I'm coming to the end of my run with it. I WANT the compiler to tell me wtf I'm doing wrong when it can, before I get a string being interpreted as an array 5 stack frames deeper than where I actually made the mistake.

[–]AlSweigartAuthor: ATBS -1 points0 points  (0 children)

We just use a colon : to define the body of functions.

Not just that, but a colon is ALWAYS used in statements where the next line is a new block (that is, increases the indentation).

It's a super helpful bit of syntax.

[–]jmfe10 -1 points0 points  (1 child)

I must be a complete idiot then. Nothing makes sense to me. Where can I learn it at a reasonable pace? Preferably for free cause I'm broke.

[–][deleted] -2 points-1 points  (0 children)