Suppose I've mostly used untyped programming languages and don't have a great appreciation for types.
Let's do some convincing!
Suppose I've mostly used untyped programming languages and don't have a great appreciation for types.
Let's do some convincing!
For further actions, you may consider blocking this person and/or reporting abuse
Latest comments (60)
You can catch malicious attacks on your input forms of your web apps. Debugging is lot easier and code is easier to read.
Depends on the project imo. Types are useful when building out enterprise applications with lots of inherent complexity and are meant to be read by many different developers. This is because it is easier to quickly deduce what a function expects, and what kinds of data you are working with. Additionally many editors like typescript can use the types to provide intellisense, and static type checking.
However types can get in the way and be overbearing in small projects maintained by one person where the complexity is small. It's just faster to code without types.
This is gonna be a really crappy persuasive argument, but I wanted to give pros and cons of types, and you can decide for yourself 😄
Pros:
myarray[0]will never throwCons:
That's all I can think of for now. I think typed languages pay off after you get to a medium sized codebase. I usually reach for them on day 1, because I've been burned a lot by errors in dynamic languages, that typed languages don't have.
Hope this helps!
I just like that it decreases mental load for me.
I do not have to think about what the inputs to my functions are, what the outputs are, whether I have to think about null checks, etc.
It just helps me write safer code faster.
Also it's very self-documenting. I can always ask my IDE what other functions I can call on the output of another.
Oh so you're not only a grafikart follower lol
I can see why people like them, but personally I find they slow down development and restrict creativity somewhat. All depends what you're building of course.
I always find my ideas flow into working code much, much faster using untyped vars. Doing it this way also allows for more flexible code, and encourages a better mental understanding of the code. Admittedly this works better for solo coders than for sharing code with others.
Something that bit me, recently: ended up having code-squirreliness because I wasn't paying attention and kept re-typing a structure. The resulting (unintentional) transformations to the stored data made for Good Times™ debugging. Wasn't till I found an excessively-pedantic linter that I figured out where the mangling was happening.
I should have explained better. Clojure is a dynamic language with optional typing. Also it's not an additional tool, it's baked into the language, and only possible because it's dynamic. The program is literally made from interpreting each statement instead of statically compiling everything at once.
There is also some power in not having types, or only optional types.
I really think it's a spectrum. Like in Java I sometimes miss the feature to make type aliases to make strings especially more safe. But 'cheating' with var in Java in selected places feels like a releave. And with Rust you are repeating some types a lot in some cases (but then you could use an alias). And typescript can be tricky when coming from Java, since it only checks compile time.
When I first started programming I thought dynamic languages were faster to program in. That was until I had a decently sized project and had no idea what the hell was going on.
Userobject'snameproperty tofullNameis as easy.Make the code work for you, don't work for the code!
But what if can directly verify if the code is good, like with a Clojure Repl. It's Scenario 3, as you write is function it's detectly evaluated and you get the result back.