masterspace ( @masterspace@lemmy.ca ) English74•4 months agoLmao, bruh. How do people keep praising a language where messing up a space breaks everything and there is no real type system?
Riskable ( @riskable@programming.dev ) English22•4 months agoHaha: “A space breaks everything.” Fuck YES! Are you kidding me‽ It’s one of the best features!
Why? Because it’s so easy to see. In other languages you’ve got semicolons which are surprisingly difficult to notice when they’re missing. Depending on the situation (or if you’re just new to programming) you could spend a great deal of time troubleshooting your code only to find out that you’re missing a semicolon. It’s frustrating and it makes you feel stupid which is never a good thing for people who are new programming.
Types are in a different category altogether with seemingly infinite reasons why you’d want a feature-rich, low-level type system and also why you’d want to avoid that.
IMHO, the point of Python is to be a simple language that’s quick to write yet also very powerful and speedy when you need it to be (by taking advantage of modules written in C or better, Rust). If it had a complex type system I think it would significantly lower the value of the language. Just like how when I see an entire code repo using Pydantic and type hints everywhere it makes the code unnecessarily complex (just use type hints where it matters 🙄).
I’m not saying using type hints on everything is a terrible thing… I just think it makes the code harder to read which, IMHO defeats the point of using Python and adds a TON of complexity to the language.
The promise of type hints is that they’ll enable the interpreter to significantly speed up certain things and reduce memory utilization by orders of magnitude at some point in the future. When that happens I’ll definitely be reevaluating the situation but right now there doesn’t seem to be much point.
For reference, I’ve been coding in Python for about 18 years now and I’ve only ever encountered a bug (in production) that would’ve been prevented by type hints once. It was a long time ago, before I knew better and didn’t write unit tests.
These days when I’m working on code that requires type hints (by policy; not actual necessity) it feels like doing situps. Like, do I really need to add a string type hint to a function called,
parse_log()
? LOL! masterspace ( @masterspace@lemmy.ca ) English20•4 months agoI don’t mean this insultingly because lots of programming jobs don’t require this and for the ones that do we still tend to all start here, but in all honesty this sounds like it’s coming from someone who’s never worked on a large project maintained by multiple people over time.
First of all, the hysteria over semicolons is ridiculous when JavaScript, Typescript, C#, Java, Go, Swift, etc. etc. wil all automatically highlight missing semicolons, if not automatically insert them for you when paired with an IDE and standard linter. On top of that, JavaScript and Typescript do not require semicolons at all, but they are still used alongside braces, because they make your code more scannable, readable, and moveable.
Secondly, without type safety your code is no longer predictable or maintainable. If you’re working to quickly sketch out some new fangled logic for a research paper it’s one thing, if you need to write test code so that your codebase can be tested an infinite number of times by other coders and whatever CI/ CD pipelines to make sure that nothing’s broken, then all of the sudden you start seeing the value in strict typing.
Honestly, complaining about type safety adding “extra code” is a complaint that almost every coder has when they start out, before you eventually realize that all that “extra code” isn’t just boiler plate for no reason but is adding specificity, predictability, reusability, and maintainability to your code base.
When defining types looked like this it was one thing:
String name = new String("Charles Xavier");
But when it looks like this, there’s no reason not to use strong typing:
const name = "Charles Xavier";
Ephera ( @Ephera@lemmy.ml ) English5•4 months agoYeah, the alternative to static typing is to write tons of unit tests, which definitely adds a lot more code to your codebase.
porous_grey_matter ( @porous_grey_matter@lemmy.ml ) 3•4 months agoThat’s not an alternative, you always need tests
Ephera ( @Ephera@lemmy.ml ) English1•4 months agoRight, so this is the part where I get to sound like a smart ass, because I snuck a “tons of” into there.
What you do always need, is tests serving as a specification of the intended behavior, to document it for your team members and your future self.
But the thing that static typing is an alternative to, is integration tests for many code paths. For example, in dynamic languages you have no reassurance that a call to your database library still works, unless you have an integration test which actually calls into the database. Similarly, you hardly know whether the many error-handling code paths are working, unless you write tests for those, too.
In static languages, we don’t test this stuff outside of the specification-like integration tests, because the database library and the error handling library are already separately tested, and the type system ensures that we interface with them correctly.
Riskable ( @riskable@programming.dev ) English5•4 months agowithout type safety your code is no longer predictable or maintainable
This sounds like someone who’s never worked on a large Python project with multiple developers. I’ve been doing this for almost two decades and we never encounter bugs because of mismatched types.
For reference, the most common bugs we encounter are related to exception handling. Either the code captured the exception and didn’t do the right thing (whatever that is) in specific situations or it didn’t capture the exception in the right place so it bubbles up waaaaay too high up the chain and we end up with super annoying troubleshooting where it’s difficult to reproduce or difficult to track down.
Also, testing is completely orthogonal to types.
masterspace ( @masterspace@lemmy.ca ) English9•4 months agoThis sounds like someone who’s never worked on a large Python project with multiple developers. I’ve been doing this for almost two decades and we never encounter bugs because of mismatched types.
Have you worked on major projects in other languages in that time period to be able to compare and contrast?
The last two python projects I had to work on didn’t have bugs because of type issues, but it was much harder to come into the codebase and understand what was going on given that you didn’t have type information in many many places which forced you to go back and comb through the code instead.
Gamma ( @GammaGames@beehaw.org ) English5•4 months agoIt’s kinda funny that Godot’s custom language GDScript is, at least on a surface level, pythonic (no list comprehensions, context managers, decorators, etc, it’s mostly syntactical similarities). But type hints do make it run faster!
I was blessed to get to skip most of the old pains in python. I only had a handful of scripts that ever needed to be ported from 2 and they didn’t rely on any libraries. The ecosystem is easy to work with and I’m looking forward to working with Python for the foreseeable future
unterzicht ( @unterzicht@lemmy.ml ) 2•4 months agoI have never once, in nearly 20 years of using python, encountered IndentationError. Until today actually. I tried to make it happen because I couldn’t remember the class name.
HiddenLayer555 ( @HiddenLayer555@lemmy.ml ) English2•4 months agoA statically typed Python would be my dream programming language.
Can someone please make Typethon?
ma1w4re ( @ma1w4re@lemm.ee ) 4•4 months agoPyright language server makes Typethon out of your Python at the cost of massive bugs and performance. I used to like it, until I got really sick of waiting about 10 seconds for a suggestion to appear when typing open() and really fucking sick of the entire server crashing after I type pow()
porous_grey_matter ( @porous_grey_matter@lemmy.ml ) 3•4 months agoType checking for python is not bad these days, just run pyright (or mypy, I would like to prefer the non MS solution, but we have found pyright much more rigorous) on your code. Yes obviously you can still get out of it with an ignore statement, and that might occasionally be necessary for some libraries, but if you enforce no errors in pre-commit or CI then it’s only a little worse than compile time.
porous_grey_matter ( @porous_grey_matter@lemmy.ml ) 2•4 months agowhere messing up a space breaks everything
Messing up some character breaks everything in any language, skill issue
there is no real type system
What does “real” mean? It’s pretty robust these days.
Ismay ( @Ismay@programming.dev ) 2•4 months agoNot even the worst. This function declarations with separations between positional and enum variables… Or the infamous global…
kittenzrulz123 ( @kittenzrulz123@lemmy.blahaj.zone ) 45•4 months agoRust:
DannyMac ( @DannyMac@lemm.ee ) English32•4 months agoJesus Christ! No thanks! I can’t imagine improperly placing cabinet knobs on closet doors like that
KamikazeRusher ( @KamikazeRusher@lemm.ee ) 10•4 months agoI already hate that style of door but the knobs make it even worse
Prunebutt ( @Prunebutt@slrpnk.net ) 12•4 months agoIs the archinstall script not working?
kittenzrulz123 ( @kittenzrulz123@lemmy.blahaj.zone ) 5•4 months agoIdk, it was some image I found on Unix socks
apotheotic (she/her) ( @apotheotic@beehaw.org ) English8•4 months agoMissing a fursuit or cat ears and a tail plug
Lucy :3 ( @30p87@feddit.org ) 8•4 months agoOr fox ears :3
apotheotic (she/her) ( @apotheotic@beehaw.org ) English7•4 months agoFoxgirls are absolutely valid sorry for this erasure
kittenzrulz123 ( @kittenzrulz123@lemmy.blahaj.zone ) 7•4 months agoI prefer cat ears and tail plug. Im not a furry, I’m a catgirl :3
(No problem with furrries tho)
apotheotic (she/her) ( @apotheotic@beehaw.org ) English4•4 months agoCatgirls are cute and I will pet any who will allow
kittenzrulz123 ( @kittenzrulz123@lemmy.blahaj.zone ) 4•4 months agoMrrp :3
(I wan headpats)
apotheotic (she/her) ( @apotheotic@beehaw.org ) English4•4 months agopat pat pat happy girl!
kittenzrulz123 ( @kittenzrulz123@lemmy.blahaj.zone ) 3•4 months ago:333
QuazarOmega ( @QuazarOmega@lemy.lol ) 8•4 months agoPink Fedora logo is class
jia_tan ( @jia_tan@lemmy.blahaj.zone ) English25•4 months ago fl42v ( @fl42v@lemmy.ml ) 21•4 months agoI’ve learned python after CPP… And I can’t #even remember all the cases when I thought “damn, I wish I could’ve just used pointers”
Tiefling IRL ( @tiefling@lemmy.blahaj.zone ) 12•4 months agoI’ve been in industry for a decade, big tech for over 6 years. And I STILL fucking hate Python. I can write in it, but everything about it just feels wrong
paris ( @paris@lemmy.blahaj.zone ) 11•4 months agoMight I introduce you to the wonderful language known as Nim? Python-like syntax, compiles to C, C++, and even JS, has mature libraries and good tooling, and some memory safety features built in! And yes, you can use pointers!
nothacking ( @nothacking@discuss.tchncs.de ) 5•4 months agoOr a complier that tells me when I mispell a variable in an assignment or use the wrong type for something.
CarrotsHaveEars ( @racketlauncher831@lemmy.ml ) 13•4 months agoLet me guess. Are the Java and Python programmers happy after because they leave up their technical debt for someone else to resolve? 🤭
eldavi ( @eldavi@lemmy.zip ) English5•4 months agothat’s why it’s so addicting. lol
boredsquirrel ( @boredsquirrel@slrpnk.net ) 9•4 months agoCobol
💰💰💰💰💰
lud ( @lud@lemm.ee ) 4•4 months ago
Eiri ( @Eiri@lemmy.ca ) 9•4 months agoPython managed to turn me away before I wrote a single line of code.
Running an already functional project took me nearly two hours and three separate tutorials.
yetAnotherUser ( @yetAnotherUser@discuss.tchncs.de ) 10•4 months agoWhat’s so difficult?
import project as p p.run()
Eiri ( @Eiri@lemmy.ca ) 11•4 months agoHmm, I follow the package’s readme and only get invalid command errors.
Gotta install the pip dependencies.
Oh but first you need to create a venv or everything will be global. Why isn’t that local by default like with npm? Hell if I know!
Ah but before that I need to install the RIGHT version of Python. The one I already have likely won’t do. And that takes AGES.
Oh but even then still just tells me the command is invalid. Ah, great, I live CLIs. Now I’ve gotta figure out PATH variables again and add python there. Also pip maybe?
Now I can follow the readme’s instructions! Assuming I remember to manually open the venv first.
But it only gives me errors about missing pieces. Ugh. But I thought I installed the pip dependencies!
Oh, but turns out there’s something about a text file full of another different set of dependencies that I need to explicitly mention via CLI or they won’t be installed. And the readme didn’t mention that, because that’s apparently “obvious”. No it’s not; I’m just a front-end developer trying to run the darn thing.
Okay. Now it runs. Finally. But there’s a weird error. There might be something wrong with my .env file. Maybe if I add a print statement to debug… Why isn’t it showing up?
Oooh, I need to fully rebuild if I want it to show up, and the hot reload functionality that you can pass a command line argument for doesn’t work… Cool cool cool cool.
🇨🇦 tunetardis ( @tunetardis@lemmy.ca ) English6•4 months agoI can’t speak for others, but the python3 transition wiped the smile off my face for awhile there.
Riskable ( @riskable@programming.dev ) English9•4 months agoWhy? The most annoying thing that I remember about it was popular modules that hadn’t been ported yet. In essence, a temporary problem; growing pains.
The Unicode/string/bytes changes were welcome (to me). But that might just be because I had actually encountered situations where I had to deal with seemingly endless complexity and ambiguity related to Unicode stuff and encodings. Python 3 made everything much more logical 🤷
Swedneck ( @Swedneck@discuss.tchncs.de ) 4•4 months agolooking at python2 code these days is very uncanny, just the fact that
print
is a magical keyword is so wrong: what is this? bash?
Swedneck ( @Swedneck@discuss.tchncs.de ) 3•4 months agoyep, that’s how major version changes do be working. if they didn’t decide to implement breaking changes to improve the language people would have been complaining about how terrible python2 is to use
JackbyDev ( @JackbyDev@programming.dev ) English5•4 months agoIf Python has no haters I’m dead.
ZonenRanslite ( @ZonenRanslite@feddit.org ) 3•4 months agoWhere Delphi?
jmcs ( @jmcs@discuss.tchncs.de ) 6•4 months agoDead and buried?
Excel ( @Excel@beehaw.org ) English1•4 months agoIt turned into C#
interdimensionalmeme ( @interdimensionalmeme@lemmy.ml ) 2•4 months agoCoding space characters? Fuck no
wdx ( @wdx@feddit.org ) 2•4 months agoPython with ESModules would be neat.
Every time I type if typing.TYPE_CHECKING a part of me dies inside
pfm ( @pfm@scribe.disroot.org ) 1•4 months agoWhy does JavaScript before-guy look like Alan Kay? 🤔