Ask Lemmy
A Fediverse community for open-ended, thought provoking questions
Rules: (interactive)
1) Be nice and; have fun
Doxxing, trolling, sealioning, racism, and toxicity are not welcomed in AskLemmy. Remember what your mother said: if you can't say something nice, don't say anything at all. In addition, the site-wide Lemmy.world terms of service also apply here. Please familiarize yourself with them
2) All posts must end with a '?'
This is sort of like Jeopardy. Please phrase all post titles in the form of a proper question ending with ?
3) No spam
Please do not flood the community with nonsense. Actual suspected spammers will be banned on site. No astroturfing.
4) NSFW is okay, within reason
Just remember to tag posts with either a content warning or a [NSFW] tag. Overtly sexual posts are not allowed, please direct them to either !asklemmyafterdark@lemmy.world or !asklemmynsfw@lemmynsfw.com.
NSFW comments should be restricted to posts tagged [NSFW].
5) This is not a support community.
It is not a place for 'how do I?', type questions.
If you have any questions regarding the site itself or would like to report a community, please direct them to Lemmy.world Support or email info@lemmy.world. For other questions check our partnered communities list, or use the search function.
6) No US Politics.
Please don't post about current US Politics. If you need to do this, try !politicaldiscussion@lemmy.world or !askusa@discuss.online
Reminder: The terms of service apply here too.
Partnered Communities:
Logo design credit goes to: tubbadu
view the rest of the comments
Static typing can kiss my ass.
The only reason you like it at work is because you are surrounded by idiots.
I've got a growing appreciation for Rust. There's a lot of benefits. But it is overkill for most things I guess.
I'm a big fan of type hinting like in Python though. You can have some of the safety of static analysis with the flexibility to fuck around if you find it makes it easier to grok the code.
What is static typing?
In programming you declare variables. To keep it simple let’s say there are only 2 types, numbers and words.
Now 1 is obviously a number, and ‘word’ is obviously a word. If I ask you to divide 100 by ‘word’ you’d have to tell me that’s not possible.
Now what if a say divide 100 by the “word” ‘10’? Well I’m a strongly typed programming language, you’d have to tell me “well, because you defined it with the single quotes, that’s actually a word so you can’t do math on it.” In a loosely typed language you’d be like “yeah I get that ‘10’ meant the number 10 so I’ll do the math.
This creates amusing weirdness in loosely typed languages, especially when they use math operators to represent word actions. For instance JavaScript is infamously loosely typed and uses the + sign to join words together so if I say ‘Java’ + ‘Script’, I get back ‘JavaScript’. So all the following are true in JavaScript:
1+1=2 1-1=0 ‘1’+1=11 because the ‘1’ makes it think you want to join words and it converts the second number 1 to a word ‘11’-1=10 because there’s no word operation applied to the minus sign, so it converted the word ‘11’ to a number
There’s lots of other tomfoolery, but I’m trying to keep the explanation simple. But any mixing of words and numbers in a strongly typed language would just give you an error.
I’m with the top reply of this thread, you don’t need strong typing if you understand what the code does.
I think strong/static typing with inference is the sweet spot. Complex types can change, so it helps to at least have your boundaries well defined. Within the scope of a function, if you need explicit typing on everything then your function might be getting too complex.
Careful - you are going to be liking Perl before you know it:-).
It's a feature of a programming language that usually, but not always, requires you to declare what sort of data everything is (this is a number, this is text, this is a person object I made, etc.). Then you are required to run your program through a program called a compiler before you are allowed to run it, to (among other things) make sure that everything is what you said it was.
Basically, it requires you to be extra pedantic, but some say it catches common errors. But imo these are the sort of errors that only come up because you have tons of people working on one project.
i like it in personal projects too. it makes everything neater and safer, especially with algebraic data types