No, I'm not.
I'm simply pointing out that most statically typed languages, the most used ones especially, don't particularly benefit from static typing.
> Static typing with functional programming languages works really well because
IMO it is because they are mostly used by more experienced programmers, that can already layout the types in their head.
Try to teach the average Java programmer (I'm not saying I'm a better programmer, Iḿ just intending it as "they are trying to get through the day with the tool they already know") how to effectively use types "like in Haskell" and they will be confused at best.
> OCaml, or Haskell, or F#
I do look at them but together they make probably less than 5% of Java programmers, even less if we measure lines of code
EDIT:
My position is based on the time spent reading studies about the subject.
Let's not be emotional and downvote what we don't like to hear and be more rational and look at the facts.
If you like statically typed language because they make you feel safer, use them.
Is it an universal property of statically typed languages? Id it a measurable phenomenon?
Are statically typed languages inherently safer for everybody?
The problem, at the time of writing, is undecidable.
here's a review on the literature on the matter
https://danluu.com/empirical-pl/
> Other than cherry picking studies to confirm a long-held position, the most common response I've heard to these sorts of studies is that the effect isn't quantifiable by a controlled experiment
That's an opinion presented as fact. You are outright discounting the opposing view. That's why you're being downvoted, not because anyone is being emotional.
Some benefits:
- performance. compiler can make huge optimizations if it knows the types.
- refactoring. changing functions might change data expected in another function. you could remedy this with unit tests, or just use static typing.
- onboarding. new developers on a project, regardless of experience, don't "layout the types in their head", static typing helps.
do you think I haven't used dynamic languages? I started using elixir in 2016. I started my career in Ruby, JS, and PHP.
Just because you can conceptualize the entire codebase's type system in your big brain, doesn't mean other don't have a rational reason for preferring static typing.
> Did you have this problem recently?
Every time I refactor, my dude.
Bitstring in OCaml: https://bitstring.software/
Just as simple as in Erlang.
> I know for a fact that static typed languages don't help that much.
How do you know this?
> We all know that static typed languages are harder to learn and master
Again–how do you know this?
> Erlang has int (arbitrary length, like in real life) and floats. It is definitely easier.
OCaml has int and float, simple.
> We've all seen companies like Github, Twitter, Airbnb, born because Ruby on Rails exists.
These companies are now using Haskell, Scala, TypeScript.
> Facebook was written in PHP.
Fb created Hack, a statically-typed language that compiles to PHP. It has at least two other static-typing language compilers.
> Rust creates incredibly fast code, it has an incredibly slow compiler.
Is this proving something?
> Did you have this problem recently?
Yes–I and many others have this problem constantly, because we are mostly paid to work on existing codebases, not throwaway scripts.
> Of course the answer is "this is the programmers fault", but if it's wrong, why is it allowed?
Why is it allowed in dynamically-typed languages? Because it's useful. Same reason.
> Types are harder to understand and to correctly plan ahead for.
Types are not unchangeable; the whole point is that you can safely change code that has a typing discipline.
> it takes a great programmer to use types correctly in a way that others will comprehend without prior knowledge of the domain.
Then it must take an incredible programmer to maintain a dynamically-typed codebase.
> Try to teach the average Java programmer (I'm not saying I'm a better programmer, Iḿ just intending it as "they are trying to get through the day with the tool they already know") how to effectively use types "like in Haskell" and they will be confused at best.
Counterpoint: I don't use any ML/Haskell languages regularly, but I do use a couple of projects written in them[1]; my preferred language is Common Lisp, the It dynamic language. When I needed a feature, it was dead simple to do so.
1: matterhorn, the Mattetmost client and bower, the E-mail client, which are written respectively in Haskell and Mercury.
I'm faster at finding and solving the issues with languages I know best (not surprisingly) regardless of their static or dynamic nature.
Experience, in my case, is knowing where to look, being able to quickly parse an error message, from the compiler, the linter or the runtime, but most of all knowing the code base at heart.
When I confront a code base that is new for me, I feel lost, whatever paradigm has been used.
I simply don't know where to put my hands before I spent time reading and analyzing it.
The time required to understand it depends exclusively on the complexity of the project.
There hasn't been a single time where types have helped me (more than being able to grep the function signature) or their absence slowed me down.
And as someone who has written JS for over a decade, TS is hands down better, it’s not been close how much nicer it is to work in the latter. The bigger the project is the more it helps.
Don't want to sound harsh, but it doesn't take much to be better than JS
I have had the opportunity to teach java programmers the basics of Haskell, and indeed, it was not great. Trying to tell java programmers to write haskell-flavored java is not a great idea.
On the other hand, I have also had the opportunity to work with C#, JS, C programmers that were taught to work in a haskell codebase, and the result was much better.
I guess using a language explicitly made for this helps a lot.
Not because of their Java background, but because the complexity of developing in Java is hidden behind tooling not available in other languages, that make it manageable
It is almost unimaginable for Java programmers to use vim or a non Windows setup (thanks to Java IDE like Eclipse, Nerbeans or Intellij that's less of a problem nowadays)
Static typing with functional programming languages works really well because the types are so simple. If you look at OCaml, or Haskell, or F# you simple types, but with a lot of benefit of type checking.