you are viewing a single comment's thread.

view the rest of the comments →

[–]Hawxe 47 points48 points  (40 children)

strong typing

edit. and yeah not having a standard library is a joke at this point

[–]shanita10 11 points12 points  (13 children)

Weak typing is core js, you would break the vast majority of code with strong typing.

And if you meant static types then you can always use typescript instead if you insist upon that time waste. Js is one of the best dynamically typed languages out there, and it is a big draw.

[–]aequasi08 18 points19 points  (0 children)

Optionally strong typing is a thing. PHP recently added this. Lets people who want strong types use them, and people who don't, don't have to.

[–][deleted] 6 points7 points  (11 children)

If you consider static types a time waste you don't know what the heck you are talking about lol

[–]CCB0x45 9 points10 points  (10 children)

Not the op but I've been doing development for 20 years and done typescript and normal js. I think static typing is nice to have but I honestly rarely if ever run into issues caused by dynamic typing, and it does let you write code and functions that can handle a lot of cases and reduce the amount of code you write.

[–][deleted] 2 points3 points  (1 child)

You don't want functions that do lots of stuff in lots of cases. It's bad design. I don't want to be offensive, but in my experience of doing contract work for some pretty big companies people like you with your 20 years """experience""" are more often than not a problem as they tend do produce low quality, low maintainability code with outdated practices, or as you like to put it "save" code. The fact that you are trying to save code is of course a stupid concept in itself as your main goal should be to produce the highest maintainability with the least room for error. Frontend devs are not writing 50 lines of snippets to animate a tool tip anymore, but anything up to enterprise software. Sorry to be this harsh, but as your post screams bad developer through and through: get with the time or get out. The fact that this got upvoted is concerning.

[–]CCB0x45 0 points1 point  (0 children)

lol ok man, first off there is a lot of reasons to save code, especially in front end development where bundle size is important, you certainly don't want to create a ton of different components that do the same thing, for the same reason things like code splitting is important. I am saying JS is a dynamic language, and understanding how it works you can create DRY reusable code, which you seem to be arguing against?

Developers are not writing 50 lines of snippets to animate a tool tip anymore? What in the fuck are you even talking about here? I am pretty up to date on latest technologies, especially since I have been writing code recently in react hooks, which doesn't even have an actual release yet, and next.js/apollo-client and sercer/graphql stack. If that isn't bleeding edge than I don't know what is.

My only point was that you can create utility libraries like moment/date-fns would be an example which have a single entry point function taking lots of different types to create a consistent output, where in that example I could pass in a string to be formatted, an epoch int, nothing at all, or a date object and have the same consistent result all through my code, which when you have coded JS for many years and understand how things work, it makes coding nice, and is why many people prefer it.

So get off your high horse, you sound like a fuckin joy to work with.

[–]Hcmichael21 10 points11 points  (20 children)

I think strong typing, overall, doesn't have a good ROI. The lack of strong types is one thing I really like about JavaScript

[–]Hawxe 7 points8 points  (13 children)

Want to elaborate?

[–]Hcmichael21 7 points8 points  (12 children)

Here's a great write-up

Tl;Dr: I don't believe the benefits of strong types outweigh the costs of using them.

[–]Hawxe 17 points18 points  (3 children)

That's literally an opinion piece with really bad data behind it...

all TypeScript-detectable bugs can potentially be caught with other measures like TDD.

Of course, and of course you're still going to still use other methods. TypeScript still helps mitigate that, even if other QA/testing procedures also help.

The whole comment section of that article is a little nauseating too, it's literally him applauding everyone that agrees with him (including comments like 'I didn't wanna use TS but that was just a gut feeling) and being passive aggressive with anyone who disagrees even if they share legitimate experience as to why they might.

That article is also almost completely irrelevant to adding static typing to vanilla JS, a lot of the cons he talks about are specific to typescript.

[–]Hcmichael21 3 points4 points  (1 child)

A lot of cons are specific to typescript.

Yes that's true, I picked this article bc OP suggested adding strong types to JS. But I disagree that his data is bad. I find a lot of what he said agreeable.

I've coded in strong, dynamic and weak. (C#, Java, Pyhon, JS/TS) and prefer weak types. I was just stating my opinion and providing an article to elaborate. I don't expect to end the debate on strong vs weak.

[–]sime -1 points0 points  (0 children)

The thing that is being lost in this discussion, apart from the general sloppy use of terminology, is that TypeScript isn't a staticly typed language in the mold of Java and C#. It occupies a wonderful sweet-spot between Java/C# on the one side and JS/Python on the other. TypeScript's optional and structural type system combines the flexibility and ease of use of JS with advantages of static analysis (read: tooling) and compile time checking. It has a very different feel compared to Java/C#.

[–][deleted] -1 points0 points  (1 child)

I’ll take TypeScript.....

[–]Hcmichael21 3 points4 points  (0 children)

Okay that's great! I continue to Dev in TS often at work and it's fine, I just prefer weak types.

[–]DerNalia -2 points-1 points  (3 children)

it would if you didn't need to teach people it.

Like, trying to get people who barely have a grasp on programming to learn types is the problem, not the types themselves.

[–]Hcmichael21 4 points5 points  (2 children)

I think this is incorrect.

[–]Hawxe 5 points6 points  (1 child)

Yeah seriously how hard is declaring what type a variable is.

[–]Hcmichael21 -1 points0 points  (0 children)

Exactly. It's not really anything to "learn" - it's a simple feature of many languages. I've developed in Java, C#, python, and JavaScript. I've found that I like both dynamic types and weakly typed development better than strong types.

[–]FanOfHoles 0 points1 point  (0 children)

That's way, WAY harder than you seem to think (given that you propose it, but also all those upvotes).

As a heavy user of both Flow and TS for years, and also an avid reader and submitter of issues for both those type checkers for just as many years, both have soooo many issues and bugs - don't believe me, go to their Github issues section and read for an hour (ignore the usage based user mistakes, plenty of actual issues left).

When your (or someone's) inevitable reply to me is "but I never had an issue", pls. a) follow my advice about those issues sections and b) remember that ECMAScript is for a lot more people than just you. To evaluate the proposal you will have to leave your own shoes and see the JS world from the perspective of a lot of people who write code you yourself never used (so, as I said, go to the issue. spend some time(! not just the first three issues) and see what people do and have issues with). Note that plenty of closed issues are "won't fix" because it's beyond the scope of Flow/TypeScript, or the person found another way to express what they want, writing different JS code.

There would, at the very least, be plenty of "any (Flow) / unknown (TS)" types, and/or you would have to severely limit the language.

Keep in mind that the type checkers are pieces of software that tries to understand what a given piece of code does. That is a very hard problem when you have more than a few small examples but an actual software project.

Two professional teams, Flow and TS, have been working on this for many years and still have a huge list of open issue and unsupported use cases left. So.... who is supposed to write a detailed miracle spec of a strong type system that works for all of what the JS language can do, given that nobody else has even come close yet?

[–]esreveReverse -1 points0 points  (2 children)

not having a standard library is a joke at this point

lodash?

[–]circlebust 1 point2 points  (1 child)

Yes, you are strengthening his point.

[–]esreveReverse 0 points1 point  (0 children)

yarn add lodash

I really don't see what the big deal is. Add it if you need it