<oprypin>
it just requires a passthrough pointer to push the closure data through. or i guess you could make the closure global which kinda defeats the point
<FromGitter>
<watzon> Hmm forgot about the wrapper
<FromGitter>
<watzon> There's no way to make this simpler on the developer?
<FromGitter>
<watzon> Because I find myself getting this pretty often when trying to wrap C libs
<FromGitter>
<grkek> It's not one of the brightest out there but there are some examples if you want to take a quick look
ur5us has quit [Ping timeout: 252 seconds]
_whitelogger has joined #crystal-lang
early has quit [Quit: Leaving]
early has joined #crystal-lang
_ht has joined #crystal-lang
ur5us has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
ur5us has quit [Ping timeout: 256 seconds]
darkstar_13 has joined #crystal-lang
ur5us has joined #crystal-lang
<FromGitter>
<naqvis> is there any way to find out how many bytes were read from an IO when an `IO::EOFError` is raised? Under normal conditions `read` does return the count, so my question applies to conditions when `EOFError` is raised
<FromGitter>
<naqvis> assuming the count to 0 is invalid, as I've seen stdlib does read into slice, but raises when conditions applies, so some portion of data has been read into slice passed, but there is no way to know the count
<FromGitter>
<naqvis> I tried to do pointer subtraction, but `to_unsafe` always returns the same pointer, so before and after pointer subtraction always yields 0
<FromGitter>
<naqvis> also `IO::pos` is not reliable one, as default implementations raises and only `IO::FileDescriptor` and `IO::Memory` implements this
<FromGitter>
<j8r> count manually?
<FromGitter>
<j8r> each time you read a byte, increment a counter?
<FromGitter>
<naqvis> yeah, that could be done if reading byte by byte
<FromGitter>
<naqvis> but if you are going to read in chunk, there is no way to do that
<FromGitter>
<j8r> yep :/
<FromGitter>
<j8r> I don't think it is possible
<FromGitter>
<j8r> *with the current stdlib
<FromGitter>
<naqvis> another naive approach would be to fill the slice with some special value and once encountered EOF do a scan to find the first index of that special value 😆
<FromGitter>
<j8r> good idea
<FromGitter>
<naqvis> lol, then will need to find a globally unique value, which no data will ever contain
<FromGitter>
<naqvis> or else this approach is out of luck
<FromGitter>
<naqvis> lol
<FromGitter>
<j8r> but it is already filled with `0`
<FromGitter>
<naqvis> true, but there are null strings, especially in binaries
<FromGitter>
<naqvis> so will it be safe bet to scan for next null value to figure out the count?
<FromGitter>
<j8r> IO only accepts `Bytes`, which is `Slice(UInt8)` - not much choice
<FromGitter>
<naqvis> yeah true
<FromGitter>
<j8r> between 0 or 255, all can be used
<FromGitter>
<j8r> what is your IO?
<FromGitter>
<naqvis> could be any
<FromGitter>
<naqvis> Network, File, Memory etc
<FromGitter>
<naqvis> function accepting any implementation of `IO`
<FromGitter>
<j8r> because each one has its own implementation of `#read(bytes)`
<FromGitter>
<j8r> how does it helps to have a counter?
<FromGitter>
<naqvis> don't think that will help, as it's the Reader::IO which is going to trigger the EOFError
<FromGitter>
<naqvis> so implementing a Counter on reader side, will suffer from same implications
<FromGitter>
<naqvis> in that way, implementation side, when raising this exception, will provide the count for user side to capture
<FromGitter>
<grkek> Instead of changing the error code override the File read function and implement it in there no need to push that to std
<FromGitter>
<naqvis> @grkek monkey patching require knowledge of underlying implementation
<FromGitter>
<naqvis> my question applies at generic level, it should be the responsibility of the implementation side to provide the details to user side, not the otherway around
<FromGitter>
<grkek> Interesting, suggest that on the crystal issues page
<FromGitter>
<stronny> @naqvis IO#read says that "Returns the number of bytes read, which is 0 if and only if there is no more data to read (so checking for 0 is the way to detect end of file)."
<FromGitter>
<stronny> it shouldn't raise on EOF
<FromGitter>
<naqvis> `io.read_fully`
<FromGitter>
<naqvis> and many other methods implemented by `IO` raises this exception
<FromGitter>
<naqvis> `read` is the bare minimum method which implementor need to implement
<FromGitter>
<stronny> so how would you use the count?
<FromGitter>
<stronny> my point is that if you are okay with partial read why do you use read_fully?
<FromGitter>
<naqvis> I agree, but question would be what's the use of raising an exception while not fully giving the information back to user side?
<FromGitter>
<naqvis> there is no way to know how much bytes has been read, when you encounter this exception
<FromGitter>
<stronny> the logic would be like this: "I need this exact number of bytes; if anything goes wrong then I have nothing useful to do with the result"
<FromGitter>
<stronny> if your usecase is different, don't use read_fully
<FromGitter>
<naqvis> i would argue against your logic here
<FromGitter>
<naqvis> when reading IO, you get no clue on how much data is there
<FromGitter>
<naqvis> simple example would be reading a network
<FromGitter>
<stronny> of course
<FromGitter>
<naqvis> in general, its always good practice to provide as much info back as possible, instead of simply saying "something bad happen" lol
<FromGitter>
<stronny> use IO.read
<FromGitter>
<naqvis> and that was the trigger for my this discussion
<FromGitter>
<naqvis> yeah and I use IO.read only
<FromGitter>
<stronny> I think you're misrepresenting stdlib here a little
<FromGitter>
<naqvis> not stdlib, but this specific EOFError
<FromGitter>
<stronny> many methods don't raise, there even is read_fully? if you prefer nil
<FromGitter>
<naqvis> other than that, i'm good with stdlib
<FromGitter>
<stronny> gets doesn't raise, read_line does
<FromGitter>
<stronny> or do you see no utility in EOFError in general?
<FromGitter>
<naqvis> point is, when action is performed (though not fully), what has been done, should be propagated back to user
<FromGitter>
<naqvis> those methods in question does raise EOF even when they have read bunch of data
<FromGitter>
<naqvis> but how much work was done? user is left in dark
<FromGitter>
<stronny> exceptions don't work in the pattern you describe
<FromGitter>
<naqvis> doesn't it make sense to provide the details of you asked 100 and there was only 10 left
<FromGitter>
<naqvis> something like this
<FromGitter>
<naqvis> Exceptions are a way to break
<FromGitter>
<stronny> they contain the context of error, not other actions
<FromGitter>
<naqvis> but that doesn't dictate on you can't capture details
<FromGitter>
<naqvis> yes, context is there, but it is incomplete, that's my point
<FromGitter>
<stronny> can you point out an example of the language/runtime that behaves like your proposal?
<FromGitter>
<naqvis> and such context provide no useful info back to user
<FromGitter>
<naqvis> I do that way
<FromGitter>
<naqvis> every exception raised, provide meaning information back
<FromGitter>
<stronny> where does EOFError contain the read count/data?
<FromGitter>
<naqvis> it doesn't
<FromGitter>
<stronny> any idea why it doesn't?
<FromGitter>
<naqvis> that's my question
<FromGitter>
<stronny> so here's the answer: it isn't helpful, it's unuseful information
<FromGitter>
<stronny> if you think you will gain anything with it show some example code
<FromGitter>
<stronny> chances are it could be made better with no such facilities
<FromGitter>
<stronny> do you wish to stuff the entire execution context into every exception? presumably no, so you only include *relevant* data
<FromGitter>
<stronny> what's been read isn't relevant to EOFError
<FromGitter>
<naqvis> either I wasn't clear in my communication or you couldn't get my point
<FromGitter>
<naqvis> i'm not taking about stack tracing here
<raz>
i'll side with naqvis here and agree it would be nice if exceptions generally provide meaningful context (where possible, sensible and it of course shouldn't add runtime cost)
<FromGitter>
<naqvis> my whole point was, when some data is read, there should be some way to report back
<FromGitter>
<stronny> they do provide it already
<FromGitter>
<stronny> there is a way, it's IO.read
<FromGitter>
<naqvis> or if you can guide me to the direction, where I can capture such details from the slice which I pass
<FromGitter>
<naqvis> if you read my initial question, that does convey the intention
<FromGitter>
<stronny> so what you ask for is a method `read_fully_unless_there_is_not_enough_data_in_which_case_read_as_much_data_as_there_is`
<FromGitter>
<grkek> kek
<FromGitter>
<grkek> imagine that function name in the std
<raz>
that's a nice method name
<FromGitter>
<grkek> lib
* raz
adds to clipboard
<FromGitter>
<stronny> how would you use it and how it's different from `read`?
<FromGitter>
<stronny> so to conclude my thoughts: ⏎ ⏎ 1) if you process data chunk-by-chunk all you need is bare `read` ⏎ 2) if you need the whole input you have `gets_to_end` ⏎ 3) read_fully is useful in all-or-nothing cases [https://gitter.im/crystal-lang/crystal?at=5e98321e2ff88975b422d484]
<FromGitter>
<grkek> i dont like the weird naming scheme
<FromGitter>
<grkek> gets
<FromGitter>
<grkek> puts
<FromGitter>
<grkek> thats from ruby right?
<FromGitter>
<stronny> right
<FromGitter>
<naqvis> Thanks @stronny , out of my experience with crystal, I've never used any other method than read on IO 😆
<FromGitter>
<grkek> Crystal might be one greatest langs to work with IO
<FromGitter>
<grkek> imo
<FromGitter>
<naqvis> but question was, why is stdlib doing half-baked activity like reading IO and writing to populate the slice and then BOOM
<FromGitter>
<naqvis> and don't give users any clue on how much data was read into slice before this big BOOM
<FromGitter>
<grkek> which function do you mean/
<FromGitter>
<stronny> because if you need this information you don't use thid method
<FromGitter>
<grkek> ?
<FromGitter>
<naqvis> yeah, so I don't
<FromGitter>
<stronny> so no problem =)
<FromGitter>
<naqvis> as I said, i only use IO.read and IO.write
<FromGitter>
<aamir-s18> Hey I tried to build my crytsal app for windows and got this "Error can't find 'c/arpa/inet' is there any solution for this thank you :)
<FromGitter>
<stronny> do you have a portable program or is it just windows?
<FromGitter>
<aamir-s18> what do you mean?
<FromGitter>
<stronny> is your program supposed to run on windows only or win/lin/mac?
<FromGitter>
<aamir-s18> Ah on all three
<FromGitter>
<stronny> what does it do? I'm just curious
<FromGitter>
<aamir-s18> its just a little software project for an uni course. We have courses where we can submit our programming solution and it will check it automaticly. We wrote a CLI for this.
<FromGitter>
<Afront> Woah, you can use Crystal in your uni?
<raz>
some unis are smart <3
<FromGitter>
<stellarpower> I'm hoping I can rework something I did in second year in python into Crystal and take it forward for projects in later years
<FromGitter>
<stellarpower> Used a script to parse and spit out equivalent Ruby and then going form there, file by file
<raz>
i never understood why they seem to use so much python in unis
<FromGitter>
<stronny> someone decided it's good for learning
<FromGitter>
<stronny> I disagree, but my opinion was not considered lol
<FromGitter>
<stellarpower> So they told me (physics) that they used C a good while ago
<FromGitter>
<stellarpower> But people couldn't handle pointers
<FromGitter>
<stellarpower> And then went to Java
<FromGitter>
<stellarpower> And finally gave up and chose python
<raz>
well, it's not. not only is python ugly from an aesthetic pov but it's also hideously unpure. neither does it teach proper OOP nor any low-level stuff.
<FromGitter>
<stronny> yep, I don't like python
<FromGitter>
<stellarpower> I can see the argument that Python has a lot of libraries available and is widely used in the sciences so it's good to go out the box for many things
<FromGitter>
<stellarpower> But as a language I hate it
<FromGitter>
<stellarpower> I realised though it's a bit hard to complain
<raz>
well yes, those math libraries seem to be the big draw
<raz>
pity they had to be written in python of all things
<FromGitter>
<stronny> good scientists are rarely also good programmers
<FromGitter>
<stellarpower> I see people taking up programming for the first time and get quite into it with no idea how memory allocations, types, etc. work. To that end it has done the job of abstractinga virtual machine and expressing a program in domain-level concepts
<FromGitter>
<stellarpower> But
<FromGitter>
<stellarpower> Icky
<FromGitter>
<tenebrousedge> list comprehensions are a really silly thing to choose over proper higher-order functions
<FromGitter>
<stronny> in the good old days they didn't have to write programs themselves
<FromGitter>
<stellarpower> I had to use numpy and matplotlib for said project
<raz>
tenebrusedge++
<FromGitter>
<stellarpower> Numpy was horrendous
<FromGitter>
<stellarpower> It kept trying to infer dimensions incorrectly and it took forever to trace it down
<FromGitter>
<stellarpower> Everything was fine and then suddenly broke because it collapsed an array to a scalar argument when previously it iterated over
<raz>
every time a pythonista praises their "amazing" list comprehensions i throw up a little in my mouth. they are a nasty kludge to a problem that had long been solved properly elsewhere.
<FromGitter>
<stellarpower> We had to do them in Haskell
<FromGitter>
<stellarpower> Like
<FromGitter>
<stellarpower> They aren't really necessary in Python
<FromGitter>
<stellarpower> Haskell felt a lot like TMP in C++
<FromGitter>
<stellarpower> But I'm really pleased Crystal exists. I've always preferred Ruby over Python but the main thing that annoys the hell out of me over time is just it's a pain to debug. It's fast to write and slow to debug, you by and large just turn what could be compile-time errors into the runtime domain and that's just very annoying.
<FromGitter>
<stellarpower> So to be able to drop into my preferred scripting language and yet find it's got proper bigboy features and compiles down is great
<FromGitter>
<stronny> yes, but
<FromGitter>
<stronny> it takes 10x time to write
<FromGitter>
<stellarpower> Which does?
<FromGitter>
<stronny> crystal vs ruby
<FromGitter>
<stellarpower> Ruby takes 10x to run and debug
<FromGitter>
<stellarpower> I find
<FromGitter>
<stronny> yep, that's the choice
<FromGitter>
<stellarpower> I'd rather think than run a really slow webdriver script that keeps breaking and takes forever to initialise cause the website is broken and then realise I made a typo and it crashes and can;t output my results.
<FromGitter>
<stellarpower> Plus, thinking about your code overall is probably a good thing
<FromGitter>
<stellarpower> If it takes long to write hopefully I've thought about it carefully
<FromGitter>
<stronny> if you can afford it
<FromGitter>
<tenebrousedge> I think Ruby's debugging tools are stronger at the moment: `icr` is no `pry`. But many categories of error in Ruby are not possible in Crystal
<FromGitter>
<stellarpower> I mean different strokes for different folks
<FromGitter>
<stellarpower> But I am trying to port or write as much new stuff in Crystal as I can to get used to it and I think for the way I work it will speed me up
<FromGitter>
<stronny> I'm not saying crystal is worse than ruby
<FromGitter>
<stellarpower> I've not really set up a proper debugger yet but it should be possible to step through it properly and watch what's happening if compiled with debugging symbols, right?
<FromGitter>
<stronny> just keeping perspectives
<FromGitter>
<stellarpower> Oh no, I didn't think you are
<FromGitter>
<stellarpower> It just suits me
<FromGitter>
<stellarpower> Well in theory
<FromGitter>
<stellarpower> I've not managed o write much recently where I can choose the language
<FromGitter>
<stronny> hobby projects?
<FromGitter>
<stellarpower> Yeah, not had much time to work on them properly
<FromGitter>
<stellarpower> Plus am getting my feet with Illumos, a lot of tidying up is stacking up until I can clear some of the bottlenecks
<FromGitter>
<stellarpower> So e.g. the webscraper, there are shards for webdriver but I think still relatively new
<FromGitter>
<stellarpower> It's a shame but I think for some things it may be a matter of putting them on the pile so hopefully more libraries are available or are more mature in say 6 months' time
<FromGitter>
<stronny> pity we can't use C libs without any code
<FromGitter>
<stronny> you still need to write/generate a wrapper
<FromGitter>
<stellarpower> Yeah, that's often the catch
<FromGitter>
<stellarpower> Some moves may be made in automating more of it I guess
<FromGitter>
<stellarpower> Also a shame one can't just hook into an existing gem. I know they are separate and distinct languages and not at all the same under the hood, but some small ruby libraries are a nice layer over the top of e.g. a C library that expose a minimal API that is enough like Crystal it would be nice if that could work in the meantime
<FromGitter>
<stronny> no, that is probably impossible
<FromGitter>
<stellarpower> Yeah
<FromGitter>
<stellarpower> Or at least not worth the effort
<FromGitter>
<stellarpower> I was wondering whether or not it'd be possible at all to marshall across things like hashes, arrays, etc. using the C implementation parts
<FromGitter>
<tenebrousedge> it would probably be easier to rewrite, especially if it's just a translation layer
<FromGitter>
<stronny> there are no arrays/hashes in C
<FromGitter>
<stellarpower> Just conceptually because they're semantically close in the respective languages, if you relax type restrictions for a second
<FromGitter>
<stellarpower> As in the c libraries of the ruby implementation
<FromGitter>
<stronny> ruby ext? native extensions in gems?
<FromGitter>
<stronny> no, that code is useless in crystal
<FromGitter>
<tenebrousedge> well, you could embed a Ruby interpreter in Crystal 😬
<FromGitter>
<stronny> mruby yes
<FromGitter>
<stellarpower> As in Matz's ruby is written in C and so it exposes the data structures that represent objects in memory as C structs. I don't know that much but much of what specifies fundamental types is built into the C, sometimes because the types are so fundamental and sometimes for speed on very common methods.
<FromGitter>
<stronny> hm? what data structure are build in c?
<FromGitter>
<stellarpower> As a thought experiment I was wondering how far one could go before the wheels fell off if you e.g. wanted to hook into a function in ruby
<FromGitter>
<stronny> it probs could be done, but with a great effort
<FromGitter>
<stronny> yes, you need to integrate mri into your program
<FromGitter>
<j8r> Wow, I just cut by half generating a 3 matrix using preview_mt
<FromGitter>
<j8r> 1minute on 1thread, 30seconds on 4threads
<FromGitter>
<j8r> Generating the X row on a first pass, then spawn to generate Y and Z rows
<FromGitter>
<j8r> Most of the world will be random, even blocks
<FromGitter>
<j8r> I will do my best to separate the store to the other logic, so future refactorings would be simpler
<FromGitter>
<sam0x17> @j8r love to see you making a crystal fork of the open-simplex-noise rust crate. I've actually used that one before
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
<FromGitter>
<grkek> @j8r have you ever dealt with timeouts of sockets?
<FromGitter>
<grkek> websockets*
<FromGitter>
<stronny> there were some topics on the forum
<FromGitter>
<j8r> @grkek no, I didn't use them much
<FromGitter>
<j8r> for now. I hope I won't have them :/
<FromGitter>
<j8r> I believe I have to use Hash to have sparse arrays
<FromGitter>
<kinxer> @j8r Are you open-sourcing this or writing it just for yourself (not that the latter is bad). If you're open-sourcing it, I'll be very interested to see how you implement the server.
<FromGitter>
<j8r> @kinxer Ho, yes. I don't know how all of this will go, for now I am doing this because it is fun :) ⏎ I'll open source it if it end up being working, by luck haha
<FromGitter>
<j8r> I don't know if girng is still around - too bad he was a pro on this topic
<FromGitter>
<tenebrousedge> msgpack seems like a good idea
<FromGitter>
<Blacksmoke16> pretty sure he just sends an array of data and uses enum/constants in gotdot to point to correct index
<FromGitter>
<Blacksmoke16> array of arrays*
<FromGitter>
<tenebrousedge> that seems like a less good idea
<FromGitter>
<ImAHopelessDev_gitlab> i do `masterclient.get_utf8_string(masterclient.get_32())` and it returns a string (which i parse into a gdscript dictionary). i don't know if this classifies as raw data, i just use whatever works lol
<FromGitter>
<ImAHopelessDev_gitlab> @j8r what are you creating?
<FromGitter>
<ImAHopelessDev_gitlab> nvm I scrolled up
<FromGitter>
<j8r> noice, I'll problably ask you some other things in the future :)
<FromGitter>
<randiaz95> guys.. When will we have Crystal for Windows?
<FromGitter>
<randiaz95> I hate oracle more than windows...
<FromGitter>
<ImAHopelessDev_gitlab> :D
<FromGitter>
<randiaz95> can't be on a virtualbox
<FromGitter>
<j8r> Use VMWare or Citrix... lol
<FromGitter>
<randiaz95> plus.. If I have to put another curly brace.. I feel like I will throw up lol
<FromGitter>
<j8r> or HyperV
<FromGitter>
<randiaz95> which do you recommend?
<FromGitter>
<randiaz95> lol
<FromGitter>
<randiaz95> You gave me 3 hours of researching here buddy.
<FromGitter>
<ImAHopelessDev_gitlab> rofl
<FromGitter>
<j8r> haha
<FromGitter>
<randiaz95> Wait.. Hyper v is a software product that helps people leave windows?
<FromGitter>
<randiaz95> Lol!
<FromGitter>
<randiaz95> made by windows?!
<FromGitter>
<j8r> You could use WSL or Docker (no kidding) if you don't like VirtualBox
<FromGitter>
<j8r> or even DualBoot
<FromGitter>
<ImAHopelessDev_gitlab> haven't used hyper v since cis class
<FromGitter>
<randiaz95> i mean.. I have to configure my screen size every time I start a new virtual box project..
<FromGitter>
<ImAHopelessDev_gitlab> i heard WSL2 is a thing and apparently faster file accessing. i wanna try crystal on it but i don't want to break anything that's not broken right now. i got a perfect dev setup
<FromGitter>
<randiaz95> interesting..
<FromGitter>
<randiaz95> Is this why we haven't created web 3.0?
<FromGitter>
<randiaz95> virtualizations of os are too slow?
<FromGitter>
<ImAHopelessDev_gitlab> the slower the os experience, slower dev time needed to create something faster. *taps head*
<FromGitter>
<Afront> I used to use WSL for Crystal, but it broke for me. Now, I use VirtualBox if I need SSL ⏎ How about QEMU?
<FromGitter>
<randiaz95> I don't know why words, sounds from a human mouth can be owned..
<FromGitter>
<ImAHopelessDev_gitlab> @randiaz95 man you always got me dying, i love it
<FromGitter>
<tenebrousedge> words can't be owned, but in certain contexts they can be trademarked
<FromGitter>
<randiaz95> It's like saying because I built a house with lumber i must give Old Abe a fee.
<FromGitter>
<kinxer> Yeah, IP is tricky. I certainly wouldn't want to say that all software (or books or journalism or poetry or word art...) should be totally free because it's composed of the symbols in our writing system(s) (alphabet or otherwise), which shouldn't be owned.
<FromGitter>
<kinxer> I know that's an extreme example, but my point is just that there's not a clear line between using words fairly and authentically infringing on intellectual property.
<FromGitter>
<kinxer> If people couldn't just lie about their intentions, it'd be easier. :P
<FromGitter>
<kinxer> Thanks for sharing, @tenebrousedge. I'll admit I've lost a lost of respect for Jefferson over the last few years as I've learned more about him, but he was undoubtedly an excellent writer and provoking thinker. His insistence on declarations of the rights of citizens in the nascent US (and his home state of Virginia, where I'm from) was, I think, one of his greatest contributions to the long-term health of the
<FromGitter>
... nation.
<FromGitter>
<randiaz95> Does anyone know a github repo with an example of basic session auth in crystal?
<FromGitter>
<randiaz95> I feel like my implementation has many copies of strings that are not good,.
Deuns has joined #crystal-lang
<Deuns>
hey!
<FromGitter>
<randiaz95> hi
<FromGitter>
<ImAHopelessDev_gitlab> hi
<FromGitter>
<j8r> @randiaz95 You are using cookies?
<FromGitter>
<j8r> I implemented one
<FromGitter>
<j8r> the cookie store a random ID
<FromGitter>
<j8r> the back-end has a Hash, with the ID as a key and sensitive info as value
<FromGitter>
<j8r> haa ok ⏎ ⏎ > Unlike other cookies, session cookies do not have an expiration date assigned to them, which is how the browser knows to treat them as session cookies.
<FromGitter>
<Blacksmoke16> eya
<FromGitter>
<Blacksmoke16> yea
<FromGitter>
<j8r> So, I can just not set a expiration date :)
<FromGitter>
<ImAHopelessDev_gitlab> In 2025. TCPServer.new will be accessed by NetworkManagementFactory::TCPServer
<FromGitter>
<ImAHopelessDev_gitlab> the end is nigh
<FromGitter>
<randiaz95> Have you guys heard of super cookies?
<FromGitter>
<randiaz95> all fang companies partnered with OS to hide data.
<FromGitter>
<randiaz95> kind of like localstorage/localforage
<FromGitter>
<ImAHopelessDev_gitlab> nope
<FromGitter>
<randiaz95> playing kanye west Amber song while writing scaffolds in amber is a special experience...
<FromGitter>
<ImAHopelessDev_gitlab> that it is
<FromGitter>
<randiaz95> Ambuuuurrr
<FromGitter>
<randiaz95> Ambiiirrr
<FromGitter>
<randiaz95> I wish I used ruby when I first started coding... Never knew these command line tools were so powerful
<FromGitter>
<randiaz95> WHY DO THEY TEACH JAVA?!?!?!
<FromGitter>
<randiaz95> in school!!
<FromGitter>
<Daniel-Worrall> because it's more employable
<FromGitter>
<j8r> I forgot, i think it was a Math method - how to have the difference between two numbers (negative or positive)
<FromGitter>
<randiaz95> lol... We teach Java because it is more employable, and we employ java because it's well taught.
<FromGitter>
<randiaz95> circle of life
<FromGitter>
<j8r> there is also PHP - we are saved!
<FromGitter>
<ImAHopelessDev_gitlab> i never coded java before
<FromGitter>
<randiaz95> 1) o
<FromGitter>
<tenebrousedge> Java is too ew for me to ever have touched it
<FromGitter>
<randiaz95> What turned me off was the three statically typed objects within themselves.
<FromGitter>
<randiaz95> it was like a russian doll of monstrosities
<FromGitter>
<ImAHopelessDev_gitlab> i saw a tutorial by thechernoproject on youtube, of him doing some user interface with java code, that's about it tho
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
<FromGitter>
<randiaz95> buffers should always I MEAN ALWAYS be a parameter of the function.. Not buffer objects or structs.
<FromGitter>
<randiaz95> Freaking sadists.
<FromGitter>
<j8r> @ImAHopelessDev_gitlab to be host, not sure it is a good idea to write the game in 2 languages
<FromGitter>
<j8r> I won't be able to share code
<FromGitter>
<ImAHopelessDev_gitlab> i always remember way back when i was younger, i hated installing java to run an app. i think that acted a deterrent throughout my life to not touch it
<FromGitter>
<kinxer> I don't particularly love Java, but I think it's unfair to dismiss it as terrible without having used it. I mean, it's fine.
<FromGitter>
<kinxer> Not really better than fine, but fine.
<FromGitter>
<randiaz95> I used it to write an interpreter for a simpler language
<FromGitter>
<randiaz95> it used tons of arrows
<FromGitter>
<randiaz95> for data flow and buffers
<FromGitter>
<kinxer> The simpler language did?
<FromGitter>
<randiaz95> Then i just used python cause life is easier over there.
<FromGitter>
<randiaz95> Yep took me 1 minute to create the gui and 1 year to make the interpreter lol
<FromGitter>
<randiaz95> Java/C# is useful for Desktop gui apps with their drag and drop functionalities.
<FromGitter>
<ImAHopelessDev_gitlab> i'm in m yhappy space now. gdscript and crystal. i don't think i'll ever find something more enjoyable to use
<FromGitter>
<stronny> java for desktop apps? oh hell no
<FromGitter>
<kinxer> I mean, Java is portable, right? Isn't that its main strength?
<FromGitter>
<randiaz95> Portable until you get to ios apps
<FromGitter>
<stronny> I work at a place that has a "portable" java desktop app
<FromGitter>
<randiaz95> dart is more portable than java
<FromGitter>
<stronny> I mean it works, but at what cost
<FromGitter>
<stronny> even unity is probably better
<FromGitter>
<randiaz95> Also, the reason why I got so good at python was because of the fast bootup time for small scripts and programs.
<FromGitter>
<randiaz95> i could trial and error. and also didnt feel like my computer was taking a crap
<FromGitter>
<kinxer> I think it probably has the best combination of portability and wide adoption (i.e. inertia and corporate support), with the possible exception of C#.
<FromGitter>
<ImAHopelessDev_gitlab> @j8r yeah
<FromGitter>
<kinxer> But I've not used C# personally, so I can't say much about that.
<FromGitter>
<stronny> where do I even start
<FromGitter>
<randiaz95> Sure, C# has better syntax
<FromGitter>
<randiaz95> and better package manager
<FromGitter>
<kinxer> Lol. I'll prepare myself to be educated.
<FromGitter>
<stronny> we package our own jdk with our app
<FromGitter>
<ImAHopelessDev_gitlab> i just started watching c# tutorials with winforms last night cause was bored and winforms give me that ui nostalgia
<FromGitter>
<ImAHopelessDev_gitlab> c# looks interesting to me
<FromGitter>
<stronny> it's by no means openjdk 11 mind you
<FromGitter>
<Afront> Welp at first glance, I thought you meant Godot is considering using Crystal over GDScript
<FromGitter>
<randiaz95> The premium libraries from microsoft are fire though..
<FromGitter>
<randiaz95> like emotion recognition from images within 2 lines of code.
<FromGitter>
<randiaz95> I might just rewrite my etl pipeline for work in crystal... Too damn slow.
<skrzyp>
Can I somehow embed other files during building a Crystal binary? Like, embedding ECR templates stored in other files
<FromGitter>
<randiaz95> Do you mean other crystal files or folders/text files?
<FromGitter>
<stronny> like "resources"?
<FromGitter>
<randiaz95> Just have resources created in a folder somewhre
<skrzyp>
yes, something like that
<FromGitter>
<stronny> I think forum has a topic
<FromGitter>
<randiaz95> like /Documents/appname/characters.sqlite
<FromGitter>
<randiaz95> for your mmorpg
<FromGitter>
<stronny> but I would advise against
<FromGitter>
<randiaz95> Shouldn't it go in Programs folder?
<FromGitter>
<randiaz95> for windows?
<skrzyp>
in this case it's just only for ECR templates for my tiny backend, so I could deploy it by single binary
<FromGitter>
<kinxer> @ImAHopelessDev_gitlab @j8r How would y'all feel about a project with the goal of creating GDNative bindings in Crystal? So you could write client game logic in Crystal?
<FromGitter>
<stronny> why do you avoid packaging?
<FromGitter>
<stronny> it's not that hard
<FromGitter>
<randiaz95> Just failed to linuxbrew install crystal-lang :'(
<FromGitter>
<randiaz95> Crystal is like an immature Naruto
<FromGitter>
<randiaz95> I want hokage Naruto already.
<FromGitter>
<kinxer> You have a way with unlikely metaphors, @randiaz95.
<skrzyp>
because I want it for my personal use for now, and in general I don't think I need a package for single binary which doesn't do anything within the system state
<FromGitter>
<Afront> I don't know... I found the syntax of Ruby (and I guess Crystal) to be very intuitive compared to a lot of languages
<oprypin>
why is there all this talk about 1.0 - i'm actually getting worried
<hightower2>
Hey folks, I just compared running String#index in a long file with the argument being both a string and regex. For some reason, the regex search is 5 times faster... what explanation for this am I missing?
<oprypin>
hightower2, well libpcre is pretty epic, i dont know.
<skrzyp>
oprypin: I quite don't know, it's just a number
<oprypin>
"ok we are officially boring now"
<skrzyp>
but I really don't know what's left on todolist to add into Crystal in terms of language specs, from what I read in the docs it has everything it need to have
<skrzyp>
maybe I'm missing something
<FromGitter>
<stronny> string search is pure crystal, regex is probably libpcre
<hightower2>
stronny: yes probably, but I was expecting that a literal comparison would always be faster
<oprypin>
also string literals go into read0only memory so i had to make a dynamic dup
<FromGitter>
<stronny> anyway, I'd just go with `LibC.strstr`
<oprypin>
what does that solve
<FromGitter>
<stronny> a quick substring search
<hightower2>
Yes no the need I have is to do a search within a limited region of the string, and also based on my tests for searching within strings up to 103 chars the substring search is faster, while for those longer regex search is faster.
<hightower2>
so I probably couldn't help myself with strstr for both of those reasons
<FromGitter>
<tenebrousedge> is performance pretty critical here?
<oprypin>
hightower2, well it's possible that strstr faster than both, im not sure how that refutes it
<oprypin>
i wouldnt use strstr for *other* reasons but whatever
<FromGitter>
<stronny> well you can easily have a start offset with strstr
<hightower2>
tenebrousedge yes, that's the point of the task. well, both performance of search itself as well as not unnecessarily using more memory just to contain subsets of other strings
<FromGitter>
<stronny> and ig you don't mind flipping bytes to/from \0 end offset as well
<hightower2>
oprypin, oh you think? I thought String#index with string argument boiled down to something like that in itself... but maybe... good suggestion, I'll do a comparison just to see
<hightower2>
ok... great, good ideas, thanks for the discussion as always
<FromGitter>
<stronny> anytime
<oprypin>
hightower2, u can flip a byte to 0 for strstr the same way that i showed but with `+3+n` instead of `+1` that i used
<oprypin>
(it could still be pointing to readonly memory though if it's from a string literal)
<FromGitter>
<stronny> or maybe to_slice
<oprypin>
yea. well same stuff
<FromGitter>
<stronny> yeah, subtle diffs
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
<hightower2>
docs say slice is read-only so would have to change the byte beforehand. Also maybe its description could be improved as it says "Returns the underlying bytes" with no indication if it's done with a pointer or copy
<FromGitter>
<stronny> look at the source =)
<oprypin>
hightower2, well no, i think "underlying" quite strongly implies no copy
<FromGitter>
<stronny> read-only is a problem if you modify through slice
<oprypin>
hightower2, but indeed look at the source code
<FromGitter>
<stronny> if you then use slice's pointer it's no longer r/o iiuc
<hightower2>
will do. The results I have now is that String#index(String) is faster up to original string of size 103 if regex object is already created. If Regex.new is called as part of every String#index(regex), then the break point is at around 550 chars
<oprypin>
aaaaaaaa why is github search so garbage
<FromGitter>
<naqvis> reason is simple, because their search service is not written in Crystal 😆
<oprypin>
hightower2, wait why does this have warmup and calculation set to 1, does it mean it does it only once/???
<hightower2>
no it's in seconds
<oprypin>
oh ok
<oprypin>
should be 1.seconfs
<oprypin>
really owrrisome for thatcrystal implenentation
<hightower2>
no luck with Char, it tells me... argument #1 of 'C#strstr' must be Pointer(..type that I put..), not String (nor Pointer(UInt8) returned by 'String#to_unsafe')
<hightower2>
Hey I see Time.parse() requires the format to be specified. Are there any methods or shards you know of which can autodetect the format?
<FromGitter>
<Blacksmoke16> are you not getting a standardized format?
<FromGitter>
<Blacksmoke16> parsing an arbitrary string into time is prob not trivial
<hightower2>
yes, I'm aware. But I think I recall Ruby having a method which figures out the format on its own to some extent.
<hightower2>
(but yes, I am getting dates in arbitrary format)
<FromGitter>
<Blacksmoke16> ouch
<FromGitter>
<Blacksmoke16> where are they coming from?
<hightower2>
web pages and such
<hightower2>
(the pinnacle of free-form input :)
<FromGitter>
<Blacksmoke16> rip
<FromGitter>
<straight-shoota> oprypin, I'm not sure you can view my response, I have hidden both our comments because they're resolved. I mean `C:\crystal`
<oprypin>
straight-shoota, yes i can view them and also by email notification. and yes, i think this is the perfect way to handle that interaction.
<oprypin>
reply, edit, then hide both
<oprypin>
also i suppose you're right. there's one big mention of it at the beginning that should apply to the rest. but it's *too* implicit
<FromGitter>
<straight-shoota> great :P
<FromGitter>
<straight-shoota> hightower2 ⏎ ⏎ > Are there any methods or shards you know of which can autodetect the format? ⏎ ⏎ Not that I'm aware of. Would be great to have, though. And I'd expect this can be implemented with a very high success rate. [https://gitter.im/crystal-lang/crystal?at=5e98eefae920022432ad5401]