by bluefishinit · 3y ago · 0 comments
If all you have are TS developers, writing a CLI in TS is not just fine, it's the right decision. Forcing Rust upon them is not going to make anyone involved more happy.
Where I live, (a) there's much more junior and mid-level talent with 0-2 years of experience than anyone else, (b) talent is far more likely to have TS/JS experience.
If you hire for JS talent, you ship. If you try to hire anybody else, you struggle to hire, struggle to collaborate ("I don't know X, so I'd prefer to open a ticket than to struggle and open a PR to that other team's repository"), and therefore ultimately struggle to ship.
Startups should run on the JS ecosystem by default and only write code in other ecosystems if there's a very good reason to do so (business competitive advantage, JS ecosystem options are severely lacking...).
But that's never going to be the best tool for CLI development, and someone with no experience outside of JS/TS (or any single language) is never going to be the best engineer.
Sure I could ask my devs to write our CLI tools in Rust, and some of them would habituate to both languages but there’s no denying it’s a higher mental burden to split training time between two languages, or three languages.
The only way I’m going to learn a new language is if my work requires it and makes time for me to learn it. Well, we have far too much work to do to carve out time to learn new languages, so they just keep us using what we already know. That’s fine with me. I receive a hefty six figure income to pay for my life outside of work.
And in general I expect that the actual work I'm doing will be more interesting than the programming language I get to use. I really enjoy learning new things, and digging into new programming languages just for the sake of it, but when I need to actually ship something I don't want my programming language to be the exciting part of what I'm doing.
If by TS you mean Javascript with ": any" tacked onto the end of each variable, then perhaps. Actual TS proficiency is rare, in my experience.
But if proficiency is a concern, you're not going to slap any random web developer on a command line tool project. It is an entirely different skillset. Amongst the developers proficient in command line tools, I expect the common language they are familiar with is typically not TS.
A lot of common screwdrivers can turn Philips head screws enough to get the job done.
Does it change anything to reframe this as having a common denominator across all developers? As in, rather than “All of my developers know only TS” to “TS is the common language all of my developers know”.
Particularly in small companies I think it makes more sense to focus on a restricted set of tools and technologies. It makes interviewing easier, ensures mobility of hires to different areas of the code, and produces an easier onboarding experience for new team members.
> It is also boring using only one programming language every day
Interest and passion come from more aspects of a project than the language it was written in. Some projects are interesting because of they incorporate cutting edge research, some because they have highly visible impact on users, and others because the solution involves a careful balance of design constraints. Choice of (or diversity between) language doesn’t have to be the distinguishing factor that makes a project interesting.
[1]: https://andrewkelley.me/post/not-a-js-developer.html
[2]: The creator of Zig[3]
[3]: https://ziglang.org/
I do agree that is boring, but it also pays the bills!
Maybe most people are not good human based on your definition.
Companies should be properly staffed to support the platforms they're distributing on. If you're building a CLI tool, you should have devs familiar with doing that use an appropriate language. You should not repurpose front-end web developers to build the CLI tool in a web front-end language just because that's all they know. That's pushing your business, training and hiring problems down to the user.
Not to say web front-end devs can't make great CLIs (or servers)! It's just that they should train up on an appropriate stack if they're going to do so.
That's his point, though. Command line tools require a different skillset. If a team has only worked on browser applications, they won't have the skills for command line tools and will need to learn them. Taking time to learn contradicts the grandparent comment, which suggests that people should stay in their lane and that there is nothing worse than forcing developers to work on things they are not already familiar with.
If one is going to hold that developers shouldn't be forced to learn on the job, even if by way of fellow teammates trying new approaches that others will need to maintain, you simply can't have them working on CLI tools and bringing on new teams that will operate independently is the only way to see movement into new areas.
I do acknowledge I have a lot of bias, though, because I work at a TS shop where the primary reason we continue to use it is because we always have. The longer I have to put up with it, the more I feel like this is a broken foundation to stand on
I'm not saying that performance, memory consumption etc. are completely insignificant. I myself prefer to use faster tools that use less memory. But if all you have is a bunch of Typescript devs, and you want them to develop a CLI, you're not going to get a better result by telling them to do it in Rust. To get a better result you'd have to tell them to learn Rust and work in it for half a year. And yes, that would be better for users in the long run, but that doesn't mean it's realistic in all cases.
And I wouldn't strictly differentiate between these areas. My game development experience helps me to write better backends and frontends alike. They are separate insofar that you have to learn each environment to be able to write idiomatic code, but it's not like you can't re-use parts of your knowledge across all of them.
It was a bad combination of "green" JS engineers writing servers and a new batch of fresh FAANG veterans mentoring them into writing extremely complex and expensive systems. There is a large dollar value attached to this fiasco.
Another one would be to pick Java or C#, but the stereotype of a developer like that is that they will overcomplicate and make a heavy, enterprisey back-end; Node backends feel lighter, so I can again understand why they would rather have a Node / JS type developer, they're more pragmatic.
Ideally you'd get a "polyglot" developer, or a developer who has embraced that language is just an implementation detail, someone who can see beyond a language and its ecosystem and stereotypes. But the hiring pool for those is small, and convincing them to work for your company is really difficult if it doesn't do anything exciting, new, or cannot pay a lot.
That's kind of the approach I'm proposing. Don't care about the language, use the one your developers know best, because the language itself is just an implementation detail, while the proficiency will help you in any language. You're not going to get a large group of great polyglot developers, so you have to reverse the process and choose the language your developers know best.
I think there are much, much worse things than this. Most of the time, I would count among those things the humongous downsides of JS, but it depends on your situation, obviously. There are plenty of cases where you should use JS/TS. But if I only knew TS and had an opportunity to write a CLI in Rust, I'd jump at the opportunity. It's not always the case, but lots of things are appropriate to use as an excuse to learn something new.
Could you explain these "humongous downsides of JS"?
Just write it in C# and take the afternoon off.
But I think you're making a mistake in assuming they mean someone should force a specific language on them. In practice nearly every working TS dev knows something else, python, ruby, elixir, yeah maybe go. They should choose one of those other languages for the tool. A specific one doesn't need to be forced on them, just the decision that it should not be TS.
I was with you when you said command lines, but servers? JS is a fine choice for servers. I haven't seen Rust do anything on the server but slow people down, and I have found people who think they know Rust don't really
Plenty of people are productive in JS, and when working with ES6, it can even be comparable to immutable functional languages. It's on the team if they aren't reviewing code or are allowing bad habits.
I disagree. JS is single threaded. Sure there are some hacks to kinda, sorta get around that, but it's the nature of the language. Tying yourself to a single thread or dancing around that is an unnecessary restriction that compiled languages aren't going to have. JS is designed for web pages, not servers and not apps.
Zig looks promising, but the ecosystem isn't mature yet. Suggesting that Zig can replace a production-grade server based on Express.js today is.. madness.
> completely ignoring the ecosystem that makes shipping projects possible in the first place.
There are so many bad js libraries out there, more than any other language I've ever seen. There's no special sauce in the JS ecosystem, there's tons of libraries available for any modern language (not Zig, I included that as it probably will get there). There's nothing you can do in JS that you can't also do in Go and the quality of the library your using is going to be much higher than whatever's on NPM.
JavaScript's async IO is plenty fast for any typical web use case, and the marginal savings you might get from having a few fewer servers will be more than made up for by the time your team of web developers (who already know JavaScript) wasted learning Rust or Zig.
Multithreading is a nice to have; it has a bunch of costs around needing to introduce locking and synchronization primitives into the language, those costs aren't the worst thing ever but it's often nice to not have to deal with them.
This statement is the reason we're all having to use Electron applications.
The amount of tooling that you need to use to surround your JavaScript code to make it somewhat correct is insane.
You're using a dynamic language. There is literally a whole slew of bugs that you cannot detect until you actually run the code.
You do get those things with Rust.
Getting Rust (same like when I used F#) to compile is hard.
But claiming that that is the reason JavaScript is faster is actually a reflection of not understanding what this compilation does for you.
I didn't even kind of say this. Rust is complicated for reasons beyond compilation. I actually like F# and strong type systems.
> The amount of tooling that you need to use to surround your JavaScript code to make it somewhat correct is insane.
There's no practical evidence of this, it's just a feeling you have. Big systems are built in dynamic languages fine.
> This statement is the reason we're all having to use Electron applications.
How is "JS is fine for servers" the reason you have to use Electron apps? Pick a topic. I am not overapplying JS
> You're using a dynamic language. There is literally a whole slew of bugs that you cannot detect until you actually run the code.
If you're using Rust, you're introducing a whole slew of bugs that you cannot detect unless you compile the code, and that you wouldn't run into in a GC language. And you're potentially doing it for no benefit because you don't understand servers aren't typically CPU bound.
For me (and, I would argue, for pretty much everyone), that would probably be whatever programming language I am most familiar with. Unless the language has huge barriers compared to another one I am somewhat familiar but less familiar with.
I wish the dogmatic hate on JS would stop, it was boring 10 years ago, it's still boring.
Even if that part of the desired outcome is true (it's not though, as it rarely takes into consideration long term benefits and focuses purely on "instant gratification"), people who go to online programming forums as HN are hobbyists. And hobbyists do care about tools. You can't expect enthusiast to have this boring approach of someone who simply want to finish job on passable level and get the fuck out of office as quickly as possible.
And even if you are not a hobbyist, using a computer to do your/some job for you is literally what programming is about. So dismissing the topic of improving that process with better tools is simply ignorant
The Javascript hate is absolutely warranted.
I genuinely don't understand how someone could make a statement like this. You mention command line apps and servers, but surely whether TS is the best solution would depend entirely what you're trying to achieve. If there's a great NPM library to help you with the problem you're solving why wouldn't you use TypeScript?
Not to mention the fact that TypeScript servers when paired with web frontends have obvious advantages. One project I worked on involved analysing 3D objects then visualising this on a web app. The simplest solution we found for visualising the analysis we were doing on the backend was just to build it all with Three.js and TypeScript then use common libraries.
I'll also note that good JS developers are generally competent enough to avoid "bad habits" and that "bad habits" in my experience are not isolated to the JS ecosystem.
Here are the criteria I'd use for choosing a language for a web server, in order of importance:
1. What does my team already know?
2. What languages have a robust ecosystem of web-related libraries?
3. Static types are better than dynamic if the team is larger than 1 or if the project will last more than 6 months.
Performance considerations might come in after this if there are still two languages left to decide between. But judging from those criteria, I think you can see why TypeScript would not be a bad choice for a full stack web team.
Learning a new language should be a frequent thing. I don't know how many languages I have learned, but it has only ever increased my understanding of computer programming, advantages and disadvantages of approaches and it certainly has made me a better engineer. If a business does not want better engineers, sure, stick to the "we can only use what we already know!" approach.
Let it take 2 weeks for people to learn a language! So what? It will pay off in the long run. You will have more experienced engineers, we have a less limited idea about computer programming and how to solve programming problems well, since they have gotten into contact with other concepts from other languages. You also get a more flexible team, that can accept building better and safer services, using the right tool for the job, instead of shoehorning everything into their only one language. You will open up more ecosystems for your whole business.
Zig may be useful in some contexts but it’s also in beta and it has a bus factor of one.
Rust is unnecessary for most projects that don’t need the extreme degree of efficiency it offers and would rather have a GC do all that work for them.
Go is fine, if you get along with it. Many people don’t like it because the type system is from the 1980s, but if you like that kind of thing then go ahead.
Why choose Typescript over any of the other hundreds of languages that transpile to JavaScript?
There may be a few exceptions that were designed from the outset with JavaScript in mind, but then you're back to being at the mercy of JS quirks.
Of all the languages you could pitch to someone already familiar with JS these would be at the bottom of the list. You want something dynamically typed, well trodden, and with a huge package ecosystem which to me sounds like Python or maybe Ruby. But honestly JS minus mountains of tooling is a really good general purpose language.
This is a joke, right?
It's enough knowing client/server types move together, avoids null/undefined/[]/0/falsy edge case bugs, param/return mismatches, etc.