Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 03:05
    maxfierke synchronize #11302
  • Oct 17 23:02
    maxfierke synchronize #11302
  • Oct 17 20:48
    Blacksmoke16 labeled #11333
  • Oct 17 20:48
    Blacksmoke16 opened #11333
  • Oct 17 19:21
    Blacksmoke16 edited #11332
  • Oct 17 19:17
    Blacksmoke16 opened #11332
  • Oct 17 19:17
    Blacksmoke16 labeled #11332
  • Oct 17 17:19
    sardaukar closed #11330
  • Oct 17 14:44
    Blacksmoke16 edited #11331
  • Oct 17 14:31
    Blacksmoke16 labeled #11331
  • Oct 17 14:31
    Blacksmoke16 opened #11331
  • Oct 17 13:22
    HertzDevil labeled #11330
  • Oct 17 13:14
    sardaukar labeled #11330
  • Oct 17 13:14
    sardaukar opened #11330
  • Oct 17 04:40
    maxfierke edited #11302
  • Oct 17 04:33
    maxfierke synchronize #11302
  • Oct 17 02:37
    maxfierke edited #11329
  • Oct 17 02:27
    maxfierke labeled #11329
  • Oct 17 02:27
    maxfierke opened #11329
  • Oct 17 02:25
    Blacksmoke16 edited #11328
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
Kirk Haines
@wyhaines
The talks aren't published yet. As for the code....I don't know if he has committed it to a branch in the repo yet, or not.
But it's pretty slick.
mfiano
@mjfiano:matrix.org
[m]
Is this the new crystal i PR?
Kirk Haines
@wyhaines
Yeah
mfiano
@mjfiano:matrix.org
[m]
That looked interesting, but will take some time to iron out for sure. I really like how Crystal is managed and coming together.
If I'm being honest, I'll share the major reason besides the toxic community that I left Nim, and I'm not seeing it here.
The project seemed like an experimental sandbox of the lead developer, pushing out new features that didn't need to exist, and before testing them, making the compiler very complex and fragile. There's like 7 garbage collector choices, and a bunch of other features that makes it feel more like C++ than a well thought out language.
mfiano
@mjfiano:matrix.org
[m]
I need some help with blocks. Not sure if what I want is possible.

I'm trying not to get into macros at this point, so ignoring them. I have a bunch of methods that all repeat a lot of code. Here's 2 of them:

    def round
      v = dup
      v.each_with_index { |elt, i| v[i] = elt.round }
      v
    end

    def abs
      v = dup
      v.each_with_index { |elt, i| v[i] = elt.abs }
      v
    end

So I was thinking of making a method:

    private def element_wise(&block)
      v = dup
      v.each_with_index { |elt, i| v[i] = ... }
      v
    end

That does all the logic, and I would like to pass in the ellipsized part to be executed if possible like:

    def round
      element_wise { round }
   end

or something or other.

mfiano
@mjfiano:matrix.org
[m]
Is this even possible or should I abort now? :)
George Dietrich
@Blacksmoke16
v = dup
v.each_with_index { |elt, i| v[i] = yield elt }
v
actually what you want is prob v[i] = with elt yield
at which point you could prob just do like