(no title)
marta_morena_28 | 5 years ago
This boggles the mind. I am using typed languages since I can think. I never once recall an instant where I was saying "Uh uh, this type signature is driving me craaazy". Like seriously, I don't even know what articles like this are talking about. Types are not your enemy, they surface issues early. Yeah you can whip something up in Python and JS, but ultimately you DO have to deal with types, except now you don't have a compiler doing this job anymore, you have to do it yourself... Somehow.
The only thing typed languages need is something like `dynamic` from C#, which automatically boilerplates untyped access with reflection, without cluttering your code. I.e. duck typing is one of the things some languages like Java need to get better at. But the situations in which I yearn for this are far and few between.
You don't think about types, unless you are new to typed languages... It's really that simple. I never have to think about types. Perhaps its subconcious, but its definitely not slowing me down, its making things faster through robust refactoring, auto-complete and welll doh: TYPE SAFETY!
dpc_pw|5 years ago
On top of it, with OOP languages it's very easy to box the code in deep layers of ridiculous inheritance taxonomies, making it pretty much impossible to refactor anything after business requirements changed. Barely any escape hatches and absolutely no flexibility.
And type-safety is kind of pointless when everything is of a given type "OR NULL".
I was always proponent of typing but after working with Java, I can totally see why so many people back in the day considered static typing as not worth it.
nicoburns|5 years ago
bigyikes|5 years ago
Some of my coworkers complain about being required to use TS instead of JS, and I just wonder why in the world you would want to use JS in a massive codebase.
lolinder|5 years ago
flohofwoe|5 years ago
jmfldn|5 years ago
Union types coming in Scala 3
valenterry|5 years ago
NOGDP|5 years ago
junon|5 years ago
Seems like you should play with C++ a bit more.
coldtea|5 years ago
You might not, but this was a common sentiment (not saying it is necessarily a valid one, mind you, but it was common). Were you programming 2 decades ago and/or paying attention to the average sentimeντ expressed in blogs/etc re types and dynamic languages (and the general tone up to around 2012 or so even in HN)?
Another common sentiment was that "who needs types when you have TDD".
taneq|5 years ago
mjcohen|5 years ago
randomdata|5 years ago
Is that sentiment based on modern languages, though?
While modern in its place in history, but adhering to older principles, I frequently hear exactly that from people evaluating Go. Languages with more complex type systems bring tools to help alleviate those concerns. Not all of those concepts were widely available looking back two decades ago. Java, for example, which was probably the most popular typed language of that time did not provide even generics until 2004. Being able to write a function once and use it for many (dynamic) types was no doubt seen as a big improvement for many use cases.
Type systems are back in fashion now largely because they are much more usable now, especially outside of the academic languages.
mdoms|5 years ago
This was OVERWHELMINGLY the sentiment on hacker news a decade ago. Strongly statically typed languages were NOT WELCOME on this website.
danenania|5 years ago
pjmlp|5 years ago
Tcl, Smalltalk, Lisp, Prolog, while great to program in the small, have taught me that I really want types when working in a team.
Python, Ruby and Perl, I really don't see the use beyond learning to program or grown up shell scripts, given their lack of attention to performance.
Daishiman|5 years ago
If you need to quickly perform some statistical analysis, you'd be hard pressed to be more productive in anything else over Python+NumPy or R.
kumarvvr|5 years ago
Because the framework is working on a level above the application, it can easily deal with objects without worrying about what is inside them.
However, people got caught up in this no-type nonsense and took it to all corners of every app development.
When you are creating, say web apps, you may not create types in dynamic languages like python, but you sure as hell will use known variables in those types.
There are a few edge cases, where dynamic types allow you to build logic on user-defined sets of data, but those cases are few and far between. Even those can be solved using generic data containers or custom data protocols such as XML.
valenterry|5 years ago
Even for that there is no need for dynamic typing anymore. This problem has been solves with type parameters (aka generics) and type-classes.
magicalhippo|5 years ago
Not only that, but they document the code.
When working with a new framework or library in Python or JavaScript I never know what I can do, I have to look at the documentation constantly.
Not seldom I'm still left scratching my head or doing stuff like "print(dir(result))" to figure out what I can do with whatever that function returned.
With a static typed language I can see what type the function expects and what it returns. If I don't know a type I can discover what it can do in a few clicks in my IDE.
mbesto|5 years ago
Uhh, someone please correct me if I'm wrong, but aren't statically typed languages about reliability (e.g. testing, mutability)?
EDIT: in addition to performance, not solely.
marta_morena_28|5 years ago
So while I would always use statically typed languages for anything that needs to be reliable, I do not see how this is in any way a necessity. You CAN write reliable programs without type safety, you just have to test things you normally wouldn't have to test (i.e. the lack of type safety introduces a whole bunch of null-pointer style scenarios where you get something your code totally didn't expect but has to deal with).
As for performance. Statically typed languages are usually faster, mostly because we do not have the technology yet to make dynamically typed ones as fast (in the general case). Not because there is something inherently different about them.
However, I imagine the technology to make them on par with statically typed languages will take another few decades. Mainly because untyped languages need sophisticated transformations to be fast. That is the job the human normally does for the compiler in typed languages. Things just fit together and play nicely. With dynamic languages, your get one big spaghetti soup with no structure and now the compiler has to figure out the "intended" types and compile for different estimated function signatures, etc. all while honoring the JIT-style performance considerations (fast startup, low overhead during runtime). This is a gargantuan task that probably will require advanced machine learning before it really takes off.
hedora|5 years ago
In C, i++ is one or two machine instuctions. In javascript, we don’t know if i is an int, or something that overrode ++ to download wikipedia. So, it ends up being a function call in naive JavaScript. Fast forward a decade, and dozens of PhD theses mean that ++ is usually a machine instruction in JavaScript, but it is not guaranteed.
zdragnar|5 years ago
d0mine|5 years ago
On type safety: Python is a strongly typed language unlike e.g. C:
vs:tomc1985|5 years ago
Also, is sprintf-style string formatting the best example here? I think that feature is type strict in a lot of languages, after all you are declaring the types you want in the formatting string. I imagine most implementations of % in dynamic languages pass to sprintf internally?
visarga|5 years ago
For example, this is ugly in Python:
def handler(on_error: Callable[[int, Exception], None]):
emptysea|5 years ago
valenterry|5 years ago
If anything, having type signatures like that are a good thing! If you think they are too complicated/ugly or driving you crazy, then you have an incentive to improve them. In many languages, callbacks are now considered bad style and that's good! Hiding the type signature does not make the problem go away, you just move it into the future where it will bite you even more.
Too|5 years ago
No type signature? Or documentation in another file somewhere else guaranteed to be out of sync, difficult to find and not enforced by the compiler? No thanks to either of them.
mixmastamyk|5 years ago
And therein lies the problem. It's a tradeoff: prototyping speed/readability vs longterm reliability. Modern languages have greatly improved the tradeoff, but it still exists, whether purists believe it or not.
I personally find the highest productivity in adding the majority of tests and typing later, after a design solidifies, not before.
unknown|5 years ago
[deleted]