News for hackers. Stuff that matters.
Re:Announcing Rust 1.6 by allan_s on Thursday January 21, 2016 @06:28PM (#10949395)
I was wondering:

As the HN crowd seems to have quite a lot of Rust supporters, would it be a good selling point in a job description ?

i.e if (it's just currently a personal hypothesis) a company were to consider to (re)write some part of its Rest-ish microservices and that Rust was the chosen language, and was looking for people to help on that, would it make a `interesting++` in your mind ? for real services used by real people by a not-so-startup company, in europe.

edit: I already deployed in production for my previous company some (with a very stricly limited scope) microservices in rust (with everyone approval) and it was quite a success, so I'm more and more thinking that rust is now enough developed to fit the market of language for microservices, as it's more or less "understand HTTP, read/write from redis/postgresql/mysql/memcache, do some transformation in between" and Rust now support these operations quite well

Re:Announcing Rust 1.6 by peteretep on Thursday January 21, 2016 @07:12PM (#10949679)
I'm a recruiter (and a developer).

Yes it would. People love to be trained on a new software stack at someone else's expense, especially if they're not having to take a seniority hit to go there.

Re:Announcing Rust 1.6 by CuriousSkeptic on Thursday January 21, 2016 @06:52PM (#10949546)
It just seems like an odd use case for rust. I can see how it would be attractive as an alternative to c++ or other systems language. But for shuffling data?

Also, since you mentioned PostgreSQL, if you can make the db handle json the shuffling part should be really trivial. Give node.js + pg-promise a spin for comparison.

But then again, I haven't used Rust for anything serious, so am happy to be wrong.

Re:Announcing Rust 1.6 by allan_s on Thursday January 21, 2016 @07:11PM (#10949667)
Rust made sense for me for that case because:

1. rust handle erros in a VERY expressive way, and I do want my services to log ANY errors, and to be sure to miss any (kind of like what go permits too , but Rust Errors are more flexible) , so with rust it's hard to forgot a case of error and finished with "errr my API did a 500 but i don't know why"

2. It's a (nearly) self contained binary with low memory overhead, I can have dozen of microservices like this on my workstation / CI environments without making the machine cries So I can deploy it on cloud provider X or workstation Y without needing to worry if it has the version of node / python / php I need

3. it creates very small docker image if you're using docker (so it beats node/python/php here)

4. if I want to make my services multi-threaded and have some internal cache for some reason I'm sure the compiler will not let me create concurrent access problem that I would otherwise only detect in production when it's too late (beats every other languages , including go , the go race detector of go is nice, but it's at runtime so not the same league)

5. no nil pointer exception things (beat other languages here too)

6. strong typing but flexible (no go, I don't want to cast everything in {}interface everytime i need to make things a bit more generic, though I know it's just a personnal opinion), because no I don't want my developer to either develop a "is_true" function , or worst to rely on type casting for if to work.

7. the compiler as my first set of test it's a whole category of things you don't need to write test for because it's already handled by the compiler.

8. highlevel when you needs, low level when you want, I know that the language is not my bottleneck (or then I've reached the point where I don't care because my system is performant enough) , but if I need to serialize my struct into a json, I can in some line of codes.

9. plenty other little things , like scoping variables, immutable by default , possibility to have your SQL request check at compile time if you use postgresql plugin, using first-class debuggers to do step by step if you need , interfacing with C libraries pretty easily

Re:Announcing Rust 1.6 by kyllo on Friday January 22, 2016 @01:28AM (#10951131)
Your above reasons why for Rust basically all apply to Haskell too, except it's higher level and garbage collected, which is why I think Haskell is the best language to write a web service in.

But, you could write embedded software, device drivers and even operating systems in Rust, that's the domain where Rust could and hopefully will dominate.

Re:Announcing Rust 1.6 by vpkaihla on Friday January 22, 2016 @06:16AM (#10952076)
Like all things in life, higher abstraction level of Haskell is not free. The price is more complex language (which many people don't have the capacity to properly learn) and less predictable runtime behaviour.
Re:Announcing Rust 1.6 by kyllo on Friday January 22, 2016 @08:47AM (#10952621)
As a self-taught programmer who's getting pretty comfortable with Haskell and also starting to dive into low-level languages (C, x86, Rust) I don't think Haskell is that conceptually complex. It's very abstract but it's also quite consistent. Because its semantics are designed around mathematical laws rather than shuffling bits between CPU registers and RAM, it doesn't have a lot of gotchas, WTFs, special cases, or safety rules to keep in your head. In Haskell, everything is an expression, all functions are closures, and all bindings are recursive, which means that you can inline or extract out expressions with incredible freedom, which makes refactoring so much easier.

Yes the runtime behavior is definitely less predictable with lazy evaluation, which is fine for web servers but terrible for systems programming.

Re:Announcing Rust 1.6 by baq on Friday January 22, 2016 @06:46AM (#10952164)
> less predictable runtime behaviour

with all my love for haskell, this is an understatement...

Re:Announcing Rust 1.6 by dikaiosune on Thursday January 21, 2016 @06:58PM (#10949588)
I've always liked the idea of using "systems" languages for data shuffling, because of the ability in some cases to stretch hardware several orders of magnitude further. I read this a while ago and just dug it up:

http://stevehanov.ca/blog/index.php?id=95

It's a bit silly, but I do think that Rust could be a very good solution here. For one thing, in my experience it is much easier to write than C++, especially for something you'd feel comfortable pointing at users.

It would be cool to see some articles that are the reverse of "scale all the things," something like "sympathize with all the caches."

Re:Announcing Rust 1.6 by Rusky on Thursday January 21, 2016 @07:32PM (#10949788)
A blog I've really enjoyed on that subject is Mechanical Sympathy: http://mechanical-sympathy.blogspot.com/
Re:Announcing Rust 1.6 by ddorian43 on Friday January 22, 2016 @04:56AM (#10951814)
Re:Announcing Rust 1.6 by nickpsecurity on Friday January 22, 2016 @12:19AM (#10950914)
First thing I see is an encoder and list of good design rules. This blog could be a gold mine if other articles are similar. Thanks for the link.
Re:Announcing Rust 1.6 by adrianN on Friday January 22, 2016 @04:10AM (#10951656)
Writing a web server from scratch in an unsafe language seems like an invitation to get hacked to me. So maybe in Rust this would make sense, but C++ is a dangerous proposition, I think.
Re:Announcing Rust 1.6 by sitkack on Friday January 22, 2016 @01:09AM (#10951073)
People often talk about scaling in a lopsided manner. Meaning scaling is only up, well scaling works both directions. For an architecture or runtime to be scalable, it needs to shrink as the demands placed on it fall. Scalability works in both directions.
Re:Announcing Rust 1.6 by lmm on Friday January 22, 2016 @04:31AM (#10951739)
Yes and no. Realistically you often have other constraints. E.g. for a lot of code I wrote at my last^2 job there would be no value in scaling below a single micro EC2 instance (I ran each service on its own instance and got value out of doing so), and almost all languages can scale down that far.
Re:Announcing Rust 1.6 by Matthias247 on Friday January 22, 2016 @04:03AM (#10951628)
I agree here. I'm often attracted to new stuff, so working with something new (like Rust) would be a plus in a job description, but I also think is the wrong tool for this kind of task - which would yield a minus for the job description.

This is the classic domain of scripting languages (PHP, Ruby, node, ...), where a huge ecosystem exactly for this kind of tasks exists. But yes, type safety and error handling is not the best there.

If a good type system and a good ecosytem is desired then F# or a JVM language (Scala with Play Framework, Kotlin, ...) could be used, which would from my perspective give a more productive setup for this task.

I don't want to say that Rust is not good, but (just like C++) I think it's best use cases are other applications then webservers, e.g. high performance audio and video processing or bare metal software.

Re:Announcing Rust 1.6 by azdle on Thursday January 21, 2016 @06:48PM (#10949525)
It would be for me, but like dikaiosune I've drunk the Rust koolaid almost fully by now.

But honestly, even if I hadn't it's be a selling point to me because it tells me that you're a place that isn't stuck writing everything in a single language but are willing to try new things are willing to use what seems to be the right tool for the job.

Re:Announcing Rust 1.6 by kbenson on Thursday January 21, 2016 @07:35PM (#10949806)
Well, sometimes depending on company size, number of developer developers, developer pool skill set, and many other factors, having a single (or very few) languages is a factor in the right tool. It's better when that's not the case though.
Re:Announcing Rust 1.6 by dikaiosune on Thursday January 21, 2016 @06:30PM (#10949411)
A friend of mine asked me about this last weekend, and I basically said that I've drunk enough kool-aid at this point to do anything to use it as my main work language. I'm lucky enough right now to have a lot of autonomy for my projects, and I'm using that to build some tools in Rust, but it's different than being able to focus on it full time.
Re:Announcing Rust 1.6 by seivan on Thursday January 21, 2016 @09:20PM (#10950331)
I know the feeling. I'd sacrifice my own free time to fill the gaps I know it's missing from Rails, it's only fair as I would operate 10x faster with things I'm comfortable with and has a full set toolbox. Considering Rust but, would prefer Swift or Typescript.
Re:Announcing Rust 1.6 by shepmaster on Thursday January 21, 2016 @10:19PM (#10950539)
Absolutely. And if you hire remote, I'd be happy to apply!
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

Re:Announcing Rust 1.6 by vitno on Thursday January 21, 2016 @10:04PM (#10950491)
yes. I would do pretty much anything to work in Rust at this point.
Re:Announcing Rust 1.6 by lmm on Friday January 22, 2016 @04:52AM (#10951799)
If I couldn't find a job writing Scala or OCaml or F# (all of which I'd consider better options for rest-ish backends) then I'd look for one writing Rust.

As I got more into this kind of language I found that the language tools gave me very strict isolation, which lowered the value of separating everything at the process level. So I've shifted towards a more monolithic style of architecture.