Live data from Hacker News

Rust and Go

medium.com

141–150 of 311 posts

Re: Rust and Go

#141

Earlier quoted context omitted.

Use unsigned integers for your index and values. That's what makes it hard to use a for loop. (Sure, you could cast a signed integer loop index to unsigned inside the loop to avoid the underflow problem in this specific case, but I'd argue that the functional style is so much clearer than code that has to work around unsigned underflow gotchas.)

> functional style is so much clearer There is something that makes me uncomfortable in there: > let descending_squares = range(0u, 5u).rev().map(|x| x * x).collect(); The overhead. I wonder about it. I am unable to get a sense of what it is. With a simple for-loop, it's rather easy to see it, but with the version above I have no idea. So "much clearer" is not what I see with the piece of code above. I see what it do…

Well then, good news! Such usages of iterators in Rust are almost always result in the same code that would be generated by old-fashioned, hand-written loops. The 'trick' is that the methods (and the closure!) are inlined, and generics are specialized at compile time.

Re: Rust and Go

#142
post #23

The article is a lightweight analysis by someone who writes small programs. He does get that, for Rust, "If the compiler accepted my input, it ran — fast and correctly. Period." That's was a common experience with the very tight languages, such as Ada and the various Modulas. It's been a while since a language that tight was mainstream. We need one now, badly. Go isn't bad for writing routine server-side web stuff th…

> Race conditions are possible in Go

Just to add a clarification on the implied comparison: Rust only protects against data races at compile time. Other forms of race conditions are still possible.

Re: Rust and Go

#143
post #130

Earlier quoted context omitted.

Nim performance compares favorably to C++. It features a Pythonic syntax, optional soft real-time GC, optional manual memory management. Porting an elliptic curve implementation over to Nim from Python was a cinch: elliptic.nim: https://github.com/def-/bigints/blob/master/examples/ellipti... elliptic.py: https://github.com/wobine/blackboard101/blob/master/Elliptic... Others have reported success converting Python cod…

The Rust vs Nim comparison is tainted by very out of date documentation hosted on some MIT servers (the condition system is entirely gone). It's unfortunate and we have contacted the web master but there's not much they can do to remove or change how it appears in search engine rankings. For reference, doc.rust-lang.org is the only place to look for documentation for the standard libraries; any other hosting of those…

Hmm, was the parent comment edited? I can't see a reference to documentation...

Re: Rust and Go

#144

Earlier quoted context omitted.

Gotcha! So will Rust then auto-parallelize these "pure" closures?

We'd like to have generic APIs in the future that will allow idiomatic automatic data parallelization. Niko Matsakis has been thinking about this for quite a while. Stay tuned :) (Note that Servo has been using this type system feature for a while now to prevent data races in our massively parallel CSS layout code.)

> Niko Matsakis has been thinking about this for quite a while. Stay tuned :)

Arrg, you have me excited now!

Re: Rust and Go

#145

Comparing Go and Rust doesn't feel right. They are obviously designed for solving different kind of problems. Go is a simple language, maybe even too simple for my taste. But simplicity is its greatest strength. And I can understand people who would prefer Go as their go-to language for dealing with specific kind of problems. Go is a boring language but gets you where you want to be in a short time and without much s…

I agree that it doesn't feel quite right, but this post seems to be more of a personal exploration of going from some ignorance of both languages, to having a better understand of where each language sits. His concluding section is nicely written.

Re: Rust and Go

#146
post #31

It's not clear how much experience the author really acquired with each language, and whether that experience was sufficient experience to justify his statement: Go felt that way to me — it was good at everything, but nothing grabbed me and made me feel excited in a way I wasn’t already about something else in my ecosystem. He's apparently using each language to write relatively small command-line utilities. If Go is…

To met it's pretty clear that the language C++ programmers were waiting for is called C++ 14.

Isn't it C++17? Modules and concepts?

Re: Rust and Go

#147
post #143
post #130

Earlier quoted context omitted.

The Rust vs Nim comparison is tainted by very out of date documentation hosted on some MIT servers (the condition system is entirely gone). It's unfortunate and we have contacted the web master but there's not much they can do to remove or change how it appears in search engine rankings. For reference, doc.rust-lang.org is the only place to look for documentation for the standard libraries; any other hosting of those…

Hmm, was the parent comment edited? I can't see a reference to documentation...

The "I missed Nim" article to which it links to includes

> Nim has Exceptions with tracking (!) and Rust has… something incomprehensible or perhaps its this, I am actually not sure ;). Again, for me, a clear win for Nim.

where "something incomprehensible" links to very old documentation of the conditions system, which was removed quite a while ago.

Re: Rust and Go

#148
post #3

Earlier quoted context omitted.

Hmm. Learning a language/framework that is exploding in popularity is probably one of the best things a dev can do to stay relevant (read: employed). Hell, very few of us would be using Javascript if it weren't for it's ubiquity/community/popularity. I sure as hell am not using it because it's a well designed language.

Quite the contrary, learning a language because it is exploding in popularity is a nice way to ensure that you'll end up being abused, poorly paid and irrelevant. You can't possibly find a worse reason for learning a new language. On Javascript you're missing the causality. Some people are learning Javascript because it is popular of course, because they've read on some forum that learning popular things gets them hi…

> Quite the contrary, learning a language because it is exploding in popularity is a nice way to ensure that you'll end up being abused, poorly paid and irrelevant.

Because I had the good fortune of starting with Rust early, I now have several foundational libraries under my belt in the Rust ecosystem. This has certainly been of great interest in interviews, and might just lead to me landing a pretty 'hip' internship over the Australian summer. Of course it won't be in Rust, but it's better than being at a hum-drum corporate placement. Being a pioneer definitely sets you apart from other candidates, and also culls the pack of potential employers to those that value curiosity and initiative, and actually care about exploring new ideas.

Re: Rust and Go

#149

Earlier quoted context omitted.

In Go: func isAnagramOfPalindrome(str string) bool { charCounts := map[rune]int{} for _, c := range str { charCounts[c]++ } numOdd := 0 for _, count := range charCounts { if count%2 == 1 { numOdd++ } } return numOdd In this case I think I do prefer the latter. I like how I can name the intermediate objects. :) Also I don't like the practice of groupBy().map(=>_.size()), which hides the performance penalty of creating…

I'll bite. In Python: def odd_count(letters): return lambda ch: letters.count(ch) % 2 def anagram_of_palindrome(letters): return sum(map(odd_count(letters), set(letters))) How's that for some higher-order function action? But really, unless you are deriving programs by doing algebra you are missing the point of things like map() and reduce() (as far as I know no one is actually doing Functional Programing the way Bac…

The Haskell programmer in me can't resist---eta reduce your functions! :P

    from functools import partial
    
    def odd_count(letters, ch):
        return letters.count(ch) % 2
    
    def anagram_of_palindrome(letters):
        return sum(map(partial(odd_count, letters), set(letters))) 

Re: Rust and Go

#150

Earlier quoted context omitted.

Doh! I fell straight in :) Overflows in general are tricky. How does Rust deal with it?

We have special checked types you can use if you want checked arithmetic. The default is to not check, because CPUs currently make it expensive to check (although I would love it if that could change--we need hardware support though).

Nice. :)
Post reply on HN