
Show HN: Jtype – a rudimentary type system for JavaScript - dosy
https://github.com/crislin2046/jtype
======
smt88
From the FAQ about why you wouldn't just use TypeScript:

> _Why add transpilation and a tool chain, and change your code, and add a
> whole bunch of assumptions, when you can write a rudimentary type system in
> JS in a couple hundred lines._

1) Transpilation isn't a tool chain. It's just one link. It's not a big deal
and doesn't even require changing an existing project's structure.

2) TypeScript doesn't require changing your code at all. This library does.

3) TypeScript is zero extra lines of code in production.

~~~
dosy
I think one other main reason for myself is I feel happier being non
conformist, and sometimes writing my own from scratch code rather than using a
popular library.

When I do that I find I perform better, feel more confident, have more
creativity, and am more engaged in my work. Feeling unique and being authentic
in work is important to me.

Writing my own stuff like this is one things that feels non conformist to me.
It’s motivating.

~~~
smt88
Let me first say that I like the approach you took in this library, and it's
surprisingly clean in terms of syntax.

As for your personal preference to be unique and non-conformist, I can't argue
with that because it's a personal preference.

I will, however, push back a little bit on the idea that reinventing a wheel
and being non-conformist results in good code. If you're fixing legitimate
deficiencies in existing solutions, great! Otherwise you're just writing code
that's harder to understand, harder to maintain, and likely buggier. And
that's the best-case scenario.

In some cases, you'll be reinventing a wheel, but you'll be doing it worse
because you're missing the cumulative hundreds of years of programming
experience that go into a great FOSS alternative.

So for code that'll never be touched by another person and can tolerate bugs,
great! Don't conform. But that's a very, very narrow category of code.

~~~
dosy
Intriguing theory. It's unrelated to how I think about it. Interesting to know
you think that way, tho.

------
acemarke
How does this differ from something like
[https://github.com/gcanti/tcomb](https://github.com/gcanti/tcomb) ?

~~~
dosy
Hard to say after a quick look at an early stage, but I think `tcomb` is
comprehensive (it even has a typed JSON format, I think), and focuses on
letting you define models, with getters / setters that are type checked.

My one abstracts all type related code into some functions so you can apply it
when you want, rather than it happening automatically. I think I like this
better because it's more clear when type will be applied. Also I prefer my
syntax, but 'tcomb' syntax is an achievement and also concise.

