News for hackers. Stuff that matters.
Re:Announcing Rust 1.6 by Thaxll on Thursday January 21, 2016 @08:26PM (#10950081)
I don't understand why would you choose Rust over Go for backend stuff. From what I see here on HN, Rust doesn't target backend app?
Re:Announcing Rust 1.6 by paulddraper on Thursday January 21, 2016 @10:38PM (#10950596)
Because he doesn't enjoy casting every time he iterates over a collection?

Because he doesn't like NULL pointers aka the worst mistake of CS?https://www.lucidchart.com/techblog/2015/08/31/the-worst-mis...

Because he doesn't want a package manager that always fetches HEAD?

I'm not saying Go is a poorly designed language where the answer to every decision is the easiest one for the implementors. I'm just saying there's a legitimate case to be made.

Re:Announcing Rust 1.6 by nickpsecurity on Friday January 22, 2016 @12:26AM (#10950938)
That's a great write-up on NULL. I've always done things to avoid it but deeply thought of why we did that past the obvious stuff. Learned something that, esp with option stuff, that might pay off in the future. Thanks. :)
Re:Announcing Rust 1.6 by nindalf on Friday January 22, 2016 @12:26AM (#10950935)
Have you actually had problems with nil pointers in Go? I've written it for years without facing it so perhaps you're doing something radically different if you managed to come across it.
Re:Announcing Rust 1.6 by sebcat on Friday January 22, 2016 @02:18AM (#10951273)
My experience is the same. Go mitigates pointer problems very well by having zero values and explicitly separating error returns.

If anyone complains about having nil in Go, I usually assume they're either forced to work a really bad codebase or lack experience in Go.

I've worked on a Go codebase for ~2 years, and I'm pretty sure the only nil pointer dereference I've seen was due to a concurrency bug, where an object cache (implemented as an array, not sync.Pool) was not locked properly.

The problem with having nil is when you expect a value to be either a valid pointer or nil to indicate an error, and you forget to check for an error. In Go, in my experience, explicit error checking and multiple return values makes that a non-problem, however ugly some people consider it to be. If I see error assignments to _, that makes me raise my eyebrows.

Re:Announcing Rust 1.6 by pcwalton on Friday January 22, 2016 @02:28AM (#10951305)
How do zero values help here? Zero values would seem to me to make nil pointer panics easier to run across, because it means the language can silently insert nil into your data structures or assign nil to your variables without any syntactic indication.

> The problem with having nil is when you expect a value to be either a valid pointer or nil to indicate an error, and you forget to check for an error.

That's not the problem with null pointers. Null is used all over the place for non-error conditions. The problem is when an object legitimately might or might not be present, but the type doesn't encode that fact, so some code mistakenly assumes that the object is always present when it isn't.

Re:Announcing Rust 1.6 by masklinn on Friday January 22, 2016 @04:05AM (#10951635)
> The problem is when an object legitimately might or might not be present, but the type doesn't encode that fact, so some code mistakenly assumes that the object is always present when it isn't.

Yes reworded slightly, types encode value invariants, nullable types can't encode one of their invariants.

Re:Announcing Rust 1.6 by fpoling on Friday January 22, 2016 @05:05AM (#10951844)
My complain with nil in Go is that there are different kinds of it as a nil pointer to a struct is not equal to a nil pointer of the interface it implements and code like https://play.golang.org/p/NwKvIztXwP prints false.

This is the reason for the rule of always returning error type in Go, not a pointer to detailed struct error. That leads to an ugly code when a check for non-nil err is followed by a cast.

Re:Announcing Rust 1.6 by echelon on Thursday January 21, 2016 @10:10PM (#10950508)
I've already written several components of my home automation system in Rust. Mio, Hyper, Iron, etc. are great tools for developing microservices.

I cross-compiled this stuff to run on Raspberry Pi, and the binaries are so small and performant!

Re:Announcing Rust 1.6 by jonreem on Friday January 22, 2016 @12:10AM (#10950881)
Hey, main author of iron here, I'd love to hear more about your use of iron! It's always nice to hear from users and your feedback is crucial to driving the project forward.

Feel free to respond here or reach out (contact details in my profile, you can find me as reem on the mozilla irc network).

Re:Announcing Rust 1.6 by Manishearth on Friday January 22, 2016 @05:40AM (#10951961)
I'd really love to see some blog posts and/or code about this. It sounds super-cool!
Re:Announcing Rust 1.6 by Cshelton on Friday January 22, 2016 @09:44AM (#10952947)
Awesome! I'm working on a home automation platform as well! Not close to being done (started last week). I'd love to see some code or examples of what you've come up with!
Re:Announcing Rust 1.6 by Manishearth on Thursday January 21, 2016 @10:50PM (#10950640)
> Rust doesn't target backend app?

This isn't the case. We have web backend libraries (servers, database thingies, template engines, I/O, etc) and it's totally possible to work on backend stuff in Rust. Rust doesn't "not target" much, really. Most of what you do in Python/Go/Ruby is also something we want Rust to work for. There is a false dichotomy of "fast language or safe language" which Rust does away with -- it's not only for situations where you would usually use C++.

Re:Announcing Rust 1.6 by pjmlp on Friday January 22, 2016 @01:27AM (#10951125)
Until the rise of scripting languages we would use compiled languages for everything.

It feels odd that someone would question it nowadays.

I surely do hope Rust gets used for everything.

Re:Announcing Rust 1.6 by alfiedotwtf on Friday January 22, 2016 @07:37AM (#10952332)
> Until the rise of scripting languages we would use compiled languages for everything.

That was because at the time, forking was expensive, threading was too hard, and memory leaked like a sieve. Rust addresses all of these problems, and does it nicely.

Re:Announcing Rust 1.6 by pjmlp on Friday January 22, 2016 @08:20AM (#10952500)
If you are speaking about C and C++ I agree.

For other compiled languages, I don't think so.

Re:Announcing Rust 1.6 by ktRolster on Friday January 22, 2016 @03:11AM (#10951435)
Except there were always those LISP guys in the back talking about how great the REPL was
Re:Announcing Rust 1.6 by pjmlp on Friday January 22, 2016 @03:23AM (#10951474)
So what?

Almost every programming language can have a REPL, it is called an interpreter. Anyone with a CS background should know this.

Also Lisp is a compiled language since the early days.

Re:Announcing Rust 1.6 by coldtea on Friday January 22, 2016 @04:17AM (#10951685)
>Almost every programming language can have a REPL, it is called an interpreter. Anyone with a CS background should know this.

That's the theory though. The practice is (was) that Lisp had an excellent REPL, and most languages didn't have one at all, or had a crappy one.

Some languages lend themselves to a REPL by making it much easier to program one. iPython is great, JS ones are decent. Go attempts at REPLs otoh are mostly BS. C++ REPLs (Cling) etc, are neither very handy nor very popular. Etc.

The truth is, some languages handle the REPL situation much better than others. And "scripting" languages are usually better than others at that.

And REPL is not really just an interpreter. You can have an interpreter without having a REPL, or without having the kind of full featured REPL we're talking about. Most BASICs run with an interpreter, but didn't have a REPL, for example.

Re:Announcing Rust 1.6 by pjmlp on Friday January 22, 2016 @04:33AM (#10951740)
That is why I mentioned almost.

I am pretty conformable with Lisp, which isn't a scripting language at all, offers both a very good REPL experience and has the option of compiling to native code, both at REPL and AOT.

Also BASICs not only had an interpreter, but they also had AOT compilers. Visual Basic had a REPL, it was called Interactive Window.

Scripting languages don't have AOT compilers to native code nor Lisp is a scripting language, so I don't get the point of the comment I was replying to.

Re:Announcing Rust 1.6 by coldtea on Friday January 22, 2016 @08:38AM (#10952584)
>That is why I mentioned almost.

Well, if by "almost" you meant "in practice few and far between", then we agree :-)

What I've seen is that languages with AOT rarely have good (or any) REPLs.

Now, LISP of course has AOT, but it also shared (and early on) many characteristics of scripting languages (GC, dynamic typing, etc).

So, maybe a better way to put it is Algol derived languages with AOT as a rule don't have a good REPL story.

Re:Announcing Rust 1.6 by pjmlp on Friday January 22, 2016 @11:09AM (#10953502)
That I agree.
Re:Announcing Rust 1.6 by eru on Thursday January 21, 2016 @08:38PM (#10950136)
Rust is a nicer language than Go---especially its type system. That might be reason enough.

What do you mean by `doesn't target backend app'?

Re:Announcing Rust 1.6 by allan_s on Friday January 22, 2016 @02:49AM (#10951365)
I've posted reasons why here : https://news.ycombinator.com/item?id=10949667

more reasons:

On error handling, in Go most of libraries and even some part of the std lib, erros are constant string, which mean that for example you can only do

`err == foo.DUPLICATE_KEY_ERROR`

but you can't extract which key, or then you start to have to either use an external library to do some string masking/unmasking, which complicate quite things and add one more dependency, or just to say "screw it, i will just log 'duplicate key error" which is unoptimal

I really did try go, to the point I even proposed a fix in the std library for a long standing bug in the xml library https://go-review.googlesource.com/#/c/15684/ , but not all the reason stated above makes me consider go as "yes sure it's an improvement over php/python/c++" but rust is like an even bigger improvement