News for hackers. Stuff that matters.
Re:Why did we choose Rust to develop TiKV? by dullgiulio on Wednesday September 27, 2017 @04:34AM (#15345886)
Even more, Go is excluded as (author's opinion) goleveldb is not as mature as RocksDB. Thus they should have used CGo, which is way suboptimal, slower etc.

The title should have been: "C++11 or Rust? We chose Rust". In a greenfield project like this one seems to be, it's I choice I would approve.

A personal note regarding future comments to this thread: I have had enough of negative advertising against Go in every language related thread. People who use Go are not stupid: they know the language limits and tradeoffs and are okay with them. Deal with it.

Re:Why did we choose Rust to develop TiKV? by peoplewindow on Wednesday September 27, 2017 @09:44AM (#15347697)
Re your last part - is that fair? It's very common that programmers have to end up maintaining code written in languages they don't like, due to the original authors moving on, lack of better jobs in their area, whatever.

People advocate against Go partly because they'd rather not have to work on Go codebases in future.

Re:Why did we choose Rust to develop TiKV? by jjuel on Wednesday September 27, 2017 @10:38AM (#15348193)
Well I don't want to work on C++ or Rust in the future should I go into every thread about it and slam them for their shortcomings? Should I call every dev that uses them stupid? That is what he was talking about. You can not like the language, but don't call people who do like it and use it idiots. There are better ways to get your points across.
Re:Why did we choose Rust to develop TiKV? by peoplewindow on Thursday September 28, 2017 @11:10AM (#15357625)
People do! But not as much with C++ because it's very rare to find a C++ developer who is genuinely in love with the language and is unaware of its faults. Not many people starting new C++ codebases today unless they feel they have no credible alternative choice.

To a lesser extent the same is true of Rustaceans - they tend to be well aware of the constraints of their language, and won't try to defend it or pump it outside of some specific use cases. Nor do the Rust designers who are fairly humble.

Nobody should be calling Go users stupid. But they typically don't. At least not here. The language itself, on the other hand ...

Re:Why did we choose Rust to develop TiKV? by jaredklewis on Wednesday September 27, 2017 @01:02PM (#15349818)
Welcome to HN lol. You’ve got it easy. Try being a front end dev, because as HN will tell you, none of us know anything about computer science, which is why we are wasting our lives making over engineered bloated shit. And we have a obsession with novelty, which is why all our technical decisions are based on what is currently fashionable.

HN is not a very understanding place...

Re:Why did we choose Rust to develop TiKV? by model_m_warrior on Wednesday September 27, 2017 @01:10PM (#15349903)
Indeed, Front enders will never be the geniuses the people writing ad hoc CRUD operation end points are.
Re:Why did we choose Rust to develop TiKV? by Thaxll on Wednesday September 27, 2017 @11:59AM (#15349101)
The reason is people have no clue about Go most of the time and advocate against it because it's popular. Pretty much like Node ect... I mean look at Erlang derivates / Haskell / Rust, you don't see negativity in related language.
Re:Why did we choose Rust to develop TiKV? by candiodari on Wednesday September 27, 2017 @12:13PM (#15349245)
Or perhaps they're language geeks. Go is truly a horror show when it comes to programming language concepts. Everything about go is a complete special case. Select ... has it's own type system exceptions (and so many exceptions you might as well say Go simply has different type systems for all built in types, for all built in functions, and for several special forms). Make ... ditto. New ... ditto. "Go" same. Channels ? Effectively a separate type system. Dicts ? Same. And so on.

Everything is a compiler exception. Nothing makes sense. Nothing.

The absolute worst in Go, in my opinion, is the "range" function/special case. It is return-type polymorphic. That's right, it does different things depending on what you assign it's result to (not even C++ dared to go there). Not parameter polymorphic, return type polymorphic. "Assign" a range to one variable, does X, two variables, does Y, nothing ? does something else yet again, channel ? Again something else and all of these are special cases in the type system (same -but not quite the same, of course- with case, channels and dicts, by the way)

Needless to say, even though you have to assign ranges to things in Go, that's the only way to use it, that assignment does something entirely different from any other assignment in Go's type system.

Go is how to make a language extremely dumb and yet make have a type system that can't be (fully) described shorter than Haskell's.

Re:Why did we choose Rust to develop TiKV? by PopsiclePete on Wednesday September 27, 2017 @01:48PM (#15350365)
I love Go and agree with everything you said.

I was never good at computer science-y "language theory" type stuff. I believe you when you say that Haskell or Forth are better languages - I just can't use them worth a damn.

Go is a practical language for me - it's not beautiful, or elegant, the type system is only 70% there, can be verbose, etc, etc, but it allows me to put my code in production and have a very high level of confidence that I won't get a phone call at 4 am. I don't have that confidence with Ruby, or Python, or Javascript.

I find that Go is very easy to pick up, and hard to really fuck up. Most people at my company can read my code and I can read theirs, which is mind-boggling to me. Go somehow achieved what I thought was impossible - to read and grok quickly other people's code.

Go sees was developed by "engineer" types - not "language nerds". And, yes, it shows.

FWIW, I also love Rust and C, but will choose Go over Rust any day when my productivity and dead-lines are more important than close-to-C performance.

Re:Why did we choose Rust to develop TiKV? by Thaxll on Wednesday September 27, 2017 @12:41PM (#15349579)
I don't code at work for programming language concept, you see you should use the tools that make sense for the task you're working on. I'm not being paid to have fun on using an academic language that no one use, have bad tooling, not enough libraries to work with. You never wonder why pretty much no one uses Haskell / Erlang if it's that great? Having the best language concepts doesn't mean a thing in the real world. I try those things at home not at work where $$$ is at play.
Re:Why did we choose Rust to develop TiKV? by peoplewindow on Thursday September 28, 2017 @11:13AM (#15357641)
He wasn't saying use Haskell instead. It was a comparison of the complexity of the type system vs power provided.

Most Go programs could have been written in Java, Scala, C# or Kotlin and been shorter, more predictable and probably faster. Certainly more maintainable (ok maybe not for Scala).

Re:Why did we choose Rust to develop TiKV? by Vendan on Wednesday September 27, 2017 @01:46PM (#15350329)
Range is hardly return-type polymorphic. It always returns the same things, you are just free to ignore them, i.e.

  for k := range map { }
is the same thing as

  for k, _ := range map { }
Would requiring the second version instead of the first actually be that much of an improvement?

The only true return-type polymorphism is type assertions, which is reasonable in my mind cause I don't think ignoring the "assertion failed" should ever be a logical thing to do.

Re:Why did we choose Rust to develop TiKV? by candiodari on Wednesday September 27, 2017 @11:09PM (#15354253)
Ok. Now consider what happens with slices/arrays instead of maps.

  1) for k := range list {}

  2) for k, i := range list {}
In python, the equivalents are:

  1) for x in lst:

  2) for x, y in enumerate(lst):
So are these "the same" ? No.
Re:Why did we choose Rust to develop TiKV? by Vendan on Thursday September 28, 2017 @08:23AM (#15356558)
more accurately it's

  for index := range list {}
and

  for index, value := range list {}
Yes, these 2 version do perform very similarly, you are just ignoring the second return value in the first version, i.e.:

  for index, _ := range list {}
Re:Why did we choose Rust to develop TiKV? by edem on Wednesday September 27, 2017 @06:26AM (#15346378)
I haven't used Go or Rust but when I compare them I have a gut feeling that I'd be better off with Rust primarily because Go's build tools are not adequate. What do you think about this?
Re:Why did we choose Rust to develop TiKV? by jimsmart on Wednesday September 27, 2017 @07:44AM (#15346786)
Well, your question is simply too open-ended: nobody can really answer that for you, as you give no indication whatsoever as to your potential use-cases.

FWIW: I've been coding in Go for a few years now, for me and (perhaps more importantly) the kind of projects I choose to use it for, the build tools have been more than adequate.

As with many things: it ultimately depends on what you're wanting to do, and what your expectations are.

Re:Why did we choose Rust to develop TiKV? by lilbobbytables on Wednesday September 27, 2017 @08:37AM (#15347129)
What kinds of projects do you use it for?
Re:Why did we choose Rust to develop TiKV? by jimsmart on Wednesday September 27, 2017 @10:26AM (#15348067)
I've implemented some website backends, a ton of 'micro' services, various command-line tools, and a bunch of data-processing stuff. (The distinction between some of these is somewhat arbitrary)

These are the areas I think Go is most suited to, currently — and they've all been a breeze to implement/test/deploy/maintain.

Re:Why did we choose Rust to develop TiKV? by Thaxll on Wednesday September 27, 2017 @08:47AM (#15347212)
What do you mean by not adequate? Go tooling is way better than Rust. The only thing that Rust does better in that field is package dependency and it's going to change soon for Go.
Re:Why did we choose Rust to develop TiKV? by steveklabnik on Wednesday September 27, 2017 @10:05AM (#15347882)
What parts of Go tooling do you miss in Rust?
Re:Why did we choose Rust to develop TiKV? by PopsiclePete on Wednesday September 27, 2017 @01:58PM (#15350467)
First, I want to say that I have great respect for you and everyone else in the Rust community. It's now my second-favorite language (after Go).

I've been learning Rust over the past months and I don't think the borrow checker stuff is as scary as people make it sound, match is amazing, so are traits, enums, cargo....

But, I can't, for the life of me, wrap my head around Rust's "concurrency" story. Yet.

Go concurrency is as close to trivial as one can get - channels, goroutines, select. That's it. And they compose nicely. I was doing concurrent networking stuff in a matter of days.

Rust has channels, select (kind-of?), but then I discovered it has futures, and something called "mio", and now something called "tokio", also read something about generators and coroutines, saw that C#-like "async/await" stuff is also being worked on, and I'm not sure how these things interact with each other.

I get the .NET async/await story, and always felt it was (good) syntactic sugar on top of "raw" JS-style futures, but how do all of them play with the CSP-style stuff like channels that's in the std. lib already? Is one being deprecated?

I feel in general Go's CSP model is more "powerful" and more "generic" than futures - you can even emulate futures/promises with Go's primitives, but I don't see how you can do what I do in Go with bare futures - "streaming" type stuff is especially hard with the futures' "all-or-nothing" approach.

I think Rust really nailed down the "one-thing-at-a-time" story - the docs, tutorials - all great. But for me it broke down quickly on the "easy concurrency" end - and maybe it's just a question of better tutorials/docs?

Re:Why did we choose Rust to develop TiKV? by steveklabnik on Wednesday September 27, 2017 @02:21PM (#15350702)
Thanks!

Yeah, so this is basically the result of two things:

1. Rust-the-language focused on making concurrency safe, and getting primtives right

2. The higher-level aspects of the story are still shaking out.

The core primitives are very simple: Sync and Send, two traits which let you declare invariants. But most people don't want to be programming with primitives. So there's been a lot of iteration on what a higher-level story looks like. There are a ton of options, and we've been iterating through them to figure it out. The stuff you're seeing is the result of that process, so you're seeing how the sausage is made, which can definitely be confusing. It's all under active work, and then, once the pieces are in place, getting the right docs/tutorials there.

So, yes. Thanks. It's a good reminder. We'll get there :)

One last thing, as a small amount of food for thought:

> I feel in general Go's CSP model is more "powerful" and more "generic" than futures

In some senses, yes, but they also come with tradeoffs, like any technical choice. Specifically, in order to do concurrency this way, you must go with green threads. And green threads lead to smaller stacks, which leads to non-zero cost of calling into C code, which is a drawback that Rust can't sustain. It works great for Go, but can't really work in Rust, generally. I mean, you can do it, yes, but that drawback doesn't work for the majority of our audience.

It's these kinds of tricky, in-the-weeds stuff that makes designs hard and take time.

Re:Why did we choose Rust to develop TiKV? by Thaxll on Wednesday September 27, 2017 @11:19AM (#15348635)
- Fast / cross compile

- Benchmark / profiling are much better ( https://blog.golang.org/profiling-go-programs )

- go fmt / go vet

- go doc

All of that that is supported by default by the Go team on all platforms, meaning it works well and I don't have to worry of using a 3rd party Cargo package.

Re:Why did we choose Rust to develop TiKV? by steveklabnik on Wednesday September 27, 2017 @11:43AM (#15348941)
Thanks!

Compile speed is certainly a thing go is excellent at. Cross-compiling, Rust is almost as good, but not quite yet, working on it!

Benchmark stuff is not yet stable, but for profiling, you don't need a special tool for Rust; all the C and C++ tooling works.

fmt/vet is rustfmt and clippy, which work today, and soon will be distributed with Rust tool.

rustdoc already ships with Rust.

So, my takeaway is mostly, needs some polish and shipping with the compiler. Thanks!

Re:Why did we choose Rust to develop TiKV? by alexnewman on Wednesday September 27, 2017 @11:29AM (#15348767)
Go doc and go fmt have rust equivalents. What’s better at profiling?
Re:Why did we choose Rust to develop TiKV? by Thaxll on Wednesday September 27, 2017 @11:40AM (#15348906)
There is nothing out of the box for profiling ( but it's bit different since no GC and use C/C++ tools ). What's the equivalent of doc godoc -http=:6060 ( it sounds silly by last time I was in a plane and was able to browse the Go doc Like if I had internet access )
Re:Why did we choose Rust to develop TiKV? by steveklabnik on Wednesday September 27, 2017 @11:58AM (#15349097)
Just cargo doc; I think it has a --open flag too. (Rust docs don't need a web server running)
Re:Why did we choose Rust to develop TiKV? by dullgiulio on Wednesday September 27, 2017 @03:51PM (#15351626)
Probably opens a "file://..." then. Go docs run their own embedded server, they don't need one, just to be precise.
Re:Why did we choose Rust to develop TiKV? by steveklabnik on Wednesday September 27, 2017 @04:18PM (#15351890)
Yeah, that's exactly what it does.
Re:Why did we choose Rust to develop TiKV? by alexnewman on Wednesday September 27, 2017 @12:40PM (#15349572)
Total nonsense rust makes it trivial to profile
Re:Why did we choose Rust to develop TiKV? by estebank on Wednesday September 27, 2017 @11:53AM (#15349050)
> - go fmt / go vet

rustfmt (will be coming with rustc soon)

> - go doc

rustdoc (comes with rustc)

Re:Why did we choose Rust to develop TiKV? by alexnewman on Wednesday September 27, 2017 @11:30AM (#15348776)
The other way around closed source development is weird in go.
Re:Why did we choose Rust to develop TiKV? by Vendan on Wednesday September 27, 2017 @01:47PM (#15350352)
That's a plus in my books :)
Re:Why did we choose Rust to develop TiKV? by Kubuxu on Wednesday September 27, 2017 @10:54AM (#15348374)
go fmt
Re:Why did we choose Rust to develop TiKV? by steveklabnik on Wednesday September 27, 2017 @11:06AM (#15348483)
https://github.com/rust-lang-nursery/rustfmt

It should be distributed along with the rest of the tooling in the coming months!

Re:Why did we choose Rust to develop TiKV? by alexnewman on Wednesday September 27, 2017 @11:26AM (#15348739)
What’s wrong with cargo fmt
Re:Why did we choose Rust to develop TiKV? by dullgiulio on Wednesday September 27, 2017 @11:36AM (#15348850)
It has options ;)
Re:Why did we choose Rust to develop TiKV? by msl09 on Wednesday September 27, 2017 @07:42AM (#15346775)
I haven't used Rust yet but I can tell you that the go tools are very robust. It's a very good language if you stay within it's optimal scope and do everything by the book, go tends to punish quite hard developers that try to be "create" with project layouts and best code practices and so on.
Re:Why did we choose Rust to develop TiKV? by jackmott on Wednesday September 27, 2017 @11:17AM (#15348605)
I will probably use Go as soon as it has generics.

=)

Re:Why did we choose Rust to develop TiKV? by PopsiclePete on Wednesday September 27, 2017 @01:49PM (#15350373)
you cheeky SOB.....

But it does have generics - maps, channels, slices! What more do you need, man!?

Re:Why did we choose Rust to develop TiKV? by rev_null on Wednesday September 27, 2017 @11:26AM (#15348734)
So... Never?