News for hackers. Stuff that matters.
Re:Fish (shell) porting to Rust from C++ by __jem on Monday January 30, 2023 @09:13PM (#34590006)
People always assume people who like Rust and are a bit more hesitant about C++ are just hype driven haters. I'm mostly exposed to C++ through my hobbies in creative coding, graphics programming, etc., and I would like to be a better C++ developer and be more comfortable with those projects. But every time I have to set up a new project it feels like death by a thousand cuts, and the fun art project I was about to work on just becomes a painful chore. I never, ever feel this way with Rust, even though it's significantly more immature in this space.

Maybe I'm just one of those spoiled younger developers who expects great DX on all my tools, but it makes me really reluctant to invest more time into learning C++ when I could be contributing to open source Rust and improving the ecosystem. Getting better with C++ just feels like learning an endless series of sharp edges.

Re:Fish (shell) porting to Rust from C++ by vvanders on Monday January 30, 2023 @11:50PM (#34591301)
This was something that Microsoft did really well back in the Visual Studio days. That said Rust really raised the bar not just on tooling but the whole end-to-end experience and with cross-platform being table stakes now it really makes for a compelling choice.
Re:Fish (shell) porting to Rust from C++ by pjmlp on Tuesday January 31, 2023 @02:07AM (#34592189)
Well, it is no surprise given their C++ investment, that Microsoft keeps briging more Rust like experience into Visual C++ then.

They are adopting Rust in some small spots like Azure Sphere, and Rust/WinRT, yet WinDev, XBox, Office, .NET (for the runtime), DirectX aren't getting rid of their C++ code anytime soon.

Rust experience is compeling if one doesn't need to rewrite the world, e.g. doing CUDA in C++ versus Rust.

Re:Fish (shell) porting to Rust from C++ by brundolf on Tuesday January 31, 2023 @12:38AM (#34591608)
Seconded. I can have fun using Rust, I can't have fun using C++, so Rust is what I've spent the past ~4 years getting more and more familiar with. Now I'm at a point where I could apply to Rust jobs, but certainly not C++ jobs
Re:Fish (shell) porting to Rust from C++ by vintermann on Tuesday January 31, 2023 @08:23AM (#34594697)
Considering this is a volunteer driven open source project with a high "for the heck of it" factor (Wikipefia: "Fish is considered an exotic shell since it does not rigorously adhere to POSIX shell standards"), I don't think the having fun argument is quite as bad as all the serious people say.
Re:Fish (shell) porting to Rust from C++ by brundolf on Tuesday January 31, 2023 @02:17PM (#34600319)
Yeah, but I was also making a further point: if everyone uses the enjoyable language in their spare time, and nobody wants to use the miserable one unless they have to, you get a gradual brain-drain. More and more people have more and more experience with the fun one, and over time it gets easier to hire for (or find contributors for)

Of course it's sticky- someone who's already an expert in the miserable language may not choose to totally re-skill themselves (and anyway, once you know something that well it tends to become less miserable). But the new generations will heavily favor the thing that's welcoming to them, not the thing that's prickly

Re:Fish (shell) porting to Rust from C++ by simplotek on Tuesday January 31, 2023 @02:12AM (#34592221)
> But every time I have to set up a new project it feels like death by a thousand cuts

Which part of the following example is hard:

program(mynewproject LANGUAGES CXX)

add_library(libfoo STATIC foo.cpp )

add_executable(bar bar.cpp main.cpp )

target_link_libraries(bar libfoo )

Edit: and this message was downvoted? Seriously?

Re:Fish (shell) porting to Rust from C++ by lifthrasiir on Tuesday January 31, 2023 @02:37AM (#34592403)
You completely ignored dependencies, which in my experience everyone seems to handle differently (and definitely not in a declarative way).

Differently put: a phrase "metabuild system" has both a lexical sense and an idealized sense. The lexical sense would be something that generates an input to build systems. The idealized sense would be something that does everything else not possible or difficult in build systems. CMake was definitely far from that ideal [1]; it was often simpler to make a configure script in your favorite language (and, for god's sake, not in M4) than using CMake.

[1] Was using a present tense but edited after realizing that I don't know much about recent changes to CMake. Still enough to justify my (and others') criticism.

Re:Fish (shell) porting to Rust from C++ by simplotek on Tuesday January 31, 2023 @02:59AM (#34592545)
> You completely ignored dependencies

Not really. When people talk about setting up a new project, they talk about starting a hello world project and build up from there.

Anyway, I'll bite. What would it take to add a dependency? If it exports a cmake config file which exports targets, all it takes is this:

find_package(MyDependency),

target_link_libraries(bar MyDependency::targetA MyDependency::targetB ... MyDependency::targetZ )

If it doesn't and it is instead a system library then you can even pass the library instead.

add_library(bar systemlibrary )

If the library exports no cmake config and you have anything exotic you can put together your own cmake find modules, and proceed to follow step A.

Alternatively, you can even bolt on something like Conan and just follow step A all the time.

> Differently put: a phrase "metabuild system" has (...)

Sorry, but do you actually have any concrete example of any difficulty setting up a C++ project?

Re:Fish (shell) porting to Rust from C++ by lifthrasiir on Tuesday January 31, 2023 @03:16AM (#34592634)
> When people talk about setting up a new project, they talk about starting a hello world project and build up from there.

The original reply said one dabbled C++ via "creative coding, graphics programming, etc.", which definitely needs dependencies from the beginning. Can you draw a nicely shaded triangle only with the C++ standard library?

> If the library exports no cmake config and you have anything exotic you can put together your own cmake find modules, and proceed to follow step A.

They are not exotic, libraries without cmake config are common. So, as I've said before, people had to come up with their own find modules and this requires lots of trial and error to get it right. Guaranteed, it might have been possible to collect those into some sort of registry (a la DefinitelyTyped for TypeScript .d.ts files), and probably something like Conan can provide that, but ideally that should have been built into CMake. And keep in mind that Cargo---something we were comparing against back in time---does all of them declaratively. (Arguably, from users' perspective, it can handle C/C++ dependencies better than CMake!)

Re:Fish (shell) porting to Rust from C++ by simplotek on Tuesday January 31, 2023 @06:30AM (#34593838)
> The original reply said one dabbled C++ via "creative coding, graphics programming, etc.", which definitely needs dependencies from the beginning. Can you draw a nicely shaded triangle only with the C++ standard library?

Taken straight from Qt's page on OpenGL support:

find_package(Qt6 REQUIRED COMPONENTS OpenGL) target_link_libraries(mytarget PRIVATE Qt6::OpenGL)

https://doc.qt.io/qt-6/qtopengl-index.html

Do you feel this is too hard to setup?

Re:Fish (shell) porting to Rust from C++ by lifthrasiir on Tuesday January 31, 2023 @06:42AM (#34593918)
That's because Qt 6 wholeheartedly converted to CMake for you. (At least it is better than qmake.) In order to support this Qt has this large battery of CMake files [1]. Qt is of course a clear outlier, but you can't expect the same level of support from every other library you want. My points about "anything exotic" still stand.

[1] https://github.com/qt/qtbase/tree/dev/cmake

Re:Fish (shell) porting to Rust from C++ by simplotek on Wednesday February 01, 2023 @03:35PM (#34617248)
> That's because Qt 6 wholeheartedly converted to CMake for you.

It's not Qt6. The same goes for Qt5, which has been around for what, close to a decade?

And what's your point, exactly? That things are hard if you purposedly ignore all the examples that prove that things are patently easy and trivial? Because it seems evident to me that if you want to quickly setup a C++ project to try out stuff, a CMake project with single-digit lines of code that get you a window with an OpenGL context going is right what you'd be looking for.

But instead you complain that the choice of build system and framework made things easy? And that's why things are not hard

What exactly do you think is your point?

Re:Fish (shell) porting to Rust from C++ by __jem on Tuesday January 31, 2023 @11:30AM (#34597307)
Yes! I spent 2 hours the other day trying to figure out why some OpenGL header had moved in between macOS versions, or had failed to install correctly with Xcode. OpenGL is indeed, not an exotic library, but this is the perfect example of why working on these projects is annoying. It's totally platform dependent, and while people who spend most of their time in C/C++ land are used to hunting down system libraries, "where does this random file that got installed with unrelated platform toolchain get installed" is painful.

I have no doubt that people who work on big commercial C++ project have sensible build systems and documentation that's not too hard. But it's incredibly common when working in this art/graphics space to need to try to get someone's bitrotted random project without docs or build system running. Common to have to do that AND have to do it on another platform.

Re:Fish (shell) porting to Rust from C++ by cozzyd on Tuesday January 31, 2023 @12:16PM (#34598055)
OpenGL is particularly strange because the libraries can be provided by the graphics card vendor.

That said... Rust and OpenGL have quite an impedance mismatch, don't they?

Re:Fish (shell) porting to Rust from C++ by __jem on Tuesday January 31, 2023 @12:38PM (#34598445)
There totally is an impedance mismatch. It's definitely not as bad as you might think, but this is exactly the reason that I theoretically want to use C++. Art code is the perfect example of code where (a). mutability is whatever / good and (b). safety literally does not matter. Its the ultimate domain of hacking something together to make something pretty on the screen, not serious software engineering.
Re:Fish (shell) porting to Rust from C++ by nicoburns on Tuesday January 31, 2023 @05:58AM (#34593679)
In Rust, using a library is as simple as “cargo add library”, and this is always the case. It’s even the case for most popular C/C++ libraries which tend to have Rust wrappers available that seamlessly integrate them with cargo.
Re:Fish (shell) porting to Rust from C++ by pjmlp on Tuesday January 31, 2023 @11:17AM (#34597092)
In modern C++ if one isn't using either vcpkg nor conan, they shouldn't complain about having an hard time to find libraries.

The options are there to be used.

Re:Fish (shell) porting to Rust from C++ by Const-me on Tuesday January 31, 2023 @06:24AM (#34593811)
> do you actually have any concrete example of any difficulty setting up a C++ project?

Take a look: https://stackoverflow.com/questions/75270938/thread-pool-wit...