684 karma · joined Jun 20, 2017 (9y ago) · 230 submissions
comment 8y ago · link · parent
The end result is that good GC-based memory systems tend to perform better than malloc/free style APIs (with the call to free() possibly being implicit). to get good performance in C/C++/Rust, the programmer needs to be concientious about allocation. You have more control, but also more responsibility. In OCaml, allocation is bumping a pointer -- go nuts.
comment 8y ago · link · parent
But most languages have had a solution to the resource problem at least as far as memory is concerned for a long time: garbage collection. It has huge advantages over Rust's approach, in that you can basically not think about RAII or ownership at all; as long as you're not actively holding on to an object, the memory will get reclaimed for you.
But this doesn't solve the problem for other resources like files, since when a file is closed actually matters semantically. You don't want to just let the garbage collector decide when to shut down a tcp connection.
So what the gp is suggesting is, it would be nice to have a language that uses GC where it makes sense, as it's generally easier to work with, but also provides sane mechanisms for releasing resources like files and sockets.
comment 8y ago · link · parent
comment 8y ago · link · parent
There are more convenient ways of composing monads than monad transformers; extensible effects are a lot easier to work with.
Ulttimately I agree though, monads are not the right abstraction for a systems language. I'm quite happy using them in languages like Haskell and OCaml, where you've not only got a garbage collector solving the tricky ownership qustions for you, it's also faster than it has any right to be, so you can basically ignore the overhead of heap allocating a closure.
They become much less attractive when you're in a problem domain where you actually want to worry about fiddly details around memory allocation. This is much smaller space than people think it is, but it's what Rust is for.
comment 8y ago · link · parent
comment 8y ago · link · parent
comment 8y ago · link · parent
comment 8y ago · link · parent
https://github.com/bradfitz/webfist
But it never really went anywhere afaik.
comment 8y ago · link · parent
foo >>= \_ -> bar
It is well within its rights to evaluate bar and then foo, or do both in parallel, or not evaluate foo at all, as long as it can guarantee that the resulting value is the same. The big thing it needs to be careful of is not to introduce nontermination.What makes this do the right thing for effects is what values of type IO actually are, and what bind means specifically for IO. It's helpful to think of an IO value as code in another (imperative) language. Bind takes two fragments of code in that other language, and stitches them together into a script that executes one after the other.
The key thing is that the order in which you compute parts of the script is entirely orthogonal to the order the commands appear in the script.
In Haskell, evaluation does not cause side effects, period. `main` is a value of type IO, which is executed when the program is run. The effects of that execution are independent of how the value `main` is computed.
Obviously, the computation itself takes time and space though.
comment 8y ago · link · parent
A good rule of thumb is to by default mark fields for basic types like Int, Bool, etc. as strictly evaluated, and leave larger structures (trees, lists, etc) lazy. But you still need to be careful.
The compiler trying to silently fix things is probably a bad idea. The current behavior is at least easy to understand; I'd hate to have a program that's working because the compiler could figure out that it could make something strict, and then I bump something mostly unrelatrd such that the optimizer can't be sure anymore, so I get a space leak.
Also, unintended evaluation can potentially cause high memory use as well (e.g. [1..1000000]), so the compiler also has to be careful about introducing excessive memory use.
The compiler does do some strictness analysis, but it's a hard problem.
I like the way idris does things -- strict by default, laziness controlled by the type system, and some nice support for automatic coercions.
comment 8y ago · link · parent
comment 8y ago · link · parent
https://github.com/gopherjs/gopherjs
...and already has a reasonable js interop story, whereas my understanding is that calling the dom api from wasm is not the simplest thing.
comment 8y ago · link · parent
A sibling comment points out one use case for symmetric-only crypto.
I'm also curious what people would actually do if forced to deal with a symmetric-only world.
I think it is more likely that we'd see cumbersome ways of dealing with key distribution than that people would just stop using crypto in all the places we rely on public key schemes today. Think symmetric keys printed on your bank statement (maybe with a qr code?) We'd definitely see it used a lot less than now.
That said, we'd probably have about the same number of people doing end to end email encryption; key distribution with an asymmetric scheme is no picnic either :P.
comment 8y ago · link · parent
For symmetric crypto, some schemes will have to be dropped, and others will require larger keys. But we can (for example) just keep right on using AES 256.
For asymmetric crypto, we'll have to switch to some new schemes, but those exist (though I don't know of any current software using them). For example:
https://en.m.wikipedia.org/wiki/Lattice-based_cryptography
The bigger worry I think is what about all of the existing traffic that has been archived?
comment 8y ago · link · parent
Second, and more to the point, internet service is generally much cheaper in other countries, but the reasons are most definitely not lack of regulations. It basically comes down to local monopolies, and the usual effects of lack of competition. Giving large ISPs more power will not help. This article gives a decent overview of the situation:
https://mobile.nytimes.com/2014/10/31/upshot/why-the-us-has-...
comment 8y ago · link · parent
https://arstechnica.com/tech-policy/2017/12/att-says-it-neve...
As the article points out the kind of abuses people are talking about are nit theoretical; they were done before the 2015 rules went into effect. This was especially true on mobile plans.
Another thing is you can look at how this has played out in other countries, and it isn't pretty. There's an image floating around of an ad for a Portuguese ISP, which looks like a cable tv add from the 90's -- explicit lists of sites that are provided.
It's hard to study this kind of phenomenon with the level of rigor we'd expect from a physicist. That sort of thing is kinda the best you can do.
Finally, I have friends who work at companies who do larger scale traffic analysis on the net, and from what they've told me, at least before the 2015 rules, throttling was basically the norm, though you'd be hard pressed to get the pr departments to admit it.
comment 8y ago · link · parent
comment 8y ago · link · parent
Also, as a sibling comment points out, the "thread safety" guarantee is relatively narrow -- it won't guarantee a general lack of concurrency bugs any more than a gc will guarentee reasonable memory usage.
I haven't thought through the details, but I suspect it's possible to adjust the semantics of rust in a way that allows multiple mutable references without sacrificing memory safety.
What you would hit is that the compiler would be hindered when doing optimizations in the same way that c and c++ compilers are, because of pointer aliasing.
There's a trade off there, and I think you can make the argument either way.
comment 8y ago · link · parent
In the case of rust, I suspect one of the biggest issues is the way parametric polymorphism is implemented. Basically, if in your program you end up using e.g. Box<usize>, Box<MyType> and Box<Result<String>>, you're compiling Box 3 times.
I don't know enough about swift to hazard a guess as to where the build is spending its time.
My experience with Haskell is that compile times are neither great nor terrible.
comment 8y ago · link · parent
That said, as someone who is no stranger to contributing to upstream, the prospect of becoming the maintainer strikes me as something that is certainly not to be done lightly.
comment 8y ago · link · parent
comment 8y ago · link · parent
I don't know of a magic formula for being able to tell the difference, so it's hard thing to talk about in the abstract.