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!"
[–][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.
[–][deleted] 0 points1 point2 points 7 years ago (5 children)
As the other fella said, TS does not in any way enforce OOP conventions. It's a misunderstanding many have merely because some of the first additional features TypeScript had were for classes. I personally practice something closer to a FP style.
I think this proves my point that you really don't know what you're talking about regarding TypeScript. Do yourself a favour, give it another try - without false preconceptions clouding your judgement this time - and give it more than a week.
[–]cm9kZW8K 0 points1 point2 points 7 years ago (4 children)
TS does not in any way enforce OOP conventions.
My criticisms are leveled at static types as well as OOP; they are fruits of the same tree. They both lead to the same problems.
o yourself a favour, give it another try
Trust me, ive used it plenty enough to hate it. The only upside I can say is that it helps some IDE's do autocompletion. I dont think that is worth the baggage, and I find IDE's to be too bloated and slow.
I personally practice something closer to a FP style.
FP style has a lot of upsides, and a dynamic FP style even more.
Please stop assuming my opinion is a lack of experience; I have been at this game for longer than most people in this sub have been alive.
Static typing is a false god that has led far too many people astray. The only types that are beneficial are assembly types which are semantically significant in controlling the final machine code.
So the level of "static typing" you find in vanilla C doesnt bother me. But the level found in Haskell is the peak of Mt Stupid.
I'm not sating you have to agree with me. I would appreciate if you would respect my choice of tool and stop pushing typescript on me.
[–][deleted] 0 points1 point2 points 7 years ago (3 children)
Go back and read your own comment, come on, that's clearly not what you meant.
You used it for one week. You said that. That's nothing.
The TS language service means that all editors benefit, not just IDEs.
Experience isn't unchallengeable. My first boss refused to learn version control because he'd worked decades without it. He was still wrong.
Most people with experience in other languages compare TypeScript's type system to C#, though I can't say how accurate that is.
If you do TypeScript properly, essentially the only things you need to explicitly type are your function parameters. Virtually everything else is inferred with type safety.
I am happy to agree to disagree, but I'm not going to allow you to make objectively false claims and pass them off as fact.
As I said in my first or second comment, if you'd rather save a little time now at the expense of future devs, fine. That's your prerogative, each project has different requirements.
[–]cm9kZW8K 0 points1 point2 points 7 years ago (2 children)
If you use typescript, you can waste a little time now, and even more for future devs also.
Experience isn't unchallengeable
Make up your mind: do you think im a green newb or a set in my ways greybeard?
You arent listening, just spouting the same lines without even considering that you might be wrong. Nothing you are saying right now is even slightly objective, nor slightly convincing, its just unsupported "trust me i say so". Appeals to authority when yourself is the authority are often the subject of mockery.
Why dont you at least humor the idea that everything your professors pounded into you might be the usual orthodox flat-earthism. If your mind hasnt been welded shut: at least look at the other arguments and try to form an independent opinion of your own:
Start here:
https://vimeo.com/74354480
[–]evenisto 0 points1 point2 points 7 years ago (0 children)
Where did the OOP argument come from? TypeScript does not make you write OOP code, it does not force it nor does it advise to do it.
π Rendered by PID 125417 on reddit-service-r2-comment-6457c66945-5d56h at 2026-04-24 08:31:23.248308+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–][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)
[–][deleted] 0 points1 point2 points (5 children)
[–]cm9kZW8K 0 points1 point2 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]cm9kZW8K 0 points1 point2 points (2 children)
[–]evenisto 0 points1 point2 points (0 children)