4 ms·
Which one would you recommend? My ideal C++ alternative would be something like Swift but faster.
by RivieraKid 2y ago
Which one would you recommend? My ideal C++ alternative would be something like Swift but faster.
- nextaccountic 2y agoJust so you know, Rust is in many ways a lot like Swift, and not just because many Rust compiler devs went later to work on the Swift compiler.
- deepsun 2y agoFor low-level compiled system applications: Rust, Zig etc. For compiled garbage-collected applications (web/cli): Go. For high-level applications (web/cli/etl/desktop): Java, C#. Also here is good writeup: https://hackernoon.com/the-real-c-killers-not-you-rust https://hackernoon.com/the-real-c-killers-not-you-rust discussed here two times: https://news.ycombinator.com/item?id=34792932 https://news.ycombinator.com/item?id=34792932 https://news.ycombinator.com/item?id=39770467 https://news.ycombinator.com/item?id=39770467
- ghosty141 2y agoI have a similar opinion: For low level stuff Rust or more "obscure" langs like Zig or Carbon offer a lot in that space. The moment you leave low-level I'd always go with C#/Java or TS for web-stuff. The productivity gains you get from switching from C++ to C# are absolutely insane.
- neonsunset 2y agoLittle reason to use Go here. C# is a much better language at allowing you to tactically write high-performance low-level code where it matters and relying on higher level abstractions when it's not (struct generics are just like in Rust allowing you to expend a little effort for achieving zero-cost abstractions, although not as convenient as just using objects everywhere). Go is inadequate, poorly typed, has abysmal FFI overhead and bloated binary sizes as it does no metadata compression and other tricks C#'s AOT compilation does.
- paulddraper 2y agoWith Go, I can easily cross-compile a statically linked binary for each of the major platforms. You cannot do that with C#.
- posix_monad 2y agoCross compilation story in C# is very good actually.
- paulddraper 2y agoWith Go, I can use my Linux CI server to compile a statically linked binary for MacOS.
- posix_monad 2y agoYou can publish across platforms with modern .NET
- nickpp 2y agoBut the fact that developers often need to be able to cover any one (or even multiple) of these areas, and that language proficiency (with platform APIs and various quirks) is quite hard to achieve - makes me think that the actual alternative is the elephant in the room, the one not even listed here: JavaScript.
- deepsun 2y agoHaving been programming continuously on JavaScript for over 20 with all the popular frameworks, I'd try to stay away from it as much as possible: 1. Dynamic typing must die. Except for R/Julia/Python (aka JuPyteR) notebooks use-case, where it's awesome. My list includes only statically-typed languages. Typescript is much better, but its type-checking still fails sometimes, unlike real static-typed languages. 2. NPM is a mess that allows any transitive dependency to run arbitrary code on your machine at a time of installation (including cleaning up after itself). Compare that to Java's Maven -- libs quality is much better. no arbitrary code runs, just downloading.
- throwitaway1123 2y ago> allows any transitive dependency to run arbitrary code on your machine at a time of installation This point gets parroted so often on HN [1]. You can install packages with the --ignore-scripts flag to disable this behavior, or just set the option globally in your NPM config file. I do like the way Bun disables lifecycle scripts by default [2], but it takes me all of two seconds to run `npm config set ignore-scripts=true` on a new machine, so it's basically a non-issue for me. [1] https://news.ycombinator.com/item?id=38797176 https://news.ycombinator.com/item?id=38797176 [2] https://bun.sh/docs/cli/install#lifecycle-scripts https://bun.sh/docs/cli/install#lifecycle-scripts
- palata 2y agoAre you seriously mentioning JS as a C++ alternative? I am confused.
- nickpp 2y ago
- jandrewrogers 2y agoI think it depends on what you use C++ for. For low-level high-performance systems work, the thing I probably miss most in many of the alternatives is the extensive metaprogramming and generics capabilities of C++. This is unfortunate given both the power of this language feature and how much opportunity there is to improve the ergonomics of C++ metaprogramming.
- neonsunset 2y agoThat's C# :)
- hot_gril 2y agoRust, since you're mentioning speed. It was refreshing to use, partially because the standard library is so much nicer.