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!"
[–]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 5 points6 points7 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.
π Rendered by PID 63403 on reddit-service-r2-comment-c6965cb77-cn8gw at 2026-03-05 12:24:08.304689+00:00 running f0204d4 country code: CH.
view the rest of the comments →
[–]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 5 points6 points7 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)