News for hackers. Stuff that matters.
Re:Can Rust Beat JavaScript in 2023? by andybak on Friday April 21, 2023 @08:51AM (#35652941)
Does anyone remember when the trend was towards expressivity in languages? At th time that meant dynamically typed languages like Ruby and Python.

The pendulum has swung away from dynamic typing but are we sometimes sacrificing expressivity as a result?

I don't really know Rust but from what I've seen of it, it doesn't feel like a natural fit for the web - either front or back-end.

Maybe I'm missing something?

Re:Can Rust Beat JavaScript in 2023? by nicoburns on Friday April 21, 2023 @09:13AM (#35653225)
> Maybe I'm missing something?

IMO Rust is more expressive than most languages including languages like Python. Traits and enums are just... a joy to work with. It is also more constrictive in some ways, and a rust-like high-level language could do probably do better still (Swift/Kotlin/Elixir are close).

There's also a tradeoff between expressivity and performance and correctness. The way I see Rust is you get maybe 75% of the expressivity, along with much better performance and correctness guarantees.

I'd agree it's not a good fit for frontend, but IMO it's an excellent fit for backend.

Re:Can Rust Beat JavaScript in 2023? by krn on Friday April 21, 2023 @09:03AM (#35653085)
I believe that many people from Ruby on Rails and Django communities moved on to Clojure, Elixir, and Kotlin.

Others chose between Rust and Go, if performance was the most important thing.

The thing about dynamically typed languages and their expressiveness, is that you are sacrificing the ease of long-term maintenance for the ease of short-term prototyping.

Personally, I am a big fan of Clojure as a tool for designing software, but I would prefer having to maintain a code base written in Rust.

Re:Can Rust Beat JavaScript in 2023? by fulafel on Friday April 21, 2023 @09:27AM (#35653404)
Even the maintainability argument is suspect I think: Static type systems as commonly used are not very powerful compared with schema validation style approaches used in the dynamic languages world (eg malli or spec in Clojure world). Static types lose in expressiveness, flexibility of when & where they are enforced, and ability to pass around the data shape specifications as data.
Re:Can Rust Beat JavaScript in 2023? by krn on Friday April 21, 2023 @09:52AM (#35653752)
That's true, and Clojure (when used with metosin/malli) is probably the only reasonable alternative to statically typed programming languages in terms of long-term maintainability.

Essentially, it's like two completely different reasoning models: inside-the-box (ALGOL / SQL), and outside-the-box (LISP / Datalog).

The first model (ALGOL / SQL) is about designing for machines to better understand, and the second model (LISP / Datalog) is about designing for humans to better understand.

I think that the main issue with dynamically typed languages is the lack of robust enforcement.

Re:Can Rust Beat JavaScript in 2023? by kaba0 on Friday April 21, 2023 @06:29PM (#35661098)
I believe it is a lost fight, but why have Rust and Go become a collocation?! It’s as faulty as C++ and JS.
Re:Can Rust Beat JavaScript in 2023? by krn on Saturday April 22, 2023 @05:06AM (#35664643)
Go becomes an answer when one is willing to trade the correctness of Rust for a garbage collector and a bullet-proof standard library.
Re:Can Rust Beat JavaScript in 2023? by kaba0 on Saturday April 22, 2023 @07:04AM (#35665286)
So does Java, C#, D, Nim, Haskell, OCaml, and a litany of other languages.
Re:Can Rust Beat JavaScript in 2023? by krn on Saturday April 22, 2023 @08:51AM (#35666122)
Rust and Go were designed with concurrency and portability in mind – unlike Java (which requires the JVM), C#, D, Nim, Haskell, or OCaml.
Re:Can Rust Beat JavaScript in 2023? by kaba0 on Saturday April 22, 2023 @09:08AM (#35666257)
Java literally has a synchronized keyword and it literally runs on your SIM/bank card, was originally created for DVD players, and runs on every major OS. Plus it used to have 20 years ago as well, but has right now also ways to produce a single native binary.

Rust is a low-level language, quite similar in the target niches to C++, while Go is a managed language with a barely-optimizing compiler for fast compile times, and a GC that prioritizes latency over throughput. They are nothing alike.

Re:Can Rust Beat JavaScript in 2023? by krn on Saturday April 22, 2023 @10:01AM (#35666690)
Rust and Go are very much alike, when Java is not an option because of the JVM startup time and memory requirements (GraalVM Native Image solves this, but at the expense of highly reduced performance).
Re:Can Rust Beat JavaScript in 2023? by kaba0 on Saturday April 22, 2023 @11:20AM (#35667480)
GraalVM native might have worse performance than the same application running on the JVM, but highly reduced is a scratch.

And sure, just as alike as Rust and D, Haskell, OCaml - they all produce a native binary with in-built GC, just like Go.

Re:Can Rust Beat JavaScript in 2023? by galangalalgol on Saturday April 22, 2023 @12:16PM (#35668066)
I'm not sure what your use case is that only rust and gonare options, but is unusual.

NIM supports concurrency and is as portable as the c and js it can generate to.

C#/F# work on x86 and arm which covers most targets today. And supports concurrency. And is situationally more performant than go.

I can't speak to the other languages mentioned, but they all seem quite similar to go as well, except for haskell.

Rust is more like c, c++, zig, ada etc.

Re:Can Rust Beat JavaScript in 2023? by krn on Sunday April 23, 2023 @04:48AM (#35674555)
I see Rust and Go as the best high-performance high-concurrency programming languages today, and choose between Rust and Go depending on the bottleneck (Rust – CPU / RAM, Go – I/O).
Re:Can Rust Beat JavaScript in 2023? by miniupuchaty on Friday April 21, 2023 @09:21AM (#35653331)
That depends on what do you mean by expressive. I would call languages with more advanced type systems, like rust here, more expressive, as in allowing programmer to express his intention to both computer and other programmers clearer.
Re:Can Rust Beat JavaScript in 2023? by rob74 on Friday April 21, 2023 @09:10AM (#35653176)
"Compiled language" doesn't have to mean "much harder to read" though. I guess that's why many web devs like Go - it's a compiled language that feels more like a dynamic language because it tries to get the types out of the way as much as possible. Of course it doesn't have all the bells and whistles of Rust (now that generics were added, the next major complaint is nullability), but that's exactly what makes it easier to grok.
Re:Can Rust Beat JavaScript in 2023? by KingOfCoders on Friday April 21, 2023 @08:55AM (#35653004)
After some years chasing exprssivity with Typescript and Scala, I now really enjoy the dumb simplicity of Go.

I do think we'll see more simplicity (not Lisp-like) in the future.

Re:Can Rust Beat JavaScript in 2023? by bayesian_horse on Friday April 21, 2023 @09:00AM (#35653059)
Both Python and Javascript are eating Rust's lunch in terms of popularity. And Typescript is just a typechecker, it's still a very dynamically typed language/runtime underneath.

Especially with Rust you have to think way more about banalities of the data model you normally really don't care about in web development.

Re:Can Rust Beat JavaScript in 2023? by TheRealDunkirk on Friday April 21, 2023 @09:01AM (#35653064)
You are not missing anything. I think people are going crazy for strict static typing because they want to feel like they're on the front edge of progress. But I don't think it's _better_; I think it's just _different_. I got bogged down in with Java and Angular awhile back. The amount of boilerplate required to keep the front end and back end compilers in sync was treacherous. Also, I had to make exceptions for corner cases that wouldn't match up. So it was no benefit to me. Maybe if your application is large enough that it involves big teams on each side, you would need static typing to keep everyone straight. And I think this is a large part of the back-and-forth on this forum. We discuss things that vary based on problem context without realizing (or admitting) that the implementation is situational.
Re:Can Rust Beat JavaScript in 2023? by wiz21c on Friday April 21, 2023 @09:11AM (#35653198)
I code alone and need performance for my project. I had choice beween C++ which I know a bit of; Go or Rust which I had to learn. Considering that I screw my mallocs and threads in C++ more often than not, I decided to check Rust. I am not disappointed: the safety helps a lot in getting my codebase free of many bugs (rust won't let me be lazy, I have to solve many bugs upfront). Sure the BC is madenning at times, but the support of the compiler allows me to not think too much about what I do and spend time on my business.

Now, on my old PC, the compiler is super slow so I end up prototyping tricky stuff (like maths) in python and then I port it to rust when I feel it's ready.

(my stuff is emulator: no DB, not much GUI but lots of performance, threading, etc.)

Re:Can Rust Beat JavaScript in 2023? by jvanderbot on Friday April 21, 2023 @01:41PM (#35657350)
Not to be too snarky, but malloc really seems out of place in modern c++.
Re:Can Rust Beat JavaScript in 2023? by wiz21c on Saturday April 22, 2023 @11:37AM (#35667619)
yeah, I admit it's been a long time :-)
Re:Can Rust Beat JavaScript in 2023? by TexanFeller on Friday April 21, 2023 @09:31AM (#35653464)
Java's type system is anemic compared to modern languages, please don't use it as the point of comparison in typed vs untyped debates.
Re:Can Rust Beat JavaScript in 2023? by kaba0 on Friday April 21, 2023 @06:27PM (#35661077)
If we for some weird reason were to put go as a modern language, than Java is some Haskell :D

But jokes aside, Java’s type system can’t express HKTs, but up to that point it really is surprisingly strong — there is vavr, but I have also personally followed my former “define Haskell basic data types yourself in Haskell” class quite far in it, including Lists, Eq trait, Maybe type, etc.

Re:Can Rust Beat JavaScript in 2023? by jvanderbot on Friday April 21, 2023 @09:08AM (#35653145)
I disagree that you aren't missing "anything", there's no such thing as a free lunch. But I agree that _some_ of the uptick is because people are excited about being a "safe" and "rigorous" developer, but they get a nice package manager with Cargo that feels a lot like pip or npm.

I get a question over and over from front end devs when I teach or mentor about being a "real" computer scientist and picking up c, Cpp, or rust, which is silly. Who do you think invented the dynamically typed languages, English majors?

Re:Can Rust Beat JavaScript in 2023? by shrimp_emoji on Friday April 21, 2023 @09:15AM (#35653238)
>there's no such thing as a free lunch

Yeah. The bill was paid when the language devs bothered to write a compiler, so that your runtime bugs become compiletime bugs and so you can understand what's happening when your program is bigger than a tiny script.

Re:Can Rust Beat JavaScript in 2023? by qtzaz on Friday April 21, 2023 @08:57AM (#35653025)
Personally, I expected dynamic languages to ever match or at least get close to the performance of static languages. That seems that it will never happen, and there's a point where I can't afford that much hardware just to run a website. Think of Twitter abandoning RoR, etc.
Re:Can Rust Beat JavaScript in 2023? by andybak on Friday April 21, 2023 @10:01AM (#35653903)
Several dynamic languages are faster than some static languages depending who you talk to. LuaJIT is famously fast and Javascript is no slouch
Re:Can Rust Beat JavaScript in 2023? by ModernMech on Friday April 21, 2023 @09:02AM (#35653078)
It makes more sense coming from the Rust side. For example, I can write a lightweight desktop app using the egui rust framework. But I can also compile that for the web, and run it in the browser. Basically for free, I just have to target wasm.

This also means that if you architect your app right, you have have the front-end and back-end self contained in the same app, or split them over a network boundary.

So let's say you are writing a 3d modeling app or something. You write the engine and the gui in rust, and you ship that binary to your users. You can then also, again basically for free, put a network between the gui and the rendering engine, then you can serve the gui to client browser, and handle the rendering on a server.

The point is this is easy for the rust dev, so they don't need to be a JavaScript dev as well.