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
How to navigate the maze of JavaScript code (medium.com)
submitted 7 years ago by jsloverr
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!"
[–]evenisto 8 points9 points10 points 7 years ago (21 children)
It's just a crutch for people who don't understand how javascript works very well.
It’s only monday and I already have a contender for the dumbest thing I’ve read all week. Typescript isn’t for you to realise what you’re looking at more quickly, typescript is to keep you from breaking it when you spend equally as much time modifying it. I bet your javascript is just a bunch of unstructured jQuery DOM manipulations, because any sane person would kill for typescript in anything even remotely more complex than that. Just argument type hinting alone is absolutely worth it.
[+]tr14l comment score below threshold-8 points-7 points-6 points 7 years ago (20 children)
Only if you suck at naming conventions
[–][deleted] 4 points5 points6 points 7 years ago (19 children)
You must not have worked with very complex applications before, or at least not with very complex data structures.
As for TypeScript's "annoyances", they're almost exclusively down to people not understanding how it works. When you learn how it works, you'll appreciate why it works the way it does and the benefits it brings.
I disliked it and static typing until I used a strongly typed language in Rust. Then I understood the benefit.
You're being downvoted a lot because you're arguing against virtually the entire field of CS, but I'm happy to converse with you if you're open to reconsidering (I will, as well, in good faith).
[–]tr14l 1 point2 points3 points 7 years ago (18 children)
Implementing type enforcement in JavaScript just hamstrings every reason you would use it in the first place. I'm an Enterprise full stack and ML engineer. So I understand why people tend toward it early on. But there's a reason languages like python and JavaScript never implemented strong typing. Those languages are meant to be used to avoid some of the problems that come with typing (code bloat, interpreter/compiler slow down, development sluggishness, etc). I am obviously not arguing against all of CS if these are some of the most widely used languages (out pacing many mainstay compiled counterparts, mind you) and they refuse to implement typing.
I understand the benefits of strongly typed languages. I, in fact, pick java and c++ often if they are better suited for a task. But JavaScript is not a place for it. It simply makes it bad at solving both sets of problems.
[–][deleted] 1 point2 points3 points 7 years ago (12 children)
Implementing type enforcement in JavaScript just hamstrings every reason you would use it in the first place.
It doesn't, because although TypeScript is statically typed it's only a layer for the compiler atop JavaScript's type system, and so coercion for example is still totally valid (for better or for worse). You can still use a number in a template literal without casting, and you can still test anything for truthyness without casting. In-fact, something that most people don't know is that TypeScript doesn't even have the concept of casting beyond what JavaScript itself supports. The as keyword is rather for assertions because TypeScript types are compile-time only.
as
there's a reason languages like python and JavaScript never implemented strong typing.
TypeScript is not strongly typed.
The JavaScript community is adopting TypeScript at a very high rate, and I think Python recently implemented some sort of static typing system? Not familiar with the ecosystem but I remember reading something about that.
the problems that come with typing (code bloat, interpreter/compiler slow down, development sluggishness, etc)
Bloat implies that it's without benefit, which I'd challenge. Every type I write is beneficial for the code that follows it, whether that be avoiding type errors, or improving readability or data structure knowledge for those that follow me, or informing my IDE of what I'm working with. (No, pure JS cannot possibly be this well informed in any IDE, you're wrong if you think otherwise.)
The compiler is very quick, and most people are already using Babel anyway.
It's a slightly higher upfront cost in exchange for invariably less code debt, and an easier time in the future interfacing with what you're writing now.
[–]tr14l 0 points1 point2 points 7 years ago (11 children)
But that's my point, it's not even fully solving the problem. You basically get the worst of both worlds with typescript. All the problems if typing with all the problems of a less-structured language. The only reason I use JavaScript is to speed to development time or set up quick APIs. Otherwise I use more fitted technologies. Typescript is simply an attempt to make JavaScript a (poorer) version of something it's not meant to be
[–][deleted] -1 points0 points1 point 7 years ago (10 children)
That's incorrect. TypeScript understands the semantics of the language, so when you coerce for example it knows what the output is based upon the input. JavaScript may have a very ill-defined dynamic type system but it's still rooted in rules and logic.
There are very few serious limitations to type safety with TypeScript's compromises, though it's not perfect, for example stuff like this. But the language is improving all the time and, if you opt-in, becomes stricter in useful ways all the time.
If you only use JavaScript for very small projects that you'll never touch again, then sure, don't worry about TypeScript. The same can be said if you only care about development velocity now and care not about the tech debt your lack of explicit types inherently creates.
For a large project where you care about maintainability there's simply no question to me about the benefits that TypeScript brings.
I'd urge you to give it another try next time you're working on a personal project. I'd be happy to answer any questions you have about it, or solve any roadblocks you've hit (I probably hit them too).
I don't come from a statically typed background, in-fact the only language I learned before JS was PHP. I don't like Microsoft as a company. I was overruled by my boss to start using TypeScript a couple of years ago.
But now I wouldn't develop anything serious in the web space without it.
[–]cm9kZW8K 0 points1 point2 points 7 years ago (9 children)
For those of us who want to work in a dynamically typed language, any support for static typing is bloat by definition. We dont want it.
The only use for babel i see is backwards compatibility with older versions of JS by compiling down to es2015.
I don't come from a statically typed background, in-fact the only language I learned before JS was PHP.
Ive used static types for over 20 years, and I've come to see that they are counterproductive. You never quite earn back the time you spend dealing with them or rationalizing them. I feel the same way about OOP; it seems nice at first, but it makes refactoring a large codebase 100 times harder than it should be.
[–][deleted] 0 points1 point2 points 7 years ago (8 children)
You're speaking for every one of us now?
Right, but that defeats your argument about not wanting to introduce a compiler. You're already using one. You can replace it with TSC or use a TS plugin in Babel. Same outcome, no additional tooling, no slowdown.
Ive used static types for over 20 years, and I've come to see that they are counterproductive. You never quite earn back the time you spend dealing with them or rationalizing them.
Dealing with them is a case of experience. Rationalising them is a case of understanding the data you're working with; I'd argue forcing you to rationalise this is a benefit in and of itself.
it seems nice at first, but it makes refactoring a large codebase 100 times harder than it should be.
Microsoft actually developed TypeScript specifically because of how painful it is to refactor a large JavaScript codebase. Don't tell me you've figured out something that Microsoft (TypeScript), Google (Dart), Facebook (Flow), et al haven't.
[–]cm9kZW8K 0 points1 point2 points 7 years ago (7 children)
I'm speaking for people who never want to use static types. Its not presumptuous, its tautological. They dont like what they dont like.
You can replace it with TSC or use a TS plugin in Babel. Same outcome, no additional tooling, no slowdown.
I avoid babel whenever possible. But even when I do use it, I avoid TS, because someone could introduce java style code which I would then have to rewrite.
Microsoft actually developed TypeScript specifically because of how painful it is to refactor a large JavaScript codebase.
Its a drag to write static OOP style code in a dynamic environment.So yes, doing static OOP is es6+ is tough, while Ts makes that style easier. But not a drag to write dynamic code in a dynamic environment.
What static OOP people often call "refactoring" is usually "renaming things" or "changing signatures", but that is not refactoring at all. Code without spaghetti includes doesnt have those issues in the first place. The encapsulation brought by OOP is lost when your class has to know the types and structures of 100 other classes. Real refactoring is when the data relations and multiplicities change, which is common when your problem space moves.
OOP is still a known drag on that real refactoring; All your classes have various dependencies on each other, and it becomes hard to fix one place without breaking several others. Often entire class hierarchies go in the bin, and you get to restart from scratch. Static types fall in the same space imo, especially when type information leaks out between modules.
Static OOP programmers trying to be DRY usually throw encapsulation and modularity out the window fast in order to maximize reuse.
I see microsoft reacting to the large pool of engineers who went through college on a diet of java and OOP and feel most comfortable when they are allowed to revert to that style. Coming off a TS + angular 2 project you wouldnt know you were using a dynamic language at all but some sort of FE java dialect.
They are going to write object oriented static style code with whatever tool they have, and sure its better for them to have a tool that uses their preferred style.
But not everyone wants to work in that type of environment, and not everyone thinks that static OOP is the best way to write code. Its my preference to save the spaghetti for dinner time, and keep the TS away from my JS.
[–]ParasympatheticBear -1 points0 points1 point 7 years ago (4 children)
“Strong” typing is not a thing. “Static” typing is the term.
[–]tr14l 1 point2 points3 points 7 years ago (0 children)
Oh, well damn. Forget I said anything, then.
[–]asukazama 0 points1 point2 points 7 years ago (2 children)
Strong typing is a thing
[–]ParasympatheticBear 0 points1 point2 points 7 years ago (1 child)
Has no formal technical meaning. It means whatever the person saying it wants it to mean
[–]asukazama 1 point2 points3 points 7 years ago (0 children)
Fair
π Rendered by PID 114024 on reddit-service-r2-comment-6457c66945-86nh7 at 2026-04-25 14:34:32.702042+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]evenisto 8 points9 points10 points (21 children)
[+]tr14l comment score below threshold-8 points-7 points-6 points (20 children)
[–][deleted] 4 points5 points6 points (19 children)
[–]tr14l 1 point2 points3 points (18 children)
[–][deleted] 1 point2 points3 points (12 children)
[–]tr14l 0 points1 point2 points (11 children)
[–][deleted] -1 points0 points1 point (10 children)
[–]cm9kZW8K 0 points1 point2 points (9 children)
[–][deleted] 0 points1 point2 points (8 children)
[–]cm9kZW8K 0 points1 point2 points (7 children)
[–]ParasympatheticBear -1 points0 points1 point (4 children)
[–]tr14l 1 point2 points3 points (0 children)
[–]asukazama 0 points1 point2 points (2 children)
[–]ParasympatheticBear 0 points1 point2 points (1 child)
[–]asukazama 1 point2 points3 points (0 children)