News for hackers. Stuff that matters.
Re:Rust in 2018: easier to use by yen223 on Sunday January 14, 2018 @03:20AM (#16143312)
This is going to sound weird, but I would like to see a garbage-collected Rust. Take away the borrow checker, and you still have a modern language with UTF-8 support out-of-the-box, algebraic data types, pattern matching, a focus on performance, and great tooling (cargo + rustup = <3).

OCaml almost fits the bill (Rust is inspired by OCaml after all), but the tooling around it is lacking to put it mildly.

Re:Rust in 2018: easier to use by bvinc on Sunday January 14, 2018 @04:14PM (#16146507)
You should know that rust always intended to have owned/shared references, Rc<T> reference counting, and Gc<T> garbage collected pointers. It turns out that LLVM made precise garbage collection a hard thing to add on to the language inside of it's standard library. I believe recent changes to LLVM make this easier and it's still a planned feature in the future.

It still doesn't really meet your idea you probably have in your head. When people can choose between different types of pointers, people will choose rust's normal lightweight lifetime references 99% of the time. Gc<T> will probably only be used in those rare cases where an object has no clear owner. They figured this out in the early days of rust.

Re:Rust in 2018: easier to use by Nelkins on Sunday January 14, 2018 @11:59AM (#16145000)
F# sounds like it fits the bill. ADT, pattern matching, performant, great tooling (multiple amazing IDEs, a REPL, etc.), and a huge ecosystem of software packages to use with it (all of .NET). It's my favorite general purpose programming language (can be used for frontend programming, server, mobile apps, etc.).
Re:Rust in 2018: easier to use by andendau on Sunday January 14, 2018 @03:09PM (#16146084)
F# has hit a huge sweet spot for me in productivity, strong typing, inferred typing, multi-paradigm and syntactic sugar. The tooling just gets better and better. I struggle to think of a language that's so well rounded.
Re:Rust in 2018: easier to use by carlmr on Monday January 15, 2018 @10:07AM (#16150909)
Couldn't agree more. My only wish is more people would use it.
Re:Rust in 2018: easier to use by eggy on Monday January 15, 2018 @12:59PM (#16152137)
My wish too! I have no issues with F# on Windows or Linux using .NET Core I use F# as my general high-level language and Zig as my C replacement/Rust alternative for low-level work. I can gradually re-write C stuff in Zig, and be productive.

  [1] - ziglang.org
Re:Rust in 2018: easier to use by marmaduke on Sunday January 14, 2018 @03:33PM (#16146212)
I wanted to get into f# but had a hard time with tooling, cross platform. For example, I'd see a great library and the instructions assume VS while I'm on Linux. There are a variety of build tools and package managers.

As Python dev since 10 years I can't point fingers -- Python is probably worse though I've memorized the idiosyncrasies -- but I couldn't justify my way up the tooling learning curve in addition to the language curve.

Re:Rust in 2018: easier to use by phillipcarter on Sunday January 14, 2018 @04:23PM (#16146568)
(I work on F# at MS)

Do you remember the library? The landscape has changed dramatically in the past ~6 months with .NET Core 2.0 support. For example, I can use Fable[0] and Giraffe[1] with the .NET CLI[2] to build full-stack F# apps on my machine which runs .NET Core. The big remaining blocker for most people to just jump wholesale onto .NET Core and forget anything Windows-based is the lak of Type Provider support, but we're quite close to finishing that.

[0] http://fable.io

[1] https://github.com/giraffe-fsharp/Giraffe

[2] http://dot.net/core

Re:Rust in 2018: easier to use by e12e on Sunday January 14, 2018 @06:11PM (#16147100)
> The big remaining blocker for most people to just jump wholesale onto .NET Core and forget anything Windows-based is the lak of Type Provider support, but we're quite close to finishing that.

Is there a viable cross platform ui option for f# on core?

Re:Rust in 2018: easier to use by Nelkins on Sunday January 14, 2018 @08:49PM (#16147848)
Re:Rust in 2018: easier to use by phillipcarter on Sunday January 14, 2018 @06:46PM (#16147292)
Yup! Fable. In fact, a web app written in fable will even run in more places than a .NET Core app due to the reach of browsers.
Re:Rust in 2018: easier to use by marmaduke on Monday January 15, 2018 @02:15AM (#16149082)
I was looking at Brahma.FSharp and something else with type providers, both with Nu Get instructions, and I didn’t see how to get it working with VS Code.
Re:Rust in 2018: easier to use by phillipcarter on Monday January 15, 2018 @12:01PM (#16151708)
Ah, yes, this is using Code Quotations to generate code into OpenCL. Useful, but unfortunately, not something that is likely to work on .NET Core for a number of reasons today.
Re:Rust in 2018: easier to use by trumpsamerica on Sunday January 14, 2018 @12:03PM (#16145010)
Do you have a good learning guide and a development guide (setting up ide, vim, tools etc)? I want to jump start into f#
Re:Rust in 2018: easier to use by Nelkins on Sunday January 14, 2018 @12:25PM (#16145142)
For learning the language, there is no better guide than F# for fun and profit. Start here[1], then maybe check out this series[2] and this one[3]. If you want to learn about monads and such, go through this series[4]. Look through this[5] page for other good stuff.

Unfortunately, the fsharp.org site is kind of out of date. I think that's mostly a function (heh) of the MS F# docs becoming much better (can be found here[6]). These instructions for getting a dev environment set up are pretty good[7]. If you hunt around, you can also find blog posts which may be a little more comprehensive[8][9][10].

[1] https://fsharpforfunandprofit.com/why-use-fsharp/

[2] https://fsharpforfunandprofit.com/series/designing-with-type...

[3] https://fsharpforfunandprofit.com/series/thinking-functional...

[4] https://fsharpforfunandprofit.com/series/map-and-bind-and-ap...

[5] https://fsharpforfunandprofit.com/site-contents/

[6] https://docs.microsoft.com/en-us/dotnet/fsharp/

[7] https://docs.microsoft.com/en-us/dotnet/fsharp/get-started/

[8] https://atlemann.github.io/fsharp/2018/01/13/fsharp-on-ubunt...

[9] http://www.prigrammer.com/?p=363

[10] https://medium.com/@edgarsanchezg/four-easy-steps-for-instal...

Re:Rust in 2018: easier to use by Nelkins on Sunday January 14, 2018 @12:28PM (#16145156)
Also a weekly roundup of F# news can be found here[1].

[1] https://sergeytihon.com/tag/newsf-weekly/

Re:Rust in 2018: easier to use by devit on Sunday January 14, 2018 @08:11AM (#16144117)
The problem is that it turns out that cyclic garbage collection is essentially useless, except for running existing code that expects a garbage collector to be present (e.g. JavaScript code if you are writing a web browser).

Since it's useless, not having it is great since you no longer have to worry about it and the problems it causes like random pauses, sawtooth-shaped and excessive memory usage and inability to use swap properly (although you have to worry about heap fragmentation, but usually that's not as terrible).

Also you'd need lifetimes and borrowed references anyway to have static guarantees like that there are no remaining references to mutex-protected data after you unlock the mutex, so having a GC as well actually increases complexity.

Re:Rust in 2018: easier to use by twic on Sunday January 14, 2018 @01:46PM (#16145567)
If i've understood you properly, i would phrase this slightly differently: because Rust doesn't have GC, it has evolved a lot of language and library features that make it practical to not have GC, and so adding GC doesn't make Rust easier to use.

I think there's a lot to that. I'd be really interested to try it, though, to see how it pans out.

Re:Rust in 2018: easier to use by alkonaut on Sunday January 14, 2018 @01:06PM (#16145366)
There are plenty of language choices fitting nearly every feature set.

What I’d like to see is for one language to be possible to use “vertically” through a stack. That is - for example a C# systems version with manual memory that you can use instead of C interop for the small core of your app. Or, the opposite, a dumbed down version of Rust that works well for classic reference heavy UIs and similar.

Re:Rust in 2018: easier to use by currymj on Sunday January 14, 2018 @06:26AM (#16143803)
rust at one point had garbage-collected references. And there's still Rc/Arc types for reference counting.

I get what you're saying though. Another poster mentioned Swift and indeed Graydon Hoare, Rust's creator, is now working on Swift at Apple. And I believe some kind of notion of borrow checking/lifetimes is supposed to be coming to Swift in the future?

Re:Rust in 2018: easier to use by pjmlp on Sunday January 14, 2018 @07:07AM (#16143929)
Yes, the initial support is already there in Swift 4, it is called enforced exclusive access to memory in Apple documentation.
Re:Rust in 2018: easier to use by joshlemer on Sunday January 14, 2018 @10:29PM (#16148296)
Not all that familiar with Rust's history or anything but why would he leave to work on Swift at Apple? He creates a language which is getting a huge amount momentum and praise around it, and decides to do something else? Must have been a lot more money, because a situation like that don't come up very often.
Re:Rust in 2018: easier to use by steveklabnik on Monday January 15, 2018 @08:20AM (#16150276)
He didn't leave to work on Swift; he left, then got a different job, then left that job eventually to work on Swift. I'm being vague because well, it's his personal life, and he'd generally prefer people not talk about it too much or read too much into it.
Re:Rust in 2018: easier to use by dom96 on Sunday January 14, 2018 @06:45AM (#16143864)
This sounds a lot like Nim to me. Give it a go if you haven't already. It's a systems programming language that primarily uses a garbage collector.
Re:Rust in 2018: easier to use by grayrest on Sunday January 14, 2018 @03:33AM (#16143341)
> Ocaml almost fits the bill, but the tooling around it is lacking to put it mildly.

I know the Reason guys want to tackle project setup / build / deps in addition to their syntax changes. I've found the current release's bsb toolchain to work pretty well for js targets but I haven't tried to set it up for native compilation.

Re:Rust in 2018: easier to use by yen223 on Sunday January 14, 2018 @03:47AM (#16143366)
I've built several toy projects with ReasonML. I found the overall experience fairly positive, so please take this comment kindly.

I'm concerned about the ReasonML -> OCaml -> Bucklescript -> JS compilation chain. The laws of leaky abstraction pretty much guarantees this is not a robust way to do things.

I also wished the ReasonML folks started from scratch, instead of inheriting OCaml's baggage (no forward references, a plethora of file types to deal with, no UTF8 strings without bringing in an external lib, and so on).

Re:Rust in 2018: easier to use by xfer on Sunday January 14, 2018 @08:37AM (#16144188)
No builtin utf-8 strings is a good/bad thing is debatable.

You don't need to use bucklescript toolchain to write Ocaml, it has a very good package manager, the build-system tooling is getting better, already has great editor support for many years now(merlin).

I think the tooling scene is much better than Haskell. Not sure what you mean by "no forward references"?

Re:Rust in 2018: easier to use by bjz_ on Sunday January 14, 2018 @10:04AM (#16144495)
> Not sure what you mean by "no forward references"?

I'm guessing they are talking about having implicit mutual recursion between items in a module, like Haskell has.

Re:Rust in 2018: easier to use by yen223 on Sunday January 14, 2018 @02:09PM (#16145691)
> Not sure what you mean by "no forward references"?

I probably got the name wrong, but it's the ability to use a function before it is defined.

In OCaml/ReasonML, you'd have to use the rec keyword and structure your codebase in a particular way to define mutually-recursive functions. It is a small but noticeable papercut, especially since recursion is so common in a functional language.

Re:Rust in 2018: easier to use by botverse on Tuesday January 16, 2018 @05:27PM (#16163331)
May be the word I’d “hoisting”
Re:Rust in 2018: easier to use by phillipcarter on Sunday January 14, 2018 @04:30PM (#16146598)
There's a similar chain for F# running with Fable:

F# code (with a catch) --> F# AST --> Bable AST --> JS

The big thing here is that the F# code you write has slightly different semantics than "normal" F#. That's because the runtime environment is different, and so you can't escape that. Rather than attemp to gloss this over, the Fable creators are pretty explicit about this, including documenting each of the (small) differences. The result is pretty good. Abstractions don't seem too leaky from my vantage point.

Re:Rust in 2018: easier to use by fhars on Sunday January 14, 2018 @09:03AM (#16144272)
There ist no ReasonML -> Ocaml compilation step in that chain, ReasonML is just another syntax for ocaml.
Re:Rust in 2018: easier to use by yen223 on Sunday January 14, 2018 @01:56PM (#16145622)
There is still a necessary syntactical transformation sstep via `refmt`, and that transformation step does occasionally break.
Re:Rust in 2018: easier to use by readittwice on Sunday January 14, 2018 @04:00AM (#16143405)
Yep, that's exactly what I would also like to see.

AFAIK there is some work on a GC in Rust, but it doesn't take away the borrow checker like you wished ;) So you will still need to use `.borrow()` and `.borrow_mut()`.

A language similar to Rust but with GC (and no borrow checker) could be quite useful for a lot of applications out there. Basically Go but a more "modern" language.

Re:Rust in 2018: easier to use by weberc2 on Sunday January 14, 2018 @02:52PM (#16145968)
Just seeing this. You might be interested in my previous comment here: https://news.ycombinator.com/item?id=16145940
Re:Rust in 2018: easier to use by mmirate on Sunday January 14, 2018 @10:07AM (#16144507)
That's easy, just change your program so that every value of type T is now a value of type Arc<Mutex<T>>.
Re:Rust in 2018: easier to use by foota on Sunday January 14, 2018 @04:06PM (#16146444)
Reference counting does not handle cycles.
Re:Rust in 2018: easier to use by mmirate on Sunday January 14, 2018 @05:02PM (#16146759)
Use Arc::downgrade() to get a Weak<Mutex<T>> as needed. Weak<U> is like Arc<U> but does not affect the value's reference count.
Re:Rust in 2018: easier to use by Manishearth on Sunday January 14, 2018 @04:15AM (#16143437)
This sounds like Swift :)

(ARC, not tracing GC, but still.)

Re:Rust in 2018: easier to use by littlestymaar on Sunday January 14, 2018 @07:36AM (#16144009)
If Arc counts, then it juste sounds like Rust actually ;).
Re:Rust in 2018: easier to use by Manishearth on Monday January 15, 2018 @12:54AM (#16148783)
ARC, not Arc.

ARC is automatic reference counting. Arc is Atomic reference counting.

In Rust you still have to manually .clone() to addref an Arc. In swift you don't. This is a major difference ergonomics-wise.

Re:Rust in 2018: easier to use by K0nserv on Sunday January 14, 2018 @07:49AM (#16144050)
I dunno if I agree, the borrow checker in Rust requires a lot more active thinking and intervention to get memory right. Objective-C and Swift ARC is really straightforward and there are few gotchas. Kinda like GC.
Re:Rust in 2018: easier to use by littlestymaar on Sunday January 14, 2018 @08:01AM (#16144080)
If you use Arc everywhere you just end up with the same behavior than Swift (except for closures I guess).
Re:Rust in 2018: easier to use by steveklabnik on Sunday January 14, 2018 @02:45PM (#16145926)
Small note: Swift's ARC and Rust's Arc are different: Rust's Arc is atomic reference counting, while Swift's is automatic reference counting.
Re:Rust in 2018: easier to use by dbaupp on Sunday January 14, 2018 @08:08PM (#16147677)
The acronyms are different, but at runtime they're pretty much the same: the only difference is the Swift compiler inserts the clones that a Rust programmer has to do manually (that is, Swift retain/releases are atomic too).
Re:Rust in 2018: easier to use by steveklabnik on Monday January 15, 2018 @08:21AM (#16150282)
Yes, I should have elaborated more, thanks :)
Re:Rust in 2018: easier to use by kazagistar on Sunday January 14, 2018 @11:02AM (#16144777)
I would like to see a different GC rust... an ability to integrate into an external GC system that it is embedded in, like Javascript or Java or whatever else. In other words, `Gc<_>` would mean "owned by the other runtime". I think there was a proposal like this, though I am not sure what happened to it.
Re:Rust in 2018: easier to use by robohamburger on Sunday January 14, 2018 @11:49AM (#16144960)
I agree. Part of whats kept me going is the language is very nice, even though I don't always need borrow checking.

I wonder how threading would work without the borrow checker though. It would be cool if you could still have the "fearless concurrency part".

Re:Rust in 2018: easier to use by weberc2 on Sunday January 14, 2018 @02:47PM (#16145940)
I have a similar desire. OCaml and others push heap-allocated reference types by default (limiting your options for controlling allocations), and many have weak tooling and library support. F# looks neat, but it seems to have a lot of baggage relating to C# interop. F# also doesn't compile static binaries yet. I think I decided the best shot is to build a language that compiles to Go, since it has the right semantics, great libraries and tooling, and a world-class runtime (GC, painless async IO, lightweight thread scheduler for real parallelism). Obviously this is still a huge effort and probably a pipe dream, but its the path of least resistance to get a "Rust with GC".
Re:Rust in 2018: easier to use by agbell on Monday January 15, 2018 @02:32PM (#16152790)
Scala Native may sort of fit the bill
Re:Rust in 2018: easier to use by gbersac on Sunday January 14, 2018 @12:43PM (#16145253)
I am surprised no one already mentionned Scala. It perfectly fit the bill ans is even more mature !
Re:Rust in 2018: easier to use by vvillena on Sunday January 14, 2018 @01:04PM (#16145351)
The main problem of Scala is that it brings in the whole JVM. That's awesome for certain kinds of apps, but not so great for other things like small tools. I have high hopes on scala-native, though!
Re:Rust in 2018: easier to use by nine_k on Sunday January 14, 2018 @11:26PM (#16148473)
Java 9 / Jigsaw should make small self-contained executables possible. Startup time could be an issue, though.
Re:Rust in 2018: easier to use by paulddraper on Sunday January 14, 2018 @01:11PM (#16145391)
The biggest difference is that Scala requires JVM (or JS).

But if you are willing to accept runtime GC, a JIT runtime like JVM/Node might also not be out of the question.

So Scala Native would be spot on, if it were ready for production use.

Re:Rust in 2018: easier to use by trumpsamerica on Sunday January 14, 2018 @03:23AM (#16143319)
Garbage collected allocation is coming. There's even an rfc I think. Manishearth is working gon it