Rust 1.32.0 Stable Release Includes New Debugging Macro, 'Quality of Life' Improvements (rust-lang.org) 96
An anonymous reader summarizes the changes in Thursday's release of Rust 1.32.0 stable:
"Quality of life" improvements include a new dbg macro to easily print values for debugging without having to use a println statement. For example, dbg!(x); prints the filename and line number, as well as the variable's name and value, to stderr (rather than to standard output). Making it even more useful, the macro also returns the value of what it's debugging -- even all the boolean values returned by each execution of an if-then statement.
Rust macros can now match literals of any type (string, numeric, char) -- and the 2018 edition of Rust also allows ? for matching zero or one repetitions of a pattern.
In addition, all integral numeric primitives now provide conversion functions to and from byte-arrays with specified endianness.
Rust macros can now match literals of any type (string, numeric, char) -- and the 2018 edition of Rust also allows ? for matching zero or one repetitions of a pattern.
In addition, all integral numeric primitives now provide conversion functions to and from byte-arrays with specified endianness.
Re:Quality of life (Score:4, Insightful)
People here used to be excited or at least interested/thoughtful about real actual nerdy news.
Now it doesn't matter the topic of conversation, the perpetually offended snowflakes cannot shut up about SJW. Bleh.
If one ignores the hype, the fanbois, the haters and the plain stupid, Rust is an interesting language. It's the first credible attempt to displace C++ in areas where C++ is king. And by credible, I mean not designed by someone who clearly hates and or plain doesn't understand C++ and can't see why it's used.
It's not a perfect lanaguage and it's not a panacea (fucking duh) but it makes some of the knottier problems of C++ go away, especially in certain domains and it's given the C++ community interesting things and directions to think about. So yeah it's interesting because I'm a nerd and interested in programming languages.
And fuck anyone here who isn't. News for nerds.
Re: Quality of life (Score:4, Interesting)
Your first error was in assuming C++ is replaceable. You can stop using C++ and use something else because C++ is good at one thing and better than anything else at that one thing. Don't want C++? Choose the best choice. You don't use a language to replace another language. You use a language because its what you want.
Nonsense.
For any given context, there is no single perfect language. There are always different options, with various pros and cons. And as the options and the context both change over time, it often does begin to make sense to replace one language with another. The value of the new language has to be very significant to justify rewriting working code, though.
Re: (Score:2)
Indeed. One of the few actually insightful statements so far. Also, very often a specific language is used because it is hyped or because the developers you have cannot do anything else.
Re: (Score:2)
Also, very often a specific language is used because it is hyped or because the developers you have cannot do anything else.
Availability of programmers is one of the most important language features you have to consider when choosing a language for a project. If the language is an absolutely perfect fit, but no one knows it and no one is interested in learning it, it's the wrong choice. In practice, you can usually find people willing to learn most anything, so schedule and cost are additional considerations. If choosing the perfect language will mean three months of ramp-up and one month of development, but an already-known lan
Re: (Score:2)
Rust is an interesting language. It's the first credible attempt to displace C++ in areas where C++ is king.
There are areas where the utterly borked C++ is king? That language is so badly designed it is staggering.
Re: (Score:2)
Rust is an interesting language. It's the first credible attempt to displace C++ in areas where C++ is king.
There are areas where the utterly borked C++ is king?
Lots and lots of them. Basically anywhere you need the low-level performance and control of C, but need the greater productivity provided by an object-oriented language.
That language is so badly designed it is staggering.
C++ wasn't designed so much as accreted. However, if you look at modern C++, there is a smaller, cleaner, safer language emerging. Using it requires discipline since you need to avoid all of the other stuff that's still there because it can't be taken away. I'm actually really enjoying C++ since C++11, and it's still getting better.
That
Re: (Score:2)
There are areas where the utterly borked C++ is king?
Lots and lots of them. Basically anywhere you need the low-level performance and control of C, but need the greater productivity provided by an object-oriented language.
That one is a myth. This "greater productivity" does not exist. It is however that lots of semi-smart people went looking for it, and then found they could not back out again. In true human fashion, they then claim that the mistake they made was actually a good move.
Re: (Score:2)
That one is a myth. This "greater productivity" does not exist.
I have decades of experience proving you wrong on this, including plenty of examples of parallel development of the same or very similar projects in C and C++.
Re: (Score:2)
However, if you look at modern C++, there is a smaller, cleaner, safer language emerging. Using it requires discipline since you need to avoid all of the other stuff that's still there because it can't be taken away. I'm actually really enjoying C++ since C++11, and it's still getting better.
Well, that is good to know. Of course, they should pack all the problematic stuff away into some "#pragma oldstuff" or the like and define a clean, simple and clear core language. Then I would take another look. Don't get me wrong, I do know that there is a sane core in there in C++, the problem is just that most people working in C++ do not know this or understand what it is and end up using and abusing the really problematic stuff. Also, have they finally fixed the virtual function dispatch performance me
Re: (Score:2)
However, if you look at modern C++, there is a smaller, cleaner, safer language emerging. Using it requires discipline since you need to avoid all of the other stuff that's still there because it can't be taken away. I'm actually really enjoying C++ since C++11, and it's still getting better.
Well, that is good to know. Of course, they should pack all the problematic stuff away into some "#pragma oldstuff" or the like and define a clean, simple and clear core language. Then I would take another look. Don't get me wrong, I do know that there is a sane core in there in C++, the problem is just that most people working in C++ do not know this or understand what it is and end up using and abusing the really problematic stuff.
Good taste is essential. Of course, that's true in every language. It's just more true in C++.
Also, have they finally fixed the virtual function dispatch performance mess?
There's no problem with virtual function dispatch performance. It's very close to optimal; you might be able to beat it by careful organization of vtables to optimize cache usage, but it is precisely an offset load to get the vtable address, then an offset load to get the function address and then jump. And actually ARM and X86 can both accept an offset address as a load or jump target, so it's all done in two
Re: (Score:3)
There are areas where the utterly borked C++ is king?
Yep. Areas populated by grown-ups, who need performance but for some inexplicable reason don't want to spend all their time micromanaging a computer by hand when it can be done programmatically.
Even C now depends on C++. All the compilers people actually use (the ones with decent optimizers) are writen in C++ now.
C++ has its share of warts, but anyone who thinks it's "utterly borked" is flat out ignorant.
Re: (Score:2)
There are areas where the utterly borked C++ is king?
Yep. Areas populated by grown-ups, who need performance but for some inexplicable reason don't want to spend all their time micromanaging a computer by hand when it can be done programmatically.
Since one does not have to do anything with the other, you are clearly clueless. Just could not keep silent, could you?
Re: (Score:2)
you are clearly clueless.
Says the guy who doesn't see why people use C++ despite his favoured language depending on C++ infrastructure.
Re: (Score:3)
I too am interested in Rust and, indeed, any new language. I'm always curious to know which ones will thrive and which ones won't, and what the use-cases for each are, in other words, where would you use one rather than the other.
I'm not altogether sure of the relevance of 'SJW' is to this technically, especially as the term seems to be applied as a term of abuse (by others) rather than a term of self-identification (so in this case presuma
Re: (Score:2)
I'm always curious to know which ones will thrive and which ones won't, and what the use-cases for each are, in other words, where would you use one rather than the other.
The reason for rust's existence is to write irregular, fine grained multithreaded code in a language that basically has the same machine and memory model as C++, with zero overhead abstractions etc. Multithreading is notoriously hard and C++ doesn't provide any solid tools to avoid races. Rust has the entire type system bent to that cause
Re: (Score:2)
Or do you mean that the binary requires and installer? If so that's just lazy and there's no excuse.
Yep, that's me, Lazy. Strangely I find don't need an excuse for being that!
Actually, I will get round to trying to install locally at some point. I think I compare it to Java or Go, where I can just download, extract, add one item to the $PATH environment variable, and then go.
Re: (Score:2)
Yep, that's me, Lazy.
Well I wasn't calling you lazy. However since you didn't bother to read what I wrote, I might now... :)
Actually, I will get round to trying to install locally at some point. I think I compare it to Java or Go, where I can just download, extract, add one item to the $PATH environment variable, and then go.
I was comparing to GCC which doesn't need the environment variable.
Re: (Score:2)
> I think my main objection so far to Rust is that I can't just download a tarball, unzip, set up some environment variables, and run. It seems that you have to run an installer, which I really dislike! But that's me.
You could start with
https://play.rust-lang.org/ [rust-lang.org]
No need to download anything at all.
From what I remember (it has been a while since I ran rustup-init.exe), Rust installer does not need admin privileges and does not have a registered uninstaller. All it seems to do is download, unzip and just
Re: (Score:2)
Re: (Score:2)
> I think my main objection so far to Rust is that I can't just download a tarball, unzip, set up some environment variables, and run. It seems that you have to run an installer, which I really dislike! But that's me.
This might interest you too
https://forge.rust-lang.org/ot... [rust-lang.org]
Re: (Score:2)
No the "first credible attempt" (Score:5, Informative)
No, there is an earlier "credible attempt to displace C++": D [dlang.org]. D was created by Walter Bright, who previously was "the main developer of the first C++ compiler to translate source code directly to object code without using C as an intermediate language" (quoting Wikipedia), and so is clearly "credible" by your criteria.
The thing about Rust is that the ownership/borrowing system makes it better than C++ in important ways. Programmers have to specify variable usage details, but this (1) makes the code easier to maintain, (2) gives you a much more powerful form of RAII, (3) makes reference counting work so well that you don't need a tracing garbage collecter, and (4) makes the resulting code significantly faster in many cases. That is why Rust should compete successfully with C++, whereas a "C++ without the warts" like D could not.
Re: (Score:2)
Yes good point, I completely forgot about D. D really takes metaprogramming top a whole new level compared to C++ (and rust). It's more than C++ without the warts. D was certainly credible and it's interesting why it didn't succeed.
I think that one problem was that D wasn't created to solve a specific problem better than C++. It was designed to be C++ without the flaws, but maybe there was nothing where D was such a hugely definitive advantage that you had to use it. New languages have a big energy barrier.
Re: (Score:2)
Me, me, me!
I'm an old C and C++ guy. I've ignored all the nonsense that was invented after I went to university, and I still shake my head at Node.js and having been forced to actually use it for a prototype project, not out of ignorance. I write a lot of stuff in PHP these days because it's C-like (plus just the right amount of OO, the only thing I'm missing from C) and because for web-programming there's no good C solution.
Rust is the only new programming language that actually interests me. It's the only
Re: (Score:1)
Re: (Score:2)
Indeed! We need to ban the discriminatory if-then construct! And what about other actions that are left out completely? This cannot stand. We need a "do everything" construct and drop all this other toxic nonsense.
Re: (Score:1)
Re: (Score:1)
Re: (Score:2)
How can you be so unethical! All the negative number are left out! They already go through life with the stigma of being negative and now you just ignore them! Instead they should be celebrated and elevated in affirmative action! I propose therefore that the privileged positive number be dropped altogether and to use fuzzy logic based entirely on negative numbers!
Re: (Score:2)
Re: (Score:1)
Do you need a safe space, snowflake?
Re: (Score:2)
You have nothing to say but could not keep your mouth shut? You should complain to your parents for failing in your upbringing...
Why Rust (Score:3, Interesting)
Re: (Score:2)
That doesn't mean the features they choose were implemented in popular languages: some were just implemented in research languages.
Re: (Score:1)
Possibly a pun on the fact that it is meant to be close to the metal?
Re: (Score:2)
In theory, a fungus (Score:3)
No joke, supposedly named after a fungus [stackoverflow.com].
And you know the answer is right, since it comes from Stack Overflow!
Which on the other hand references Reddit, so... hmm.
Re: (Score:2)
Why did they call a language "Rust"?
To better fit in with all the other terrible names geeks have come up with, of course. Gimp? Ogg Vorbis? Gnu Hurd?
Re: (Score:2)
C is the descendant of B (which in turn is based on BCPL (... CPL)). Java refers to the drinking habits of programmers (coffee...).
So arguably C is descriptive and Java cute for some values of descriptive and cute.
The feature I really want (Score:1)
Is a way to print the type of an expression.
Due to various reasons it's sometimes not clear what the exact type of an expression will be, so you have to give it an invalid type so the compiler will complain with the real type, and then you can copy paste that one.
Kind of annoying.
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Yep. The RLS is a little bit primitive that way and doesn't have this yet, I think.
Re: (Score:2)
Indeed, and C is for wanna-by coders who can't write reliable, secure assembly.
Curious, though. This is possibly the first time that I have ever heard Rust being called "dumbed-down". Much more common to hear people complain that its too hard.
Re: (Score:2)
Indeed, and C is for wanna-by coders who can't write reliable, secure assembly.
Actually, the idea behind C wasn't to make code more reliable (you can fuck up in C at least as easily as in assembler). The idea was to make programming less tedious.
I still learnt assembler in university. Kids nowadays learn programming with Java, that should be a crime. I've written 1000 lines assembler code that I could do in 50 lines in C. That's what C is for. Then a few more modern languages emerged that could do things C does in 50 lines in 5 - because, for example, automatic memory management, stri
Can the devs do it themselves? (Score:3)
Did he Rust maintainers have to implement the dbg!() method, or could any Rust dev add their own? I know in Ruby I could have created my own:
def dbg!(x)
STDERR.print "#{__FILE__}:#{__LINE__} #{x.inspect}\n"
x
end
Just curious, don't know how flexible Rust is when it comes to extending the language itself.
Re: (Score:2)
Woops. Replying ot myself. Just realized my code prints the filename and line number of the dbg!() method itself, not its caller. I shoudl have parsed caller[0] instead...
Re: (Score:2)
It's relatively straight forward to implement. Rust has macros which are quite nicely integrated into the language.
My experience of Rust macros is that you can do most things that you want with them, but you can't actually extend the language because they are not that flexible at matching syntax. It's not like lisp where you can't really tell whether you are using a language built-in or a macro.
So, I think that you would find Ruby is more flexible as a language. But it's probably one of the reasons that Rus