« first day (1132 days earlier)      last day (2360 days later) » 

12:57 AM
@BernardoMeurer chiming in after a while, my answer to "should I learn X" where X is programming related is almost always going to be "yes"
 
@Shepmaster Should I learn Brainfuck?
 
Only by learning something can you appreciate its good points and bad
 
:P
I bought SICP
Let's see what happens
 
@BernardoMeurer certainly
The big thing is always about what set of knowledge do you have already
learning a second lisp would not be as useful, for example
but each lisp will have unique turns on things
I also did some Clojure
 
@Shepmaster Do you know Scheme?
 
I've heard about Clojure before, never looked into it though
 
I know of Scheme, that's about it
 
Hmm, Clojure runs on the JVM :(
I do not like the JVM
 
@BernardoMeurer The JVM is a pretty magical piece of technology
It has drawbacks, of course
but it allows things like Truffle and Graal
 
Yeah, it's magical
What's Truffle and Graal?
 
1:06 AM
And the entire concept of runtime optimization of your code based on the specific usage of it is pretty amazing
Rust (likely) won't ever have something like that
 
Woah, that is badass!
Honestly, I'm a huge fan of LLVM
I find it to be just amazing
 
 
11 hours later…
12:15 PM
Whew; quicksort in Rust is hard
For my parallelization question I really wanted to have something like Haskell's stupidly simple example.
(of course it's not very performant, but just to have an example)
 
85
Q: Why is the minimalist, example Haskell quicksort not a "true" quicksort?

rybosomeHaskell's website introduces a very attractive 5-line quicksort function, as seen below. quicksort [] = [] quicksort (p:xs) = (quicksort lesser) ++ [p] ++ (quicksort greater) where lesser = filter (< p) xs greater = filter (>= p) xs They also include a "True quicksort in C"...

 
@kennytm Sure, I know
 
you could do let lesser = xs.iter().filter(|x| x < p).collect() etc if you disregard all those things that make quicksort fast
 
just for the sake of a simple parallelization case
@kennytm hmm, perhaps this could even be parallelizable by Rayon, but I haven't checked its parallel iterators yet
My other code that I wanted to benchmark couldn't use them, though
 
note that that expression gives wrong lifetime (.iter() yields &T not T). it's not a problem in Haskell because of the GC.
you'll need Vec::drain_filter to respect ownership
 
12:25 PM
interesting
ah, it's nightly API - that's why I didn't recall it
looks pretty useful
 
 
2 hours later…
2:00 PM
@ljedrz I once ported a quick sort algorithm for the Julia micro benchmark. github.com/Enet4/julia-bench-rs/blob/master/src/main.rs#L199
It uses indexing though.
 
2:24 PM
@ljedrz Can't chat now, but one thing that stands out to me is that you're spawning threads for subarrays of length as small as 2
performant variations on quicksort often defer to insertion sort or some other algorithm for arrays smaller than some threshold
 
@trentcl actually the parallel code does have an edge over the sequential one, but not with Bencher
 
@ljedrz oh interesting
gotta go
 
2:36 PM
@E_net4 it's a much nicer implementation, but it lacks that sweet divide-and-conquer spot for trivial parallelization
 
3:21 PM
@ljedrz Yeah, I wouldn't image this one being excellent. The micro benchmarks are mostly made to measure a language's usability/performance ratio.
So performance isn't the only thing that matters. It should also be easy and idiomatic to write certain algorithms.
I'd say Rust still has some edge here. :)
 
@E_net4 I agree, of course
 
I think I need HRT's in my code now. :(
 
@E_net4 I hope they are introduced soon
I miss them from Haskell
 
I was making my sprite manager generic over a lifetime 'g, but at the root it complained about conflicting requirements.
 
Oh, I misread; I thought you meant HKTs
I'm usually able to avoid explicit lifetimes, but my projects aren't too complex
 
3:27 PM
Yeah, I was thinking HRTB's actually.
It's easier to memorize if I call them hearty boys.
 
Horizontal Rotating Tubular Bioreactors? :D
2
 
Higher Ranked Trait Bounds. :P
 
@E_net4 that's a nice mnemonic
my favorite one will always be "When Grandma Burps, Patrick Obeys" from the Borderlands game
 
Hmm, I don't know that one. Not Borderlands savvy.
 
I think it had something to do with item quality order, though I remembered the mnemonic better than its meaning :P
 
3:30 PM
:|
 
3:59 PM
Ok, I know I did something wrong when I find compiler error messages that I had never seen before.
 
@E_net4 nice
 
E0488. I might be doing some crazy carp here.
 
@Shepmaster if a question is answered and then marked as a duplicate it is still deleted after a few days, right? Or does it break the housekeeping process in any way?
 
@ljedrz As far as I know it stays open forever
all duplicates should; they serve as signposts for different sets of search terms
@E_net4 that's not even in the error index
 
> lifetime of variable does not enclose its declaration
I was thinking about using hearty boys, but it's tricky.
 
4:04 PM
@E_net4: looks like LLVM is not smart enough to turn 2.pow(a) into 1 << a godbolt.org/g/hVgmYa
(although my comment is mainly about not needing to spell out 2usize ^^)
 
@kennytm wat
 
Wat. Context?
 
even with optimizations, I see
 
What a pity.
 
1
A: How do I write a value doubling iterator?

ljedrzYou could do the following: fn main() { for i in (0..).map(|n| 2usize.pow(n)).take(10) { // take(10) so it stops println!("{}", i); } } Output: 1 2 4 8 16 32 64 128 256 512 It's pretty efficient, there's no need to implement your own iterator for this.

 
4:06 PM
I see...
 
@kennytm ah yes, that makes bit fiddling preferable :)
though not most newbie-friendly
the asker came from a JS background, so I preferred a more "high-level" approach
 
yeah if you want to generalize as 3^n etc it's better to keep the pow()
@ljedrz JS also has bitshift operators though
 
I mean if you wanna be newbie friendly, multiply by two
 
@kennytm sure does, though I suspect they aren't that popular
@Shepmaster do I sense discontent (on a Sunday? on my Christian server?) or just trolling :P?
though the user did ask about multiplication, so it wouldn't be wrong
 
println!("{}", 1);
println!("{}", 2);
println!("{}", 2*2);
println!("{}", 2*2*2);
println!("{}", 2*2*2*2);
println!("{}", 2*2*2*2*2);
println!("{}", 2*2*2*2*2*2);
println!("{}", 2*2*2*2*2*2*2);
println!("{}", 2*2*2*2*2*2*2*2);
println!("{}", 2*2*2*2*2*2*2*2*2);
 
4:14 PM
@kennytm not the most iterator-y solution
works perfectly, though
btw, is "not enough iterators" already a meme?
kind of reminds me of JavaScript's "-1, not enough JQuery"
 
f e a r l e s s i t e r a t i o n
 
@ljedrz no trolling (see my new answer)
 
@Shepmaster nice combo
scan and fold remind me of my old functional ways
and foldl vs. foldr
 
@ljedrz there used to be unfold
now lives in itertools
 
@Shepmaster ah yes, I remember - played with it once
really useful, but one can easily get the same functionality out of a custom iterator
@Shepmaster that makes sense, good to know; just wanted to know if it was preferable to delete my answer in the duplicate
 
4:32 PM
@ljedrz My opinion would be to delete it and move it to the duplicate
Your version would work just as well there (and be a bit more generic, to boot)
 
I guess that could work
 
@ljedrz but you'd have to hurry, deleting is much harder when it's accepted
 
Success!
 
@ljedrz and I try to make sure that the loss of upvotes doesn't happen when people do that
 
No hearty boys were needed. Only some simplifications and associated type assignments.
I'm still not quite sure why I didn't get this to work earlier 'n' stuff, but shrug.
And all this was just to have textures working. Yay me.
 
4:36 PM
@Shepmaster done
 
@ljedrz I tweaked it a bit to answer the directly stated question, too :-)
 
@Shepmaster ah yes, it's better now
I'll try to remember to move my answers when I forget to check for duplicates.
 
@ljedrz <3
@LukasKalbertodt I dunno if type ascription would help here — (foo, bar) is a pattern, not an expression. Or did you mean for (i, item) in bytes.iter().enumerate(): (usize, std::iter::Enumerate<std::slice::Iter<u8>>) { ?
 
 
1 hour later…
5:52 PM
@trentcl knows my secrets now
I just ask compiler devs to solve everything
then I format their back and forth into a nice answer
 
@Shepmaster lol, hey, if it works...
 
 
5 hours later…
10:36 PM
Looks like I missed the lisp conversation by a day. @BernardoMeurer If you're still deciding which lisp to try, I strongly suggest Common Lisp. It is (in my honest opinion) the most powerful lisp in existence currently. Its design allows the compiler to optimize it heavily (it's a lisp-2 with optional type declarations and such), and its macros are great (hygienic macros are unnecessary when you have gensym + packages). It even has goto, and when you macroexpand your loops, you can see it.
It also doesn't force you (or rather encourage you) to use tail-recursion for iteration like scheme and other functional dialects do. CL can be used very imperatively. And finally, its Object system has no match in any language (methods are not bound to objects, it has multiple dispatch, multiple inheritance, etc, etc...)
 
Hmm... Being able to use Lisp like an imperative language sounds odd to me. :P
 
It's certainly not what most people think of when they hear lisp ;)
The immediate assumption is functional
 
@Byte And I'd argue that it's a reasonable one. Because pure Lisp is functional.
 
I agree. But adhering to language purity is a limitation in my opinion. Sometimes a solution is easier expressed in an imperative style with a bunch of setfs and do/loop loops. I think maximizing expressiveness (with macros if necessary) is the lisp way.
But anyways, about Rust now! I'm slowly going through the Rust book. I am a beginner :)
Have not reached the borrow system just yet, I'm rather curious to see how it works.
 
10:57 PM
Welcome aboard! :)
We all had to start from somewhere. The book is a pretty good guide.
 
It's quite succinct and descriptive.
 
@Byte re lisp / imperative — one thing i liked about clojure was the ability to drop out of pure immutable world for performance reasons
similar conceptually to rust's single mutable reference and/or internal mutability
 
@Shepmaster Mutability can be very useful sometimes, agreed.
Common Lisp references seem mutable by default, but as long as setf or incf/decf aren't used, everything is copied a la functional style
I think it would be interesting to write a lisp OS... in Rust.
 
@Byte do it. There's a few OSes in Rust you could start from
 
11:12 PM
@Shepmaster I've only heard of the microkernel Redox OS.
 
Thank you
 
Till next time :)
 

« first day (1132 days earlier)      last day (2360 days later) »