News for hackers. Stuff that matters.
Re:Why I love Rust by pcwalton on Friday January 08, 2016 @03:47AM (#10863706)
This is a weird answer to the question, especially since Rust very probably has whatever "modern C++ techniques" you were thinking of.
Re:Why I love Rust by Animats on Friday January 08, 2016 @03:55AM (#10863730)
Learning C++ means you have to learn a lot about how to debug C++, and understand exactly what's going on at the machine, OS, and debugger level. Whether this is a productive use of your life is up to you.
Re:Why I love Rust by hellofunk on Friday January 08, 2016 @03:48AM (#10863712)
I disagree. As others have pointed out, the demand for C++ jobs is still much higher than Rust jobs, so I think my answer still stands as a way to set yourself apart when thinking of a new language to spend a few months on.

Ideally, one would learn Rust and C++ both and see how they differ, and why.

Re:Why I love Rust by pcwalton on Friday January 08, 2016 @03:55AM (#10863727)
> I disagree. As others have pointed out, the demand for C++ jobs is still much higher than Rust jobs, so I think my answer still stands as a way to set yourself apart when thinking of a new language to spend a few months on.

It's not going to be a particularly interesting thread if everyone who works in a language that trends higher than Go on Google chimes in to say "you should learn my language instead, because it's more popular".

> Ideally, one would learn Rust and C++ both and see how they differ, and why.

Aside from uninteresting language-specific details, C++ essentially doesn't teach you anything that Rust doesn't.

Re:Why I love Rust by hellofunk on Friday January 08, 2016 @04:06AM (#10863753)
>It's not going to be a particularly interesting thread if everyone who works in a language that trends higher than Go on Google chimes in to say "you should learn my language instead, because it's more popular".

I think C++ is unique in that it is really not as popular as many new languages, not as trendy and as much in the news, and not even taught as much in college programs, yet, it remains the language where so many jobs are. This gives anyone with the desire to learn it a good and marketable skill that can make it possibly easier to find work and continue making a living doing software development. That does not apply to Rust, so I think it's a fair point to make to anyone who is asking about what languages are good to learn.

As for whether C++ has any techniques to teach that Rust does not, C++ is definitely a unique experience to go through and certainly gives a developer more insight into the actual machine they are working on in a way that few languages do.

Re:Why I love Rust by pcwalton on Friday January 08, 2016 @04:08AM (#10863758)
> it remains the language where so many jobs are

"The" language where so many jobs are? It's one of many.

> As for whether C++ has any techniques to teach that Rust does not, C++ is definitely a unique experience to go through and certainly gives a developer more insight into the actual machine they are working on in a way that few languages do.

Can you name, specifically, a way in which C++ gives you "more insight into the actual machine" compared to Rust?

Re:Why I love Rust by hellofunk on Friday January 08, 2016 @05:01AM (#10863920)
I think that Rust simplifies some things that you must do yourself in C++, and learning how to do them is valuable. At the very least, it will help you appreciate other languages, but it can also show you areas where you get manual control over performance in ways no other language offers.

And, perhaps most significantly, there are a wealth of C++ libraries out there that have no equivalent in other languages, and being able to use them is an education in itself.

Re:Why I love Rust by nickpsecurity on Friday January 08, 2016 @10:19AM (#10865433)
The C++ programmers here disagree given how often they point out that C++ close to the machine is actually the C style of programming done with C++ language. It's actively discouraged by the C++ community in favor of the C++ style of programming described in Modern C++, etc. The C++ style gives low-overhead abstractions that increase safety and maintainability (in theory) while aiming for C compatibility and performance. Main libraries and well-written apps are big on metaprogrammed constructs.

So, learning to code professional C++ will not help you understand machines more. You'd have to learn C, basic OS/CPU structures, and which compilers produce for certain C statements. Maybe read Write Great Code by Hyde or some online articles. Learn C++ to understand machines? Not happening unless you microprogram a CPU for it on a FPGA.

Re:Why I love Rust by yoklov on Friday January 08, 2016 @09:29AM (#10865040)
As someone who has written a lot of C++ (and essentially no rust), I think you're mischaracterizing C++. It has a lot of magic that the compiler does for you under the hood, and even more if you are using libraries.

If you want to understand what is actually happening on the machine, I do not think it is the best choice. C would be much better.

Re:Why I love Rust by pcwalton on Friday January 08, 2016 @11:37AM (#10866092)
> I think that Rust simplifies some things that you must do yourself in C++, and learning how to do them is valuable.

Given that you didn't answer the question, I think it's pretty clear at this point that you haven't used Rust. Rust is a low-level language with low-level control over memory and resources.

Re:Why I love Rust by curun1r on Friday January 08, 2016 @07:52PM (#10869474)
Speaking about C, since I never went too deep into C++.

The original assertion was:

> ...gives a developer more insight into the actual machine...

For better or worse, Rust feels like a reference is a proper abstraction over a memory location whereas C drives home that it really is just a number. Perhaps I don't know Rust well enough but, without unsafe, I'm not sure how I would refer to an arbitrary memory location or use pointer arithmetic to access memory locations relative to a known memory location in Rust. Vector indexes in Rust appear to be more than just syntax sugar for addition whereas C allows both array[2] and 2[array]. And I know that Rust will prevent me from accessing memory that's already been freed since it's one of the selling points of the language.

Now you can argue that Rust is mostly saving you from unpleasant consequences, and you'd be right. But the fact that C forces you to understand those unpleasant consequences teaches you something about the nature of the underlying machine. C makes you realize just how much of a "wild west" situation exists at that level. It would be very easy for someone to learn Rust without being confronted with that fact.

Re:Why I love Rust by hellofunk on Friday January 08, 2016 @02:36PM (#10867577)
I certainly don't know Rust as well as C++. Some other fellows in this thread provided some features in C++ that you can't learn about in Rust, fyi.
Re:Why I love Rust by pcwalton on Friday January 08, 2016 @02:50PM (#10867670)
> Some other fellows in this thread provided some features in C++ that you can't learn about in Rust, fyi.

Variadic generics and template templates are hardly interesting compared to concepts, pattern matching, and lifetimes. I use those every day in Rust, they simply don't exist in C++, and with the exception of lifetimes plenty of other languages have them too, so they're broadly useful to know. Variadic generics and template templates, on the other hand, are useful for a small subset of advanced library authors who have been programming in C++ for years.

Re:Why I love Rust by cjfont on Friday January 08, 2016 @07:42AM (#10864443)
If my understanding is correct, you can use any of those C++ libraries from Rust as well.
Re:Why I love Rust by kibwen on Friday January 08, 2016 @08:01AM (#10864525)
If those C++ libraries expose a C API, then yes.
Re:Why I love Rust by fiedzia on Friday January 08, 2016 @09:56AM (#10865238)
Well, it may teach you why its a good idea to throw away old features every couple of decades :-)
Re:Why I love Rust by neppo on Friday January 08, 2016 @05:55AM (#10864071)
OPs asked which language to learn from a career perspective, so C++ is good advice in that respect
Re:Why I love Rust by nickpsecurity on Friday January 08, 2016 @10:14AM (#10865386)
You must say the same thing about COBOL in other threads. Demand for it remains high with people getting paid a premium in some areas for the shortage. Something like a billion lines of it out there. Microfocus is probably hiring, too.

So, anyone following your argument should skip C++ and learn COBOL because COBOL is easier to learn, in widespread use, and has jobs available.

Re:Why I love Rust by hellofunk on Friday January 08, 2016 @11:00AM (#10865773)
Interesting point. I was curious about this, and turned to Wikipedia:

>In 2006 and 2012, Computerworld surveys found that over 60% of organizations used COBOL (more than C++ and Visual Basic .NET) and that for half of those, COBOL was used for the majority of their internal software. 36% of managers said they planned to migrate from COBOL, and 25% said they would like to if it was cheaper. Instead, some businesses have migrated their systems from expensive mainframes to cheaper, more modern systems, while maintaining their COBOL programs.

Re:Why I love Rust by nickpsecurity on Friday January 08, 2016 @11:31AM (#10866033)
It was an extremely, easy-to-use language that even laypeople could write business logic in. Similar to how BASIC got so many people started. Except, Fortune 500 companies were writing all their backend stuff in COBOL on mainframes from the 60's onward. Needless to say, there's a lot of it around dependent on existing libraries, interfaces, language variants, compilers, etc. Porting it is huge risk. So, they just maintain and extend it.

Main vendor even has it on Visual Studio: http://www.microfocus.com/solutions/cobol/index.aspx

The job is boring, predictable, and 9-5-ish at most places. Exactly what some types of people are looking for. They figure they can play with the fun stuff at home. One person even jokingly made a web framework for it: COBOL on Cogs. So, yeah, I throw COBOL at anyone using the "use language X for users or jobs" argument to see how they react to what they're actually arguing.

Interesting that you at least looked it up and didn't go into denial mode. I'm impressed. ;)

Re:Why I love Rust by shin_lao on Friday January 08, 2016 @04:33AM (#10863835)
Not really. From a carreer perspective you are 100% certain that there will be a lot of demand for C++ in 5 years (since the whole IT infrastructure is written either in C or in C++), whereas for Rust you are taking a huge bet.
Re:Why I love Rust by seren on Friday January 08, 2016 @05:41AM (#10864034)
Maybe my perspective is biased because I work in a very conservative industry, but a large part of C++ jobs in the next 5 years will likely be about maintenance/evolution of massive legacy C++98/C++03 applications. And you won't likely use a lot of C++14 or C++17, while on the other hand the rare Rust project might be a bit more exciting. But if you're primary motivation to learn a new language is to get a job, Cpp is surely a safer bet.
Re:Why I love Rust by pcwalton on Friday January 08, 2016 @12:34PM (#10866590)
> a large part of C++ jobs in the next 5 years will likely be about maintenance/evolution of massive legacy C++98/C++03 applications

This is exactly right, and it's been true for many years now. That your old codebase is written in C++ is a totally legitimate reason to use C++.

Re:Why I love Rust by hellofunk on Friday January 08, 2016 @05:05AM (#10863933)
Exactly, C++ has been around for a very long time, so much runs on it, depends on it, and it is not going anywhere any time in our lifetimes, I'm certain of that. That makes it a very valuable skill. You can always study the newer languages when interested in them (I find them all fascinating), but for a deep leg into the way the industry works at its core, I think knowing C++ gets you very far. Google touts Go a lot, but so much of Google's tools are actually C++ at heart (protobufs and Chrome for example), and Apple touts Swift and has its own frameworks in Objective-C and now Swift, but under the hood, so much of their toolkits and the language of Swift itself are implemented in C++; nearly all cross-platform games we know and love for a wide variety of devices and OS are C++ -- my point is that it is a crucial language and it does not hurt to understand it.
Re:Why I love Rust by jbandela1 on Friday January 08, 2016 @08:19AM (#10864615)
Rust lacks higher kind types which C++ has had in the form of template templates since 1998. Rust also lacks the equivalent of variadic templates. If you want to see where that is different take a look at generic tuple manipulation in C++11 vs Rust.
Re:Why I love Rust by pcwalton on Friday January 08, 2016 @12:42PM (#10866639)
And Rust has other features that no shipping version of C++ has, like full-featured pattern matching, lifetimes, and concepts. These are features you will use hugely more often than template templates and variadic generics.

But really, what's the point? The reasons you'd learn a low-level systems language are to learn how to manage memory and resources, to learn how to explicitly lay out data and to understand how to program without a runtime. Both Rust and C++ will teach you these.