Static typing turns so many runtime errors into compile errors. Makes life a lot easier when you don't have to hunt down where the wrong thing came from.
I'm convinced people who don't like explicit typing have never worked on a large project and seen the benefit it has, both in the IDE and also keeping slop under control.
University projects and hacking around are one thing. Projects with a team of developers that evolved over a decade need all the help they can get to fight against the relentless entropy and disorganization that occurs otherwise.
Same. When your "programming" experience is just writing some scripts so small they don't even require scrolling it's really easy to not run into the problems that are very common in any program of serious size and scale.
The team that's been working in the big legacy monolith for that decade isn't helping much here, unfortunately. They know the quirks of the system by heart, they don't know there even is a problem here, their own knowledge of the language stopped accepting pull requests (so to speak) when none of these new features existed, and they have neither the time nor inclination to learn.
Add in slop code that just mirrors the current style instead of attempting to upgrade it without specifically being told to do so, and what we get is shit copying shit and producing more shit that reinforces the shit.
Dynamic typing can seem great until you have to spend days trying to figure out where, exactly, in 20,000 lines of badly documented code JavaScript arbitrarily decided that something should be a string for the rest of forever even though it's only been given numbers to work with.
If you type x = 1 + '1' any sane language will go "what the fuck is wrong with you?"
That, and just learning a new library / API: I hate how in python you can never be sure what type you need to put in, are going to get back, and what all of the fields and functions do. Sure, you can dig that up, but that's not my job!
I especially hate how difficult it is in Python to find out what fields a type even has and what I can do with it. It just looks very cluttered to me but maybe that's just because I primarily use c#.
This exact thing caused a bug in my company's system. Went years without noticing it until someone (me) had to build something that did a calculation between the number of units of a product and its weight in grams. It was data we ingest constantly but, there's so much of it, and its not something we really interacted with until we wanted to build a feature around it like 5 years later.
Was real fun when the database data pipelines started breaking because it turns out multiplying two 86 digit numbers together is bigger than the size of an integer column. As soon as I saw it I knew where to look, the quantity was like 202020202019191918181520202020202020141299920202020 etc.
Just to be clear, Javascript is not just dynamically typed, but it is also WEAKLY typed. The latter is where most of its problems/quirks/headaches come from. Implicit type casting is just evil. Dynamic, but strong, typing will still surface errors, just at runtime and not compile time.
Most of it wouldn't be needed if languages had powerful enough type systems. But few general purpose mainstream languages offer dependent types or higher order types. Apart from Haskell, what do you have? Only Scala and TypeScript come to mind.
And that's where dynamically typed languages come in, they let you express things that many statically typed languages simply can't due to limitations of the type system.
That being said, portions of the code that can be statically typed, should be statically typed.
I’m very anchored to Java. Every time I try to leave it and “write a super quick project” in something like Python, I always get reminded how much the compiler is able to do for me with static typing.
Why would I want to take compiler errors and instead make them runtime logic errors?
With modern IDEs Java's "verbosity" is very much a meme. Sure, the characters are still there on the screen. But you didn't have to type them.
And honestly if typing is a problem for any programmer then they need to close hackernews and all the other "look at new shinies" sites and open up a typing trainer game.
Some do. Really depends on the kind of university/program you pick. My first programming language was JavaScript, because my program was about communication and multimedia design (read: web development, graphic design and marketing). And I heard that on some economics programs they teach students Python and/or R. In other words: you don't have to do a computer science program to get taught programming.
I always wanna cry when I see people recommend Python as a first language. Hell, even when I got started myself I used C#. In college we started with a bit of C. We only did python and JS the second and third years lmao
Wait till you learn we can have both. Strong typing without having to name them all. It's called type inference and it's only been around for a few decades.
TBH: it's nice to see mainstream catching on to how important types are in general and how they can prevent bugs. People will get there eventually.
There is room for quick hacky small BS in the world. As a C++ dev who never touches Javascr*pt, Typescript is the true evil IMO because it encourages making huge projects in a fundamentally hacky language.
If your JavaScript project has grown to the size static typing is a genuine aid, stop writing JavaScript!
Love me some Python when I just need 100 lines to parse some csvs
But then how can we use our frontend developers on the full stack? We're simply trying to not pay bAcKeNd DevEloPeRs those pesky "salaries" they keep begging for.
I don't really want to build a website in Java. APIs in Java, sure. Building a serious, dynamic site in Java with server-side rendering just sounds like a nightmare compared to using Angular. I'll even accept React, which I don't use because I haven't learned it.
Replacing desktop applications with electron and making them web clients, though, that was a mistake.
It's great when you get an undocumented python code base, and the key logic function takes a variable just called "context". What variables and functions does it have? No one knows.
Having to follow the spaghetti to find where it even originated is so god damned annoying.
Oh but when I write it, no problem. Makes perfect sense.
That's the one thing about Lua that I didn't like. It feels wrong to just declare a variable and let it fly. It's like driving without a seatbelt. I can't be held responsible for whatever happens to that guy!
Literally did this with my current project. Never used type hints in Python before, during uni it was a blessing being able to just do whatever with whatever because all that really matters is that the code worked, but now I've used them once I will bring it up in every future project
I first learned explicit typed. Later I learned about JS and thought, "what is this monstrosity." Many years later I still don't understand why anyone would want dynamic typing.
you can have smart dynamic typing like python where 1 + "1" throw an exception because you're adding object of different type and Js dynamic typing where you can substract an array with a toyota yaris and get a result
Man, I started in JS/PHP. There's so much cult-like devotion to the languages. The only valid argument is that it reduces the iteration time because you don't have to wait for a compile. I don't know about Java, but I use Go now and the compilation step is about 1-2 seconds.
The idea that prototyping is faster in loosely typed languages is a total myth. I can build much faster when I know the type. And AI kind of broke everything, so it's better to have the compilation step.
I am using typescript almost exclusively now and I still think a few type errors occasionally are not worth the effort of writing down types for everything.
It's not just errors, wait until you're working on bigger projects where you're constantly passing around large objects (eg from the DB). The IDE can tell you exactly what fields are available and what they are.
Thats because typescript kinda sucks because it has to cope with being Javascript (i.e. a language without typing). Languages built with types in mind from the start tend to work a lot better and be cleaner.
To me the trade off is: Do you wanna spend the extra effort in explicitly writing down your types? Or would you prefer to spend it in fixing the class of bugs caused by you having lost track of the exact shape of your data.
Exactly, you described it perfectly. For me JS vs TS is not even a debate. If you lean towards JS, you clearly didn't spend enough time debugging both.
Types aren’t just there to prevent you from writing bugs in your own code; they’re also there to prevent other people who work with it from writing bugs in theirs.
It’s horrible until you get out of school and start working on projects that are more than just a homework script and you realize just how much organization and tooling reliant on explicit typing helps.
I started on C# and loved explicit types. Then I got to Python and I started loving the wild freedom. The thing that actually surprised me is, after learning Php, perl, and javascript, when i go back to python what I find missing is the explicit declaration. "Let x" or "my x" or whatever to indicate you are creating a new variable here, in this scope, not mistyping the name of another variable you already created
I love it most of the time, but if I'm working on a small program I just want done quickly then suddenly typing is the one thing the compiler contains about.
This seems to be discovered by everyone at some point. Weak typing is a great tool (e.g. Python), but should never be trusted to newer programmers. Force them to use a strongly typed language and then later on (when they understand types) they can use weaker typed languages.
I used to tutor a lot of CS101 people where the class was taught in Python. It caused a lot of confusion.
Maybe I have a pigeon brain, but something about knowing exactly what the type is is just... Orgasmic. One fewer thing to try to remember in my pigeon brain
Lol we are really going in circles. Some 10-15ish years ago when probably most of the users here were barely able to write, dynamic typed languages were ALL the rage. JAVASCRIPT! I DON'T NEED TO USE TYPES BECAUSE I CAN JUST PASS A STRING, A NUMBER, AN OBJECT, A FRIGGING FUNCTION to the same parameter and I EXPECT IT TO WORK NO MATTER WHAT!
PYTHON ! DUCK TYPING ! THE TYPE WILL BE OBVIOUS FROM THE PARAMETER NAME, ARE YOU STUPID? VARIABLE ARGUMENTS! KEYWORD ARGUMENTS! YOU JUST NEED A COUPLE OF EXAMPLE CODE, WHO NEEDS OVERLOADED FUNCTIONS?
Java? The language of AbstractSingletonBeanFactoryVisitorBean ? Who needs that?
one thing is i think even better implicit type deduction like hindley milner and simmilar, ao you write code and compiler, lsp and you know exactly what type things are. give f# a shot, or ocaml, or haskell. the thing when you write a function and the compiler know exactly what you want this is good stuff.
Var is real until literally anyone has to go through the code and figure out what it is doing. It’s not the biggest thing, but knowing what type the original author was trying to return/use is at least one more clue
I can't program for my life without telling the piece of shit variable what type it is I try loosely typed languages, we are just not compatible. It doesn't work
What I hated most about reading python at work is that I have to often hunt what is the type assigned or returned or whatever. Maybe it's a skill issue. I also hate when people abuse 'auto' in cpp. Great they saved 5s of their time and waste 1minute of mine.
...if you have a small program... there are times explicit writing is good. Any many times it is really bad. Especially if your program lives for generations of programmers.
...living with a language that doesn´t have strong typing at all...
I'm of the mind that a decent programmer can track his own typing. I'm 47, and haven't been tricked into complacency yet. As I'm fond of saying, everything's just bytes, and it's good to have as much control over those bytes as possible.
In 11 years of programming with only lua at work, I have seen one type-related bug in production, and that one involved a pretty gnarly array[1] vs array["1"] bug due to a sandbox env running code snippets loaded at run-time. Point being: While a type error, I'm not sure you could design a statically typed system with similar capabilities that would have caught it, but I'm not completely certain either way. It's also a very specific lua weirdness in that x[1] vs x["1"] is both legal code but distinct, and if anything, I think that was more the issue than the actual types.
That was the only bug involving classic stupid type mistakes on production. I have seen many type related bugs in C++ because int isn't uint isn't int8 isn't uint16 isn't float isn't double and yet they all silently convert to one another. In a dynamic language like lua you only get "number" and that really solves this issue.
Type-related bugs happen in development, not production, because you can always find them all during testing. If you manage to push a build that fucks up adding a string and a number, you clearly had zero tests for that, because it doesn't matter which number and which string you try to add so you fail. It's not an edge case, and if you have one test which at some point executes the line of code that's wrong, you'll have a failing test due to crashing.
If static typing reduced bugs in shipped software, we would know by now. We know that QA and TTD help. We have no statistics that show that lua is more buggy than C#.
This makes me think of python-juniors comparing strings as if they where enums. Pair this with having to explain in a polite and professional manner why this is bad, meanwhile "do we really need code-review?".
I spent hours trying to debug some code where a property kept being null when it turns out it was referenced as both color and colour. Never have to deal with that sort of bullshit with statically typed languages.
I once spent two months applying a new-fangled static code analyser to a mature Java/C++ based commercial product.
It was incredible the things it found, many of which absolutely shouldn't even have compiled. Others were super subtle like if statements with a semicolon after the condition, meaning the 'true' block was executed every time.
So many long-running bugs went away after that marathon cleanup. It was interesting whenever a test failed after a round of static code fixes to see how often the test was set up to pass only the wrong code and was failing now it was right.
Templates in C++ were always duck typed (sure, at compile time rather than runtime, but good luck understanding the error vomit when an instantiation failure happens somewhere 8 layers deep), but since C++20 concepts they can be less duck typed.
So in a way, they are moving more towards explicit typing.
Auto is generally just sugar for template parameters anyways when used for return or parameter types.
Are concepts really less duck typing? I view them more as just a way to formalise the requirements of the type to work in the template so that you get a better error rather than a template monstrosity.
Like it's basically saying "you must meet these conditions in order to be a duck", rather than leaving it to the programmer to work out in what way their type is not the right kind of duck.
It's still duck typing in the sense that if a type satisfies the concept the instantiation can still fail if the template code contains some implicit assumption about the type that isn't present in the concept.
But if the applied concepts/requires clauses are well thought out enough then it should be the case that it communicates intent towards the programmer sufficiently that you understand what sort of types does the template work with.
So in this sense I see quite a lot of similarities with static type annotations in Python which also will not prevent you from putting in the wrong types, but at least the reader won't have to guess what sort of things that function is supposed to work with, and language servers can give proper code intelligence (with that said my experience with clangd and concepts is not good, it will give me appropriate error reports at the use site but autocomplete is kinda wonky even if i am trying to access operations permitted by the concepts).
auto is either "implicit template" or "non-template, deduce from assignment", depending on the context. Parameters tend to be the former, and return type tends to be the latter (unless the return type is dependent on a function template).
Because templates are templates and not generics. And even without traits, you'll get a compile-time error if you try to wire up incompatible types, or are simply, instead of something else breaking down during runtime.
But the most important part is that types remain immutable during runtime.
auto is just the "I typed it on the right of the =, so I shouldn't need to type it on the left, too" keyword, more than anything else. Oh, and the "this needs to be a template, but the syntax doesn't let me use a template here" keyword.
It's essentially just an inline template, which means it's supposed to deduce the exact type on assignment, then statically type itself to match and never change again.
857
u/enigma_0Z Sep 25 '26
Static typing makes the IDE work for you better.
Type hints in Python and TS do the same but make you work harder for it /IMO
990
u/GargantuanCake Sep 25 '26
Dynamic typing can seem great until you have to spend days trying to figure out where, exactly, in 20,000 lines of badly documented code JavaScript arbitrarily decided that something should be a string for the rest of forever even though it's only been given numbers to work with.
If you type x = 1 + '1' any sane language will go "what the fuck is wrong with you?"
1.1k
u/Common-Brush-7027 Sep 25 '26
I hate dynamic typed
225
u/semioticmadness Sep 25 '26
I’m very anchored to Java. Every time I try to leave it and “write a super quick project” in something like Python, I always get reminded how much the compiler is able to do for me with static typing.
Why would I want to take compiler errors and instead make them runtime logic errors?
72
u/Erisymum Sep 25 '26
New programmers start with dynamic types now? We always started with C at my uni
38
u/Masterflitzer Sep 25 '26
implicit types are great as long as the language is statically & strongly typed
32
u/DontDoodleTheNoodle Sep 25 '26
I learned with Java, so explicit typing was my bread and butter (and still is)
Que my absolute “what the fuck….” when I was handed a JavaScript + python project for the first time. Languages favored by the utterly deranged.
23
u/TheShirou97 Sep 25 '26
Static typing with type inference >>>>
28
u/Local_Surround8686 Sep 25 '26
I didn't even know there was an alternative. We got taught explicit in school and I always thought the alternative was a quirk of some languages haha
61
u/aberroco Sep 25 '26
Wait till you try static nullability checks.
13
u/FriendshipProtocol Sep 26 '26
Yup. It makes the code so much easier to review/debug.
43
u/SaveMyBags Sep 25 '26
Wait till you learn we can have both. Strong typing without having to name them all. It's called type inference and it's only been around for a few decades.
TBH: it's nice to see mainstream catching on to how important types are in general and how they can prevent bugs. People will get there eventually.
126
u/samanime Sep 25 '26
You'll pry my vanilla JS from my cold dead fingers. It'll always be my favorite way to do quick scripts and prototyping.
But explicit typing does make long term code way more maintainable.
11
u/DasGaufre Sep 25 '26
It's great when you get an undocumented python code base, and the key logic function takes a variable just called "context". What variables and functions does it have? No one knows.
Having to follow the spaghetti to find where it even originated is so god damned annoying.
Oh but when I write it, no problem. Makes perfect sense.
10
u/Donut Sep 25 '26
Imagine what it is like going in the opposite direction.
"WHAT IS THIS VARIABLE EVEN HOLDING????"
33
u/iamdestroyerofworlds Sep 25 '26
Learning Rust was and still is pure balm for my soul.
8
u/Vyrnin Sep 25 '26 edited Sep 26 '26
That's the one thing about Lua that I didn't like. It feels wrong to just declare a variable and let it fly. It's like driving without a seatbelt. I can't be held responsible for whatever happens to that guy!
15
u/JackReedTheSyndie Sep 26 '26
It’s just so good that I question why there are dynamic typing in the first place, it only added confusion.
11
u/Keebster101 Sep 25 '26
Literally did this with my current project. Never used type hints in Python before, during uni it was a blessing being able to just do whatever with whatever because all that really matters is that the code worked, but now I've used them once I will bring it up in every future project
21
u/X-lem Sep 25 '26
I first learned explicit typed. Later I learned about JS and thought, "what is this monstrosity." Many years later I still don't understand why anyone would want dynamic typing.
5
u/Knighthawk_2511 Sep 26 '26
Imagine dynamic types being so hellish , an entirely new language was created just to add types ( I don't use either of scripts)
9
u/[deleted] Sep 26 '26
The classic programmer arc: hate types at 20, defend them at 30. Explicit declarations are documentation the compiler actually checks.
8
u/Karisa_Marisame Sep 26 '26
As a compiler dev whose company wants our stuff have a Python frontend because users use python… this hits too close to home
4
u/Fidodo Sep 26 '26
IMO, dynamic typing was an over reaction to C's tedium and Java's verbosity.
9
u/scheimong Sep 25 '26
You're on track towards haskell
14
u/achilliesFriend Sep 25 '26
Joke where?
3
u/ZunoJ Sep 26 '26
Strating with a dynamic typed language is a huge mistake
3
u/SE_prof Sep 26 '26
As an SE professor, this thread has made me so happy!
3
u/xubaso Sep 26 '26
Fine until nested generic type definitions can't be shown on a single monitor anymore.
3
u/robertshuxley Sep 26 '26
except if it's too type anal like old school Java. Typescript and c# do it better
3
u/jacob_ewing Sep 26 '26
Having done C in my youth and now doing JavaScript feels like regression.
13
u/Dmayak Sep 25 '26
I am using typescript almost exclusively now and I still think a few type errors occasionally are not worth the effort of writing down types for everything.
4
u/grandalfxx Sep 25 '26
Unless its typescript. We all just pretend to like type script
2
u/Ok-Panda-178 Sep 25 '26
Explicit type enforced code
Me: any
2
u/kelpyb1 Sep 25 '26
It’s horrible until you get out of school and start working on projects that are more than just a homework script and you realize just how much organization and tooling reliant on explicit typing helps.
2
u/FrigoCoder Sep 25 '26
Anyone who advocates for dynamic typing deserves to refactor a humongous codebase.
2
u/ThePhyseter Sep 26 '26
I started on C# and loved explicit types. Then I got to Python and I started loving the wild freedom. The thing that actually surprised me is, after learning Php, perl, and javascript, when i go back to python what I find missing is the explicit declaration. "Let x" or "my x" or whatever to indicate you are creating a new variable here, in this scope, not mistyping the name of another variable you already created
2
u/o0Meh0o Sep 26 '26
that's it. i'm leaving.
2
u/Safebox Sep 26 '26
I love it most of the time, but if I'm working on a small program I just want done quickly then suddenly typing is the one thing the compiler contains about.
2
u/Luna-Hazuki2006 Sep 26 '26
Literally me
2
u/def-pri-pub Sep 27 '26
This seems to be discovered by everyone at some point. Weak typing is a great tool (e.g. Python), but should never be trusted to newer programmers. Force them to use a strongly typed language and then later on (when they understand types) they can use weaker typed languages.
I used to tutor a lot of CS101 people where the class was taught in Python. It caused a lot of confusion.
3
u/MocknozzieRiver Sep 25 '26
Maybe I have a pigeon brain, but something about knowing exactly what the type is is just... Orgasmic. One fewer thing to try to remember in my pigeon brain
3
u/OVectorX Sep 25 '26
when I was Junior, my lead dev first thing he told me, Do Not Use Var ever, its good but you will pul your hair figuring out what the variable is
8 years later, I never ever used in any of projects I shipped and cant be more thankful for such advice
3
u/marcodave Sep 25 '26
Lol we are really going in circles. Some 10-15ish years ago when probably most of the users here were barely able to write, dynamic typed languages were ALL the rage. JAVASCRIPT! I DON'T NEED TO USE TYPES BECAUSE I CAN JUST PASS A STRING, A NUMBER, AN OBJECT, A FRIGGING FUNCTION to the same parameter and I EXPECT IT TO WORK NO MATTER WHAT!
PYTHON ! DUCK TYPING ! THE TYPE WILL BE OBVIOUS FROM THE PARAMETER NAME, ARE YOU STUPID? VARIABLE ARGUMENTS! KEYWORD ARGUMENTS! YOU JUST NEED A COUPLE OF EXAMPLE CODE, WHO NEEDS OVERLOADED FUNCTIONS?
Java? The language of AbstractSingletonBeanFactoryVisitorBean ? Who needs that?
4
u/stlcdr Sep 25 '26
So being lazy and ignorant isn’t a good thing? Who’d a thunk it?
4
u/ReasonableNet444 Sep 25 '26
God I hate programming "humor"
1
u/Streakflash Sep 25 '26
python at its core
1
u/Anthonyg5005 Sep 25 '26
Haven't seen a chicken thoughts template used in over 5 years
1
u/mojur Sep 25 '26
Poly wants a cracker
1
u/QuackersTheSquishy Sep 25 '26
Learning SQL and Python for college, and started C# on my own. Loving static language
1
u/Mateorabi Sep 25 '26
Vhdl > verlog. At least systemveeilog gas the option to be pedantic
1
u/Luneriazz Sep 25 '26
The moment you touch data model. type is your friend
1
u/Afraid-Locksmith6566 Sep 25 '26
one thing is i think even better implicit type deduction like hindley milner and simmilar, ao you write code and compiler, lsp and you know exactly what type things are. give f# a shot, or ocaml, or haskell. the thing when you write a function and the compiler know exactly what you want this is good stuff.
1
u/vastle12 Sep 25 '26
I learned on strictly typed languages, dynamic typing has been a necessary evil to me
1
u/BoredOY Sep 25 '26
Your first language should never be dynamically typed. Teaches way too many bad habits.
1
u/Crumineras Sep 25 '26
Var is real until literally anyone has to go through the code and figure out what it is doing. It’s not the biggest thing, but knowing what type the original author was trying to return/use is at least one more clue
1
u/MedalReddit Sep 25 '26
auto
1
u/shiny0metal0ass Sep 25 '26
Said all JavaScript devs ever
1
u/Zealousideal-Deer101 Sep 25 '26
I can't program for my life without telling the piece of shit variable what type it is
I try loosely typed languages, we are just not compatible. It doesn't work
1
u/comtrends123 Sep 25 '26
I thought world war II means World war 11?
1
u/StephenRoylance Sep 25 '26
explicit type declaration is a huge pain. but you know what's worse?
FINDING A STRING IN YOUR NUMBER AT RUNTIME
1
u/aleopardstail Sep 25 '26
not just explicit type declaration, but also a naming convention that indicates intended usage
1
u/undeadpickels Sep 25 '26
Oh look it's me a while ago.
1
u/SuperCarla74 Sep 25 '26
Pretty much why Typescript exists, and the name begins with *type*.
1
u/DarthCloakedGuy Sep 25 '26
I tried it... still not sure what the benefit is, and for some things it is very much not wanted
-14
u/Old-Attention-3936 Sep 25 '26
It's not hard to be consistent with what you store in variables
0
u/Motleypuss Sep 25 '26
I'm of the mind that a decent programmer can track his own typing. I'm 47, and haven't been tricked into complacency yet. As I'm fond of saying, everything's just bytes, and it's good to have as much control over those bytes as possible.
1.8k
u/[deleted] Sep 25 '26
[removed] — view removed comment
42
u/[deleted] Sep 25 '26
[removed] — view removed comment