News for hackers. Stuff that matters.
Re:IPFS 0.5 by lachlan-sneff on Tuesday April 28, 2020 @07:23PM (#23013364)
I wish they hadn't picked go. Go isn't a bad language really, but it's a huge pain to integrate a go library into an app written in another language.
Re:IPFS 0.5 by echelon on Tuesday April 28, 2020 @07:29PM (#23013415)
C or Rust would be perfect. No GC runtime, no name mangling, fast, great ffi story.

Rust needs to start edging out Go for new tools. Kubernetes, Envoy, IPFS, etc. would have benefitted from it.

It might not have been time four years ago, but it's time now.

Re:IPFS 0.5 by stryan on Tuesday April 28, 2020 @08:41PM (#23013951)
Rust will start edging out Go once Rust becomes easier than Go to prototype/start projects.

Rust is a great language, but right now I can start a project in Go and have someone else start a project in Go and have something up and working in a week. Rust still takes significantly longer to learn and/or find skilled developers for. Go is up there with Python in terms of "Get something out now".

Re:IPFS 0.5 by rosywoozlechan on Tuesday April 28, 2020 @09:56PM (#23014435)
Rust isn't that difficult to prototype or start projects with? What trouble do you run into? I think the hardest parts to understand are the concepts of borrowing, lifetimes, and ownership, but you don't have to know all the subtleties of that to prototype. A basic understanding is fine to get started with. Just like a developer doesn't have to understand all the subtleties of generics to get started with either, lots of devs don't know what covariant or contravariant means and use generics.
Re:IPFS 0.5 by plerpin on Wednesday April 29, 2020 @01:27AM (#23015685)
Understanding the concepts is one thing, applying them is another thing entirely. The Rust compiler is an incredibly difficult beast to placate.
Re:IPFS 0.5 by hobofan on Wednesday April 29, 2020 @05:28AM (#23017174)
Especially in prototyping you can mostly .clone() everything, and stop worrying about any lifetime problems.
Re:IPFS 0.5 by plerpin on Thursday April 30, 2020 @09:05PM (#23038103)
Lots of deferred pain for when you productionize.
Re:IPFS 0.5 by hobofan on Friday May 01, 2020 @04:55AM (#23040267)
Yes, but this was on the topic of "is Rust suited for prototyping?", and I would say that cloning makes it much more suited, as it sidesteps a lot of the lifetime pains. You will have similar deferred pain if you e.g. prototype something in JS and then when it's time to move to production gradually move it to Typescript.

From personal experience of Rust projects in production, you can get by with cloning for a long time, and optimizing later is not too big of a pain in most cases. Performance problems due to excessive cloning are also very obvious in code and easy to profile for.

Re:IPFS 0.5 by StreamBright on Wednesday April 29, 2020 @04:17AM (#23016730)
Just a minor example.

https://github.com/awslabs/aws-lambda-rust-runtime/blob/mast...

Could you explain to a junior what Box<dyn std::error::Error + Send + Sync + 'static> does and how should a person who is starting to learn Rust come up with something like this?

Second minor example. I have a configuration string like let's say timeout for a certain type of connection. What is the recommended way to have that as a string that is accessible to all functions without fighting with the borrow checker?

In Elixir, I would use @timeout in the module for example. In Rust, I am not sure. Cloning the value to every place it needs it as a workaround.

Re:IPFS 0.5 by viraptor on Wednesday April 29, 2020 @07:09AM (#23017811)
I get what you're trying to say, but disagree with the examples. If you want to prototype and start a project, you don't care what exactly that box type means. You can use it and things will not break. It's part of that particular boilerplate.

It's like people using `std::string` and not necessarily caring for years what `template<class CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>> class basic_string;` means or does.

For the second example: environment variable. Once you need more, you can start researching static cells and use a ready crate for configuration loading / processing. If you want more, googling "rust mutable global configuration" brought me https://stackoverflow.com/questions/27791532/how-do-i-create... which gives a pretty good solution.

Re:IPFS 0.5 by StreamBright on Wednesday April 29, 2020 @09:05AM (#23018610)
>> If you want to prototype and start a project, you don't care what exactly that box type means.

I disagree. The whole point is to get to know a language. What do you how many things can you have in your code that you do not understand? Now you put it in production and it breaks. Who is going to fix it? I do not have a particulary positive experience with Rust on Stackoverflow. As a tech decision maker I put Rust in the risky category because it is hard to understand and many of the language features are implemented in a way that it is not easy to work with. Don't get me wrong, I like what Rust could bring to the table but with this upfront complexity it is not worth it. I know many companies who will be ok to take on Rust and they are ok with the way things are.

Your answer is funny to the second one. From SO:

Non-answer answer

Avoid global state in general. Instead, construct the object somewhere early (perhaps in main), then pass mutable references to that object into the places that need it. This will usually make your code easier to reason about and doesn't require as much bending over backwards.

Why would I pass in a mutable reference when all I need is a global static immutable value? You see this get ugly very quickly. We went with the lazy_static! way, but still. I would rather avoid these things entirely.

Re:IPFS 0.5 by viraptor on Wednesday April 29, 2020 @07:42PM (#23025921)
> The whole point is to get to know a language.

When you're actually starting up (you set the context to "someone starting to learn rust"), there will be some unknown things in any language. You'll get there, but you don't need to understand it from the beginning. If you do want to understand it, then you should get it from the official guide. Errors, dyn, box, lifetimes and send are covered.

"Value on the heap, which implements the error interface, is available forever, and can be shared between threads" is... not that complicated.

> Now you put it in production and it breaks.

If you're still learning the language and don't understand the boilerplate, you don't put your app in production.

> Why would I pass in a mutable reference when all I need is a global static immutable value?

You missed the context. The fragment was about a mutable global. If you just need an initialised, but immutable config, you pass a non-mutable reference.

Re:IPFS 0.5 by simonebrunozzi on Thursday April 30, 2020 @10:59AM (#23031538)
A good related question is: what will be the "future" of software development? I would bet that WASM and Rust will become more and more dominant in a 5-10 years timeframe. But it's so hard to come up with an informed opinion, as many developers tend to become "religious" about their language of choice.
Re:IPFS 0.5 by thefounder on Tuesday April 28, 2020 @09:45PM (#23014375)
>> Rust will start edging out Go once Rust becomes easier than Go to prototype/start projects.

I guess that time will never come...unless Go somehow looses its way

Re:IPFS 0.5 by StreamBright on Wednesday April 29, 2020 @04:12AM (#23016701)
Not to mention the learning curve. For junior developers to be productive it takes forever. I can teach F# to a junior in a week, Rust maybe a month. Even for senior devs, it is hard to decipher what is the actual meaning of the code sometimes. There is a lot of noise in Rust that makes it harder to grasp what is happening.

Before downvoting, this is our experience.

Re:IPFS 0.5 by jhoechtl on Wednesday April 29, 2020 @04:55AM (#23016954)
And therefore Rust will never outcompete Go in this regard in as much as Haskell, Ocaml, ... never overtook C. Rust might draw from the better principles and get things right C, C++, D, Go, ... failed to incorporate. But in order to get things done a company has to source developers from a market and consider that developers get replaced by another, taking over.

Even in a globalized developer market a smaller developer force is a risk.

In German we have a saying "to die in beauty" (in Schönheit sterben), does that translate? Your boss wants to get things done in due time and I see Go outcompete Rust in this respect.

Re:IPFS 0.5 by StavrosK on Wednesday April 29, 2020 @06:12AM (#23017453)
> does that translate?

It does, and it's very evocative.

Re:IPFS 0.5 by momack2 on Tuesday April 28, 2020 @07:38PM (#23013501)
There's actually a new Rust-IPFS implementation looking for more contributors. Seems to be moving pretty fast - https://github.com/ipfs-rust/rust-ipfs
Re:IPFS 0.5 by drudru11 on Tuesday April 28, 2020 @10:18PM (#23014565)
Rust does name mangling by default. However, you can turn it off per symbol just like in C++.
Re:IPFS 0.5 by spsoto on Tuesday April 28, 2020 @07:40PM (#23013509)
Envoy is written in C++, not Go.
Re:IPFS 0.5 by echelon on Tuesday April 28, 2020 @08:49PM (#23013995)
I'm aware. The creator occasionally pokes fun at the Rust folks for arguing that Envoy should have been written in Rust. And rightly so--Rust wasn't mature at the time Envoy was written.

If we revisit that now, C++ is the wrong language to start Envoy in today.

[dead]
Re:IPFS 0.5 by keeganpoppen on Wednesday April 29, 2020 @03:31AM (#23016422)
a citation is most definitely not needed. it's obviously a fucking opinion. and they are under absolutely no obligation to meet your standard of proof to demonstrate anything to you. clearly citations are not a necessary condition to posting-- this comment has no citations, but yet... hey look-- it's been posted! the horror!

classic HN obnoxious "citation needed" commentary strikes again. i swear i'm just gonna keep doing this every time i see this... until i get bored and give up, i guess.

Re:IPFS 0.5 by ncmncm on Wednesday April 29, 2020 @03:58AM (#23016603)
Jeez, calm down. "Citation needed" generates no more obligation than the original unsupported opinion did. Would you blow up the same way about "I disagree"?

The fact is, most opinions about what language somebody else ought to write their next library in are worth about what they cost to post.

Another is that, trendiness notwithstanding, Rust right now is best suited for a library few people will need. That may change in five or ten years. It might well not.

Re:IPFS 0.5 by keeganpoppen on Friday May 01, 2020 @01:53PM (#23044683)
Citation needed.
Re:IPFS 0.5 by tadfisher on Tuesday April 28, 2020 @08:41PM (#23013949)
Keybase and KBFS as well.
Re:IPFS 0.5 by hecturchi on Tuesday April 28, 2020 @07:54PM (#23013590)
Go can handle 100k goroutines (green threads) without a sweat.

This is useful for p2p systems in which you are connected to thousands of peers multiplexing several p2p protocols with each concurrently. You want to be able to switch threads as fast as possible.

The concurrency model is a bit easier to reason about too.

It would be good to see how Rust and others do. Other languages excel at other things (i.e. embedded devices ).

Re:IPFS 0.5 by jzoch on Tuesday April 28, 2020 @08:14PM (#23013756)
Rust can handle the same thing though the typical model now is using async-await and scheduling tasks on a threadpool. While I won't say its conceptually as simple as go can be, Rust also has channels, mutexes, and other concurrency primitives that allow you to create a similar story. It will also end up being more performant and less work to make correct (typically) due to its small runtime and extensive compile-time checking.
Re:IPFS 0.5 by hecturchi on Tuesday April 28, 2020 @08:28PM (#23013849)
Maybe if IPFS had started today they would have picked Rust.

Honestly I'm not sure why Go was picked specificall, but if you put things in the context of 5 years ago it doesn't seem a crazy choice.

Re:IPFS 0.5 by SparkyMcUnicorn on Tuesday April 28, 2020 @11:39PM (#23015071)
The Discord team wrote an article (or a few), and I think you'd find them very interesting.Specifically about their Go implementation, porting to Rust, and then the decision to use Rust wherever it makes sense as a result.

They're very sensible about it, and advocate using the right tool for the job.

Re:IPFS 0.5 by m-p-3 on Wednesday April 29, 2020 @09:23AM (#23018800)
I'm not sure if that applies here, but Discord switched a portion of their backend from Go to Rust because of some performance issues.

https://blog.discord.com/why-discord-is-switching-from-go-to...

Re:IPFS 0.5 by lachlan-sneff on Tuesday April 28, 2020 @07:58PM (#23013627)
Rust can easily do the same.
Re:IPFS 0.5 by matheusmoreira on Wednesday April 29, 2020 @12:58AM (#23015534)
Any language that lacks a simple and stable binary interface ultimately can't be used to build reusable code. If it's not simple, only compiler hackers will be able to work with the objects produced. If it's not stable, compatibility between two binaries isn't guaranteed and people won't even try to integrate existing libraries into their own software.

A big reason why C is still widely used. A library that's written in C can be used in any other language.

Re:IPFS 0.5 by karatestomp on Tuesday April 28, 2020 @08:23PM (#23013818)
Same thing that turned me off. There’d have been lots of cool and useful integrations popping up “for free” all over the place if they’d written it in a good library/integration language. Good language for a daemon, bad language for the reference (so, for anything halfway complicated, usually only) implementation of something intended to become a foundational protocol.
Re:IPFS 0.5 by momack2 on Tuesday April 28, 2020 @08:50PM (#23014001)
...there are a lot of cool and useful integrations popping up: https://blog.ipfs.io/weekly-84/.

go-ipfs is where the majority of new development happens right now as the desktop/server implementation (compared to js-ipfs=browser & rust-ipfs=IoT) - but if you want to prove that Rust is clearly better/faster _in general_ - have at it: https://github.com/ipfs-rust/rust-ipfs ;)

I think the thing jbenet was selecting for back in 2013 was concurrency support & modularity, and golang is still a decent choice for that. Rust 1.0 didn't happen until 2015 after the go-ipfs alpha was already out - but agree it's made awesome progress since then!

Re:IPFS 0.5 by karatestomp on Tuesday April 28, 2020 @09:35PM (#23014308)
I don't care about performance, exactly, it's just that with (say) a C implementation if you're even halfway popular you'll end up with modules in a dozen languages (wrapping your C lib) and an apache module and a storage backend for a few databases, maybe a Linux kernel module, and so on, in no time, and they'll all be pretty much in sync with what's
Re:IPFS 0.5 by correct_horse on Tuesday April 28, 2020 @07:31PM (#23013432)
They also picked javascript ¯\_(ツ)_/¯
Re:IPFS 0.5 by Groxx on Tuesday April 28, 2020 @08:33PM (#23013888)
JS has a better library-integration story than Go does, since there are so many JS implementations in other languages. Go drags all its runtime threads along with it.

But fair point :)

Re:IPFS 0.5 by wwright on Tuesday April 28, 2020 @08:31PM (#23013872)
I used to hate JS, but honestly, it made a lot of really smart decisions for dynamic documents. Some decisions weren’t great, but somehow they didn’t go as far wrong as C++ managed to in the same era…
Re:IPFS 0.5 by hecturchi on Tuesday April 28, 2020 @08:02PM (#23013664)
Browsers picked... until recently it was the only way to run in browsers.......