Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 22:42
    straight-shoota closed #12800
  • 22:41
    straight-shoota edited #12800
  • 22:41
    straight-shoota closed #12770
  • 22:41
    straight-shoota closed #12773
  • 20:38
    straight-shoota closed #12819
  • 17:58
    HertzDevil synchronize #12784
  • 15:51
    Blacksmoke16 review_requested #10648
  • 15:50
    Blacksmoke16 synchronize #10648
  • 15:48
    Blacksmoke16 synchronize #10648
  • 15:00
    Blacksmoke16 closed #12820
  • 11:38
    straight-shoota closed #12807
  • 11:38
    straight-shoota closed #12808
  • 11:38
    straight-shoota closed #12816
  • 00:00
    douglascamata closed #12820
  • Dec 03 23:10
    Blacksmoke16 closed #12821
  • Dec 03 23:10
    Blacksmoke16 labeled #12821
  • Dec 03 23:09
    Blacksmoke16 labeled #12821
  • Dec 03 22:13
    hutou labeled #12821
  • Dec 03 22:13
    hutou opened #12821
  • Dec 03 22:01
    douglascamata edited #12820
George Dietrich
@Blacksmoke16
esp for more complex models so that the structure of the request doesnt need to be tightly coupled to the db schema
moe
@moe:busyloop.net
[m]
yea, rails has ActiveModelSerializer for this. guess i may just want too much ("just return whatever you want, we'll render & auto-doc it").
works fine up to the point of auto-doc'ing & validating the input parameters. but the return value, that's really a tough cookie.
George Dietrich
@Blacksmoke16
ultimately you'd need to define what those validations are somewhere
using a DTO for that would get you that + the structure of the request
and have another for the response that describes the response
moe
@moe:busyloop.net
[m]
yup. i'll dig more into it in the coming days.
George Dietrich
@Blacksmoke16
could use the validation component for that ;)
but sounds good :+1:
Hayden Jones
@wrq
does crystal having anything like timeit for python? I've never profiled before, but I'm trying to determine where to use Structs and where to use tuples and such in a large data model, and I was hoping to put together numbers for the performance of each design
George Dietrich
@Blacksmoke16
structs and tuples are both on the stack so they'd be essentially the same. Is suggested to use structs over tuples/namedtuples majority of the time anyway
Hayden Jones
@wrq
okay, that makes sense
thank you
George Dietrich
@Blacksmoke16
but to answer your question, i'd checkout https://crystal-lang.org/api/master/Benchmark.html
Hayden Jones
@wrq
AH, okay. I'm embarrassed that I missed that, what an obvious name for it
jwaldrip
@jwaldrip:matrix.org
[m]
Is 1.4 dropping today?
I saw the release nodes reference todays date
George Dietrich
@Blacksmoke16
sure looks like it, or if not very soon
jwaldrip
@jwaldrip:matrix.org
[m]
Does the new version still require a compile time flag to get the interpreter?
Or is it enabled by default now?
George Dietrich
@Blacksmoke16
still need to manually build it with the flag
Hayden Jones
@wrq

I want to implement something like a dispatch table for a series of pseudo-bytecode instructions. I'd like to lookup each instruction and then yield my little VM to a proc, and execute each instruction that way.

Is this wise? And also, I don't see a yield_self method, am I missing something crucial?

Hayden Jones
@wrq
oh, that's wonderful. thanks again. I swear I actually can read, I guess I just overlook all the good stuff!
George Dietrich
@Blacksmoke16
iirc there are some issues with tho
so debatable if its worth just not declaring a block arg
but if it works fine for your use case :+1:
Hayden Jones
@wrq
Do you think it makes more sense then to just implement all the bytecodes as methods under the main VM class? I had already thought of that, but it just seemed inelegant. I haven't worked with a statically typed language before, so I don't really have the right intuition for this sort of thing. If it were ruby, I would just have the VM object be very simple and then have a big hash of procs as the values and use yield_self to execute them by passing in the vm object
George Dietrich
@Blacksmoke16
Got some example code?
doesn't compile, just a quick example I crapped out
I'm writing my own Push interpreter
but that's the general idea for execution
From IRC (bridge bot)
@FromIRC
<riza> @wrq it seems like a good use of a macro to generate a dispatch method based off of some classes or methods
<riza> i suppose it depends on how many instructions are in your instruction set
Hayden Jones
@wrq
I've been dreading learning macros, but that's because I'm lazy
George Dietrich
@Blacksmoke16
any reason to not just have them as methods on vm versus passing that in?
would have to benchmark what would be more performant, but i imagine having methods on the same type would be than a bunch of procs
Hayden Jones
@wrq
I have no clue, but I trust your intuition and I suppose I'll just do it that way
From IRC (bridge bot)
@FromIRC
<riza> the benefit to macros is you can generate code which is very performant but still maintainable, paying the conversion cost at compile time rather than at runtime
<riza> going along with what Blacksmoke has suggested, you could easily make a macro that collects all the methods on your VM class, filters out methods with a prefix, and generates the parser/dispatcher for that
<riza> So adding an instruction to your bytecode is as simple as defining a method called instruction_add
Hayden Jones
@wrq
right, I definitely want to do as much as possible before runtime. Alright, well this has been very helpful information. I suppose I'll spend some time with macros and do it with methods.
Ary Borenszweig
@asterite
Always start without macros. Add macros if you find repetition in your code
Hayden Jones
@wrq
I gotta get used to that. I am not a huge fan of metaprogramming in Ruby, I've always envied the FP style of things. I know that macros aren't exactly the same and offer much stronger guarantees. I'm reading up now on macros in crystal.
Benjamin Wade
@RespiteSage
Is there an issue/PR for ordering of classes affecting method overload resolution? E.g. https://play.crystal-lang.org/#/r/cytw vs https://play.crystal-lang.org/#/r/cytv
I know about crystal-lang/crystal#9750, but I think that's a bit different, since this isn't exactly a method ordering difference.
George Dietrich
@Blacksmoke16