Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 12:51
    BlobCodes opened #11535
  • 12:06
    gballet synchronize #9848
  • 09:33
    straight-shoota closed #11521
  • 09:29
    straight-shoota labeled #11534
  • 09:29
    straight-shoota labeled #11534
  • 09:25
    straight-shoota labeled #11533
  • 09:25
    straight-shoota labeled #11533
  • 09:25
    straight-shoota labeled #11533
  • 01:55
    HertzDevil synchronize #11524
  • 01:38
    neatorobito edited #11534
  • 01:34
    neatorobito opened #11534
  • 00:51
    HertzDevil synchronize #11437
  • Dec 02 21:00
    straight-shoota closed #11496
  • Dec 02 20:59
    straight-shoota closed #11298
  • Dec 02 19:30
    straight-shoota synchronize #11472
  • Dec 02 19:25
    straight-shoota demilestoned #11366
  • Dec 02 19:09
    straight-shoota milestoned #11519
  • Dec 02 17:09
    Blacksmoke16 synchronize #11533
  • Dec 02 17:07
    beta-ziliani milestoned #11529
  • Dec 02 16:34
    Blacksmoke16 opened #11533
mfiano
@mjfiano:matrix.org
[m]
in my code, i am mutating the ivars of an Indexable struct
Not constructing an intermediate sequence
From IRC (bridge bot)
@FromIRC
<riza> dup?
mfiano
@mjfiano:matrix.org
[m]
Yeah I'm doing it on a copy as a test to prevent some foot guns that were bothering me
From IRC (bridge bot)
@FromIRC
<riza> okay, I see. It looks like Indexable doesn't include map anyway
mfiano
@mjfiano:matrix.org
[m]
But self.each_with_index { |elt, i| self[i] = elt.round } doesn't return anything, unlike map
It modifies my struct in place
From IRC (bridge bot)
@FromIRC
<riza> sure, whats your end goal with this which each_with_index doesn't achieve?
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!