Dynamically typed languages for
large code bases are terrible
The success of Wikipedia, Wordpress, Facebook, Youtube, GitHub etc etc etc and last but not least Reddit seem to prove otherwise. Dynamically typed languages for
large code bases are terrible
The success of Wikipedia, Wordpress, Facebook, Youtube, GitHub etc etc etc and last but not least Reddit seem to prove otherwise.Prove how? They could have succeeded in spite of dynamic typing, not because of it. Facebook defined a new programming language to add static typing to HHVM. The process of plugging into WordPress is infamous in its disorganization.
There’s a lack of good statically-typed languages, so it’s natural for many popular things to be built in dynamically-typed ones, but that doesn’t make the dynamic typing approach better.
Prove how?
By means of natural selection. They could have succeeded in spite of
dynamic typing, not because of it.
You think the otherwise smart and successfull founders of these projects all made the wrong choice when it came to selecting the right tool for the job? Facebook defined a new programming language
No, they wrote a faster runtime. to add static typing to HHVM
No, they added type annotations. There’s a lack of good statically-typed languages
No, in the past statically typed languages were the norm. C, C++, Java...It's just that dynamic languages outcompeted them.
Not at all! I think dynamic typing hurts code, but there are:
- not always alternatives
- many other slightly suboptimal choices that it’s quite possible to succeed in spite of
> No, they wrote a faster runtime.
I’m referring to Hack, which is in fact another language with static typing. (Type annotations are static typing with compromises, and you can see what’s being gone for.)
> No, in the past statically typed languages were the norm. C, C++, Java...
Those are not remotely good. Some examples closer to being good are Rust, a step in the right direction that’s still unfolding, and Haskell, a wonderful language hampered by a slow compiler and a lack of decent packages. (And probably several less popular languages, but popularity is an important factor…)
Wait: so you are arguing that startups should use languages that are either incomplete (Rust) or that have slow compilers and poor library support (Haskell), or possibly some other "good" language that doesn't actually even exist?
Probably should have clarified that earlier since it looks like I agree with the statement that choosing Python was “a mistake”; sorry. I don’t. Vehemently.
All "trending" languages are statically typed (Rust, Go, Swift, Kotlin, ...) and all the popular JavaScrip-improved-languages are statically typed as well. Even further, many dynamically typed languages have pushed in recent years to add type annotations or even static typing (e.g. mypy).
Dynamic typing is the brainchild of the 90s for rapid initial development. Sustainability has been a big issue from the outset.
Of course, like dynamic typing and Lisp, visual environments also had Smalltalk from way back, but they were before big business became infatuated with the ideas.
You can see errors at run-time from mismatches between the code-behind and the forms, but this has nothing to do with the language. It's just the way that certain products like Delphi decided to handle such mismatches. You'll see these types of issues with any code that performs run-time serialization/deserialization of class instances. Our product, Elevate Web Builder, uses a similar architecture with its WYSIWYG form designer/forms (they use JSON instead of a custom key-value format), but it simply ignores properties in forms that don't exist in the actual code.
That said, I do agree that static typing is in vogue.
Highly dynamic languages like Python or PHP or Perl are easy to start with, so they're great for prototypes. Then either a serious rewrite follows, using a statically checked language, or scaffolding is erected to continue to make do with the dynamic code. Microservices help!
Nobody is perfect. Mark Zuckerberg has had his fair share of controversies for example.
>No, in the past statically typed languages were the norm. C, C++, Java...
Not good examples for your argument. These are largely considered poorly statically typed. Compare to ML, Haskell, Ada, Rust, Swift for reference.
Which includes a statically-typed version of PHP, namely Hack, that they use for their code.
> No, they added type annotations.
Hack's type checking is much more sophisticated than mere “annotations”. That label might be better suited to PHP's type system.
Yes, they could have. Evidence for your hypothesis would be the existence of similarly successful companies that used compiled statically-typed languages from the beginning.
Are there any recent ones?
I asked for examples. Can you provide one?
But you're right. Moreover I noticed obsession with a particular language is often a hallmark of a junior engineer or a recent grad. This this idea of "If you don't use Go/Node.js/etc you'll totally fail".
was the original argument. Success/failure of entire companies has somehow been brought into it.
Then maybe the burden of proof is on you?
If you started your career recently, it's easy to be caught up into this "static typing" as some kind of the only way.
I’m saying that the parent doesn’t prove its point, and I’m not attempting to prove its parent’s point.
> If you started your career recently, it's easy to be caught up into this "static typing" as some kind of the only way.
I didn’t, and the bulk of what I’ve built has been in languages with dynamic typing. See https://news.ycombinator.com/item?id=14675577. Dismissing stuff as “recent starts” is pretty cheap, anyway.
Also, all of the examples you cite a rather the "in spite of" kind. Wikipedia? Struggles to maintain the code base, lest to speak of significant new development. Wordpress? Afterwit of web security. Facebook? Facebook literally developed a new PHP implementation (edit: actually, two) and then turned that into a separate language (which is statically typed) because that's easier than to clean up their PHP code base. YouTube? Maybe some help pages are still on Python. The application most likely isn't at all. GitHub? Goes down every few days with 500s after buggy code was deployed.
As type systems vary, almost every statically-typed language allows some errors of the class statically-typed languages, in general, can prevent, so this is not really true.
What is true is that on the continuum from no static validation to something like Idris or Agda, you accept more statically-avoidable type errors the closer you are to the former rather than the latter.
Dynamic languages excel at fast initial development and "gimmicky" code (wildfire monkey patching, introspection, dynamic code generation etc.), and to get there you pay dearly. Practically all other properties suffer; stability, maintainability, performance, memory usage, ease of deployment, distribution and so on and so forth.
That doesn't mean that dynamic languages have no place, or applications developed using them are somehow generally inferior to those written in statically typed languages; choice of language is only one mosaic stone of many. But it is also a foundation stone, and dictates many constraints, both technical, and social.
If print() in Python includes a string and an int, I think the interpreter should be able to implicitly cast my int to string in order to make it all work. As it stands, I have to go back in and cast it myself, which kills productivity.
Any idea as to why implicit casts aren't more supported in strictly typed languages?
I'd prefer a warning on runtime than having to go back to the code.
That's the difference between weakly and strongly typed. If you take a strongly typed language, and add implicit casting, you get a weakly typed language.
How this is resolved (or if at all) depends a lot on the language. For example, in C++ it is straightforward to define implicit conversions (which can become confusing). In Python on the other hand, it is generally up to the receiver to call some kind of conversion function, like str(), which will use an object protocol (like __str__) on the instance. This is what print("foo", 1) does, or "foo %s" % 1.
Conversely, you're also able to write equivalent functionality with less code and with idioms you can't use in statically typed languages. It's an engineering trade off, the static typed handcuffs prevent you from making a certain kind of mistake but they also prevent you from writing certain kinds of code that are extremely powerful; many prefer the power over the handcuffs. Type bugs just aren't that painful.
The amount of code one writes says more about the language than whether or not it's statically typed.
To me, adding "bigint" or "bool" to the occasional variable and function declaration isn't "more code", it's an extremely terse way of avoiding different code (e.g. type assertions).
Meanwhile, how often is code made worse because you have to write multiple Max implementations? And I doubt that there's many instances where such repetition is necessary, or can't be mitigated with wrapper functions.
Nothing stops pigs from flying either... hypothetically, but they don't, and languages don't, so debating what they could do is rather pointless, they don't.
> how often is code made worse because you have to write multiple Max implementations
Similar situations occur quite often.
> I doubt that there's many instances where such repetition is necessary, or can't be mitigated with wrapper functions.
That they have to be mitigated is the point, I don't have to do stuff like this at all in a dynamic language, things just work.
So you can understand the point being made, congratulations, it's what engineering is all about.
If you can write code that works for some combination of types, it's because those types present a common interface that could be specified in a sufficiently-expressive static type system, either via something like OOP interfaces or something like Haskell typeclasses.
> You can't write a single Max function in C# that works for any type supporting >=, it simply can't be done.
You can, in fact, do so for any type supporting the IComparable<T> interface. That the operators are defined independently is a C# type-system quirk, not a fundamental limitation of static type systems.
Ah the mythical sufficiently-expressive static type system, I'm concerned with type systems that are in use in real jobs, not vaporware ones that could exist if only. Dynamic language support it now.
> You can, in fact, do so for any type supporting the IComparable<T> interface.
Which requires forethought on the designers of said library, I'd rather have duck typing which works without requiring correct future planning with interfaces.
> Type bugs just aren't that painful.
You haven't learned the true power of a decent type system then.
And yes, Haskell is terse. Other popular statically typed languages (Go, Kotlin, TypeScript, Dart) are not.
Haskell, OCaml, Elm, Purescript, arguably Scala although I don't like it personalyl.
Conversely you haven't learned the true power of dynamic types or like coding with handcuffs to keep you safe. What static types offer me is not as useful to me as what they forbid me from doing, so no it isn't an issue what what I don't know, but rather of what I do. And Haskell, no thanks, I'm not a masochist.
> and the Python's harder to maintain too!
That's an issue with Python, not with dynamic types. My Smalltalk code is a joy to maintain.
Look, I get it, you like static typing, how about accepting that we all don't; we value different things from a language, and extreme late binding in all things is something we value more than being protected from ourselves with a type system. Don't assert to others what they have or haven't learned just because their preferences differ from yours.
You claimed "Type bugs just aren't that painful". Haskell allows you to make all sorts of bugs into type bugs, from SQL well-formedness, through certain concurrency guarantees, to guarantees that your HTTP routing is correct. So yes, type bugs can be very painful, and that's a good thing!
The quality of your code base largely affects the ability to roll out new features with limited regressions.
Anyway, to each their own. I want "Unobtrusive Typing" to be a thing.
Look at the mess of wordpress code. It's an abomaly and security history proves how it was never a technical success.
- Wikipedia is mostly PHP https://github.com/wikimedia/mediawiki
- Wordpress is PHP https://github.com/WordPress/WordPress
- Facebook started in PHP https://www.quora.com/What-programming-languages-are-used-at...
- YouTube started in Python https://www.quora.com/Is-YouTube-still-written-in-Python
- GitHub is Ruby https://github.com/showcases/projects-that-power-github
- Reddit is mostly Python https://www.reddit.com/wiki/faq#wiki_what_is_reddit_written_...
It's not amazing as a language still but it's much much better and the ecosystem has really improved, modern PHP leveraging good composer components is pretty good.
Even some good static analysis tooling these days.
(https://github.com/python/mypy/commits/master because I know the pain of linkless comments)