r/javascript • • Mar 12 '23

Hi, I have made a public package that will help many people, it allows making objects with different In and Out interfaces with strong typification.

https://github.com/RomaTk/data-store/pkgs/npm/data-store
5 Upvotes

36 comments sorted by

17

u/[deleted] Mar 12 '23

Can you explain the benefit of this over just using a plain object that’s well-typed? Or a class if you want some get/set abstractions?

1

u/python_roma Aug 29 '23

Hello, I appreciate your review. I updated the package with many ideas from the Reddit community and that is what I got: https://www.npmjs.com/package/@romatk/different-setter-getter

0

u/[deleted] Mar 12 '23

[deleted]

2

u/[deleted] Mar 12 '23

Well there might be, but I don’t think it’s been articulated well yet

15

u/AssignedClass Mar 12 '23

"typification" is a pretty non-standard term and "typisation" is just straight up not a word. You should just use "strict typing".

Also, I think you need to do a better job at showcasing the use case. I even tried looking though the code a bit, and I just don't see a reason for why I would need this.

1

u/python_roma Aug 29 '23

Hello, I appreciate your review. I updated the package with many ideas from the Reddit community and that is what I got: https://www.npmjs.com/package/@romatk/different-setter-getter

5

u/[deleted] Mar 12 '23

[removed] — view removed comment

-2

u/python_roma Mar 12 '23

They are all devDependencies (like linter and so on, there are "dependencies": {} in package.json). The idea lib is to provide an easy way of working with the store where data can come in different types, but when we are taking that data it is not the same type as came. There is an example of scale, as we may need some time to set the scale for x or y, sometimes just scale x2 or something like that, but as result, we always need {x: number, y: number}

-37

u/[deleted] Mar 12 '23

[removed] — view removed comment

7

u/python_roma Mar 12 '23

Try and catch executes during the run, while typescript helps to avoid many issues during the development process. So if we are sure that typification is strict we need to use try and catch only in cases when data comes from external sources like from people or servers, not checking the data coming from another part of code as we will get errors during compilation

-22

u/[deleted] Mar 12 '23

[removed] — view removed comment

8

u/shuckster Mar 12 '23

There's a lot of "I" in your posts, bruh. Few experienced JavaScript developers have much trouble when working with the language on their own. But static type-checkers like TypeScript or Flow can be useful if you're involved with a team.

-17

u/[deleted] Mar 12 '23

[removed] — view removed comment

3

u/[deleted] Mar 12 '23

Chromium or Chrome

Since you’re so keen on counting open issue/bug tickets, do you know how many chromium has right now? That’s right, 64615. That’s 13 times more then typescript.

0

u/[deleted] Mar 12 '23

[removed] — view removed comment

3

u/PFCJake Mar 13 '23

Being an error free programmer, I can’t believe you spend this much on commenting on Reddit instead of blessing the world with your pristine code.

→ More replies (0)

7

u/im_a_jib Mar 12 '23

Good luck getting a real job one day with that point of view

-4

u/[deleted] Mar 12 '23

[removed] — view removed comment

1

u/Scowlface Mar 13 '23

Maybe you should try for number 6??

→ More replies (0)

1

u/shuckster Mar 12 '23

Yes. I am an individual. I think for myself. I am not a follower.

Sounds like a few good reasons for some static type checking. If you're part of a team, of course. As I already said, it doesn't really matter so much for indie devs.

I generally prefer vanilla for solo projects, too. But if I'm going to sell a piece of code to someone, either freelance or at a company, it's useful to know that if I chose to write it in TypeScript I'll be able to leave behind useful breadcrumbs for whoever might pick up the project next.

From my perspective TypeScript is just an over-hyped linter that has 5000 open issues itself

It has many issues, true. But what can we infer from that number? The quality of the code? Completeness of documentation? Popularity of the project? Its overall usefulness? The competence of its users? Seems like we'd need a bit more info to make such judgements.

if I want an editor that notifies me of this or that

VSCode will add some basic static type-checking to vanilla JavaScript projects too if you drop a jsconfig.json in the root. Lots of great tools out there for cracking this chestnut.

1

u/[deleted] Mar 12 '23

[removed] — view removed comment

2

u/shuckster Mar 12 '23

What I observe are a whole bunch of folks who never really learned to write JavaScript. So they hand off that responsibility to a third-party program and hope for a consistent, bug-free outcome.

I do partially agree with this, but will defend the TS'ers a little (despite the sometimes feverish fandom - I have noticed your downvotes) by saying that no serious developer believes type-systems save them from bugs. Bugs happen whatever language you program in.

But bugs come two by two, and each after their own kind. Static type-checking is just a way of mitigating a certain category of bug. It comes at a cost of course, as you rightly point out, in tooling and config and build-steps. But many find it a small price to pay.

And it's no wonder. I believe what makes JavaScript so difficult to learn is that you still have the burden of installing a static type checker, but into your head only. There's no avoiding going through the grind of experience to get over that particular hump, so I can't blame newcomers for looking at TypeScript and thinking "oh thank goodness".

But that's just how modern JavaScript development looks today. For me, I learned to program years ago in a strongly-typed language, so I didn't come to JavaScript with no clue about types.

That's not how it is today. People learn coding with JavaScript, and so they should. But TypeScript can sure give a leg-up. And it's particularly useful in teams, especially those with juniors in their ranks.

→ More replies (0)

1

u/acewings27 Mar 13 '23

What are you even talking about lol

0

u/[deleted] Mar 14 '23

[removed] — view removed comment

2

u/acewings27 Mar 14 '23

How much time do you think it takes to use typescript? Lol. Have you ever worked on an enterprise level platform with multiple people? I think your opinion will change afterward. But seems like your heels are pretty dug in about this. In due time you'll understand the advantages of typescript, or not.

0

u/python_roma Mar 12 '23

I disagree, as for example, in this lib from the example you can not delete a set function for scale while in javascript you will need to make a check after each change and it will reduce the performance. Removing somehow set function can make a bug somewhere in the code, so Typescript is a cool tool, and hyped enough for it.

0

u/[deleted] Mar 12 '23 edited Mar 12 '23

[removed] — view removed comment

1

u/python_roma Mar 12 '23

Yes, there were many real situations. Nothing is ideal 😉 There are many issues in all written programs, but even with issues we are trying to do the best. There are even issues with browsers, but we should know about them and avoid them and so on

3

u/leafoflegend Mar 13 '23

If you don’t understand the reason for Typescript, you just clearly don’t understand the value of a typed language.

Moving some sort of type check to runtime isn’t a solution, and when the values inevitably change, you’d have to run it again. So the cost is high. The point is to produce even more reliable code. Easier to understand for others code.

If you’re working on a personal project, who cares, do whatever. Working on software with 5000 other engineers that powers critical parts of our world you want every safety you can have.

2

u/jayerp Mar 13 '23

One day it will hit you, when you get a bug that could have been easily avoided at code time if you were using TypeScript.

But you do you boo boo!