News for hackers. Stuff that matters.
Re:Why Rust? by pjmlp on Tuesday October 18, 2022 @07:36AM (#33245765)
> C++ promised to be a language that was both high performance and very expressive but I always found it very difficult to work at a high level of abstraction in C++. The sharp details always stab through.

I wonder why, doing Windows programming with OWL in 1993 was quite delightful, or Mac with AppToolbox/PowerPlant,...

Yes there is always C stuff coming throught the cracks, but I see similar aproaches with Rust code making use of unsafe when there are safe alternatives.

Re:Why Rust? by dannymi on Tuesday October 18, 2022 @08:44AM (#33246314)
>I wonder why, doing Windows programming with OWL in 1993 was quite delightful,

For me, it's because memories are not trustworthy (rose-colored glasses). Also, I had less experience back then. And we as an industry didn't know any better.

I got started in programming in Borland Pascal and Borland C++. Because of nostalgy, I've tried using them for fun again ten years ago and boy is there a reason I stopped using them in the first place. Sheesh.

Example OWL snippets:

  for (int index = 0; index < count-1; index++) {
    int len = GetStringLen(index);
    TAPointer<tchar> buf(new tchar[len+1]);
    GetString((tchar*)buf, index);
    *outStream << (tchar*)buf << _T('\n');
    //delete buf;
  }
  ...

  TClipboard cb(*this, false);
  if (cb.EmptyClipboard()) {
    int len = GetStringLen(index);
    HANDLE cbhdl = ::GlobalAlloc(GHND,len+1);
    LPTSTR buf = (LPTSTR)::GlobalLock(cbhdl);
    GetString(buf, index);
    ::GlobalUnlock(cbhdl);
  ...

  class tGastValid : public TEdit {
  public:
   tGastValid(TWindow *Win, short ID) : TEdit(Win, ID) {}
   void EvKillFocus(HWND);
  DECLARE_RESPONSE_TABLE(tGastValid);
  };
  DEFINE_RESPONSE_TABLE1(tGastValid, TEdit)
  EV_WM_KILLFOCUS,
  END_RESPONSE_TABLE;
  void tGastValid::EvKillFocus(HWND hWnd) {
    GetParentO()->SendMessage(WM_COMMAND, DB_BTGAST, 0);
    TEdit::EvKillFocus(hWnd);
  }
^-- I liked THAT? What was wrong with me ;)

That said, Borland had really good class libraries. If I had those libraries in a modern language, hey that wouldn't be so bad. But these languages? No, thank you.

Re:Why Rust? by pjmlp on Tuesday October 18, 2022 @09:00AM (#33246459)
Compared with Win16 Petzold style, that looks great, and it also reveals lack of knowledge from OWL features that don't require direct Win16 calls like raw strings instead of TString.

By the way, you should have a dive into how the "modern" development experience with Rust/WinRT compares with C++ Builder in 2022.

Re:Why Rust? by bluejekyll on Tuesday October 18, 2022 @09:24AM (#33246722)
> I see similar aproaches with Rust code making use of unsafe when there are safe alternatives.

Really? I review and read a bunch of Rust code on a weekly basis from projects I might use in various contexts. I hardly ever see unsafe used, except in contexts where it is necessary like FFI.

I am pretty sure that your comment is provably false, if someone wanted to run a report on crates.io. Oh, looks like someone did, and it trends to 0: https://www.reddit.com/r/rust/comments/g0wu9b/percentage_of_...

Re:Why Rust? by torstenvl on Tuesday October 18, 2022 @09:27AM (#33246770)
That isn't a trend line, the crates are sorted by percentage of unsafe code.

From your link: To get this plot I ordered all crates by unsafe code % and then plotted it, so each point on the graph is unsafe code % for a single crate.

The link is still some evidence in support of your position, given that it drops off close to the left edge, i.e., a small number of crates have a large amount of unsafe code. But it isn't nearly the smackdown of GP's position you must think it to be for you to be so aggressive toward them.

Re:Why Rust? by bluejekyll on Tuesday October 18, 2022 @12:44PM (#33250235)
Yes, you’re correct trend is the wrong term. Was that an aggressive statement? It wasn’t intended to be.

I find the statements around unsafe in Rust to generally be incorrect though, from what I can tell, it’s only ever used in quite narrow cases and not generally across the vast majority of Rust software.

Re:Why Rust? by pjmlp on Tuesday October 18, 2022 @01:25PM (#33250904)
Have a look at Rust/WinRT where the Microsoft team is the opinion others should provide the safer wrappers on top.
Re:Why Rust? by bluejekyll on Tuesday October 18, 2022 @08:04PM (#33255755)
Isn’t that an FFI boundary though? There are a lot of examples of FFI crates where the inner FFI is wrapped by an outer safe crate with a Rust API.

Not having looked at that API specifically, it might be that they think there are perhaps different approaches to implementing the safe interfaces, and those may be best left to specific implementations for UI abstraction frameworks, like Druid.

Just speculating.

Re:Why Rust? by cageface on Tuesday October 18, 2022 @09:27AM (#33246775)
Yeah everything was perfect back in my day and there's nothing new under the sun. You kids get off my lawn.

I've been coding C/C++ since 1995. I'll take Rust any day, thanks.

Re:Why Rust? by pjmlp on Tuesday October 18, 2022 @11:09AM (#33248433)
Are we GUI, CUDA and SYSCL yet?

Don't forget that to contribute to Rust backends on their present forms, some C++ is required.

Re:Why Rust? by badsectoracula on Tuesday October 18, 2022 @09:39AM (#33246937)
> doing Windows programming with OWL in 1993 was quite delightful

I never used the C++ version OWL (though i do have Borland C++ 5 around here, perhaps i'll try it for fun at some point), but the Turbo Pascal version of OWL (which i also really used but had a brush with - and some docs) wasn't really that great - more of a helper library for the underlying Windows API, needing to know the underlying API, in practice not very different than MFC (also more of a helper library to make using Win16/Win32 easier than something to let you ignore it).

VCL was by long long far the best API/Framework (and in some ways it still is, though FCL/LCL is better since it is richer and also crossplatform).

FWIW i did a partial recreation of Turbo Pascal OWL in Free Pascal some years ago[0]. It doesn't have much of a practical use though (unless you want to make some small GUI EXE files in Free Pascal) since i think even Borland abandoned the Pascal version of OWL and i doubt many people used it.

[0] http://runtimeterror.com/tech/fowl/

Re:Why Rust? by pjmlp on Tuesday October 18, 2022 @11:13AM (#33248494)
When the alternative was raw Win16, it was certainly delightful and felt pretty much an evolution from Turbo Vision.

Naturally VCL was even better, Microsoft is still trying to catch up with C++ Builder and failing spectacularly at it. C++/CX could have been it, but then the ATL/WRL folks at WinDev had to kill it.