jsigbiz / spec

JavaScript signature notation
131 stars 6 forks source link

comparison to typescript and flow? #53

Open dominictarr opened 8 years ago

dominictarr commented 8 years ago

it would be interesting to see a comparison to other js type systems (i am currently aware of typescript, and facebooks "flow")

The one time I used typescript I wasn't able to actually express the type I needed, but I think you have hit it with the | and & and \ operators. However, It would be very interesting to see this compared side by side with other type systems.

junosuarez commented 8 years ago

this comparison would be interesting, and I still think the enterprise of trying to describe structural types in javascript programs is useful, both at the cognitive level for programmers to reason and communicate about their code, and for tooling.

historically, jsig came about as an evolution from javadoc, primarily as a documentation concern.

later, typescript was released with its HM-based type inference and other language-class tooling (compiler, ide services, etc). the type description was primarily based on C# - although early versions of typescript did not support generics and it still (to my knowledge) does not support type constraints

jsig was an attempt to rationalize structural types onto existing javascript programs without modifying the expressiveness or semantics of javascripts other features. since it was originally concerned with describing hidden assumptions about types to humans (ie, documentation concern), the features grew from the sorts of things that you might do in a function, such as checking if a string is defined or if an object has a certain set of properties defined. it is not at all concerned with classical inheritance hierarchy, but rather the effective structure of an object at runtime (duck typing).

about a year after that, facebook made their work on flow public. I haven't followed flow as closely as it might deserve, but I understand it has many of the structural typing features of jsig, and the set theory-derived operators (although maybe not \ complement?). I've seen facebook trying to do other advanced things that make sense in their ecosystem, such as integrating it with jsx.

at this point, both typescript and flow have broader user bases than jsig and richer tooling ecosystems. they also have broader charters than jsig (especially so for typescript since it's a full language extension, although it has a broad audience merely as an interface description language, e.g. in the definitelytyped community).

jsig is reasonably complete for es5. due to the timing of most of the development of jsig, it hasn't been updated for es6 features like modules and some other things (there is not a full inventory of missing es6 features, although that would make a good gh issue)

Raynos commented 8 years ago

I briefly evaluated flow for a few days and decided on writing my own type checker for jsig.

If the type checker is ever v0.1 it would be interesting to compare features.