<deimos_>
for a random datapoint, i re-wrote some parsing/etl/m-r scripts from c to ruby to crystal. the c code kept segfaulting due to encountering random data. used ruby to prototype the code, was parsing around 2.8m lines/second/core. convert the ruby code to crystal, it's at 31m lines/sec/core.
<deimos_>
turns out i could have just used crystal to prototype instead of the intermediate step
<deimos_>
about 95% of the ruby code was literal copy/paste into crystal
<FromGitter>
<Blacksmoke16> π nice
<deimos_>
so now crystal is approved as experimental at work
<deimos_>
it's so new the worry is it doesn't have a long lifetime
<deimos_>
for comparison, the c code was doing around 20m lines/sec/core
<deimos_>
i have around 5000 cores to mess with
<FromGitter>
<Blacksmoke16> you using fibers/MT mode?
<deimos_>
however, showing how easy it is to go between crystal and ruby alleviates some concerns
<deimos_>
well, i cheat
<deimos_>
i use ruby and parallel gem to spin up all the crystal-based binaries
<deimos_>
and for another metric, it took me 45 hours to convert from c -> ruby -> crystal, where about 20h was spent trying to understand the c code
<deimos_>
the original c code was written around 2002 and took a contractor 3 months
<deimos_>
so, if you know ruby, crystal is really easy
<deimos_>
i code both ruby and crystal in a functional style, fwiw
<FromGitter>
<Blacksmoke16> ok
<deimos_>
i've done some with fibers, but not wrapped my head around how to handle huge numbers of them, or how crystal will handle it
<FromGitter>
<jrei:matrix.org> so maybe Ruby/Crystal is not the best language for you
<FromGitter>
<jrei:matrix.org> have you tried Nim?
<FromGitter>
<jrei:matrix.org> or Elixir
<deimos_>
none of those
<deimos_>
we have erlang here, because of course we do
<FromGitter>
<jrei:matrix.org> Why not using a more functional language rather than an object oriented?
<deimos_>
i look at more of a hybrid than strictly one or the other
<deimos_>
mostly because i know ruby the best, and now learning crystal much better
<deimos_>
wasn't trying to get into oo vs fp, just that crystal is really fast, easy to prototype like ruby, and so far, stable
<deimos_>
and the apache 2 license means i can probably get it approved for more critical and sensitive work
<FromGitter>
<Sija> @deimos_ since u already use Erlang, Elixir looks way moar your alley
<deimos_>
forget i ever mentioned functional
<FromGitter>
<jrei:matrix.org> you said you program in a functional way
<deimos_>
yes, i do, but i think that's a distraction. mostly, impressed with crystal and got it into a prod environment parsing trillions of log lines
<deimos_>
with this success, trying to get employer to help fund crystal development
<FromGitter>
<jrei:matrix.org> nice :D
<FromGitter>
<jrei:matrix.org> what I regret is the lack of transparency
<FromGitter>
<jrei:matrix.org> we don't know exactly where the money go
<FromGitter>
<jrei:matrix.org> no very related: no survey since a long time
<FromGitter>
<watzon> Yeah a survey is much needed
<FromGitter>
<watzon> What pokemon games have you tested?
<FromGitter>
<mattrberry> Looks like it's failing to compile the shaders..
<FromGitter>
<mattrberry> Hmm
<FromGitter>
<oprypin:matrix.org> @mattrberry if you wanted to try to *run* this binary in CI, can it exercise any code at all without bios/rom?
<FromGitter>
<mattrberry> Not as of right now
<FromGitter>
<oprypin:matrix.org> any rom and bios that's publicly downloadable? π€ͺ
<FromGitter>
<watzon> Iβve just tested Fire Red so far
<FromGitter>
<mattrberry> I'm a complete noob when it comes to opengl. It took me way longer than I care to admit to even get to the point I am now, and all I'm doing with it is applying a little shift to the colors lol. Maybe I can remove it for now and just go back to pure sdl. I can do the color change on the cpu..
<FromGitter>
<mattrberry> That's my old pure sdl renderer
<FromGitter>
<mattrberry> Only downside for now is lack of color correction :/
<FromGitter>
<mattrberry> @oprypin:matrix.org The bios I linked above is public and legal. You can also google Normatt's bios and find it in the ReGBA github repo iirc. As for roms, there are a handful of homebrew games that are totally fine to download. There are also plenty of test roms that people in the emudev community have made
<FromGitter>
<mattrberry> It's be nice to build an automated test suite someday like I did for my gbc emulator, but that's still a ways off
<FromGitter>
<watzon> @mattrberry that works
<FromGitter>
<mattrberry> Nice!
<FromGitter>
<mattrberry> Thanks for looking into it :)
<FromGitter>
<watzon> No problem. Is it expected to be very slow with really weird audio artifacts?
<FromGitter>
<mattrberry> Guess I'll just hide the opengl renderer behind a check
<FromGitter>
<mattrberry> It runs fire red at 100% speed on both my laptop and desktop, but there's still a lot of optimization I need to do (and a ton of work in general). Audio artifacts are expected if the emulator is running at less than full speed. What fps are you seeing / what cpu do you have?
<FromGitter>
<watzon> No idea about the fps, but it's gotta be less than half speed
<FromGitter>
<mattrberry> It should say in the window title
<FromGitter>
<watzon> I have an i9-9900
<FromGitter>
<watzon> Ahh I missed that
<FromGitter>
<watzon> Between 1 and 8 fps
<FromGitter>
<mattrberry> Sad, I wonder why it's so slow..
<FromGitter>
<mattrberry> There's a lot that I can and will optimize, but there's a lot that'll be harder. For example, the according to perf, the right shift operator takes 4.4% of my cpu time lol...
<FromGitter>
<mattrberry> I'm running an i7-8700K on my desktop, and I get ~120fps in most games that I've tried
<FromGitter>
<watzon> I do keep getting a bunch of Unmapped MMIO write and Unmapped MMIO read
<FromGitter>
<mattrberry> I get about 62-65 in those same games on my laptop, which I forget the cpu in. It's a 2017 laptop cpu though
<FromGitter>
<mattrberry> Do you get that after the first couple seconds of FireRed?
<FromGitter>
<mattrberry> That's because FireRed reads and writes to the serial port right when it boots, and I haven't stubbed serial yet
<FromGitter>
<mattrberry> But it should stop almost immediately
<FromGitter>
<mattrberry> Still plenty that's broken, but it's getting there :)
<FromGitter>
<mattrberry> Do you have any kind of profiler on mac to see which methods are taking the longest? I'd be curious to see what's so slow...
<FromGitter>
<mattrberry> Listening to the FireRed intro again reminds me how much louder my PSGs are than they're supposed to be relative to the DMA audio. @HertzDevil would be ashamed of me ;)
<FromGitter>
<mattrberry> I'm off for the night! Thanks for the help debugging :) I'll take a look to see if I can fix the opengl issues for mac, even if that means just falling back to an sdl renderer for now
deimos_ has quit [Quit: leaving]
deimos_ has joined #crystal-lang
<FromGitter>
<watzon> I'm sure there is, but I haven't dug that far yet
<FromGitter>
<watzon> There's no way to un-include a module is there? It can be a pain if a class you're extending is including JSON::Serializable, but you don't want any of the methods in your subclass to be serialized. Lots of `@[JSON::Field(ignore: true)]`
<oprypin>
oh hm
fifr[m] has quit [Ping timeout: 243 seconds]
<FromGitter>
<Daniel-Worrall> Maybe it could support annotating the subclass to do things like ignore further
_ht has joined #crystal-lang
fifr[m] has joined #crystal-lang
fifr[m] has quit [Ping timeout: 244 seconds]
<straight-shoota>
@watzon, that sounds weird. Why do you want to serialize properties in the base type but not in its ancestor?
<straight-shoota>
*not in a child
fifr[m] has joined #crystal-lang
ua has quit [Ping timeout: 260 seconds]
<FromGitter>
<watzon> The child doesnβt need to be serialized. Itβs an odd case Iβll admit
<straight-shoota>
then why care? =)
ua has joined #crystal-lang
deavmi has quit [Ping timeout: 265 seconds]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 272 seconds]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 272 seconds]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 272 seconds]
deavmi has joined #crystal-lang
<FromGitter>
<asterite> Instruments inside xcode
<FromGitter>
<Blacksmoke16> > Why do you want to serialize properties in the base type but not in its ancestor? β β An actual use case of this could be for like MTI, i.e. you have a base `Integration` type that should have its data serialized, like name, status, etc
<FromGitter>
<Blacksmoke16> but then you have like `GoogleUser` child that has like oauth token data that you dont really wantto expose
<FromGitter>
<Daniel-Worrall> Well, yeah, but you're assigning nil. I want the var to be Typed as Int32?, not Int32
<FromGitter>
<Daniel-Worrall> I guess I could just assign it a nil above
<FromGitter>
<Blacksmoke16> no what im getting at is the type of `var` *HAS* to be `Int32` or i wouldn't have been able to assign `nil` in the first place no?
<FromGitter>
<Blacksmoke16> `Int32?`*
<FromGitter>
<Daniel-Worrall> Well, I'm not assigning var as nil later
<straight-shoota>
>> var : Int32? = 1; typeof(var)
<straight-shoota>
it's an unclosured local var so the compiler can prove that the type can't be a union
<straight-shoota>
>> var : Int32?; var = nil; var = "foo"; typeof(var)
<DeBot>
straight-shoota: Error: type must be (Int32 | Nil), not (String | Nil) - https://carc.in/#/r/aap0
<FromGitter>
<Daniel-Worrall> Ah, it's because I'm doing proc bs
<straight-shoota>
It still values the typ restiction
<FromGitter>
<Daniel-Worrall> Right, that makes sense of what I was seeing
deavmi has joined #crystal-lang
<FromGitter>
<Daniel-Worrall> So, I'm not familiar with closures and the intricacies of them, but would type restricting them be possible within the compiler? Something like this? https://carc.in/#/r/aap1
deavmi has quit [Ping timeout: 272 seconds]
<FromGitter>
<Daniel-Worrall> Nice label spree :D
<FromGitter>
<Daniel-Worrall> You mind labelling #9957? It seems to be a good big step for win32 but I didn't even know it existed browsing on the win label
<_ht>
How can I test macro's that are defined on the class level? I seem unable to create a new class inside a test case. Then I get a "can't declare class dynamically" message.
<FromGitter>
<Blacksmoke16> Got an example?
<straight-shoota>
macros expand in the context that calls them, not where they are defined
<_ht>
Yes. I have a "Command" class with a "command" macro that takes a String parameter. It should raise an error when that parameter is empty.
<_ht>
So, I want to test when I create a new subclass of "Command", say "T", like: class T < Command NEWLINE command "" NEWLINE end, that this indeed raises an error
<FromGitter>
<Blacksmoke16> if you could make a playground link with the error that would be super helpful
<_ht>
I will try. There is a publically available playground I should use?
<FromGitter>
<Blacksmoke16> i guess what i was getting at is do you really need it tobe a macro versus just doing `@@command = "abc123"`?
<_ht>
Sort of. I looks nicer as part of the DSL than with all the @@ about. The idea is that you can wrap a CLI program without writing much Crystal code by using these macros.
<FromGitter>
<Blacksmoke16> mmk
<_ht>
Using this compile error does make things more robust
<FromGitter>
<Blacksmoke16> mhm
<_ht>
But I would still like to test that it is doing this properly, though
<FromGitter>
<Blacksmoke16> prob something like you "wrap" `git`, then in code you can do like `Git.commit` or `Git.push`
<FromGitter>
<jrei:matrix.org> Ha ok, got it
<FromGitter>
<jrei:matrix.org> It will end up being a huge library, --help are non standard
<FromGitter>
<jrei:matrix.org> I thought about something similar to generate sh completions for any command with a --help
<FromGitter>
<jrei:matrix.org> Or maybe the library won't do any validation?
f1reflyylmao is now known as f1refly
ua has quit [Ping timeout: 258 seconds]
ua has joined #crystal-lang
<_ht>
jrei: My wrapper is sort-of the inverse of the "option parser" you linked to.
<_ht>
An alternative way of using external code, as it were. Instead of binding a C library, you just bind to a program like imagemagick's convert, pandoc, pdflated, etc.
<_ht>
I've written specific wrappers before in Ruby, and now that I am switching to Crystal I am taking the opportunity to generalize my approach to any command-line program.
deavmi has quit [Ping timeout: 265 seconds]
<FromGitter>
<jrei:matrix.org> Nothing stops me from doing `Pandoc.wrong_command`?
<FromGitter>
<jrei:matrix.org> And what about docs?
<_ht>
The idea is that you specify the options you support in your wrapper. These options can have a type for their values, so Crystal will check that the values you give to the options are okay.
<_ht>
You do end up with a wrapper that is very close to the command-line application's API, which is both an advantage and a disadvantage.
<_ht>
So, to answer your question, you cannot do Pandoc.wrong_command.
<_ht>
Well, unless you specified a "wrong_command" option in the wrapper.
deavmi has joined #crystal-lang
<FromGitter>
<jrei:matrix.org> So your library can be used to make, say, a Git shard which will wrap the `git` command
<_ht>
Yes
deavmi has quit [Ping timeout: 265 seconds]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 265 seconds]
ua has quit [Ping timeout: 256 seconds]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 265 seconds]
richbridger has joined #crystal-lang
deavmi has joined #crystal-lang
ua has joined #crystal-lang
sorcus has joined #crystal-lang
<FromGitter>
<mattrberry> Breaking out of nested loops to a specific point isn't something that's supported by the language, right? Obviously there are ways to circumvent that, but it'd sure make this piece of code look nicer :p
<FromGitter>
<Blacksmoke16> neg
<FromGitter>
<mattrberry> π
<FromGitter>
<astrojuanlu:matrix.org> hi all! I see that Crystal has support for ARMv7 (#3424) but the Docker Hub images are only `linux/amd64`, are there plans to upload `linux/arm/v7` as well? β β (context: trying to build invidious on my Raspberry Pi)
<straight-shoota>
Arm docker images are not fully supported yet, but semi-official ones are available at jhass/crystal
<straight-shoota>
they're used for CI on arm in the Crystal repo, so it should be expected to work
<FromGitter>
<astrojuanlu:matrix.org> thanks @straight-shoota! unfortunately the alpine-based images do not support `arm/v7`, so I'll still have to work a bit more. but it's a good place to start
<FromGitter>
<mattrberry> @watzon Hey just want to check since you said you were getting 9 fps. My friend with some 2014 macbook pro is getting 67fps when uncapped and is holding a steady 60 when capped. Did you build for release?
postmodern has joined #crystal-lang
<postmodern>
crazy idea, hear me out, but has anyone thought of hooking crystal's GC up to another languages GC? It occurred to me we might be able to embed crystal in other GCed languages, provided it's GC somehow interfaces with Crystal's GC
<FromGitter>
<asterite> Oh, that's actually a nice idea. You mean, whenever Crystal needs memory, it asks that other language to allocate memory? The only problem I forsee is that other GCs are sometimes turned for that language. For example the GC might be precise, or move memory around
<FromGitter>
<oprypin:matrix.org> postmodern: well for crystal-imgui i hook up C++ memory allocation to Crystal's memory allocation so that's something
<postmodern>
or somehow it exposes it's GC object map to the other languages GC, or allocate crystal objects via the languages object heap?