News for hackers. Stuff that matters.
Re:Why did we choose Rust to develop TiKV? by pornel on Wednesday September 27, 2017 @04:36AM (#15345898)
I can't wait until Rust is no longer be perceived as hipster trendy choice.

It's a very solid language in the no-GC niche and shouldn't need a blog post from every project that uses it.

Does it have to be 30 years old before it's not "new" and weird?

Re:Why did we choose Rust to develop TiKV? by greydius on Wednesday September 27, 2017 @09:07AM (#15347371)
Haskell is almost 30 years old and still considered 'new' and 'weird'.
Re:Why did we choose Rust to develop TiKV? by TremendousJudge on Wednesday September 27, 2017 @09:49AM (#15347754)
I don't know about new but it is pretty weird
Re:Why did we choose Rust to develop TiKV? by wyldfire on Wednesday September 27, 2017 @10:30AM (#15348105)
Here at HN Rust seems to come up frequently and it's indeed why I decided to take a look.

For my many colleagues who do not read HN, Rust is something that they might have heard of but haven't given any real attention to. For that matter, most haven't looked at golang either and they probably couldn't tell you what the difference between the two are.

IMO it will take a while before it grabs the attention of the mainstream software community.

Re:Why did we choose Rust to develop TiKV? by luckydude on Wednesday September 27, 2017 @10:08AM (#15347913)
I'm (very) old school, C is still my language of choice (though it could use some help). I like the syntax, it's pretty simple.

I tried playing with Rust and found the syntax to be off putting. I really wonder why each new language feels it is important to come up with a different syntax to say the same stuff. Go did a lot better than Rust in this respect, at least in my opinion.

It may be that appealing to C programmers isn't a thing any more, but if it is, then Rust could have done better. And, yes, I get that the syntax isn't the selling point of Rust, trust me, I get it. I just don't get why make people wade through some weird syntax when you don't need to.

Re:Why did we choose Rust to develop TiKV? by wyldfire on Wednesday September 27, 2017 @10:40AM (#15348214)
When I look at Rust it seems to me to be very much C-inspired syntax. The code-blocks-return-a-value style makes it much easier to understand some conditional paths.

"Why would Rust change the syntax to say the same stuff?" Well, Rust is able to meet all of C's requirements while addressing one of C's big old warts: lexical analysis of C code is Very Hard. (e.g. if this particular build added "-DFOO" or "-Ibar/" to the command line then maybe there's a syntactical error or not).

This means that writing robust tools to analyze or modify C code is Very Hard. I don't know if this was an inspiration for Rust's syntax but regardless I'm thankful that they didn't try to reuse C syntax.

Most other successors to C (save perhaps C++) have taken on features that make them unable to write code that we have been able to write in C (bootloaders, OS kernels, interrupt routines, device drivers, etc). Teams had a really legitimate and mostly sane reason most of the time for saying "we couldn't possibly consider Java/Go/Python/etc because we won't be able to meet our product's latency requirements."

Re:Why did we choose Rust to develop TiKV? by Ar-Curunir on Wednesday September 27, 2017 @11:06AM (#15348470)
What is the biggest difference between C syntax and Rust syntax? I can only really think of how types are stated: in C they precede the variable, whereas in Rust you put a colon and then the type (but often you don't need to do this cuz of type inference).

This change is much better IMO because there's a clear delineation between types and variables.

The same idea applies to function signatures, which are much clearer to me in Rust than in C/C++.

Re:Why did we choose Rust to develop TiKV? by ufo on Wednesday September 27, 2017 @10:15AM (#15347970)
Your comment about syntax sounds like you just want everything to look like C.
Re:Why did we choose Rust to develop TiKV? by luckydude on Wednesday September 27, 2017 @10:35AM (#15348162)
Yes, precisely. C, for the most part (function pointers are an exception) has a pleasant syntax. Go didn't like semicolons and other stuff that it found unneeded, but mostly took a lot of syntax from C so it's easy to read Go code even without understanding the language.

Rust kind of went in a different direction. Why? Understanding C syntax is pretty basic, there are a lot of C like languages. Why not be another one?

Personally, if every language was just a C variant I'd be happier. It would feel like "OK, I've got the basics down, let's go explore this dialect that added garbage collection and strings as real types" rather than "I want strings as real types, darn it, I need to go learn this Tcl language". That might be an extreme way to make my point, but I think it's clear, right?

Re:Why did we choose Rust to develop TiKV? by ufo on Wednesday September 27, 2017 @02:23PM (#15350726)
Other than its ubiquity, there are lots of bad thigns about C's syntax:

* Assignment as an expression is bug-prone

* The precedence for the binary operators is wonky

* Optional braces in if statements make the grammar ambiguous and is also bug prone (the infamous Apple goto bug)

* The type-declaration syntax is convoluted and people need tools like cdecl to understand the more tricky ones.

* The cast syntax is ambiguous and resolving this ambiguity relies on adding dirty hacks to the lexer to tell the parser about type names.

Re:Why did we choose Rust to develop TiKV? by p0nce on Thursday September 28, 2017 @05:25AM (#15355831)
> Assignment as an expression is bug-prone

Can be fixed without syntax change other than returning void.

> The precedence for the binary operators is wonky

But that's the precedence everyone is accustomed with. D enhance this by forbidding some non-parenthesized dangerous expressions.

> Optional braces in if statements make the grammar ambiguous and is also bug prone (the infamous Apple goto bug)

I've definately seen such bugs.

> The type-declaration syntax is convoluted and people need tools like cdecl to understand the more tricky ones.

This is fixed in languages that still feel C-like in syntax.

> The cast syntax is ambiguous and resolving this ambiguity relies on adding dirty hacks to the lexer to tell the parser about type names.

Yup.

Re:Why did we choose Rust to develop TiKV? by jjuel on Wednesday September 27, 2017 @10:41AM (#15348225)
What about the people that don't like the C style syntax? I think there is room for many different types of syntax. Just stick to the style of languages you like and ignore the ones you don't. Pretty simple.
Re:Why did we choose Rust to develop TiKV? by p0nce on Thursday September 28, 2017 @05:22AM (#15355816)
What is the added value of things not looking like C?
Re:Why did we choose Rust to develop TiKV? by luckydude on Thursday September 28, 2017 @01:38PM (#15359167)
Yeah, exactly the right question. To me, C is like English, everyone has learned how to speak it. Creating some new syntax is a little like switching to a different language. I find that difficult and annoying.

Here's an example. When I was doing the GUI tools for BitKeeper 20 years ago I used Tcl because Tk was (and still is so far as I can tell) the best gui toolkit around. But Tcl? Holy moly, what a miserable language (with apologies, and respect to John O, it's miserable). So I got some compiler people to make a second, parallel, compiler that took what looked like C as input and compiled it down to Tcl byte codes.

Pingo! All the power of Tk but with a C-like language on top. And you can call the tcl library code and it can call you.

All open source at http://little-lang.org

I wish someone would take the ideas there and make a gcc/clang dialect that had all C stuff but added in a ref counter and real strings, etc.

Re:Why did we choose Rust to develop TiKV? by AYBABTME on Wednesday September 27, 2017 @11:09AM (#15348505)
Syntax is a method to express ideas. Ideas at the core of a language should be easy to express with that language's syntax.

Some ideas are not possible in C as they are possible in Go/Rust/other languages. With the years, some ideas become more mainstream and then get integrated into the new languages that arise. These new languages need to express ideas that were not expressible in C, and thus may be better served by adopting different syntaxes.

In short: the ideas at your disposition and the ergonomic with which you can express them is a function of the syntax used to represent them. Different languages focus on different ideas, and so it follows that different syntax might be warranted.

Re:Why did we choose Rust to develop TiKV? by mac01021 on Wednesday September 27, 2017 @05:08AM (#15346047)
β€œnew and weird" is always relative to the industry/domain on application. In each domain , whether it be avionics or web development, managers are not going to want to use it until it has a proven record of success in that domain.
Re:Why did we choose Rust to develop TiKV? by zerr on Wednesday September 27, 2017 @05:10AM (#15346058)
On the other hand I can't wait when Swift becomes general, non-Apple language, available on most platforms (including the most popular one) "with batteries" - that will be the end of Go and Rust I think :)
Re:Why did we choose Rust to develop TiKV? by readittwice on Wednesday September 27, 2017 @06:18AM (#15346336)
> that will be the end of Go and Rust

Will it? I don't think so, although I think Swift is great. IMHO Rust targets another market compared to Swift. Rust feels more low-level, e.g. Swift uses Reference Counting for everything. Swift also can't give you some of the nice guarantees you get in Rust.

Go also has some nice stuff compared to Swift: simplicity, goroutines or tracing GC. Go is also already widely used.

Swift is certainly great for Mac/iOS-Development, but I am somewhat skeptical for other platforms. I am afraid that non-apple-platforms will always feel a bit like second-class. It's just not Apple's main priority and most Swift-devs will always be paid by Apple. But who knows, I may be wrong.

Re:Why did we choose Rust to develop TiKV? by cyber1 on Wednesday September 27, 2017 @05:53AM (#15346237)
Swift can't replace Rust in system programming domain because he uses ARC for memory management but Rust gives you choices.
Re:Why did we choose Rust to develop TiKV? by zerr on Wednesday September 27, 2017 @06:25AM (#15346375)
I don't think ARC is an issue here - it's just a deterministic reference counting - a la implicit using of smart pointers. Besides, Swift also has some unsafe pointer types as well.
Re:Why did we choose Rust to develop TiKV? by cyber1 on Wednesday September 27, 2017 @06:37AM (#15346425)
Yes, you right according to "deterministic" but you forget about overhead. Rust gives you more safe control on memory management and in most cases, you can always write the fast and efficient safe program without the overhead. Rust give different smart pointers and even sometimes when you 100% understand what are you doing you can use unsafe raw ptr.
Re:Why did we choose Rust to develop TiKV? by zerr on Wednesday September 27, 2017 @06:50AM (#15346476)
Yes, there is a trade-off of course. I think Swift is in the middle on Usability - Safety axis (C++ being on the left and Rust on the right extremes).
Re:Why did we choose Rust to develop TiKV? by imtringued on Wednesday September 27, 2017 @11:39AM (#15348877)
For certain programs a GC can basically make a programming language completely useless (no shared libraries with C abi, no realtime audio, videogames with stutter) regardless how fast the programming language is. This is not the case for swift. It's merely slower than rust.
Re:Why did we choose Rust to develop TiKV? by pjmlp on Wednesday September 27, 2017 @02:18PM (#15350674)
Also to note that Swift has bindings to the 2D, 3D and real time audio APIs on Apple platforms.
Re:Why did we choose Rust to develop TiKV? by pjmlp on Wednesday September 27, 2017 @06:59AM (#15346529)
Apple thinks otherwise on the context of their OSes.
Re:Why did we choose Rust to develop TiKV? by abiox on Wednesday September 27, 2017 @11:40AM (#15348907)
> system programming

worth mentioning that this term has a broader meaning than how some rust evangelists use it.

Re:Why did we choose Rust to develop TiKV? by jdright on Wednesday September 27, 2017 @01:29PM (#15350141)
The Rust "evangelists" version of system is most of the time the broader meaning of it as Rust do not exclude an entire class of systems as some languages out there.
Re:Why did we choose Rust to develop TiKV? by abiox on Wednesday September 27, 2017 @01:51PM (#15350398)
apologies, but i don't quite follow. what do you refer to by 'class of systems'?

one common sentiment promulgated by rust evangelists is, for example, that go is 'not a systems language' because it has a GC. however, this definitional exclusion doesn't seem to align with (evidently broader) historical use of the term 'systems language'.

Re:Why did we choose Rust to develop TiKV? by jdright on Wednesday September 27, 2017 @03:52PM (#15351640)
Real real-time embedded systems, low-level operating system components, etc. are some kind of things that GC languages exclude completely, so by definition, the subset of "system programming" set is eliminated from use with ie. Go but not from Rust. Consequently, Rust has wider class of systems which makes it a true system programming language as C and C++.
Re:Why did we choose Rust to develop TiKV? by abiox on Wednesday September 27, 2017 @04:45PM (#15352151)
"system programming" is not composed entirely of things where GC presents a non-trivial problem.
Re:Why did we choose Rust to develop TiKV? by jdright on Thursday September 28, 2017 @11:13AM (#15357639)
But 100% > 50%.
Re:Why did we choose Rust to develop TiKV? by abiox on Friday September 29, 2017 @02:30AM (#15363206)
i don't quite follow what you're trying to say.
Re:Why did we choose Rust to develop TiKV? by jdright on Friday September 29, 2017 @11:31AM (#15366150)
Simple put: Go ISN'T a true systems programming language because it simple does not work for every and ALL type of systems.

Yes, it may work with some type of systems, but this does not make it a systems language. If you don't want to accept this fact, then you have bigger problems or you reality is narrow.

Maybe this can help you see through your bubble: https://github.com/CppCon/CppCon2017/blob/master/Presentatio...

Re:Why did we choose Rust to develop TiKV? by SAI_Peregrinus on Friday September 29, 2017 @01:55PM (#15367507)
Another way to say it: The set of systems programming tasks for which Rust can be used is a superset of that for which Go can be used. Go cannot be used for real time code, as it does not provide latency guarantees. Go cannot be used for many embedded (microcontroller) systems as the runtime is required.

I've gotten Rust code to run on an ATSAMD21G18 Arm Cortex M0 (Adafruit Feather board). That board has 256K flash and 32K RAM. Go executables can't even fit in the program flash! Considering the sheer number of systems that have microcontrollers in them somewhere it would be very hard to call a language that doesn't support them a "systems" language. Maybe "applications language" would be more appropriate.

Re:Why did we choose Rust to develop TiKV? by abiox on Saturday September 30, 2017 @01:28AM (#15371400)
oh, i see. so you were pointlessly making a some kind of fallacy argument. no "true" systems programming language, indeed.
Re:Why did we choose Rust to develop TiKV? by jdright on Saturday September 30, 2017 @07:42PM (#15375571)
Seriously? Fallacy? That is really not wanting to understand things how they are. You should really go back to textbooks and try to understand hardware.
Re:Why did we choose Rust to develop TiKV? by rf15 on Wednesday September 27, 2017 @05:29AM (#15346139)
while I think that that would be a good thing (I like what happened with C#), I see the languages specified and controlled by Microsoft, Google and Apple as second-class languages, since they are often lacking in community input and are usually designed with certain platform-specific goals in mind instead of being cross-platform. (or company-strategic goals when it comes to Google)
Re:Why did we choose Rust to develop TiKV? by hnlmorg on Wednesday September 27, 2017 @06:43AM (#15346454)
I can understand conservative choices when it comes to picking a language but what you describe is a potential risk for plenty other existing languages as well as any new language too. Rust wouldn't be where it is today if it wasn't sponsored by Mozilla. Java was Sun Microsystems baby and I remember all the concerns at the time with the Sun vs Microsoft fighting over control of the ecosystem. Plus even many of the non-corporate languages are still heavily dependant on a small subset of maintainers.

At the end of the day if a language proves popular enough in other domains outside of the area which is directly controlled by the language maintainers, then the community will usually find a way of taking over maintenance of it.

We've seen this with Pascal, various BASIC dialects (including Visual Basic), and to an extent Java too. The problem with Objective-C was that - as far as I'm aware at least - it wasn't widely used outside of Apple / NeXT's ecosystem so if Apple deprecate support for Objective-C on their own platforms then there's little incentive for the community to keep using language (much like the problems with Visual Basic - which is why few know about it's open source forks). But languages like C# and Go are used massively across a multitude of domains so even if MS/Google were to kill them tomorrow, the community would almost certainly find a way to keep language alive. Heck, Go might even become more popular if that happened since many of the complaints against it are down to the highly opinionated approach of the current leadership.

Let's also not forget that Go and C# tooling are open source so the community wouldn't have to reinvent the wheel like they did with Delphi / Object Pascal and Visual Basic.

Re:Why did we choose Rust to develop TiKV? by blub on Wednesday September 27, 2017 @05:37AM (#15346170)
Yes, there's something not quite right with these company languages.

Whoever is smart will take note of what happened to VisualBasic and is happening to Objective-C.

Re:Why did we choose Rust to develop TiKV? by pjmlp on Wednesday September 27, 2017 @07:03AM (#15346556)
You mean like C and C++ being developed at AT&T, nowadays designed at ANSI, with people on ARM, Google, Apple, Blommberg, Sony, IBM, Microsoft's payroll?
Re:Why did we choose Rust to develop TiKV? by bryanlarsen on Wednesday September 27, 2017 @08:48AM (#15347217)
Actually, C was a lot worse. For the first 9 years C was basically whatever AT&T wanted. In 78 K&R published The C Programming Language, creating a specification. In the next decade C was very much tied to Unix and non-Unix usages often had some oddities and interoperability issues. The last 3 decades have been good though.
Re:Why did we choose Rust to develop TiKV? by maelkum on Wednesday September 27, 2017 @08:34AM (#15347109)
You know... there's a difference between "(...) with people on ARM, Google, Apple, Blommberg, Sony, IBM, Microsoft's payroll?" and "people on Google payroll". In one case you have many companies cooperating, in the other - just one company.
Re:Why did we choose Rust to develop TiKV? by blub on Wednesday September 27, 2017 @07:39AM (#15346753)
Looking into the past can have some predictive value, but looking that far back and at a different company is of very limited value.

If one evaluates C# they should obviously look at what MS are doing. Same thing for Swift and Apple.

Re:Why did we choose Rust to develop TiKV? by pdimitar on Wednesday September 27, 2017 @08:08AM (#15346938)
I think what <pjmlp> is saying is that (1) these languages are too widely adopted to fail -- somebody is bound to take the ball and continue dribbling it even if the worst happens (company abandons language) and (2) to have a widely adopted language means you have to be a member of a number of committees -- because without standards you wouldn't become a widely adopted language in the first place.

In short, we're quite safe in terms of if C#, Swift and Go will live on. They will.

Re:Why did we choose Rust to develop TiKV? by blub on Wednesday September 27, 2017 @10:22AM (#15348026)
The issue with C# and Swift is that the Apple and MS dev communities enjoy having a ready made solution that they can pick up and work with immediately. Official support is very important.

C# and to some extent Swift are also two huge platforms, there are very few organisations out there that would be able to steer their development.

Finally, they are not standardised in any way. MS tried something with 2.0 and then gave up.

My impression is that these two live and die by the will of their corporate masters. I'm not saying they will kill them or anything, that would be pretty stupid of them to do.

Re:Why did we choose Rust to develop TiKV? by pjmlp on Wednesday September 27, 2017 @10:46AM (#15348278)
> Finally, they are not standardised in any way. MS tried something with 2.0 and then gave up.

They are standardized, you just need to look at the right place.

https://docs.microsoft.com/en-us/dotnet/csharp/language-refe...

https://docs.microsoft.com/en-us/dotnet/visual-basic/referen...

http://fsharp.org/specs/language-spec/

https://swift.org/documentation/

Re:Why did we choose Rust to develop TiKV? by blub on Wednesday September 27, 2017 @02:12PM (#15350609)
Documentation & specs is not standardisation, not in the C or C++ sense. But you already know that, so why are we having this conversation?
Re:Why did we choose Rust to develop TiKV? by pjmlp on Wednesday September 27, 2017 @02:19PM (#15350684)
I assume you know what a de facto standard is all about.
Re:Why did we choose Rust to develop TiKV? by pjmlp on Wednesday September 27, 2017 @07:51AM (#15346826)
If Google, Apple or Microsoft take their employees out of ANSI or from GCC/LLVM contributions, I can assure you they won't move much beyond the current state.
Re:Why did we choose Rust to develop TiKV? by blub on Wednesday September 27, 2017 @10:25AM (#15348053)
What are the odds that all big players would remove support for something that their platforms are built on? At the same time?

C++ is one of the healthiest languages in existance. It hits all the important checkboxes of standardisation, wide industry and platform support and large community.

Re:Why did we choose Rust to develop TiKV? by pjmlp on Wednesday September 27, 2017 @10:48AM (#15348313)
I imagine you never lived through the days when each C++ compiler had a different understanding what it meant to compile C++ code.

It is just like trying to compile the Linux kernel with clang instead of gcc, with the source code full of gcc extensions.

Re:Why did we choose Rust to develop TiKV? by pdimitar on Wednesday September 27, 2017 @08:04AM (#15346906)
Would you please give an example on how are Google's company-strategic goals making Go platform-specific, or hampered in any way?

Please note that I am not demeaning your statement. It's a legitimate curiosity on my side.

Re:Why did we choose Rust to develop TiKV? by sanxiyn on Wednesday September 27, 2017 @09:04AM (#15347350)
One example that comes to mind is Go dependency management. For a long time (and still?) Go had no way to do versioned dependency. Obviously this is no problem for Google which reportedly build from HEAD, but this shows Google-bias in Go development.
Re:Why did we choose Rust to develop TiKV? by AYBABTME on Wednesday September 27, 2017 @11:13AM (#15348563)
It does not show a strategic agenda that influences the language's governance, it only shows that Google was blind in that area.
Re:Why did we choose Rust to develop TiKV? by pjmlp on Wednesday September 27, 2017 @07:01AM (#15346543)
So I guess you also see C and C++ as second-class languages, given the employers of the people meeting at ANSI.
Re:Why did we choose Rust to develop TiKV? by hashmal on Wednesday September 27, 2017 @06:24AM (#15346363)
All three have different goals and solve different problems. While you can compare things like "they both have MATCH statements" or "unions are safe", deeper they have nothing to do with each other.

You would be crazy to use swift (or objc) in real-time stuff. You would be crazy to write a UI-heavy app in rust. (note: I'm talking about high level DOM-like manipulation, not about rendering engines)

Re:Why did we choose Rust to develop TiKV? by blaenk on Wednesday September 27, 2017 @01:56PM (#15350453)
> You would be crazy to write a UI-heavy app in rust. (note: I'm talking about high level DOM-like manipulation, not about rendering engines)

I think the jury is still out on that one. I agree with the current state of things but the potential to ease and facilitate this is tremendous through the use of syntax extensions (procedural macros) which can dramatically simplify that use case. In general I think procedural macros add a _lot_ of versatility/flexibility to the language. I anticipate that there will be a huge boom in that area once they stabilize, and it will catch many people by surprise.

An example of the versatility that they enable is the work-in-progress async/await [0], whereas in other languages they would usually have to be implemented in the language itself. Note that this does not preclude their implementation in the language itself, but since it's a work-in-progress they're able to experiment with them without having to implement them in the language from the beginning.

[0]: https://github.com/alexcrichton/futures-await

Re:Why did we choose Rust to develop TiKV? by hashmal on Thursday September 28, 2017 @02:02AM (#15354993)
I have to agree, things could change in the future. However, my guts tell me rust GUI libraries/frameworks won't be as great as say, Cocoa, although that's something I would love.
Re:Why did we choose Rust to develop TiKV? by pdimitar on Wednesday September 27, 2017 @08:11AM (#15346951)
Very true.

In the same lane of thought, I am in love with Go when it comes to microservices, network libraries/bridges and CLI tools but it's very ill-suited for web development. So I shrugged it off and only do web dev with Elixir.

Conversely, Elixir is awesome for a multitude of things but it absolutely can't compete with Go in its strong areas.

Language wars are pointless.

Re:Why did we choose Rust to develop TiKV? by geodel on Wednesday September 27, 2017 @10:41AM (#15348231)
Yes next version of Swift will be so awesome it will kill all programing languages.