News for hackers. Stuff that matters.
Re:RFC: Adopt a modern JavaScript framework for use with Med... by baybal2 on Thursday March 19, 2020 @05:23AM (#22625840)
> How does removing typescript help you?

https://github.com/microsoft/TypeScript/issues

Please count the number of open bugs

JS tooling is already an enormous jenga tower as it is, with tooling breakages eating a double digit of developer time. Adding typescript on top of that would be the real madness.

Typescript will not help us a dime with type checking for most of devs we hire are long past the stage when typing errors are a thing for them.

On the down side, even certainly not cheap to hire devs with 6-7-8-10+ years of experience have to battle JS tooling every day.

Like half of all genuine bug triage time is already spent on webpack, bable, and other things in the tooling stack. 200 hours a month for $30-$40 per hour devs.

Imagine doubling that digit when they have to also spend time on learning typescript, and fixing it.

No, it does not pay off at all

Re:RFC: Adopt a modern JavaScript framework for use with Med... by scrollaway on Thursday March 19, 2020 @05:37AM (#22625907)
You're removing typescript because you think it's creating bugs...

You realize you're probably creating bugs yourself by removing typescript manually, which is a thing.. typescript itself can do, by compiling down to JS?

This is some prime dailywtf material.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by afiori on Thursday March 19, 2020 @09:29AM (#22627247)
Well not exactly, the parent said something quite different, in the comment they were comparing tooling not languages and they say that the tooling makes for a significant part of the bugs they have to solve so they want a build process as slim as possible.

Nothing was said about whether typescript code is more or less buggy, just that the typescript tooling had issue to work with other tooling.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by inertiatic on Thursday March 19, 2020 @06:03AM (#22626018)
>Typescript will not help us a dime with type checking for most of devs we hire are long past the stage when typing errors are a thing for them.

Who are these mythical people?

Do they just magically decipher what interface an argument conforms to? What methods are accessible on a returned result from any random library they're using?

Re:RFC: Adopt a modern JavaScript framework for use with Med... by orange8 on Thursday March 19, 2020 @06:54AM (#22626294)
I'm not a myth. Some of us started JS programming over a decade ago, with no strong typing and IDE to hold our hand and tell us every time you make a mistake. The key is just discipline, good design patterns and a good linter.

I see TypesScript as a VERY opinionated linter that affects how you think and write JS. JS is a dynamically typed language, which means you loose a lot of its power and flexability by shoe-horning it into strongly typed languange patterns. Yes, I get it, many programmers think best and are most productive using strongly typed languages, but for those of us that can think dynamic or both, TS just gets in the way.

>> Do they just magically decipher what interface an argument conforms to?

This is a good example of the object oriented, strongly typed way of thinking. Explore languages that follow different paradigms, where interfaces just don't apply.

>> What methods are accessible on a returned result from any random library they're using?

Do not use random libraries. A good library should have even some basic docs outline its API and how to use it.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by giantDinosaur on Thursday March 19, 2020 @08:21AM (#22626757)
I don't even get this criticism - the problem with Typescript is that it's far too easy to bypass the type system and allow the dynamic parts of JS to do whatever you want. You can lie about your interfaces all day and <any> to your dynamic heart's content.

For what it's worth, my experience with programmers who think like you is that rarely they're actually genuinely talented and right, and mostly they just spew forth bugs which often sit dormant until they rear their ugly heads years later. Most people are better off thinking about their API's before they implement them, much like one would do in a real engineering discipline. Types are often (and yes, not always) a good way to draw the effort out to the front of your process.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by orange8 on Thursday March 19, 2020 @04:17PM (#22631237)
Wow! What a mature, thoughtful response \s

Only the first and last sentences actually addressed the topic, the rest was just an angry emotional attack on those who think differently from you. Hope you're feeling better now.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by DonHopkins on Thursday March 19, 2020 @10:11PM (#22633888)
\s and not /s? I didn't realize there was such a thing a reverse sarcasm. Or is that some new fangled TypeScript string escape character?
Re:RFC: Adopt a modern JavaScript framework for use with Med... by orange8 on Friday March 20, 2020 @06:26AM (#22636456)
\s or /s Dont care. Small minds, small arguments. Atleast you're consistent that way
Re:RFC: Adopt a modern JavaScript framework for use with Med... by DonHopkins on Friday March 20, 2020 @07:44AM (#22636763)
It's kind of funny how you boast that you don't want any hand holding from the compiler or IDE, yet you proudly proclaim and demonstrate that you're careless about syntax, spelling, and punctuation. And how you sarcastically complain about immature thoughtless responses, yet you're insulting and patronizing. ;) At least you're consistently self contradictory.
Re:RFC: Adopt a modern JavaScript framework for use with Med... by orange8 on Friday March 20, 2020 @09:22PM (#22643432)
LOL!! |s
Re:RFC: Adopt a modern JavaScript framework for use with Med... by DonHopkins on Friday March 20, 2020 @10:02PM (#22643604)
Are you now clear on what Andrew Hejlsberg, the designer of TypeScript and C#, meant by "multi-paradigm" languages?

>I do think one of the things that is luckily happening is that, like as Larry says, everyone's borrowing from everyone, languages are becoming more multi-paradigm.

>I think it's wrong to talk about "Oh, I only like object oriented programming languages, or I only like imperative programming, or functional programming".

Look at the nice table:

https://en.wikipedia.org/wiki/Comparison_of_multi-paradigm_p...

Re:RFC: Adopt a modern JavaScript framework for use with Med... by boomlinde on Thursday March 19, 2020 @08:29AM (#22626794)
> Explore languages that follow different paradigms, where interfaces just don't apply.

Interfaces as a general concept applies whether there is a type system to ensure that they are satisfied or not. Do you have function parameter lists? Do you have expected shapes for function inputs and outputs? Do you have distinct types? Then you have interfaces. Your shit breaks when they aren't conformed to. It has nothing to do with strong typing or object orientation. Strong, static typing is just a way to ensure at compile-time that the expected interfaces are satisfied.

> Do not use random libraries. A good library should have even some basic docs outline its API and how to use it.

Hearing this assurance from someone who just complained about their jenga tower of tooling causing issues, I'm not convinced.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by orange8 on Friday March 20, 2020 @06:35AM (#22636492)
> Do not use random libraries. A good library should have even some basic docs outline its API and how to use it.

>>Hearing this assurance from someone who just complained about their jenga tower of tooling causing issues, I'm not convinced.

It wasn't me. Maybe a TypeScript compiler will help you correctly follow the comment threads? ;)

Re:RFC: Adopt a modern JavaScript framework for use with Med... by orange8 on Friday March 20, 2020 @06:31AM (#22636478)
>> Then you have interfaces.

Not really. My definition of a language feature is something the compiler supports and checks for. JS does not have interfaces. What you're talking about are patterns and best practices, so you're getting there...

JS is a dynamic language. Just deal with it already... you sound smart enough to support both paradigms at the same time in your head.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by boomlinde on Friday March 20, 2020 @11:18AM (#22638226)
> Not really. My definition of a language feature is something the compiler supports and checks for. JS does not have interfaces.

It doesn't matter what your definition of a language feature is. The person you responded to was obviously talking about interfaces in the general sense of the word and was asking a question about it.

> What you're talking about are patterns and best practices, so you're getting there...

Nope, what I'm talking about is interfaces. The nature of function signatures as interface points is not a matter of patterns and best practices. They simply are exactly that, whether it's spelled out for you or not.

> JS is a dynamic language. Just deal with it already... you sound smart enough to support both paradigms at the same time in your head.

This doesn't constitute an argument or an objection to anything I've said. It presumes that I won't "deal with it" when there is no evidence that I'm not. It supposes that "support[ing] both paradigms at the same time", whatever that means, is a matter of my intelligence. It doesn't argue for any of this.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by orange8 on Friday March 20, 2020 @09:40PM (#22643512)
> It doesn't matter what your definition of a language feature is. The person you responded to was obviously talking about interfaces in the general sense of the word and was asking a question about it.

Really? So now this has devolved into a debate about semantics? I thought this was about JS and TS, not the "general meaning of interfaces". Using that way of thinking, even HTML and CSS have interfaces. Arguing over semantics is a very common tactic by the way, if you just want to win a debate for arguments sake. Let us keep it specific. My point is JS, as a functional language does not have or even require many of the features and constructs of a strongly typed OOP language, interfaces being a good example. The inverse also applies.

Different programming paradigms = different patterns and best practices

>>Nope, what I'm talking about is interfaces. The nature of function signatures as interface points is not a matter of patterns and best practices. They simply are exactly that, whether it's spelled out for you or not.

Are you saying an interface is a function signature and is this what you mean by interfaces in general?

>>This doesn't constitute an argument or an objection to anything I've said. It presumes that I won't "deal with it" when there is no evidence that I'm not. It supposes that "support[ing] both paradigms at the same time", whatever that means, is a matter of my intelligence. It doesn't argue for any of this.

My responses do not have to be blow by blow objections to every single point you make. This is a discussion, not a computer program. And I stand by the sentiment: for optimal results, think functional when working in a functional language.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by boomlinde on Saturday March 21, 2020 @10:03AM (#22646532)
> Really? So now this has devolved into a debate about semantics?

You just reasoned on the basis of your "definition of a language feature" that I am wrong. Don't blame me for turning it into a discussion about semantics.

> I thought this was about JS and TS, not the "general meaning of interfaces". Using that way of thinking, even HTML and CSS have interfaces.

It is about JS and TS. A poster asked, about JS developers, "Do they just magically decipher what interface an argument conforms to?". There is a reasonable answer to that, and it isn't "This is a good example of the object oriented, strongly typed way of thinking. Explore languages that follow different paradigms, where interfaces just don't apply", which doesn't answer his question and instead assumes that the poster simply hasn't explored languages that for some unargued reason will change his question.

Obviously he is not talking about interfaces as a language feature, since he acknowledges that JS doesn't have explicitly defined interfaces.

You yourself have been talking about library APIs. I'm sure you know what the I stands for.

> Are you saying an interface is a function signature and is this what you mean by interfaces in general?

I am saying that they are interfaces. I am not saying that function signatures constitute the entirety of interfaces in general, and I'm not sure what I wrote that makes you even ask that question.

> My responses do not have to be blow by blow objections to every single point you make. This is a discussion, not a computer program.

It's a discussion, and I participate to discuss things, not to hear you tell me to "deal with it". But sure, I can't stop you from participating on whatever basis you prefer. I just want to point out that I get absolutely nothing out of it, so if you're writing that for my sake you can stop.

> And I stand by the sentiment: for optimal results, think functional when working in a functional language.

This is not about functional vs. non-functional. It's about JS and TS, as you've pointed out yourself.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by inertiatic on Thursday March 19, 2020 @07:48AM (#22626571)
>This is a good example of the object oriented, strongly typed way of thinking. Explore languages that follow different paradigms, where interfaces just don't apply.

I'm not sure whether you intended this to sound so patronizing, but wow. What languages should I explore while talking about Javascript?

You are called to edit a function that takes 2 arguments:

function handle_req(request, options):

What is request in this context and what is options?

What makes me more productive, going up the stack and seeing who might call this function and with what argument, or instantly knowing what the domain of values it operates on is and being able to treat this as a separate unit?

>Do not use random libraries. A good library should have even some basic docs outline its API and how to use it.

A whole lot of the time, especially in Javascript land you will join projects where libraries are being used, and where documentation is lacking. Your advice here is basically to not be part of those projects? Instead of developing and using tooling that will ensure that these situations no longer happen?

Okay.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by danShumway on Thursday March 19, 2020 @09:58AM (#22627531)
> that will ensure that these situations no longer happen?

Well... but Typescript doesn't ensure those situations won't happen, ironically because it's a superset of Javascript and it's not strict enough. Typescript is just documentation that compiles. If a library has bad documentation, it's likely to have bad Typescript as well, and bad Typescript can be a giant curse.

Typescript will happily allow you to force a typecast that doesn't reflect reality -- it will happily allow you to say that a method always returns a string when sometimes it returns a number, and it will happily compile in those scenarios.

Tracking those bugs down are a giant pain. I don't hate Typescript, but people who look at this and think, "I don't have to care about what libraries I'm using, I can just trust the interface" are fooling themselves. I've debugged plenty of errors in Typescript code that ended up being the result of me trusting an interface that didn't reflect the reality at runtime.

There's value in Typescript for some projects, but it does not remove the need to be careful about documentation and dependencies, because it's so easy for both dependencies and downstream code to circumvent the protections Typescript gives you.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by Udik on Thursday March 19, 2020 @12:57PM (#22629321)
> it will happily allow you to say that a method always returns a string when sometimes it returns a number

Just replace "say" with "assume" and you have the javascript situation: javascript is just typescript with documentation stripped off.

> Typescript is just documentation that compiles.

Exactly. And we're arguing whether code should contain documentation or not.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by danShumway on Thursday March 19, 2020 @01:32PM (#22629689)
This is kind of a subtle idea, but in some instances, the illusion of safety can be harmful. It is occasionally (not always) better not to give people the illusion of safety when that safety doesn't actually exist. Sometimes putting an ineffective railing along a mountain path increases accidents, because it's human nature for people walking on that path to watch their footing less when they see the railing.

>> Do not use random libraries. A good library should have even some basic docs outline its API and how to use it.

> A whole lot of the time, especially in Javascript land you will join projects where libraries are being used, and where documentation is lacking. Your advice here is basically to not be part of those projects? Instead of developing and using tooling that will ensure that these situations no longer happen?

I'm not here to hate on Typescript, I think it has its uses. I use Typescript in some places. I generally avoid it for personal projects, but I would probably encourage it for larger orgs.

But the idea that Typescript protects you from needing to care about interfaces is exactly the problem with over-reliance on Typescript, and is the source of a lot of really badly written code that treats interface design like an afterthought. If you're using Typescript for documentation and you're treating it like a tool, you can write some really elegant code, you can catch some shallow bugs around types and assumptions, you can integrate your documentation into your IDE. If you're looking at Typescript and saying, "this is an efficient way for me to document what my code does", then this is all very good.

But if you're using Typescript and saying, "now I can pull in any dependency I want", then Typescript is doing you more harm than good.

The specific advice orange gives in those two sentences is good advice. If Typescript is giving you a false sense of confidence about using random libraries, then that's a real negative.

I use both pure JS and Typescript almost daily, and I consume plenty of dependencies written in Typescript. I still occasionally need to debug the stack traces in those dependencies. I still occasionally need to read through their source code to figure out what they're doing. Badly documented dependencies are not a problem that Typescript solves.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by Udik on Thursday March 19, 2020 @05:30PM (#22631959)
> in some instances, the illusion of safety can be harmful

> you can catch some shallow bugs around types

> If Typescript is giving you a false sense of confidence about using random libraries

> Badly documented dependencies are not a problem that Typescript solves.

Seriously, what is your claim? That if you have a badly documented third party library with wrong typings then typescript doesn't help? Well, that's some news! Try the same library with no documentation at all then, so you won't get a false sense of safety. If that is your problem, why don't you just avoid importing typings for libraries?

And I don't get this insistence on bugs and safety. Sure, typescript probably prevents you from doing really stupid stuff sometimes, but that's not the main reason I use it. I use it because it both allows me to write much more complex code and speeds up dramatically the development- because the tool takes on itself what is otherwise a heavy cognitive load: remembering and inferring interfaces and signatures that are there all the time, even if implicitly.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by danShumway on Thursday March 19, 2020 @11:37PM (#22634566)
> If that is your problem, why don't you just avoid importing typings for libraries?

Yes? That's exactly what people are doing when they import a dependency written in Typescript into a pure JS project.

> A whole lot of the time, especially in Javascript land you will join projects where libraries are being used, and where documentation is lacking. Your advice here is basically to not be part of those projects? Instead of developing and using tooling that will ensure that these situations no longer happen?

My claim is that Typescript does not solve the problem of joining a project with poorly written, undocumented libraries.

I'm not bashing on Typescript. If the primary way you use it is as an organizational tool to reduce cognitive load and make interfaces more explicit, then that's great. You're using Typescript as intended. And there are some scenarios where a compile-time type-checker is just obviously the right tool for the job.

You started this thread by asking how JS devs could manage 3rd-party interfaces without Typescript. I assume you genuinely want an answer to that question. The answer is that for some people on some projects, using well defined interfaces and keeping a reference page open with documentation is about as fast and about as easy as using Typescript, and that following that process doesn't increase their bug count or cognitive load to the point where they feel the need to introduce a compilation step.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by Udik on Friday March 20, 2020 @05:17AM (#22636176)
> Yes? That's exactly what people are doing when they import a dependency written in Typescript into a pure JS project.

Except that in this way they also lose good typings for any other library and for their own code as well. I understand an outdated definition file can be annoying, but there can be various ways to only ignore type definitions for that specific library.

> My claim is that Typescript does not solve the problem of joining a project with poorly written, undocumented libraries.

That is a problem that no language or tool can solve.

> You started this thread by asking how JS devs could manage 3rd-party interfaces without Typescript.

No, I didn't, you're confusing me with someone else. Inertiatic asked at the beginning of this thread

"Who are these mythical people? [the developers who never make typings mistakes] Do they just magically decipher what interface an argument conforms to? What methods are accessible on a returned result from any random library they're using?"

Then the thread proceeded by 1) ignoring the first part of his question, about having to remember signatures in general, including of your own code; 2) interpreted "random" in a strictly negative way, as if it meant "any junk library" instead of "every library".

Re:RFC: Adopt a modern JavaScript framework for use with Med... by danShumway on Friday March 20, 2020 @09:35AM (#22637363)
> you're confusing me with someone else.

Apologies. That actually explains a lot :)

> 1) ignoring the first part of his question, about having to remember signatures in general, including of your own code; 2) interpreted "random" in a strictly negative way, as if it meant "any junk library" instead of "every library".

The answer to 1) is that remembering type signatures in general (or primarily referencing them through a separate spec sheet) turns out to be about as easy as Typescript for some projects and some people. The answer to 2) is that not "every library" is complicated enough to need extensive bindings, and that since Typescript doesn't help you with junk libraries anyway, the benefits to well-documented libraries turn out to be relatively minor.

I mean, I don't even use an IDE for development. I'm on Vim/Emacs, so the immediate documentation benefits of Typescript you describe literally just don't apply to me. And there are plenty of JS devs in the same position, where their only interaction with the type checker will be during a compile.

The short answer to how people magically know the type signature of random methods is they don't. They use documentation, or they look at source code, which is something I still regularly have to do in the projects where I use Typescript.

----

> Who are these mythical people? [the developers who never make typings mistakes]

In general, typings mistakes aren't a major source of bugs in most of my projects. I only observe them to be a major source of bugs in large orgs where lots of teams are coordinating on large interfaces. And that's not because I'm a genius programmer or have a magic power, there are normal programmers who will find themselves in that situation.

> Do they just magically decipher what interface an argument conforms to?

No, I look at the documentation. In general, I also spend a lot of time on interface design so my interfaces are small enough and consistent enough that I can hold the entire API in my head without much cognitive load and without needing to check documentation very often.

> What methods are accessible on a returned result from any random library they're using?"

I look at the documentation, or the source code if I don't trust the documentation.

You are always going to be able to make the argument that I just don't understand how much time I could be saving. I don't know how to prove to you that this isn't a massive drop in productivity for me, in the same way that I don't know how to prove to you that it's not a massive drop in productivity for me to write DOM manipulation code in Vim instead of Webstorm with tab-completion. All I can say is, I use both JS and Typescript on an almost daily basis, and I pay attention to the cognitive loads, bugs, and time-sinks I have in each environment. The JS environments aren't any slower to program in.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by orange8 on Thursday March 19, 2020 @04:55PM (#22631632)
> javascript is just typescript with documentation stripped off.

JS, at its core is a dynamically typed, functional language. Typescript aims to model a strongly typed, OPP language. The two programming paradigms have their own strengths, weaknesses and most importantly: patterns and best practices.

If the only difference between your pure javascript code and your typescript code is the annotations, you are doing it wrong.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by Udik on Thursday March 19, 2020 @05:13PM (#22631800)
> Typescript aim to model a strongly typed, OPP language.

Do you think? I just take TS for what it gives me, documentation and static code analysis. I can write down my knowledge and expectations about the code and have the tool keep track of it for me, removing the cognitive load of doing it myself- which I'd have to otherwise.

Can you give me an example of a pattern that is "good" in JS and not in TS, or the other way round? I'm curious.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by orange8 on Friday March 20, 2020 @10:28PM (#22643739)
A good indirect example is an actual feature added to JS recently, which are classes. Classes are the main unit of OOP, while functions are the main unit in the functional paradigm. The class syntax in JS is not a real new structure added to the language, but just syntax sugar. Underneath it all, the JS compiler just converts it to a regular JS function using a specific pattern. You could, if you wanted, save the compiler that work by just coding using that pattern to begin with.

When using TS the class syntax fits in perfectly for me, an in pure JS I'd stick to functions.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by Udik on Saturday March 21, 2020 @09:04AM (#22646226)
So you're giving a javascript feature as an example of a pattern that doesn't fit javascript. Then you claim to use an equivalent but syntactically different form in js? How does this constitute a different pattern?
Re:RFC: Adopt a modern JavaScript framework for use with Med... by iaml on Thursday March 19, 2020 @09:41PM (#22633715)
> Typescript aims to model a strongly typed, OPP language

That's a rather puzzling statement, to be honest. Strong type system is explicitly one of the non-goals[0]. I write typescript code everyday and most of it is functional. Things like fp-ts[1] make it even more enjoyable.

[0] https://github.com/Microsoft/TypeScript/wiki/TypeScript-Desi... [1] https://github.com/gcanti/fp-ts

Re:RFC: Adopt a modern JavaScript framework for use with Med... by orange8 on Friday March 20, 2020 @09:59PM (#22643592)
Am comfortable using both OOP and functional styles, though I do enjoy the flexibility and terseness that can be produced from the functional approach.

What I meant by the comment is that when using TS, I just find it more easy and natural to go with the proper OOP approach. I think the very existence of a separate library to enable a more functional style in TS proves this goal has not been met yet.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by iaml on Sunday March 22, 2020 @12:33PM (#22656201)
Functional languages usually have extensive standard library, while js does not. Adding it is not really a goal of ts.
Re:RFC: Adopt a modern JavaScript framework for use with Med... by samhh on Friday March 20, 2020 @07:40AM (#22636744)
It's not very strongly typed at all, and it absolutely doesn't force you into the OOP paradigm.

Why don't I consider it strongly typed?: Structurally subtyped as opposed to nominal typing, the pervasiveness of any, allowance for vanilla JS coercion, exceptions and promise rejections are untyped, etc.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by orange8 on Friday March 20, 2020 @09:51PM (#22643558)
I agree, that's why I said TS aims to model a strongly typed languange.
Re:RFC: Adopt a modern JavaScript framework for use with Med... by manigandham on Thursday March 19, 2020 @10:04PM (#22633853)
Typescript won't save anyone from intentional writing bad code or using a broken library. Nothing will. I don't see how that's a criticism of TS itself.
Re:RFC: Adopt a modern JavaScript framework for use with Med... by orange8 on Thursday March 19, 2020 @04:46PM (#22631551)
> I'm not sure whether you intended this to sound so patronizing, but wow. What languages should I explore while talking about Javascript?

Why would the suggestion to explore non OOP, strongly typed languages sounds patronizing to you? The more different languages you play with, the broader your mental modelling toolset becomes. It is painfully obvious to me that someone worried about interfaces in JS is not very familiar with more dynamically typed or/and functional languages. JS is a VERY FLEXIBLE language which can be coded in any style, which is why I've suggest playing with something more opinionated to get the gist. Languages like XSLT, Erlang, LISP, Haskell etc.

> You are called to edit a function that takes 2 arguments:

> function handle_req(request, options):

> What is request in this context and what is options?

The fact that you can edit handle_req means it is application code. So how you figure that out comes down to the structure and patterns you and your team use (if any) and the available documentation (if any). You'd be surprised how far Eslint and JSDoc will take you. TypeScript accomplishes the same, and I've no problem using it within a team that needs it but personally, it feels like an overkill I don't really need to.

> A whole lot of the time, especially in JavaScript land you will join projects where libraries are being used, and where documentation is lacking. Your advice here is basically to not be part of those projects? Instead of developing and using tooling that will ensure that these situations no longer happen?

The decision to use TypeScript or any other tooling should really be made at the BEGINING of a project, so why are we talking about projects that already missed the boat, and even worse lack documentation and tests? This just proves my point, what you really need is discipline (documentation, tests, best praise etc) and a good linter, not a whole new language or programming paradgim.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by manigandham on Thursday March 19, 2020 @07:19AM (#22626408)
Typescript is as strongly typed as you want it to be. You can easily work with dynamic types and it will fill in where it can.
Re:RFC: Adopt a modern JavaScript framework for use with Med... by danShumway on Thursday March 19, 2020 @09:36AM (#22627318)
Eh... people say this, and in theory it should be true.

If you actually use Typescript with a lot of dynamic/unsafe types, in practice you will very quickly end up with a lot of code littered with `any` casts, and those unsafe code blocks will end up (for lack of a better word) infecting the rest of your code and making the compile-time errors much less useful.

For whatever it's worth, my advice is in the instances where you decide Typescript is right for you, commit to it. For the most part, use interfaces, and use strict types that don't get recast a whole bunch.

You don't want Typescript to be guessing too much about your code, because some of those intuitions are fragile and can turn into bugs later if you assume Typescript just knows what you mean. I've had code that works until it gets refactored and Typescript stops being able to intuit what a type is. At that point, going back and retroactively trying to make things more explicit becomes a lot harder and a lot more error prone. The temptation there is to just shortcut the entire process and force Typescript to accept that a type is what you say it is -- and that can lead to very subtle bugs that are hard to track down.

The best Typescript code I've seen is code that embraces the rigidness. When I see a Typescript project with a lot of `any` casts, I start to get kind of nervous.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by DonHopkins on Friday March 20, 2020 @07:52AM (#22636807)
>Some of us started JS programming over a decade ago, with no strong typing and IDE to hold our hand and tell us every time you make a mistake. The key is just discipline, good design patterns and a good linter.

A decade ago isn't very long ago. JavaScript is more than 24 years old, and we had to get along without good design patterns or good linters or good debuggers or good libraries or good documentation or good IDEs or good compilers or even good interpreters back then. It sounds like you were late to the party and missed all the fun! ;)

Re:RFC: Adopt a modern JavaScript framework for use with Med... by orange8 on Friday March 20, 2020 @10:05PM (#22643616)
I may have shaved a few years here and there to calculate that decade ;)

I'm still waiting for a browser to come with an inbuilt server like netscaape 3.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by DonHopkins on Sunday March 22, 2020 @06:02PM (#22659146)
You do now understand that TypeScript didn't lose any of the flexibility, power, or paradigms of JavaScript, since it's by definition a strict superset of JavaScript, so it only adds programming paradigms, not subtracts them, right? Or do you disagree with Andrew Hejlsberg, its designer, or the definition of "strict superset"?

https://en.wikipedia.org/wiki/TypeScript

>TypeScript is an open-source programming language developed and maintained by Microsoft. It is a strict syntactical superset of JavaScript, and adds optional static typing to the language.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by DonHopkins on Friday March 20, 2020 @10:47AM (#22637922)
>no strong typing and IDE to hold our hand and tell us every time you make a mistake

Ha ha! You remind me of Larry Wall:

https://news.ycombinator.com/item?id=22210073

>"I think IDEs make language developers lazy." -Larry Wall

https://www.youtube.com/watch?v=AO43p2Wqc08

To which James Gosling replied:

>"IDEs let me get a lot more done a lot faster. I mean I'm not -- I -- I -- I -- I -- I'm really not into proving my manhood. I'm into getting things done." -James Gosling

Andrew Hejlsberg also made some good points in that same discussion:

>Maybe I'll just add, with language design, you know one of the things that's interesting, you look at all of us old geezers sitting up here, and we're proof positive that languages move slowly.

>A lot of people make the mistake of thinking that languages move at the same speed as hardware or all of the other technologies that we live with.

>But languages are much more like math and much more like the human brain, and they all have evolved slowly. And we're still programming in languages that were invented 50 years ago. All the the principles of functional programming were though of more than 50 years ago.

>I do think one of the things that is luckily happening is that, like as Larry says, everyone's borrowing from everyone, languages are becoming more multi-paradigm.

>I think it's wrong to talk about "Oh, I only like object oriented programming languages, or I only like imperative programming, or functional programming".

>It's important to look at where is the research, and where is the new thinking, and where are new paradigms that are interesting, and then try to incorporate them, but do so tastefully in a sense, and work them into whatever is there already.

>And I think we're all learning a lot from functional programming languages these days. I certainly feel like I am. Because a lot of interesting research has happened there. But functional programming is imperfect. And no one writes pure functional programs. I mean, because they don't exist.

>It's all about how can you tastefully sneak in mutation in ways that you can better reason about. As opposed to mutation and free threading for everyone. And that's like just a recipe for disaster.

In the HN discussion of that talk, I wrote:

https://news.ycombinator.com/item?id=19568860

>Anders Hejlsberg also made the point that types are documentation. Programming language design is user interface design because programmers are programming language users.

>"East Coast" MacLisp tended to solve problems at a linguistic level that you could hack with text editors like Emacs, while "West Cost" Interlisp-D tended to solve the same problems with tooling like WYSIWYG DWIM IDEs.

>But if you start with a well designed linguistically sound language (Perl, PHP and C++ need not apply), then your IDE doesn't need to waste so much of its energy and complexity and coherence on papering over problems and making up for the deficiencies of the programming language design. (Like debugging mish-mashes of C++ templates and macros in header files!)

Re:RFC: Adopt a modern JavaScript framework for use with Med... by DonHopkins on Friday March 20, 2020 @01:09PM (#22639257)
I think what Andrew Hejlsberg himself, the designer of C# and TypeScript, said speaks to the claims orange8 is making about TypeScript being a "VERY opinionated linter" and that "you loose a lot of its power and flexability by shoe-horning it into strongly typed languange patterns".

Andrew Hejlsberg's point is that TypeScript is a "multi-paradigm" language: it's not just strongly typed, but also structurally typed, interface based, plus everything else JavaScript itself is: dynamically typed, duck typed, functional, imperative, event driven, class based, prototype based, object oriented, etc.

Even the term "object oriented" has a broad spectrum of independent meanings: JavaScript has many but not all of the a la carte menu of features or properties of "object orientation" that Jonathan Rees listed in response to Paul Graham's essay "Why Arc isn't Especially Object-Oriented".

http://paulgraham.com/reesoo.html

http://mumble.net/~jar/articles/oo.html

http://paulgraham.com/noop.html

Andrew Hejlsberg said:

>I think it's wrong to talk about "Oh, I only like object oriented programming languages, or I only like imperative programming, or functional programming".

It's a mistake to think that TypeScript restricts you to just one way of programming, and you have to give up the ways you used to program JavaScript. TypeScript ADDS to the number of ways you can program JavaScript. It's a superset of the multiple programming paradigms that JavaScript supports.

You don't "loose a lot of its power and flexability by shoe-horning it into strongly typed languange patterns" -- quite the opposite, you don't "lose" anything: you actually gain more "flexibility" and more "language" patterns.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by orange8 on Friday March 20, 2020 @10:18PM (#22643655)
>> you don't "lose" anything: you actually gain more "flexibility" and more "language" patterns.

You do not need TS to use OOP language patterns in JS. Remember TS is compiled down to JS, so all that flexibility comes from JS. The same flexibility that makes the concept of TS and the 100 other "compile to JS" languages possible. Some of that flexibility is lost because you let the TS compiler make some decisions for you as it generates the JS output.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by DonHopkins on Saturday March 21, 2020 @02:32PM (#22648685)
You're factually wrong: zero flexibility is lost. Not even any "flexability". (But I'm glad we're both using the same word now -- I was worried you had some completely different definition of "loose languange flexability" that you were arguing, because you don't seen to be making any sense, and your facts about TypeScript are wrong. Programmers who scoff at IDEs and compilers like you do should be more careful about your own spelling and punctuation and grammar and logic and facts and definitions and semantic arguments.)

The TypeScript compiler will BY DEFINITION compile any JavaScript code to equivalent JavaScript code that does exactly the same thing. So no flexibility is lost, which is obvious if you know TypeScript, or have bothered to read the second sentence of the first paragraph of the TypeScript wikipedia page. TypeScript is a "strict syntactical superset" of JavaScript. So it's impossible for the TypeScript compiler to decrease the flexibility of TypeScript, because all JavaScript is valid TypeScript. Understand?

https://en.wikipedia.org/wiki/TypeScript

>TypeScript is an open-source programming language developed and maintained by Microsoft. It is a strict syntactical superset of JavaScript, and adds optional static typing to the language.

Just the opposite of your claim, and consistent with what Wikipedia and Andrew Hejlsberg say, the TypeScript compiler "ADDS optional static typing to the language", which INCREASES the number of programming paradigms.

Yet you wrote:

>Remember TS is compiled down to JS, so all that flexibility comes from JS.

C++ is compiled down to machine language, but machine language is not object oriented, while C++ is. Do you claim that the flexibility of C++ comes from machine language's innate object oriented-ness, not the C++ compiler? That's simply wrong.

Somehow the C++ compiler is adding object oriented programming to machine language, just as the TypeScript compiler is adding generic programming and structured typing and static typing and other features to JavaScript, even though JavaScript doesn't have those features itself. They came from the compiler, not the target language. JavaScript simply isn't capable of checking types before running a program, and you know that.

You're really not getting the point, or just purposefully trying to avoid it. Read what Andrew Hejlsberg himself said about multi-paradigm languages, which I've quoted to you twice but you haven't acknowledged. Do you really so blatantly disagree with the guy who wrote TypeScript, about his own language?

If you so strongly disagree with Andrew Hejlsberg and the TypeScript manual, then why don't you go edit the Wikipedia articles about TypeScript and JavaScript, and remove the parts about TypeScript being a "strict syntactical superset of JavaScript" that "adds optional static typing to the language", and also remove the part about Javascript being a "multi-paradigm language", and see how long those edits lasts?

https://en.wikipedia.org/wiki/JavaScript

>JavaScript (/ˈdʒɑːvəˌskrɪpt/),[6] often abbreviated as JS, is a programming language that conforms to the ECMAScript specification.[7] JavaScript is high-level, often just-in-time compiled, and multi-paradigm. It has curly-bracket syntax, dynamic typing, prototype-based object-orientation, and first-class functions.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by 112 on Thursday March 19, 2020 @08:07AM (#22626670)
These mythical people are dinosaurs that have lost (or never had) their love for the work they do, and are not interested in improving.
Re:RFC: Adopt a modern JavaScript framework for use with Med... by danShumway on Thursday March 19, 2020 @09:24AM (#22627213)
N=1, but type errors are extremely rare for me in Javascript. I don't think I'm a magical or exceptional programmer. I think it's just if you spend a lot of time in dynamic languages, there's a certain style of programming some people end up adopting that makes those errors much less common.

If you held a gun to my head and forced me to recklessly provide conjecture on what the difference is, I would say that static languages encourage devs to build large interfaces that take tons of options and pass around a bunch of parameters. This is highly, highly subjective, but:

I think there's a grain of truth in what other people are saying about how Typescript projects tend to be kind of verbose. People start reaching for interfaces that are split across multiple files, people start reaching for classes. When you have really rigid types that need to be formally extended all over the place, this also encourages a lot of casting, which tends to be error prone.

I've seen some really complicated logic/type flows in Typescript that would be extremely error prone in Javascript, but there's basically no reason for them to be that complicated in the first place. There are paradigms in Javascript the codebases are not taking advantage of which are forcing them into these over-complicated logic/data flows. Basically, the more crazy boilerplate, casting, and giant interfaces that a codebase has, the more type errors will occur. The more a project is split up into dozens of dependencies and modules and whatever, the harder it is to reason about what a method or class needs passed in. But Typescript projects tend to grow in that direction very quickly, so the need for Typescript tends to become a self-fulfilling prophecy.

As a comparison, most of the personal projects I work on don't have classes at all, they're using a lot of functional interfaces, and they don't include a bunch of random libraries. Most of the dependencies in my projects are libraries that I've personally vetted. Most of my projects are careful about where state is being stored and how its being passed around.

I dunno. All of that is pure conjecture, but people in general are very dismissive of dynamic typing, but it's just not a real problem for me. There's a general consensus that dynamic languages were a mistake, and I don't dismiss the people saying this, but I also pay a lot of attention to where bugs are coming from in my own code, and I can't get past the point that typing really doesn't seem to matter that much in most things I build.

I was on the Typescript train for a while. I still use it in some projects, there are some org structures where it makes a lot of sense. If I'm working with a Java-to-Javascript dev, I want strong interfaces for them. The projects where I don't use it are because I've spent a long time paying attention to where my bugs are coming from. I can't prove to you its not a problem, I can only speak to the experiences I've had.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by manigandham on Thursday March 19, 2020 @05:26AM (#22625855)
Yea bugs exist, yet there are still thousands of teams using it to build very complex projects with less bugs because of Typescript safety and features.

TS tooling either replaces JS tooling or interacts with it seamlessly. It's not like you're skipping JS altogether and there's no type-checking in JS anyway so where's the interference?

Can you give a concrete example where TS is a blocking issue for your development?

Re:RFC: Adopt a modern JavaScript framework for use with Med... by baybal2 on Thursday March 19, 2020 @05:44AM (#22625943)
If you get less bugs because of type checks and you are a serious JS/web dev with 5+ years experience, then your skills are plainly not good enough.

People who spent time with JS and webdev in general got to learn that JS is a minefield of a language, and they work with that in mind. Typing discipline is pretty much the first thing people learn when they try doing JS seriously.

How to say. There is no way just adding typing to JS will make JS less of a JS. You still have to be a very disciplined dev to work with a typescript for it retaining many other tricky parts from JS.

> Can you give a concrete example where typescript is a blocking issue for your development?

Typical example: the tsc transpiler plainly dies, and you know nothing how to debug it, you know nothing of its internals, and you loose the rest of the day doing fruitless email exchanges with typescript dev team, and trying to trace a breaking commit.

Second example: you got a prod breakage report in some hard to reproduce case. You fire a debugger in chrome through vscode, and then you find out that the debugger completely loses the execution flow in transpiler/tooling garbage, and broken source maps. Having a debugger pick code that went through webpack (be it cursed) is already a 50/50 lottery, and additional layer of tooling makes it even worse.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by sbergot on Thursday March 19, 2020 @06:01AM (#22626012)
Do you still put your seat belt in your car after 5+ years of driving experience? If yes, would you say that you do that because your driving skills are "plainly not good enough"?

Typescript allow you to spend less energy on minor issues like typos and more energy on design. It also provides you with the ability to reason locally about some code. When you inspect a function in js, you cannot know what are the contracts that it has to deal with. To be sure you have to unravel all the calling and called functions.

Typescript also enables better intellisense.

About your issues:

- I never had tsc dying on my hand in 5 years.

- About the transpilation noise: it can be as noisy as you want. Have you checked the default result for the es6 target? It litteraly look like your source code with only your type signatures stripped. The noise comes from the transpilation to lower versions and bundling and those are independent of typescript.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by thawaway1837 on Thursday March 19, 2020 @06:08AM (#22626047)
Considering typescript compiles down to JS, and incredibly readable JS at that, the fact that your developers are unable to debug the JS directly may indicate that they are not as amazing at JS as you may believe they are.
Re:RFC: Adopt a modern JavaScript framework for use with Med... by rpastuszak on Thursday March 19, 2020 @06:09AM (#22626057)
> If you get less bugs because of type checks and you are a serious JS/web dev with 5+ years experience, then your skills are plainly not good enough.

What about linters, static analysis, code highlighting, IDEs? Should we skip those too? Should I dig out my "made with notepad" badge?

Types and good static analysis tools allow me to focus on more important things, such as business logic, scale, planning. We don't pay developers for mental gymnastics, but solving real world problems.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by baybal2 on Thursday March 19, 2020 @06:19AM (#22626118)
Of course we do that, and I looked at Flow a few times.

But typing errors are such a minor thing in comparison to everything else, than "everything else" is of much higher on the priority list

Re:RFC: Adopt a modern JavaScript framework for use with Med... by kashug on Thursday March 19, 2020 @07:13AM (#22626374)
When I am writing plain JS I often end up having to write loads of tests to check that I don't to wrong things with types. Did I remember to consider null/undefined? What if I sent in something totally different?

With TS I don't need to spend as much time with these types of tests. I just let the compiler do it for it. If my function says in it's signature the argument can't be null I don't need to do null-checks.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by williamdclt on Thursday March 19, 2020 @07:00AM (#22626321)
This is the weirdest and least convincing thing I've read about Typescript. I won't comment on such experienced devs spending so much time struggling with tooling that shouldn't change all that often, but I have to react that "fixing Typescript" means "fixing your code".

If you're saying that you can't handle the overhead of Typescript config because your devs already spend so much time struggling with the rest of your tooling, by all mean get your shit together with your tooling, this amount of time spent on it isn't any sort of acceptable. You have huge problems.

> most of devs we hire are long past the stage when typing errors are a thing for them

This is just not a thing.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by miffy900 on Thursday March 19, 2020 @07:05AM (#22626342)
> https://github.com/microsoft/TypeScript/issues > Please count the number of open bugs

You do realise the large number of open issues almost certainly relates to Typescript's compiler and language implementation? When a project is written in Typescript, it does not mean all those bugs will inevitably plague the project itself. If I wrote "hello world" in Typescript with a Webpack + Babel project starter, it doesn't suddenly mean I now have thousands of open Typescript bugs to deal with.

Also: the number of closed issues outnumbers open ones by almost x5. Moreover, the total number of issues exceeds 20 thousand; the number is only so high because so many people have already adopted Typescript into their dev workflows. It's a sign it's been battle tested extensively.

> Like half of all genuine bug triage time is already spent on webpack, bable, and other things in the tooling stack. 200 hours a month for $30-$40 per hour devs.

Half? This just seems totally implausible; this could only be true if you were constantly modifying your webpack and babel setup and config files and breaking things.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by cageface on Thursday March 19, 2020 @06:08AM (#22626051)
I would never hire a JS dev with this attitude towards typescript nor work for one.

I’ve done JS with and without types. I’d find a new job before going back to working without them. That’s how dramatic the benefits have been in my code.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by smichel17 on Thursday March 19, 2020 @07:03AM (#22626334)
I like going type-less for prototyping (pun intended), then converting to or rewriting in typescript for anything I'm going to need to maintain or refactor.
Re:RFC: Adopt a modern JavaScript framework for use with Med... by blackoil on Thursday March 19, 2020 @06:40AM (#22626217)
Ratio of open/closed issue is a very strong indicator of how active a project is. My perspective, with 21k closed and 4k open issues, shows a very active project where I should not be finding major blockers if I adopt it. If it has an issue 1000s of people are actively looking at it and it will be caught at beta stage or will be solved quickly.
Re:RFC: Adopt a modern JavaScript framework for use with Med... by MaxBarraclough on Thursday March 19, 2020 @08:54AM (#22626950)
> long past the stage when typing errors are a thing for them

Nonsense. Static type systems help you write correct code. They're also extremely helpful for refactoring. They also help readability. Outside the JavaScript world, they also help performance. The list goes on.

No-one is too smart for type systems to be helpful.

> it does not pay off at all

You've entirely ignored that TypeScript helps reduce bugs, and helps catch them earlier.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by matthewmacleod on Thursday March 19, 2020 @11:15AM (#22628253)
Typescript will not help us a dime with type checking for most of devs we hire are long past the stage when typing errors are a thing for them.

It's genuinely terrifying to think that people out there with this attitude are producing software that I might be at risk of using.

Re:RFC: Adopt a modern JavaScript framework for use with Med... by karatestomp on Thursday March 19, 2020 @03:32PM (#22630789)
Seriously. “We manage OK without static types” is one thing but “LOL we’re not n00bs so we don’t need your productivity-killing static types” is... wow. WTF. Keep anything that team writes far away from important data and processes, please.
Re:RFC: Adopt a modern JavaScript framework for use with Med... by SaxonRobber on Thursday March 19, 2020 @12:41PM (#22629167)
Sounds like you need to raise the bar on hiring if learning static typing is an impediment. I recommend less JS monkeys and looking for actual engineers.
Re:RFC: Adopt a modern JavaScript framework for use with Med... by cvlasdkv on Thursday March 19, 2020 @03:29PM (#22630765)
Their 6+ year engineers are getting paid less than many interns do in America according to said poster. The big tech monopoly means that hiring good senior engineers is nearly impossible. :)