New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust via its Core Values #19

Merged
merged 2 commits into from Jun 8, 2016

Conversation

Projects
None yet
7 participants
@IanWhitney
Owner

IanWhitney commented Apr 1, 2016

No description provided.

@respeccing

This comment has been minimized.

Show comment
Hide comment
@respeccing

respeccing Apr 1, 2016

and sticks to its core vales

respeccing commented Apr 1, 2016

and sticks to its core vales

Well, no. Rust's Core Value of memory safety leads to the following rules:
- There can only be one owner
- You can borrow a value as many times as you want, but those borrows are immutable

This comment has been minimized.

@durka

durka Apr 3, 2016

Maybe you'd rather not go into detail, but you did leave out mutable borrowing here.

@durka

durka Apr 3, 2016

Maybe you'd rather not go into detail, but you did leave out mutable borrowing here.

This comment has been minimized.

@IanWhitney

IanWhitney Apr 3, 2016

Owner

Exactly. I tried to cover it in an earlier draft, but dropped it to keep things a little simpler. Something to cover later.

@IanWhitney

IanWhitney Apr 3, 2016

Owner

Exactly. I tried to cover it in an earlier draft, but dropped it to keep things a little simpler. Something to cover later.

@phoe

This comment has been minimized.

Show comment
Hide comment
@phoe

phoe Apr 4, 2016

Hey, thanks for inspiration. I'm going to write a post in a very similar style - but for the underused, very unadvertised and very fun and powerful language called Common Lisp.

phoe commented Apr 4, 2016

Hey, thanks for inspiration. I'm going to write a post in a very similar style - but for the underused, very unadvertised and very fun and powerful language called Common Lisp.

{% rp_highlight rust %}
fn same_length(s1: String, s2: String) -> bool {
s1.len() == s2.len()

This comment has been minimized.

@brandonio21

brandonio21 Apr 5, 2016

Just a small nitpick. String.len() returns the number of bytes in the string, not the number of characters. Should this be changed to String.chars().count()?

@brandonio21

brandonio21 Apr 5, 2016

Just a small nitpick. String.len() returns the number of bytes in the string, not the number of characters. Should this be changed to String.chars().count()?

This comment has been minimized.

@respeccing

respeccing Apr 5, 2016

Does it matter in this case though? Or am I missing something?

@respeccing

respeccing Apr 5, 2016

Does it matter in this case though? Or am I missing something?

This comment has been minimized.

@brandonio21

brandonio21 Apr 5, 2016

Ah, I think you're right @respeccing . The post never mentions anything about length vs. counting chars. I made an incorrect assumption. My apologies.

@brandonio21

brandonio21 Apr 5, 2016

Ah, I think you're right @respeccing . The post never mentions anything about length vs. counting chars. I made an incorrect assumption. My apologies.

This comment has been minimized.

@IanWhitney

IanWhitney Apr 5, 2016

Owner

That's good to keep in mind though. That is the sort of thing I just assumed worked the same as in Ruby, but it doesn't. Thanks!

@IanWhitney

IanWhitney Apr 5, 2016

Owner

That's good to keep in mind though. That is the sort of thing I just assumed worked the same as in Ruby, but it doesn't. Thanks!

This comment has been minimized.

@respeccing

respeccing Apr 5, 2016

All good, no worries.
I figured, since it's just comparing the lengths, it doesn't matter the unit, as long as it's the same unit for both.
s1.len() == s2.len()
vs.
s1.chars().count() == s2.chars().count()

That is actually good information for I didn't know about the distinction(looking it up currently). Thanks!

EDIT: https://play.rust-lang.org/?gist=39c77e5d0ae546b30520dfc35cb43b71&version=stable&backtrace=2

@respeccing

respeccing Apr 5, 2016

All good, no worries.
I figured, since it's just comparing the lengths, it doesn't matter the unit, as long as it's the same unit for both.
s1.len() == s2.len()
vs.
s1.chars().count() == s2.chars().count()

That is actually good information for I didn't know about the distinction(looking it up currently). Thanks!

EDIT: https://play.rust-lang.org/?gist=39c77e5d0ae546b30520dfc35cb43b71&version=stable&backtrace=2

This comment has been minimized.

@respeccing

respeccing Apr 5, 2016

I guess it does matter which unit we use: https://play.rust-lang.org/?gist=5d3174958c76718508f6ab4566084829&version=stable&backtrace=2
With len these are not equal, whilst with chars().count() they are!
I stand corrected in my assumption

EDIT: plus, I can't think of them as units ( because utf-8 has variable(not fixed) number of bytes )

@respeccing

respeccing Apr 5, 2016

I guess it does matter which unit we use: https://play.rust-lang.org/?gist=5d3174958c76718508f6ab4566084829&version=stable&backtrace=2
With len these are not equal, whilst with chars().count() they are!
I stand corrected in my assumption

EDIT: plus, I can't think of them as units ( because utf-8 has variable(not fixed) number of bytes )

This comment has been minimized.

@brandonio21

brandonio21 Apr 5, 2016

@respeccing - Thanks a ton for making the playpen! This clearly brings forth any issues with using len() in place of chars().count().

@brandonio21

brandonio21 Apr 5, 2016

@respeccing - Thanks a ton for making the playpen! This clearly brings forth any issues with using len() in place of chars().count().

This comment has been minimized.

@respeccing

respeccing Apr 5, 2016

Thanks @brandonio21 for this great eye opener! Much appreciated!

@respeccing

respeccing Apr 5, 2016

Thanks @brandonio21 for this great eye opener! Much appreciated!

@cadeon

This comment has been minimized.

Show comment
Hide comment
@cadeon

cadeon Apr 5, 2016

Excellent, excellent post. Makes me want to rewrite one of my pieces of writing considering Rust-
http://taotedev.com/2016/01/29/3-state-v-action/

cadeon commented Apr 5, 2016

Excellent, excellent post. Makes me want to rewrite one of my pieces of writing considering Rust-
http://taotedev.com/2016/01/29/3-state-v-action/

@IanWhitney IanWhitney merged commit 2526e1b into master Jun 8, 2016

@IanWhitney IanWhitney deleted the rust_via_its_core_values branch Jun 8, 2016

@rmcsharry

This comment has been minimized.

Show comment
Hide comment
@rmcsharry

rmcsharry Sep 28, 2016

A superb post that makes its point clearly and succinctly - that understanding core principles is key to properly understand a language. So true and you nailed it!

rmcsharry commented Sep 28, 2016

A superb post that makes its point clearly and succinctly - that understanding core principles is key to properly understand a language. So true and you nailed it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment