News for hackers. Stuff that matters.
Re:Fish (shell) porting to Rust from C++ by xedrac on Monday January 30, 2023 @11:16PM (#34590992)
Aside from tooling (which is much better in Rust), C++ just isn't a very expressive language and has a high impedance with cognition. I've worked in C++ for well over a decade, and now that I've used Rust for a couple years, I just don't ever want to go back. It solves too many pain points of C++ to ignore.
Re:Fish (shell) porting to Rust from C++ by jandrewrogers on Monday January 30, 2023 @11:50PM (#34591296)
> C++ just isn't a very expressive language

Compared to what? Modern C++ is by far the most expressive systems language. That is its primary selling point. It isn’t pretty but it is uniquely powerful. One of the reasons C++ isn’t disappearing any time soon is that it elegantly and efficiently handles some software design problems that Rust struggles with. Rust and C++ are optimized for different types of software.

As is implied, the type of software someone is writing has a large impact on whether or not they need the expressiveness of C++.

Re:Fish (shell) porting to Rust from C++ by throwaway894345 on Tuesday January 31, 2023 @12:49AM (#34591692)
Can you elaborate on how Rust and C++ differ in the kinds of software they’re optimized for? And what makes C++ more elegant for purpose?
Re:Fish (shell) porting to Rust from C++ by xigoi on Tuesday January 31, 2023 @03:53AM (#34592858)
> Modern C++ is by far the most expressive systems language.

If you want to iterate over a range of integers, you need to manually explain to the computer how to do it. In 2023. Also, you need to Write Everything Twice because of the ancient header system.

Re:Fish (shell) porting to Rust from C++ by pjmlp on Tuesday January 31, 2023 @08:14AM (#34594630)
No you don't. That is what ranges and modules are for.
Re:Fish (shell) porting to Rust from C++ by xigoi on Tuesday January 31, 2023 @08:31AM (#34594774)
Ranges: kind of, there is the very awkwardly named std::ranges::iota_view, but it doesn't support random access and who knows if the compiler can optimize iteration over it into a simple loop.

Modules are not supported by most compilers (in g++ you have to enable them as an experimental feature with -fmodules-ts, and if you want to import the standard library as modules, you need to pre-compile them into your project directory with some arcane commands).

Re:Fish (shell) porting to Rust from C++ by pjmlp on Tuesday January 31, 2023 @09:48AM (#34595634)
Ranges: they are there, naming is a matter of taste.

Modules: GCC and clang will eventually get there, I am already enjoying them on VC++

Re:Fish (shell) porting to Rust from C++ by jstimpfle on Tuesday January 31, 2023 @01:25PM (#34599397)

    #define RANGE(type, name, last) type name = 0, last__ = (last); name != last__; name++

    for (RANGE(i32, i, foo->count))
        ...
That solves the problem even in C. But why care much, typing a few plain loops isn't among the hard problems to solve.
Re:Fish (shell) porting to Rust from C++ by aldanor on Tuesday January 31, 2023 @07:29AM (#34594242)
Compared to Rust.

Once you you've worked enough with proper enums and matches, that's the first thing you'll be lacking in C++ (and no, std::variant is a horrible mess without proper syntax support and doesn't even get close).

Re:Fish (shell) porting to Rust from C++ by cozzyd on Monday January 30, 2023 @11:57PM (#34591358)
If anything, C++ is too expressive...
Re:Fish (shell) porting to Rust from C++ by ahartmetz on Tuesday January 31, 2023 @12:43AM (#34591642)
There is a difference between what you can do at all, and what you can do without hard thinking. C++ makes a lot of things possible, but fewer things easily possible. I program mostly in C++ and I don't hate it, FWIW...
Re:Fish (shell) porting to Rust from C++ by throwaway894345 on Tuesday January 31, 2023 @12:48AM (#34591684)
Agreed, but I would probably still be programming in C++ if the tooling weren’t so bad, irrespective of the expressiveness. That said, I’m glad Rust is expressive, but more glad that it picked a coherent set of language features—it feels much less cobbled together than C++ if only for the benefit of hindsight.
Re:Fish (shell) porting to Rust from C++ by pjmlp on Tuesday January 31, 2023 @02:08AM (#34592201)
Not very expressive? Are we talking about ARM C++ here?

C++ has lots of problems, lack of expressiveness isn't one of them.

Re:Fish (shell) porting to Rust from C++ by simplotek on Tuesday January 31, 2023 @02:19AM (#34592273)
> C++ just isn't a very expressive language and has a high impedance with cognition.

I feel that you are the very first person ever making such a statement. Can you provide what's your single best example showing C++'s inexpressiveness and "high impedance with cognition"?

Re:Fish (shell) porting to Rust from C++ by aldanor on Tuesday January 31, 2023 @07:32AM (#34594273)
Sum types. And/or proper error handling (also related to sum types).