Live data from Hacker News

Four years with Rust

words.steveklabnik.com

151–160 of 199 posts

Re: Four years with Rust

#151
> We removed the repl from the tree, as it never really worked, and was a maintenance nightmare. This one is the only one I know of today. Some people ask about one, but nobody has done the work to get a good one together yet. It’s tough!

This is a bummer. I remember when I first tried out rust the repl was still a thing. As someone who writes mostly Haskell and Python, interactivity with a language is a huge plus. I hope that eventually another repl comes around.

Re: Four years with Rust

#152
post #148

Earlier quoted context omitted.

Can you talk more about using Pony in a production environment? What are the performance aspects of it? How do you find writing 'non-actor' code - like just doing some string manipulation? I find the language fascinating but I'm learning Erlang and I don't really want to get started with Pony at the same time. Do you have experience with Erlang? what made you choose Pony? Sorry for the bombardment of questions but I…

I've never met anyone else using Pony in production, so I'll try and give the best answer I can. > What made you choose Pony? We wanted a Type Safe language to run a REST API frontend. That is to say, we wanted to have something that could redirect requests to the appropriate servers, at scale, whilst maintaining Type Safety in the server itself. We got hit by so many issues from JSON's weak/absent typing causing run…

> Erlang has this sort of huge cognitive overload with it's syntax, making it take longer to learn, for no obvious benefits.

That's just weird. How much of an effort did you even put into it? Erlang may have ugly syntax but it's the simplest syntax of all popular languages and the cognitive load while writing is pretty much the lowest I've come across. The language itself is tiny. Or did yo mean you weren't used to a functional language and that was the cognitive overload?

Re: Four years with Rust

#153

Wow, four years already. Maybe you can help settle this question I've had. I'm a rubyist (like you were/are, and wycats, and a bunch of rustaceans), and I think that sort of drove my interest in rust. But after 4-5 years of ruby the dynamism which initially was super cool, has grown a little frustrating and I long for a more sophisticated type system and a compile step, since frustrating bugs crop up from time to tim…

Its nice to "take a break" from static types once in a while and hack together some kind of data munging script in python every once in a while. But every time I have tried to go larger in scope I ended up regretting it. I'm not sure I would want to do any kind of dynamically typed programming professionally again.

Re: Four years with Rust

#154
post #150
post #146

Earlier quoted context omitted.

What does that look like in code? I was using c# so I did the dirty: T1 arg; var foo = arg as T2; if (foo != null) .... Also, how do we format code here?

In Rust, you'd define an `enum` of two types. enum Either { Type1(T1), Type2(T2), } let's say you get a value of type Either then you can match on them: match value { Type1(v) => func(v), Type2(v) => func2(v), }

Does that let you work with the default type? What I was doing in c#:

  function(T1 thing) {
    //do normal T1 stuff here
    var foo = arg as T2;
    if (foo != null)
      foo.T2Stuff();
    //more normal T1 stuff
  }
If I'm understanding your example I would have to wrap all the T1 stuff in a match.

Re: Four years with Rust

#155

I would appreciate if anyone can share your dev setup for Rust. I tried Rust and Racer long time ago and it's not a pleasant experience.

Atom with a properly configured racer and rustfmt has been nice, though I have run into one or two very minor annoyances.

Re: Four years with Rust

#156
post #129

Earlier quoted context omitted.

Rust doesn't have a GC in the first place, so there's nothing to turn on. Even then, the fundamental hurdle with GC isn't the effect on your program's runtime, it's the effect that it has on the lifetimes of your data . GC (and RC) are means of dynamic lifetime determination. Manual memory management is static lifetime determination. The latter requires you to structure your code in a specific way, which may be less…

I was just thinking that most languages are either GCed (like Java or Go) or manually curated (C/C++/rust). My idea is that if one could write in a language like Go (which has some kind of GC), but when one wants, say "I'll take care of this memory".

Rust actually started with a model like this. The idea was when starting out for the first time you can use garbage collected pointers for everything and then switch to the manual model when you needed it. Problem is then that unless your standard library and all the major open source libraries work perfectly for both the garbage collected objects and for the manually managed objects then you need to learn manual memory management early on anyway, so the garbage collector wasn't helping anyone. The language design element of this is really tough to do in a usable way.

D has optional GC but their standard library is kind of fucked up.

Re: Four years with Rust

#157
post #148

Earlier quoted context omitted.

I've never met anyone else using Pony in production, so I'll try and give the best answer I can. > What made you choose Pony? We wanted a Type Safe language to run a REST API frontend. That is to say, we wanted to have something that could redirect requests to the appropriate servers, at scale, whilst maintaining Type Safety in the server itself. We got hit by so many issues from JSON's weak/absent typing causing run…

> Erlang has this sort of huge cognitive overload with it's syntax, making it take longer to learn, for no obvious benefits. That's just weird. How much of an effort did you even put into it? Erlang may have ugly syntax but it's the simplest syntax of all popular languages and the cognitive load while writing is pretty much the lowest I've come across. The language itself is tiny. Or did yo mean you weren't used to a…

I use Scheme extensively, which I would argue has the least syntax of the functional languages.

Erlang seems simple on the surface, but each type seems to have it's own DSL, allowing things that seem the same, to not be, which means you have to hold more context in your head.

e.g. Are these two the same?

  ensure(A, B) ->

  if A == B ->
Does -> always mean function? Or does it mean something similar to progn or begin from CL and Scheme? Or does it vary with context?

I had issues teaching where to use ; or . or end, and having people actually comprehend the reasons enough to do it without thinking.

At least with Scheme it's always )

We also investigated using Elixir, which has less overhead, and more people find easier to get up and running with. However, at the time Mix wasn't stable yet, which counted it out.

Re: Four years with Rust

#158
post #88
post #41

Rust as a language is now realizing the benefits of borrow checking. As the article points out, the syntax doesn't have to distinguish between move and assign. The borrow checker will catch a reuse of something already moved away. This turns out to be effective enough in practice that the syntax distinction isn't necessary. That wasn't obvious up front. Not having exceptions tends to generate workarounds which are ug…

> There's still too much that has to be done with unsafe code. But the unsafe situations are starting to form patterns. I think as long as those patterns can be abstracted out and moved into thoroughly-vetted libraries with a safe interface, unsafe code isn't really a problem. I expect that getting Rust's standard libraries to a place where regular applications very rarely need to create their own unsafe code blocks…

What I worry about is those "thoroughly-vetted libraries" is that the use of those will likely follow a power law distribution in terms of code dependent upon them. When that happens, a disproportionately-high amount of code will depend upon those libraries. So when a defect (or vulnerability) shows up in one of them, a disproportionately-high amount of code will become vulnerable.

Reducing this unsafe surface area should result in outsized gains overall. I'm not familiar with the unsafe patterns, and to what extent they could be addressed/reduced through Rust language/compiler design, but that'd be one area where research focus might produce even more benefit.

The other weak point may be the LLVM itself, which I guess would be sort of a background hum of risk to Rust.

Outsider view: not sure of the relative levels of risk in each layer, and to what extent they can be addressed.

Can (or will) these unsafe patterns be capable of being addressed by future changes in Rust?

Re: Four years with Rust

#159
post #157

Earlier quoted context omitted.

> Erlang has this sort of huge cognitive overload with it's syntax, making it take longer to learn, for no obvious benefits. That's just weird. How much of an effort did you even put into it? Erlang may have ugly syntax but it's the simplest syntax of all popular languages and the cognitive load while writing is pretty much the lowest I've come across. The language itself is tiny. Or did yo mean you weren't used to a…

I use Scheme extensively, which I would argue has the least syntax of the functional languages. Erlang seems simple on the surface, but each type seems to have it's own DSL, allowing things that seem the same, to not be, which means you have to hold more context in your head. e.g. Are these two the same? ensure(A, B) -> if A == B -> Does -> always mean function? Or does it mean something similar to progn or begin fro…

I think you mistook a barrier to entry (getting over the syntax) for a permanent cognitive load. At our company we don't care if you know erlang or not, but we expect a developer to learn it on the job and have had no issues either with junior or experienced developers. All who've tried it are amazed at the productivity.

Re: Four years with Rust

#160
post #125
post #78

Earlier quoted context omitted.

I've been using Rust to process fairly large amounts of streaming financial data. I am using Protocol Buffers (and evaluating Cap'n Proto) for network serialization and Kafka for buffering/queuing, and overall the library support is quite good. Previously I was using JVM languages for this purpose, but grew weary of the resource footprint, and especially the unpredictable GC pauses. I am aware of the Azul JVM which r…

What Rust libraries are you using for protobufs?

I have been using https://crates.io/crates/protobuf. It generates pure Rust protobuf implementation files.
Post reply on HN