Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 03:30
    HertzDevil labeled #11524
  • 03:26
    HertzDevil labeled #11524
  • 03:25
    HertzDevil labeled #11524
  • 03:25
    HertzDevil labeled #11524
  • 03:25
    HertzDevil opened #11524
  • 02:51
    caspiano edited #11517
  • 02:17
    caspiano synchronize #11517
  • Dec 01 22:53
    straight-shoota synchronize #11523
  • Dec 01 22:51
    straight-shoota closed #11498
  • Dec 01 22:49
    straight-shoota closed #11469
  • Dec 01 22:49
    straight-shoota closed #10984
  • Dec 01 22:48
    straight-shoota closed #11446
  • Dec 01 22:42
    straight-shoota opened #11523
  • Dec 01 22:42
    straight-shoota labeled #11523
  • Dec 01 22:42
    straight-shoota labeled #11523
  • Dec 01 21:55
    straight-shoota synchronize #11472
  • Dec 01 21:29
    straight-shoota synchronize #11472
  • Dec 01 21:13
    straight-shoota synchronize #11472
  • Dec 01 21:12
    straight-shoota milestoned #11521
  • Dec 01 21:12
    straight-shoota milestoned #11298
mfiano
@mjfiano:matrix.org
[m]
each_with_index is what I came up with, and it works. I was only wondering if there was something more concise/more idiomatic for this use-case :)
I've only played with a tiny bit of the API, and no 3rd party libraries or anything yet
From IRC (bridge bot)
@FromIRC
<riza> dealing with the indices manually doesn't feel idiomatic to me, but it's not at all wrong
<riza> (I would run a .map so I didn't need to deal with the indices)
<riza> self.map {|e| e.round}
mfiano
@mjfiano:matrix.org
[m]
that will produce an array, right?
From IRC (bridge bot)
@FromIRC
<riza> Well, #map isn't available on an Indexable so it wouldn't compile
<riza> what led you to use an Indexable instead of just an Array?
mfiano
@mjfiano:matrix.org
[m]
array is a generic class, not a module. Blacksmoke16 recommended me to include Indexable on my struct so that I can implement the abstract methods to be able to index/iterate over it
Which I have done and therefor get Enumerable and Iterable too
I'm not sure what you mean by #map not being available. It is inherited in Indexable from Enumerable
From IRC (bridge bot)
@FromIRC
<riza> oh I see, this is an exercise in implementing the modules
mfiano
@mjfiano:matrix.org
[m]
I mean what I have works. The map suggestion is only half of the work required.
From IRC (bridge bot)
@FromIRC
<riza> oh sure enough it is. I thought Indexable only included Iterable.
mfiano
@mjfiano:matrix.org
[m]
This is more than constructing a sequence of values. It is modifying the input sequence in the process, so does not need an intermediary sequence.
That's why I chose each_with_index. Maybe this is not idiomatic, but I don't see another way to do it efficiently
From IRC (bridge bot)
@FromIRC
<riza> you're probably right about that
<riza> a bunch of the crystal community sheds a lot of sweat about saving bits of memory... I try to avoid dealing with memory concerns
<riza> it's not wrong by any means, I'd just rather solve problems that aren't already more-or-less solved for me by the language
<riza> if that weren't the case, I'd write a lot more C
mfiano
@mjfiano:matrix.org
[m]
Usually a good decision, at least until profiling says you shouldn't
From IRC (bridge bot)
@FromIRC
<riza> yep, exactly
mfiano
@mjfiano:matrix.org
[m]
Ok thanks for the help :)
From IRC (bridge bot)
@FromIRC
<riza> thankfully in Crystal, it's pretty uncommon to need to care about an extra loop or copy of the data
mfiano
@mjfiano:matrix.org
[m]
Speaking of the Crystal community. It is small, but probably the most helpful for a newcomer than any of the few dozen languages I've used.
Very friendly crowd around here
From IRC (bridge bot)
@FromIRC
<riza> well I think we all count that as a win, for everyone. glad you found it welcoming, it often is exactly that
mfiano
@mjfiano:matrix.org
[m]
I left Nim, which is a similar language, due to a very toxic community (among other reasons, but mostly that)
It was sad, but I am liking everything about Crystal much better anyway
From IRC (bridge bot)
@FromIRC
<riza> Nim's a pretty neat language. It's difficult to keep a community from getting toxic or divided as it grows.
From IRC (bridge bot)
@FromIRC
<riza> @mjfiano what kind of programming do you do which you were using Nim for and are now evaluating crystal?
mfiano
@mjfiano:matrix.org
[m]
riza: Mostly 3D games, or 3D math visualizations/simulations that require soft real time performance.
From IRC (bridge bot)
@FromIRC
<riza> nice, sounds fun! Anything published? I believe there have been people working on 3D engines at some point, but I don't know if there are any active projects anymore.
mfiano
@mjfiano:matrix.org
[m]
I mostly do so in Common Lisp, which gives me the performance of C with the productivity of Python, and the ability to extend the language with macros. But, having used it for nearly 20 years exclusively, I have recently started looking for other languages, primarily to learn all the different ideas there are out there.
Nothing complete enough, or interesting enough worth publishing yet :)
I'm a researcher mostly, so just like to implement cool graphics techniques in academic papers :)
Haven't made much of anything I would call an application, but I would like to one day.
From IRC (bridge bot)
@FromIRC
<riza> I can't imagine being productive in a Lisp... I always have to sit and stare at the screen for 3 hours before typing a line. But it's a neat language, and I imagine if I spent the time on it maybe that 3 hours would shrink a bit...
mfiano
@mjfiano:matrix.org
[m]
I guess you have to have a good teacher/learning resource. I switched to Common Lisp from Python and was more productive after a week, which says a lot I think.
From IRC (bridge bot)
@FromIRC
<riza> The thing that slows me down about Crystal is the lack of a REPL. I spent years in the Ruby REPL and the lack of instantenous feedback makes the development process feel very slow to me.
<riza> I wonder what the performance benchmarks of common lisp against crystal are
<riza> maybe you wouldn't need to think about performance anymore!
mfiano
@mjfiano:matrix.org
[m]
I hear you there. Lisp is very interactive, with many more tools than the REPL, so this is very new to me.
Curious, do you think reading a book about Ruby would help me to learn Crystal better, or would I just confuse myself even more?
I know absolutely zero Ruby, but been using Crystal for about a week and loving it so far.
From IRC (bridge bot)
@FromIRC
<riza> there's just enough divergence between the ecosystems that I wouldn't recommend it
<riza> just stick with the reference and the api docs
Kirk Haines
@wyhaines
@riza, @asterite demo'd a instant feedback REPL for the Crystal Conference 1.0 a couple weeks ago.
From IRC (bridge bot)
@FromIRC
<riza> from an algorithms perspective, there are probably more reference implementations on the internet in ruby
<riza> neat! have a link? I had a ticket but couldn't go at the last minute