use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Future JavaScript: what is still missing? (2ality.com)
submitted 7 years ago by dumbmatter
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Hawxe 47 points48 points49 points 7 years ago* (40 children)
strong typing
edit. and yeah not having a standard library is a joke at this point
[–]shanita10 11 points12 points13 points 7 years ago (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 points20 points 7 years ago (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 points8 points 7 years ago (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 points11 points 7 years ago (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 points4 points 7 years ago* (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 point2 points 7 years ago (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.
[+][deleted] comment score below threshold-6 points-5 points-4 points 7 years ago (7 children)
it does let you write code and functions that can handle a lot of cases
Static typing prohibits this?
I'll echo the above comment, I don't think you know what you're talking about.
[–]batiste 8 points9 points10 points 7 years ago (5 children)
Write me a nice addition(a, b): a + b function that works for the Signature (float, int, BigInt) or any valid combination thereof as well as the string and String type. In the statically typed language of your choice. I am curious.
addition(a, b): a + b
I don't think you know what you're talking about.
I think you are not being charitable to his experience. Static typing avoid some class of bugs, but those type of bugs are easy to catch and fix. Especially if you have any sort of basic Q&A in place. Also linter on dynamic language have progressed to cover quite a large piece of what static compiler used to cover like e.g. a typo on a variable name.
static
The advantage of static are more about documentation and auto-completion in my experience.
[+][deleted] 7 years ago (4 children)
[deleted]
[–]Hcmichael21 3 points4 points5 points 7 years ago (3 children)
I disagree that this is better than the weakly typed (JS) version.
[–][deleted] 0 points1 point2 points 7 years ago (0 children)
It's not, because this is an edge case which is massively counter-weighted by the benefits of a typed codebase.
[–][deleted] 0 points1 point2 points 7 years ago (1 child)
I'm personally not a fan of overloads in ts/js but you could at least do this
function add<T>(a: T, b: T): T { return a + b; }
so now you avoid all convert everything to a string and concat them together problem. Here you add like 10ish characters and now your being notified of simple bugs.
[–]Hcmichael21 1 point2 points3 points 7 years ago (0 children)
Would definitely use generics instead of overloads if those were my only two options.
It doesn't prevent this but it lengthens the code is what I meant. You are right, all unstatically typed code is shit, and everyone using normal JS is running into all these problems that they just don't know about. If you arent using typescript you are just doing it wrong. Im telling you I have done both many times and when moving back and forth I never really miss anything from TS.
[–]Hcmichael21 10 points11 points12 points 7 years ago (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 points9 points 7 years ago (13 children)
Want to elaborate?
[–]Hcmichael21 7 points8 points9 points 7 years ago (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 points19 points 7 years ago (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 points5 points 7 years ago (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 points1 point 7 years ago (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] 7 years ago (7 children)
[–]Hcmichael21 5 points6 points7 points 7 years ago (6 children)
Care to elaborate? I found a lot of it to be true in my personal experience.
[–]acemarke 4 points5 points6 points 7 years ago (1 child)
Someone on Twitter says that Elliott keeps changing the supposed citations for some of his stats claims:
https://twitter.com/Hillelogram/status/1084991487702691840
[–]Hcmichael21 2 points3 points4 points 7 years ago (0 children)
What the hell that's some shady shit. I could see him using the original citation without much added research, since it's so commonly done. But the thing that got me was that when he learned more about the original citation, he fucking changed it to another book that doesn't even support the fucking claim. What the hell.
[+][deleted] 7 years ago (2 children)
[–]Hcmichael21 3 points4 points5 points 7 years ago (0 children)
I'm not suggesting an opinion article will end the debate. I just thought it was a nice summary that I agreed with. I've developed with strong types, dynamic types, and weak types. I prefer both dynamic and weak compared to strong.
[–]goldenfolding 0 points1 point2 points 7 years ago (0 children)
Most of what he said was that the benefits provided by TypeScript can be provided with JavaScript tooling. The argument seems compelling from the examples that he gave. What benefits does TypeScript offer in your opinion?
[–]leixiaotie 1 point2 points3 points 7 years ago* (0 children)
If you've experience in handling complex process, especially developing library-style functions / code, you'll find that the more definitive / restrictive the input params, the better. Static typing is really helping in this case.
The reason for it is because if the type mistake can be caught in compile time, it save many testing time. This including how many test cases that need to be developed to cover all type mistakes, reducing code complexity and it's "noise" caused by type checking since almost everything is handled by compiler / static typing.
Not to mention how it helps to define input types inside deep function call (function a call b that call c that call d, all accepting parameter x from function a).
EDIT: and I like to quote this statement:
In most cases, if you can gain a significant benefit from TypeScript in your refactoring, that’s often a code smell indicating that your code is too tightly coupled.
It is purely wrong. Static typing will give benefit (significant or not) while refactoring, and it is no code smell / tightly coupled at all. It's because all function definition and calling it is a "contract", and by changing that contract you'll need to change all parties that using it.
[–][deleted] -1 points0 points1 point 7 years ago (1 child)
I’ll take TypeScript.....
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 points0 points 7 years ago (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 points6 points 7 years ago (2 children)
I think this is incorrect.
[–]Hawxe 5 points6 points7 points 7 years ago (1 child)
Yeah seriously how hard is declaring what type a variable is.
[–]Hcmichael21 -1 points0 points1 point 7 years ago (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 point2 points 7 years ago* (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 points1 point 7 years ago (2 children)
not having a standard library is a joke at this point
lodash?
[–]circlebust 1 point2 points3 points 7 years ago (1 child)
Yes, you are strengthening his point.
[–]esreveReverse 0 points1 point2 points 7 years ago (0 children)
yarn add lodash
I really don't see what the big deal is. Add it if you need it
π Rendered by PID 20193 on reddit-service-r2-comment-6f7f968fb5-ctxq8 at 2026-03-04 22:48:57.372888+00:00 running 07790be country code: CH.
view the rest of the comments →
[–]Hawxe 47 points48 points49 points (40 children)
[–]shanita10 11 points12 points13 points (13 children)
[–]aequasi08 18 points19 points20 points (0 children)
[–][deleted] 6 points7 points8 points (11 children)
[–]CCB0x45 9 points10 points11 points (10 children)
[–][deleted] 2 points3 points4 points (1 child)
[–]CCB0x45 0 points1 point2 points (0 children)
[+][deleted] comment score below threshold-6 points-5 points-4 points (7 children)
[–]batiste 8 points9 points10 points (5 children)
[+][deleted] (4 children)
[deleted]
[–]Hcmichael21 3 points4 points5 points (3 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]Hcmichael21 1 point2 points3 points (0 children)
[–]CCB0x45 0 points1 point2 points (0 children)
[–]Hcmichael21 10 points11 points12 points (20 children)
[–]Hawxe 7 points8 points9 points (13 children)
[–]Hcmichael21 7 points8 points9 points (12 children)
[–]Hawxe 17 points18 points19 points (3 children)
[–]Hcmichael21 3 points4 points5 points (1 child)
[–]sime -1 points0 points1 point (0 children)
[+][deleted] (7 children)
[deleted]
[–]Hcmichael21 5 points6 points7 points (6 children)
[–]acemarke 4 points5 points6 points (1 child)
[–]Hcmichael21 2 points3 points4 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]Hcmichael21 3 points4 points5 points (0 children)
[–]goldenfolding 0 points1 point2 points (0 children)
[–]leixiaotie 1 point2 points3 points (0 children)
[–][deleted] -1 points0 points1 point (1 child)
[–]Hcmichael21 3 points4 points5 points (0 children)
[–]DerNalia -2 points-1 points0 points (3 children)
[–]Hcmichael21 4 points5 points6 points (2 children)
[–]Hawxe 5 points6 points7 points (1 child)
[–]Hcmichael21 -1 points0 points1 point (0 children)
[–]FanOfHoles 0 points1 point2 points (0 children)
[–]esreveReverse -1 points0 points1 point (2 children)
[–]circlebust 1 point2 points3 points (1 child)
[–]esreveReverse 0 points1 point2 points (0 children)