rocky has quit [Remote host closed the connection]
hako has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rohitpaulk has joined #crystal-lang
hako has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
rohitpaulk has joined #crystal-lang
Kug3lis is now known as Kug3lis_off
Kug3lis_off is now known as Kug3lis
Kug3lis is now known as Kug3lis_off
Redrield has joined #crystal-lang
<Redrield>
Hey
<Redrield>
Are there any recommended editors/IDEs for working with Crystal
<Redrield>
Also, do there happen to be any benchmarks comparing Crystal and Rust?
Kug3lis_off is now known as Kug3lis
Kug3lis is now known as Kug3lis_off
<Redrield>
I see there's a VSCode plugin
<Redrield>
That any good/
<Redrield>
?
hako has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Redrield has left #crystal-lang ["Leaving"]
<FromGitter>
<drosehn> For some of my crystal programs I use Xcode on macOS, but that's just because I use that for working on many other types of files. I also use SublimeText3 for some crystal projects.
rohitpaulk has quit [Read error: Connection reset by peer]
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
sz0 has quit [Quit: Connection closed for inactivity]
_whitelogger has joined #crystal-lang
hako has joined #crystal-lang
hako has quit [Ping timeout: 246 seconds]
LastWhisper____ has joined #crystal-lang
bmcginty has quit [Ping timeout: 240 seconds]
<FromGitter>
<elorest> What is the best way to handle versioning in crystal projects? ⏎ It seems like you have to update version in a least 3 places: ⏎ ⏎ 1) src/yourproject/version.cr ⏎ 2) shard.yml ... [https://gitter.im/crystal-lang/crystal?at=592bac050ba4d59763ee3b3d]
bmcginty has joined #crystal-lang
<FromGitter>
<elorest> I just built this to simplify the process if something else doesn’t already exist. https://github.com/elorest/crelease
Kug3lis_off is now known as Kug3lis
mark_66 has joined #crystal-lang
<FromGitter>
<greentornado> when will the new version be released ?
<FromGitter>
<greentornado> :D
zipR4ND has joined #crystal-lang
Kug3lis is now known as Kug3lis_off
Kug3lis_off is now known as Kug3lis
Kug3lis is now known as Kug3lis_off
sz0 has joined #crystal-lang
<FromGitter>
<sdogruyol> hey everyone
<FromGitter>
<greentornado> hi
<FromGitter>
<bew> hi :)
<FromGitter>
<sdogruyol> how are you doing fellow Crystallers P
<FromGitter>
<bew> great! and you?
<FromGitter>
<sdogruyol> great
<FromGitter>
<sdogruyol> writing some rails to pay the bills :D
<FromGitter>
<bew> nice, I work with python currently, I'd love to work with crystal... one day...
<FromGitter>
<sdogruyol> hehe same
<FromGitter>
<sdogruyol> let's make that happen
<FromGitter>
<sdogruyol> what are you doing with python?
<FromGitter>
<bew> a learning plateform for bigdata stuff (R, python)
<FromGitter>
<sdogruyol> wow cool
<FromGitter>
<bew> using AWS ( <--- they are awesome! )
<FromGitter>
<bararchy> Will it be faster to do `Bytes == Bytes`, or `String == String` from CPU point of view ?
<FromGitter>
<bararchy> as in, I got a ID i'm passing around and checking between a few methods, ID is passed via a socket so it's a `Slice`, should I `String.new`on it ? or just compare it as slice ?
<FromGitter>
<bararchy> it should not be relevant for users, etc..
<FromGitter>
<bew> it'll be a little faster using Bytes, but it's a matter of one more comparaison for strings
splitty__ has joined #crystal-lang
<FromGitter>
<bararchy> What do you mean by one more comparaison ?
<FromGitter>
<bew> The String `==` implementation have a comparaison to check if you're comparing the string to itself (same object_id), else, it's the same as `Slice`
<FromGitter>
<bararchy> Oh
<FromGitter>
<bararchy> as in, it will get `.to_slice` for the test ?
<FromGitter>
<bew> no, but the implementation is the same
<FromGitter>
<bew> (it doesn't create a interediate Slice object)
<FromGitter>
<bew> here without string creation inside the loop
<FromGitter>
<bararchy> Yeha, it looks almost the same speed
<FromGitter>
<bararchy> Thanks guys :)
<FromGitter>
<bew> yw :)
zipR4ND has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 272 seconds]
zipR4ND has quit [Ping timeout: 245 seconds]
<FromGitter>
<bew> Is there a way to get the current stack usage ?
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<FromGitter>
<sdogruyol> GC.stats ?
<FromGitter>
<bew> this is for heap memory, not stack
<FromGitter>
<sdogruyol> oh sorry
<FromGitter>
<bew> I'm not sure it's even possible :/
<FromGitter>
<sdogruyol> well a stack is a stack for a reason :D
snsei has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
mark_66 has quit [Remote host closed the connection]
<FromGitter>
<abidon> hi guys, is someone able to help me on an issue i'm having ? 😊
<FromGitter>
<sdogruyol> hey
<FromGitter>
<bew> it depends on the issue
<FromGitter>
<abidon> haha ok i'll take the risk 😜
<FromGitter>
<abidon> i’m new to crystal and i’d like to know about some stuff in the language to face an issue i’m having. can method resolution be dynamic ? in fact, i’m using crystal to both develop a core application and plugins (which take form of dynamic libraries, nothing fancy here), but when i pass an instance of a concrete class from a plugin to the core app, it then fails when calling its methods saying:
<FromGitter>
... `’service.bootstrap(self)’ has no type (Exception)`
<FromGitter>
<bew> methods resolutions cannot be dynamic
<FromGitter>
<sdogruyol> that's a good question
<FromGitter>
<bew> I managed to get working a crystal shared library as plugin for a C core program, but never tried yet with a crystal core program
<FromGitter>
<bew> can you share a little code example (in a repo for example), to see more what you're doing?
<FromGitter>
<bew> the error is at runtime or at compile time?
<FromGitter>
<abidon> yes of course, just give me a bunch of minutes to create a simplified version of the "thing"
<FromGitter>
<abidon> runtime error
<FromGitter>
<abidon> in fact, i have 3 things, a "lib" shard with an abstract class "Service", a plugin which is compiled using the `-shared` linker flag and implements a concrete Service, and the core which dlopen the plugin and call a method on it to ask the plugin for the services it exposes. Then, the core try to call the `bootstrap` method on the concrete Service instance (which is a method defined as abstract in the lib shard)
<FromGitter>
... and it crashes with the error message above
<FromGitter>
<abidon> i'm doing a repo with everything needed to reproduce the issue
snsei has joined #crystal-lang
<FromGitter>
<bew> I'm very interested for a plugin system like this, with crystal only :)
<FromGitter>
<abidon> so do i ! 😂
<FromGitter>
<straight-shoota> Is there an easy solution for re-raising an exception with keeping the same callstack? I want to add some additional info to an exception wich is not available where the exception is created.
<FromGitter>
<bew> your workflow (as you described it) should work.. (@abidon)
<Yxhuvud>
method resolution cannot be dynamic, but there are union types, where a value can be one of a predefined set of types, and method call resolution do work on those sets.
<FromGitter>
<abidon> @bew that's what i was thinking too, just wanted to be sure
<FromGitter>
<bew> oh @akzhan looks nice
<FromGitter>
<bew> @abidon I don't think you can use OO between the core and the plugin (because of this, and also because of the function names mangling too..), you'll need a C-like interface, with simple functions accepting a Service, but even that, I'm not sure it'll correctly work
<FromGitter>
<straight-shoota> @akzhan That won't work because `new_e.callstack` will be overwritten by `raise`
<FromGitter>
<bew> @straight-shoota it may work if you call __crystal_raise yourself.. but that's another story
<FromGitter>
<straight-shoota> Yes, I wouldn't want to touch that directly
<FromGitter>
<akzhan> hm, raise.cr may be updated to set callstack only id needed.
<FromGitter>
<akzhan> it should not change bahaviuor of stdlib because `cause` not used anywhere in sodlib.
<oprypin>
abidon, a conventional vtable is not needed, there is a more flexible alternative already in place
<FromGitter>
<bew> @abidon Not planned, currently the methods are copy/pasted for each types, there is no vtable system... Might be feasible, using low-level hacking, but I'm not sure it's a good idea to mess with that
<oprypin>
a type can always be determined at runtime and hence all the methods that concern it
<FromGitter>
<bew> I pass, the expert is there :)
<oprypin>
the compiler must know at compile time not only names of methods but also types of all arguments and generate the according machine code for that particular instantiation of the method
<oprypin>
so fully dynamic dispatch is impossible. but a dynamic dispatch already exists
<oprypin>
just do if obj.responds_to? :stuff; obj.stuff("asdf"); end
<oprypin>
should work i think
<FromGitter>
<bew> oprypin, but the `obj.stuff("bla")` will still raise in this case
<oprypin>
it cannot "raise", it might fail at compile time
<Yxhuvud>
bew: Yes, unless all members of the union type respond to stuff.
<oprypin>
it will not fail at compile time unless ANY of the members of the union type respond to stuff
<FromGitter>
<straight-shoota> @akzhan With causes you might also want to keep both callstacks of the inner and outer exception. So I don't think it should take the callstack from the cause by default.
<oprypin>
bew, well a object literally can't exist if it's abstract, but yeah, there are some convoluted ways to trick the compiler into that
<FromGitter>
<bew> @straight-shoota you could put the first callstack into the second exception as the message ?
<FromGitter>
<straight-shoota> Just don't overwrite the callstack if there already is one.
<FromGitter>
<abidon> @oprypin the fact is that the object isn't abstract, its a concrete instance from a dynamically loaded library.
<FromGitter>
<bew> @abidon but from the `core` point of view, what is it?
<FromGitter>
<abidon> @oprypin but the core program thinks its abstract, because the concrete type is not known at compile time from the core point of view
<oprypin>
abidon, could you do (Subclass1|Subclass2|Subclass3) instead of using the abstract base?
<oprypin>
it still should work even with abstract though
<oprypin>
and you're mentioning a dynamic library, that's probably not gonna work at all. a dynamic library must have only concrete types
<FromGitter>
<abidon> @oprypin not really, as i would would loose all the modularity of loading concrete instances that are of unknown type for the "core"
<FromGitter>
<abidon> @oprypin I'm doing an example repo, just give me some time
<oprypin>
Crystal classes cannot be exposed in a dynamic library
<FromGitter>
<abidon> that's why i feel constrained to switch to another programming language, sadly...
<FromGitter>
<pta2002> @faultyserver what if I want to write to stdin?
TheLemonMan has left #crystal-lang [#crystal-lang]
<FromGitter>
<faultyserver> on the child?
<FromGitter>
<pta2002> well, redirect something to the child's stdin
<FromGitter>
<pta2002> don't i need a pipe for that
<FromGitter>
<pta2002> set on inpur
<FromGitter>
<faultyserver> you can set `input` on `Process.exec` to any file descriptor
<FromGitter>
<pta2002> okay
<FromGitter>
<pta2002> why doesn't the output work though, on my example
<FromGitter>
<pta2002> that's weird, no?
<FromGitter>
<faultyserver> Worked for me: ```The program wrote require "./import.cr" ⏎ The program wrote ⏎ The program wrote import "./other2.cr", Library```
<FromGitter>
<faultyserver> (reading a different file)
<FromGitter>
<pta2002> hmm
<FromGitter>
<faultyserver> are you sure `/etc/hostname` isn't blank?
<FromGitter>
<faultyserver> or maybe it doesn't end with a newline? idk if that would affect it, though
<FromGitter>
<pta2002> it does not end with \n
<FromGitter>
<pta2002> maybe that's it
<FromGitter>
<faultyserver> That almost seems like a bug in `gets`, imo
<FromGitter>
<faultyserver> I feel like it should detect EOF and treat that as a newline
<FromGitter>
<pta2002> seems like it
<FromGitter>
<pta2002> it works with multiple lines
<FromGitter>
<pta2002> seems like the problem's with process.terminated
<FromGitter>
<pta2002> replacing the Process.exec with Process.exit hangs too
<FromGitter>
<bew> I think because you never did `child.wait`
<FromGitter>
<bew> This is needed to terminate the process
<FromGitter>
<pta2002> ah so that's what i wanted
<FromGitter>
<pta2002> where do I put wait
<FromGitter>
<pta2002> yay it works
<oprypin>
abidon, getting `plugin: version node not found for symbol *Pointer(Array(Debug::DWARF::LineNumbers::Row))@Pointer(T)#realloc<Int32>:Pointer(Array(Debug::DWARF::LineNumbers::Row))`
<FromGitter>
<pta2002> how do I test if there's any change in a file descriptor thing
<oprypin>
i dont get it
<FromGitter>
<bew> oprypin, same, I think it's shared library compilation is broken, or somthing like that
<FromGitter>
<abidon> it works on macos, i haven't tested on linux yet, but looks weird...
<FromGitter>
<abidon> maybe compiling in release would bypass debug information generation ?
<FromGitter>
<bew> compiling with `--release` works
<FromGitter>
<abidon> @bew nice
<FromGitter>
<bew> now I get `plugin: cannot open shared object file: No such file or directory (Exception)`...
<FromGitter>
<abidon> @bew ...
<FromGitter>
<bew> ok it works when using `Dyn.new "./plugin"`
<FromGitter>
<bew> I get you error
<FromGitter>
<abidon> haha ok updating the repo
ryanf has quit [Quit: leaving]
ryanf has joined #crystal-lang
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter>
<pta2002> hm
<FromGitter>
<pta2002> how do I know if there's anything left to read?
<FromGitter>
<pta2002> from an IO
<FromGitter>
<faultyserver> https://crystal-lang.org/api/0.22.0/IO.html#gets%28limit%3AInt%2Cchomp%3Dfalse%29%3AString%3F-instance-method ⏎ ⏎ `gets` returns `nil` if called at the end of an IO
<FromGitter>
<faultyserver> i.e., when there's nothing left to read
<FromGitter>
<bew> > The system will assume that a write could occur while any process has the write end open, even if the only such process is the one that is currently trying to read from the pipe, and the system will not report EOF, therefore.
<FromGitter>
<bew> and
<FromGitter>
<bew> > Even if the parent has completed writing, your while loop below this line will block for ever for the read to return 0(ie EOF). This happens since even if the parent has completed writing and closed the write end of the pipe, the reference count of the write end in the File table is still 1 (Initially it was 2) and so the read function still is waiting for some data to arrive which will never happen.
<FromGitter>
<bew> (they explain what it does when not closing the pipe end)
<FromGitter>
<pta2002> ahh, thanks a lot! :)
<FromGitter>
<pta2002> now I can fulfill my extremely stupid goal of making a web terminal
<FromGitter>
<bew> I have no idea :D
<FromGitter>
<bew> nice project
<FromGitter>
<pta2002> heh
<FromGitter>
<pta2002> i made a shell in python so I thought I'd do a terminal emulator
<FromGitter>
<pta2002> but UI libraries are a PITA
Philpax has quit [Read error: Connection reset by peer]
Philpax has joined #crystal-lang
<FromGitter>
<bew> Is there a way to write: `def initialize(external_name @internal_name)` ?
<Papierkorb>
If that doesn't work I don't have a better answer bew
<FromGitter>
<bew> nvm, I messed up sth else, it works
rohitpaulk has quit [Remote host closed the connection]
<FromGitter>
<bew> thanks :)
<FromGitter>
<bew> I think this is a bug: https://carc.in/#/r/23s0 IMO it should say that it doesn't know `UnknownType`, no?
LastWhisper____ has joined #crystal-lang
VectorGraphics has joined #crystal-lang
chatter29 has joined #crystal-lang
<chatter29>
hey guys
<chatter29>
allah is doing
<chatter29>
sun is not doing allah is doing
<chatter29>
to accept Islam say that i bear witness that there is no deity worthy of worship except Allah and Muhammad peace be upon him is his slave and messenger
<chatter29>
As-salāmu ʿalaykum (Arabic: السَّلَامُ عَلَيْكُمْ [asːaˈlaːmu ʕaˈlaikum]) is a greeting in Arabic that means "peace be upon you". The greeting is a standard salutation among Muslims and is routinely used whenever and wherever Muslims gather and interact, whether socially or within worship and other contexts. [1] The typical response to the greeti
<chatter29>
ng is waʿalaykumu s-salām (وَعَلَيْكُم السَّلَام [waʕaˈlaikumu sːaˈlaːm]; "and upon you, peace").
<chatter29>
prophet muhammad peace be upon him was sent to destroy the musical instruments
<chatter29>
men must have one fist beard
zipR4ND has quit [Read error: Connection reset by peer]
chatter29 has quit [Client Quit]
<VectorGraphics>
A fist beard? That's pretty manly
<pta2002>
the fuck
zipR4ND has joined #crystal-lang
<VectorGraphics>
Does anyone happen to know if there is a way to either list/iterate over all instance variables or if they can be selected by name? I have several properties and want to do something simple like only print the names and values of ones that aren't nil
<FromGitter>
<bew> this can be done with macros
<FromGitter>
<bew> see `Object#to_s`
pta2002 has quit [Quit: WeeChat 1.7.1]
<VectorGraphics>
Thanks, bew. I might just unroll what I'm trying to do
<RX14>
next time just ping me about the islambots and i'll ban them
<FromGitter>
<bew> roger that
<TheGillies>
it's always the same nick
<TheGillies>
which amazes me
<TheGillies>
like why don't we just ban the nick
<RX14>
oh wow it is
<RX14>
i assumed it wasn't
<RX14>
well then problem solved
<FromGitter>
<bew> oprypin I don't know if you finally tried to make it work (shard library as plugin), but I did and it works pretty well ;)
<TheGillies>
I love that as part of his proselytism he copy/pastes wikipedia. so devout in his conviction heh
<RX14>
i think thats how it works lol
<RX14>
yup
<RX14>
hopefully that solves the problem but I doubt it - they'll notice and choose a different username
Kug3lis is now known as Kug3lis_off
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]