News for hackers. Stuff that matters.
Re:Why We Chose Typescript by tqkxzugoaupvwqr on Friday June 30, 2017 @07:28PM (#14674208)
They all started with dynamically typed languages because that was what the founders knew best when they started working on their project. Yes, you can build successful projects with dynamically typed languages but it is a pain to refactor when you grow. You even introduce a class of bugs doesn’t exist for statically typed languages. You don’t see them redo everything only because the cost would be to big. Some developed their custom tooling to handle the language they are stuck with, see Facebook.
Re:Why We Chose Typescript by gnaritas on Friday June 30, 2017 @09:05PM (#14674655)
> You even introduce a class of bugs doesn’t exist for statically typed languages.

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.

Re:Why We Chose Typescript by tome on Saturday July 01, 2017 @04:47AM (#14676120)
I've had professional jobs writing both Python and Haskell. My Python code has to be far more verbose and complex than my Haskell, and the Python's harder to maintain too!

> Type bugs just aren't that painful.

You haven't learned the true power of a decent type system then.

Re:Why We Chose Typescript by bayesian_horse on Saturday July 01, 2017 @05:16AM (#14676212)
Few seem to have learned the "true" power of a "decent type system". Which seems to be only Haskell...

And yes, Haskell is terse. Other popular statically typed languages (Go, Kotlin, TypeScript, Dart) are not.

Re:Why We Chose Typescript by dllthomas on Saturday July 01, 2017 @10:55PM (#14680605)
While certainly Haskell lets you do more, you can get some interesting help from even the C type system. For instance, I was able to enforce "this can only be called from the main thread" with no runtime overhead.
Re:Why We Chose Typescript by tome on Sunday July 02, 2017 @12:22PM (#14683136)
You explained this once to me before and it was very cool. Did you ever write a blog post about it? I think it would be neat to link to in the future when these sort of discussions come up.
Re:Why We Chose Typescript by dllthomas on Sunday July 02, 2017 @03:18PM (#14683905)
No, I need to do that.
Re:Why We Chose Typescript by tome on Saturday July 01, 2017 @07:58PM (#14679838)
> "decent type system". Which seems to be only Haskell...

Haskell, OCaml, Elm, Purescript, arguably Scala although I don't like it personalyl.

Re:Why We Chose Typescript by gnaritas on Saturday July 01, 2017 @04:58PM (#14678996)
> You haven't learned the true power of a decent type system then.

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.

Re:Why We Chose Typescript by tome on Saturday July 01, 2017 @07:59PM (#14679841)
And what exactly do static types forbid you from doing? (For the sake of argument let's consider state of the art static type systems such as those found in Haskell, OCaml, Elm and Purescript)
Re:Why We Chose Typescript by gnaritas on Sunday July 02, 2017 @01:35AM (#14681076)
State of the art is hardly relevant, what's relevant are languages in demand by employees that dynamic language are actually in competition with so no I don't accept that restriction for the sake of the argument as it's moving the goalpost. However plenty of meta-programming techniques including the use of dynamically interpreting message sends to methods that don't exist in the context of the receiver, i.e. Smalltalk's doesNotUnderstand or Ruby's method missing are but one example.

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.

Re:Why We Chose Typescript by tome on Sunday July 02, 2017 @12:22PM (#14683135)
I think you're responding to an argument I didn't make.

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!

Re:Why We Chose Typescript by dllthomas on Monday July 03, 2017 @11:42AM (#14689054)
"All sorts" in a colloquial sense of "very many". Not literally all sorts.
Re:Why We Chose Typescript by tome on Tuesday July 04, 2017 @02:24PM (#14697439)
Yeah, good clarification, thanks!
Re:Why We Chose Typescript by gnaritas on Monday July 03, 2017 @01:30PM (#14689966)
Using Haskell is more painful than any type bugs it might help fix, no thanks. One can write correct code without a type system to guarantee it for them, we're fine doing this rather than dealing with said pain in the ass type system. Haskell is not my idea of a good programming language, it's not what I want from a programming language, it's not conducive to how I want to program. It's an esoteric language for a reason, few people like it and it'll likely remain that way.
Re:Why We Chose Typescript by tome on Tuesday July 04, 2017 @02:25PM (#14697443)
OK, if that's your opinion then fine. I just wanted to challenge your claim "type bugs just aren't that painful". On the contrary, they can be and should be!
Re:Why We Chose Typescript by gnaritas on Thursday July 06, 2017 @05:03PM (#14713942)
You can't challenge a claim about how I feel about something, if I say something doesn't hurt, nothing you can say will convince me it does. Pain is subjective, keep that in mind when trying to tell others how they feel about something.
Re:Why We Chose Typescript by sjwright on Friday June 30, 2017 @09:43PM (#14674826)
> you're also able to write equivalent functionality with less code

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).

Re:Why We Chose Typescript by gnaritas on Saturday July 01, 2017 @04:57PM (#14678989)
That's not what I mean by more code, by taking advantage of dynamic typing you can write more generic code than is even possible with generics in a statically typed language; code that works for any type, whereas a static language either forbids you or forces you to write multiple versions of the function. You can't write a single Max function in C# that works for any type supporting >=, it simply can't be done. This is typical of static languages, they forbid perfectly good code because it "might" be used inappropriately or because the type system can't guarantee it won't.
Re:Why We Chose Typescript by dragonwriter on Monday July 03, 2017 @01:43PM (#14690061)
> by taking advantage of dynamic typing you can write more generic code than is even possible with generics in a statically typed language; code that works for any type, whereas a static language either forbids you or forces you to write multiple versions of the function.

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.

Re:Why We Chose Typescript by gnaritas on Monday July 03, 2017 @03:12PM (#14690643)
> that could be specified in a sufficiently-expressive static type system

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.

Re:Why We Chose Typescript by sjwright on Sunday July 02, 2017 @08:39PM (#14685118)
Nothing is stopping languages from allowing both. For example, it could have some form of compound type declaration.

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.

Re:Why We Chose Typescript by gnaritas on Monday July 03, 2017 @01:33PM (#14689996)
> Nothing is stopping languages from allowing both

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.

Re:Why We Chose Typescript by sjwright on Monday July 03, 2017 @07:21PM (#14692192)
Congratulations, you have worked out that there are no perfect languages. I don't understand what point you're trying to make, other than you prefer one set of trade-offs to another.
Re:Why We Chose Typescript by gnaritas on Thursday July 06, 2017 @05:04PM (#14713954)
> other than you prefer one set of trade-offs to another. reply

So you can understand the point being made, congratulations, it's what engineering is all about.

Re:Why We Chose Typescript by cutler on Friday June 30, 2017 @10:05PM (#14674913)
The biggest advantage of dynamically typed languages is the ease of using deeply nested data structures with mixed data types. This is just a pain in languages like Java and Scala where the Any type is often reverted to.
Re:Why We Chose Typescript by andreasgonewild on Saturday July 01, 2017 @05:36AM (#14676269)
As long as the number of mixed types is finite, unions/variants give you the same ease of use with static guarantees.
Re:Why We Chose Typescript by joshuamorton on Friday June 30, 2017 @07:43PM (#14674293)
A rudimentary end2end test should catch most type related bugs. A type system aids in refactoring, not so much actually catching bugs.
Re:Why We Chose Typescript by dom0 on Friday June 30, 2017 @08:07PM (#14674392)
Type systems can enforce so much more, depending on the language. They make reasoning about the code far easier for both human and machine. They enable efficient optimization. They allow far superior static analysis. They allow superior IDE assistance. They improve code navigability (ag/grep). There are countless advantages to static typing, and most of the disadvantages simply don't exist in modern languages any more. Meanwhile, dynamic languages haven't evolved significantly, except to add type annotations, which are like types, just almost always less powerful and not enforced by default.

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.

Re:Why We Chose Typescript by rocky1138 on Friday June 30, 2017 @08:13PM (#14674425)
Since most of the stuff I work on are prototypes that might never see the light of day, I love dynamic languages like JS. I always find it confusing why more implicit casts aren't allowed when I have to use things like Python or C#.

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.

Re:Why We Chose Typescript by dom0 on Friday June 30, 2017 @08:18PM (#14674446)
> Any idea as to why implicit casts aren't more supported in strictly typed languages?

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.

Re:Why We Chose Typescript by bayesian_horse on Saturday July 01, 2017 @05:18AM (#14676218)
And still there is no proof, that ease of deployment and maintainability is enhanced through static typing.
Re:Why We Chose Typescript by raquo on Friday June 30, 2017 @08:02PM (#14674378)
Static types are better and cheaper at catching type related bugs than a myriad of end-to-end tests that check dynamic types.
Re:Why We Chose Typescript by dragonwriter on Friday June 30, 2017 @07:35PM (#14674254)
> You even introduce a class of bugs doesn’t exist for statically typed languages.

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.