Live data from Hacker News

Ask HN: Learn C++11 or Rust in 2022?

news.ycombinator.com

131–140 of 161 posts

Re: Ask HN: Learn C++11 or Rust in 2022?

#131
post #130

Earlier quoted context omitted.

Surely in any language you would have to learn tooling ? What happens when your user report performance problems on Python, Java or JS programs, you surely use some profiling tool there, no ?

If you use Python and JS chances are you do some form of web development, where most performance issues have to do with I/O, and most of those I/O issues are caused by bad queries. It ultimately comes down to using application performance monitoring software and analyzing query plans. Memory issues are an oddity and are usually caused by users doing stuff like uploading gigantic files.

> using application performance monitoring software and analyzing query plans.

soo... tooling ? how is that different from using valgrind ? it's literally one click in my IDE to use it and it will show e.g. the time spent at each line of code directly in it.

> If you use Python and JS chances are you do some form of web development, where most performance issues have to do with I/O, and most of those I/O issues are caused by bad queries.

I don't know about this, what I know is that multiple times in my career I had people come at me with python software that was slow, and transliterating them almost line by line to C++ made them much, much, much faster.

Also I have all these apps on my system which apparently depend on python, none of them being a web app:

    Name            : 3dsconv
    Name            : anydesk-bin
    Name            : arandr
    Name            : asciidoc
    Name            : bind
    Name            : binwalk
    Name            : bpytop
    Name            : breezy
    Name            : carla
    Name            : ceph-libs
    Name            : cmake-format
    Name            : cppcheck
    Name            : cppman-git
    Name            : cython
    Name            : deluge
    Name            : deluge-gtk
    Name            : diffuse
    Name            : distcc
    Name            : fio
    Name            : fontforge
    Name            : fvwm
    Name            : fwupd
    Name            : gconf
    Name            : gcovr
    Name            : gdb
    Name            : gdb-common
    Name            : gdown
    Name            : glusterfs
    Name            : gnome-tweaks
    Name            : gobject-introspection
    Name            : gtk-doc
    Name            : i3-workspace-groups-git
    Name            : ibus
    Name            : inkscape
    Name            : iotop
    Name            : ipython
    Name            : itstool
    Name            : jack_mixer
    Name            : kajongg
    Name            : kig
    Name            : kitty
    Name            : kitty-shell-integration
    Name            : libffado
    Name            : libixion
    Name            : libopenshot
    Name            : libreoffice-fresh
    Name            : libsearpc
    Name            : libsigrokdecode
    Name            : lldb
    Name            : mallard-ducktype
    Name            : meld
    Name            : mercurial
    Name            : meson
    Name            : mono
    Name            : mypy
    Name            : namcap
    Name            : node-gyp
    Name            : nuitka
    Name            : openshot
    Name            : pahole
    Name            : paperwork
    Name            : pax-utils
    Name            : pcsclite
    Name            : perf
    Name            : ps_mem
    Name            : pyalpm
    Name            : pyside2
    Name            : qemu-tools
    Name            : reflector
    Name            : repo
    Name            : rubber
    Name            : samba
    Name            : scons
    Name            : seafile
    Name            : setconf
    Name            : smbclient
    Name            : smem
    Name            : solaar
    Name            : speech-dispatcher
    Name            : tellico
    Name            : thefuck
    Name            : thonny
    Name            : torbrowser-launcher
    Name            : udiskie
    Name            : virtualbox
    Name            : yelp-tools
    Name            : youtube-dl
    Name            : yt-dlp
    Name            : zim

incidentally, my day to day experience definitely does not classify any of the software I actually use in the "fast and enjoyable" category, except zim and tellico. Like, just launched a couple that I had forgotten about: solaar, a GUI for configuring logitech mice, and thonny, a minimalistic IDE for arduinos, etc. and they take actually observable time to start, on a 1k€ CPU, which I really find to be entirely ridiculous (and made me remember why I don't use them more).

Re: Ask HN: Learn C++11 or Rust in 2022?

#132
> So I don't really have time to invest in both languages; any directions?

Why not? It's not like "two languages == double the time".

In this particular case, learning both side by side and comparing design choices may well lead to a better understanding and even be faster than just learning one of them.

Re: Ask HN: Learn C++11 or Rust in 2022?

#133
post #76

Earlier quoted context omitted.

> I'm confused when people preach Zig and then safety in the same sentence. Zig enforces correctness much more than C or C++ does (e.g. no implicit 'lossy' conversions, much stricter and enforced error handling, no implicit null, etc.), so it's completely fine to say that Zig is much safer than C or C++. The main difference between Zig and Rust is the borrow checker, but a lot of memory corruption issues in C and C++…

Except the little detail about sloppy use after free.

Agreed but doing this at compile time would require some sort of pointer lifetime tracking in the compiler. Don't know how much of this is feasable without going "full borrow checker", but static analyzers for C do a similar thing, by far not as watertight as Rust of course.

The General Purpose Allocator can optionally catch use-after-free by not recycling virtual memory addresses, not very efficient for small high-frequency allocations of course, but then Zig isn't an OOP language either (where it would be common to create and destroy massive amounts of tiny objects).

Re: Ask HN: Learn C++11 or Rust in 2022?

#134
post #123
post #115

Earlier quoted context omitted.

I know C++ since 1993, I am quite curious how pointer semantics have anything to do with RAII.

Yeah, doesn't make sense. Pointers are less useful in C++, because we have better things now.

Of course we do. You still need to know how pointers work to use RAII effectively, though.

Re: Ask HN: Learn C++11 or Rust in 2022?

#135
post #115
post #88

Earlier quoted context omitted.

Fully disagree. Understanding pointer semantics is a pre-requisite for understanding RAII.

I know C++ since 1993, I am quite curious how pointer semantics have anything to do with RAII.

Because smart pointers are still pointers under the hood. You're forgetting the time before you know what pointers were - people coming from higher level languages don't immediately grok the concept. By teaching them automatic memory management patterns like we use in C++ without teaching them why you need such things, they'll never fully understand the code they're writing.

It's like the "I know React but not JavaScript" crowd all over again.

Re: Ask HN: Learn C++11 or Rust in 2022?

#136
post #70

I remember when Stroustrup's C++ came out in 1986. I used to be able to cite the Annotated Reference Manual (ARM) by chapter and verse. But if I were a young programmer in 2022 and looking at learning either C++ or Rust I'd choose Rust in a heartbeat. Why? Many reasons. For starters, C++ is 40 years old at this point and embodies software engineering practices from the late 70's to early 80's (for you young folks, st…

Honestly, I think the shift you are already seeing is from C++ -> a GCed language (python, javascript, java). While C/C++ are everywhere, they are mostly in very low level places. You don't find a lot of new backend projects that go the C++ route. Rust will likely eat up a significant chunk of C++'s current market share and SOME of the backend service market share (where CPU and Memory are REALLY important). However,…

> You don't find a lot of new backend projects that go the C++ route.

TBF, C++ was never a great backend language. Rust "the language" isn't either, but "Rust the package ecosystem" might be one day (because unlike C++, Rust is coming out of the "web hemisphere").

Re: Ask HN: Learn C++11 or Rust in 2022?

#137
post #135
post #115

Earlier quoted context omitted.

I know C++ since 1993, I am quite curious how pointer semantics have anything to do with RAII.

Because smart pointers are still pointers under the hood. You're forgetting the time before you know what pointers were - people coming from higher level languages don't immediately grok the concept. By teaching them automatic memory management patterns like we use in C++ without teaching them why you need such things, they'll never fully understand the code they're writing. It's like the "I know React but not JavaSc…

If you think RAII is about smart pointers, you really don't understand it.

RAII is about resource management, regardless of where those resources live on.

Heap allocated, OS handles, indexes on a fixed sized buffer, network sockets, ...

Re: Ask HN: Learn C++11 or Rust in 2022?

#138
post #134
post #123

Earlier quoted context omitted.

Yeah, doesn't make sense. Pointers are less useful in C++, because we have better things now.

Of course we do. You still need to know how pointers work to use RAII effectively , though.

Not at all, because RAII is about constructors/destructors, and not at all about pointers.

Heap allocated data is one special case of OS resources that can be managed by constructor/destructor pairs.

Re: Ask HN: Learn C++11 or Rust in 2022?

#139
post #76

Earlier quoted context omitted.

Except the little detail about sloppy use after free.

Agreed but doing this at compile time would require some sort of pointer lifetime tracking in the compiler. Don't know how much of this is feasable without going "full borrow checker", but static analyzers for C do a similar thing, by far not as watertight as Rust of course. The General Purpose Allocator can optionally catch use-after-free by not recycling virtual memory addresses, not very efficient for small high-f…

> ...but static analyzers for C do a similar thing..

Exactly, which begs the question why bother with Zig at all.

Re: Ask HN: Learn C++11 or Rust in 2022?

#140
post #130

Earlier quoted context omitted.

If you use Python and JS chances are you do some form of web development, where most performance issues have to do with I/O, and most of those I/O issues are caused by bad queries. It ultimately comes down to using application performance monitoring software and analyzing query plans. Memory issues are an oddity and are usually caused by users doing stuff like uploading gigantic files.

> using application performance monitoring software and analyzing query plans. soo... tooling ? how is that different from using valgrind ? it's literally one click in my IDE to use it and it will show e.g. the time spent at each line of code directly in it. > If you use Python and JS chances are you do some form of web development, where most performance issues have to do with I/O, and most of those I/O issues are c…

Imo the biggest difference is that in the Python / JS world you can be considered a senior developer at many respectable companies and still be clueless about tooling, optimization etc. Most shops (exceptions being places that do a lot of ETL, data processing...) are OK with clunky Python as long as it is not unusable. On the other hand if you are working with C / C++ a more active approach is needed if you don't want your software to blow up.
Post reply on HN