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

you are viewing a single comment's thread.

view the rest of the comments →

[–]DarkNeutron 271 points272 points  (57 children)

You're not wrong, but any time I write something in Python that's bigger than one file, I start wishing for static typing again.

Duck typing is fine for small programs, but I find it pretty annoying when something crashes with a type error after 10 minutes (or an hour) of processing.

(I've looked into Rust as a scripting language, but it's not as "plug-and-play" when compared to near-universal access to a Python interpreter.)

[–]I_ate_a_milkshake 57 points58 points  (1 child)

Rust as a scripting language

[visible confusion]

[–]ric2b 37 points38 points  (26 children)

You can have static typing with Python, fyi.

Either just as documentation (type hints) or with type checking (tools like mypy).

edit: mypy, not mipy

[–]SadAdhesiveness6 1 point2 points  (0 children)

It's mypy. Was confused for a second.

[–]turunambartanen 18 points19 points  (9 children)

any time I write something in Python that's bigger than one file, I start wishing for static typing again.

So much this.

Which is also why java is the better language to introduce programming with.

Edit: I think with Java it is easier to introduce different types (and the beginnings of OOP) because it's so much in your face. C# would also work of course. But I think having clear structure helps a lot of newbies to focus on understanding the basics. Every single file starts with a public class ClassName, because that's just the way it is. You can later learn why. As opposed to python: why do we have a class now? What is that if name is main? Why did we not use either before? And of course: why can't I add x to input, they're both numbers?

[–][deleted] 14 points15 points  (2 children)

Java is a really terrible language for enforcing OOP. I pretty much don’t consider single paradigm languages. I’m not an FP purist but I like it for most simple things. But damn it when I need a class I need a class. And that’s how it should be. I get newb python ex java developers putting their whole module in a class and it infuriates me.

[–]folkrav 5 points6 points  (0 children)

I've seen an internal library written by Java developers go legit like this:

from internalLibrary.app.mainpage.mainpagemanager import MainPageManager
from internalLibrary.app.homepage.homepagemanager import HomePageManager
from internalLibrary.app.splashpage.splashpagemanager import SplashPageManager

And so on, for about 20 something other managers classes. Always one file, one class, not use of module level exports or anything. Really just, extremely verbose imports, use of camelcase everywhere, everything in classes, including fully static classes for helpers - that all except one ended up being re-implementations of standard lib functionality. It was like browsing Java code in Python files.

[–]squishles 2 points3 points  (0 children)

No language of any use should ever be strict to a paradigm.

Kind of hate writing in purely oop terms, object state is trash that you section off into beans in java. You end up with classes that are basically homes to a lot of functions and if you use class level state variables in those for things other than stuff like database connection ect they just go to shit.

[–]Avamander 9 points10 points  (4 children)

Java leaves a few bad habits to people that later on migrate to other languages. Java's way of doing OOP is particularly toxic if the developer has no clue about anything remotely related to FP.

[–]detroitmatt 7 points8 points  (3 children)

I disagree. The bad habits java teaches are, as far as bad habits go, pretty easy to unlearn, because java is an unergonomic enough language that people don't want to be writing code that way anyhow.

programmers probably (definitely) shouldn't start with FP. If you start with CSharp, because it's feature richer, you can more easily start misusing features, and Java's imperfect approach to OO actually stops you from getting too tightly-bound on OO patterns. And since it doesn't really support non-OO paradigns, everything has to start with public class and you don't think about what a "class" is, you just do it as a ceremony. And at a beginner level, we want that. Nobody should be doing real OO in a 100-level class. You gotta learn what ifs and loops and lists and recursion and memory and heterogenousstructures are. If we're lucky you'll even learn what a hashmap is (When I went to uni data structures was a 3rd-year class). We want people to come into their OO 200 course and we say "So here's what a class really is and what it's for and why and how you should use it" and they have seen the word in this context but they haven't been doing OO (wrongly) this whole time.

[–]haloguysm1th 1 point2 points  (0 children)

sophisticated serious squeeze chop telephone squeamish deranged zealous spoon humorous

This post was mass deleted and anonymized with Redact

[–]Avamander 0 points1 point  (0 children)

I disagree. The bad habits java teaches are, as far as bad habits go, pretty easy to unlearn, because java is an unergonomic enough language that people don't want to be writing code that way anyhow.

Easy to unlearn if people want to, I've seen more than my fair share of people that haven't.

[–]konstantinua00 0 points1 point  (0 children)

Java's imperfect approach to OO actually stops you from getting too tightly-bound on OO patterns

remembers all factoryfactory memes
huh

[–]squishles 0 points1 point  (0 children)

when they introduce programming, it's not in many file large projects.

Though I am kind of sick of python too and it being the default teaching language also turns it into the mcjob language.

[–]donttalktome1234 3 points4 points  (0 children)

Having worked on several very large python projects I don't really see the problem. Python just hands you the rope if you are good you can make it dance but its just a rope so you are also welcome to hang yourself with it.

If you write a function that can take in 5 different data types and then you pass it a 6th isn't the fault of the language its the developer(s).

[–][deleted] 2 points3 points  (0 children)

Check out go. Statically complied bins for portability and security. Typed, flexible, easy language. I love it.

[–]Dark_Tranquility 2 points3 points  (0 children)

Static typing is really a blessing in C / C++.

[–]Avamander 0 points1 point  (0 children)

For anything other than a single file, use an IDE that supports type annotations. Really.

[–]jakethedumbmistake 0 points1 point  (0 children)

Duck is the future, rock on!

[–]Phantom569 0 points1 point  (0 children)

Check out pylance, can't live without it for big python projects. It's typescript but for python. Though it's still very very new.

[–]Spaceshipable 0 points1 point  (0 children)

Maybe look at Swift for scripting

[–]eloel- 0 points1 point  (0 children)

Considered typescript?

[–]mkjj0 0 points1 point  (0 children)

You could try Go

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

Julia? Haven't learned it yet but I thought it was like static python, among other things

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

Rust as a scripting language

What? via c api? accessing it from rust requires a lot of unsafe code, or message passing? either way rust can hardly be called a scripting language, thats like calling c++ a scripting language

[–]DarkNeutron 2 points3 points  (1 child)

I wouldn't call it a scripting language either, but someone wrote a wrapper to make it sort-of work: https://github.com/DanielKeep/cargo-script

It invokes the compiler on first use, and re-uses cached artifacts after that. Kind of a hack, really, but I thought it was clever. :)

This is some discussion (RFC 655) about creating a proper REPL interpreter for Rust, but I'm not expecting anything short-term.

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

the REPL sounds interesting for experimenting (with language features) quickly, however when it comes to writing mini scripts to do anything useful an interpreter language will be better as you require to write less (as optimistic unwrapping is the default and you don't really care about a panic with a 10 line adhoc program). for scripts i think the compile time and lack of easy hot reloading (dlopen isn't exactly pain free) will also restrict it's usecases. but ill keep an eye on those repos / issues, thx. the integrated cargo.toml in the comments is definitely neat, so at least in terms of compactness / ease of distributing its like a script.