<FromGitter>
<fridgerator> dang @oprypin you put a lot of work into this
<FromGitter>
<fridgerator> documentation is great
hightower4 has quit [Ping timeout: 255 seconds]
Disrecollection has quit [Ping timeout: 246 seconds]
<FromGitter>
<johnjansen> has anyone done a multi factor sort ⏎ ergo RUBY `a.sort { |a, b| [a['foo'], a['bar']] <=> [b['foo'], b['bar']] }`
<FromGitter>
<johnjansen> im trying to think this through, but nothing is happening up top right now ;-)
<FromGitter>
<johnjansen> all elements are the same type, but the sort factors are of different types
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
qard has joined #crystal-lang
qard has quit [Client Quit]
bjmllr has quit [K-Lined]
<FromGitter>
<bararchy> @fridgerator I've used glove and CrSFML , I got a better working examples using the 2nd , but I prefffer glove as its 100% Crystal
<oprypin>
fridgerator, I'm just curious what made you exclude my lib from your initial list of choices
<FromGitter>
<bararchy> oprypin , yeh ... Forgat about the shaders :/ it was hell to setup ... I guess doc wise and performance wise CrSFML is better , I also love the mainloop model and keyboard capture which is missing in glove
vifino has quit [Ping timeout: 246 seconds]
<FromGitter>
<codenoid> sup, is my mysql package from shards doesnt support `` IS NULL `` function in SQL Query ?
Philpax_ has joined #crystal-lang
Groogy has joined #crystal-lang
<Groogy>
Morning! ( ´_ゝ`)
<FromGitter>
<sdogruyol> Good morning @groogy
<Groogy>
What do people usually name their crystal projects after? Like in Ruby you want the word Ruby or start with the letter R
<FromGitter>
<sdogruyol> ummm, mostly like ending with .cr
<FromGitter>
<sdogruyol> @groogy thank you, please help us reach 10k :P
<FromGitter>
<martincsimpson> Hello all
<FromGitter>
<martincsimpson> I'm just wondering - has there been much activity with crystal and it's new year goals? There hasn't been a blog update in a fairly long time, and I'm super interested in the project.
martin____ has joined #crystal-lang
<Groogy>
I mean last blog entry was in march?
<FromGitter>
<martincsimpson> Yes, last one was in march.
<Groogy>
before that is february for version 0.21 and right now it is on version 0.23 I think?
<FromGitter>
<bararchy> Yeha , v0.23
<FromGitter>
<bararchy> But 0.23.1 is near
<FromGitter>
<martincsimpson> Yeah, so I saw the 0.21 update, I assumed there would be an update for 0.22 and 0.23 (naively) haha
<FromGitter>
<bararchy> There are changrlogs
<FromGitter>
<martincsimpson> I just wanted to check on the project and see how things are proceeding... we're hoping crystal can get to v1.0 as our entire team is interested in using it.
<Groogy>
yeah 0.23 tag on github was done 7 days ago
<Groogy>
it looks like
<FromGitter>
<martincsimpson> I'm going to check the change logs :) Thanks guys
<Groogy>
so yes it seems very much alive :)
bjmllr has joined #crystal-lang
<FromGitter>
<martincsimpson> I see support for CentOS has been dropped :(
<FromGitter>
<akzhan> @martincsimpson CentOS support should be returned by 0.23.1 I suppose
<FromGitter>
<martincsimpson> That's good enough
<FromGitter>
<martincsimpson> :)
<FromGitter>
<martincsimpson> Does anyone know the status of parallelism / concurrency?
<martin____>
@akzhan, we're currently using crystal in production with little to no problems at all.
<martin____>
We're just all counting on the multi-threading coming to fruition :)
<FromGitter>
<akzhan> @ martin____ you are crazy :)
<Groogy>
what kind of production?
<martin____>
We're serving over 12,000,000 hotel searches per day.... that kind of production
<FromGitter>
<sdogruyol> @martin__ wow, that's amazing!! Are you using Kemal by any chance?
<martin____>
We aren't, actually 90% of our infrastructure is written in ruby, including an in-house messaging queue
<martin____>
However, our team got extremely excited about the speed gains of Crystal whilst maintainig ruby-like syntax, so we rebuilt our message-queue in crystal
<Groogy>
oh speaking of ruby, is there a ruby-crystal binding library or something?
<FromGitter>
<bararchy> martin___> Nice ! (ps ... why this nick ? so hard to mention hahah)
<martin____>
^ it was auto chosen, let me switch vack to gitter
<FromGitter>
<martincsimpson> The code is pretty terrible, admittedly - but it functions perfectly for our needs
<FromGitter>
<martincsimpson> We're pushing ~5Gbit/second through it and it's not even breaking a sweat
<FromGitter>
<martincsimpson> Once v1 comes out we're going to start re-writing our stack, but crystalmq was a proof of concept for us to see if it'd suit our needs
<FromGitter>
<sdogruyol> @martin__ what're you using to server that hotel searchs?
<FromGitter>
<martincsimpson> Our stack consists of Sinatra (ruby) on the front end to turn HTTP requests into Event Messages
<FromGitter>
<martincsimpson> The event messages are sent through crystalmq to any number of waiting microservices (either java, ruby or crystalmq), which will in turn raise event messages back
<FromGitter>
<sdogruyol> if you're using Sinatra i think you can easily switch to Kemal http://kemalcr.com/
<FromGitter>
<martincsimpson> Yes, we're looking at moving to kemal in the long-term.
<FromGitter>
<sdogruyol> that's great to hear
<FromGitter>
<martincsimpson> But before we commit to that kind of investment, I wanted to make sure the project is still on track :D
<FromGitter>
<sdogruyol> feel free me to ping me :)
martin____ has quit [Ping timeout: 260 seconds]
<FromGitter>
<sdogruyol> you mean Kemal or Crystal
<FromGitter>
<martincsimpson> I will, thanks for that.
<FromGitter>
<martincsimpson> Both
<FromGitter>
<martincsimpson> I've investigated Kemal already, but failed to get it to run.
<FromGitter>
<sdogruyol> well Kemal is actively being developed for the last 2 years
<FromGitter>
<sdogruyol> it's still alive and kicking :metal:
<FromGitter>
<martincsimpson> I think I was using a mismatch of crystal / kemal versions to be honest
<FromGitter>
<martincsimpson> That's why we decided to wait until v1.0 is out - then hopefully the breaking changes will stop :)
<FromGitter>
<sdogruyol> i can help you with that for sure
<FromGitter>
<sdogruyol> :)
<FromGitter>
<martincsimpson> Alright, we'll reinvestigate it next sprint and I'll be in touch
<FromGitter>
<martincsimpson> You're here usually?
<FromGitter>
<martincsimpson> Oh one thing, does Kemal support websockets yet?
<FromGitter>
<sdogruyol> Ofc
<FromGitter>
<sdogruyol> It's been supported from the beginning
<FromGitter>
<martincsimpson> Looks good, I'll check it out
<FromGitter>
<martincsimpson> @sdogruyol holy crap that's some good throughput :)
<FromGitter>
<sdogruyol> Thanks
<FromGitter>
<martincsimpson> When we've benchmarked crystalmq we're seeing an average of 150,000-200,000 messages per second are processed. It's amazing
<FromGitter>
<sdogruyol> Awesome!
<FromGitter>
<martincsimpson> This is why we're so excited about crystal
<RX14>
@martincsimpson with how many producers/consumers?
<FromGitter>
<sdogruyol> Yeah Crystal is great at performance
<RX14>
i assume that's pretty IO bound and each message is sent to a lot of consumers
<FromGitter>
<martincsimpson> @RX14 this was with two producers / two consumers.
<RX14>
seems a bit low then
<FromGitter>
<martincsimpson> @RX14, you're completely correct. The more consumers there are the worse the performance becomes.
<FromGitter>
<martincsimpson> @RX14 we actually got limited by network bandwidth.
<RX14>
ah that makes sense then
<RX14>
if crystal can do 100k HTTP requests per second I would have guessed at 500k+
<FromGitter>
<martincsimpson> That being said, even with hundreds of consumers we're still not bottlenecked in production.
<FromGitter>
<martincsimpson> Plus, the code could use a severe rewrite, but we've just not got the bandwidth at the moment
<RX14>
yeah i can see that haha
<FromGitter>
<martincsimpson> One of the issues we faced with crystal was debugging - we're missing the tools from Ruby a lot such as pry
<FromGitter>
<sdogruyol> We got some great people here who can help you with performance issues / tricks @martincsimpson
<FromGitter>
<martincsimpson> Plus, Thread.abort_on_exception doesn't seem to play nicely.
<RX14>
yeah you do have to do puts debugging
<RX14>
you can sort of get away with gdb for simple code
<FromGitter>
<martincsimpson> @sdogruyol that'd be awesome, I'd like to get the project to a point where it's usable by everyone wtihout looking at the code going "WTf"
<RX14>
but it can't understand complex variables
<FromGitter>
<sdogruyol> Happy to help @martincsimpson :)
<FromGitter>
<martincsimpson> @RX14, yes puts debugging is where we're at unfortunately. We've been seeing some issues with sockets not being closed but it's been nigh-on impossible to debug when Threads are involved.
<FromGitter>
<molovo> Has anyone done a write up on basic performance tips/tricks for Crystal? I’d be interested in reading that
<Groogy>
also thanks again @RX14 for yesterday, as soon as I get really indepth knowledge of crystal I'll stop bothering you about questions :P
<FromGitter>
<akzhan> you may use llbm debugger, even in VSCode IDE
<RX14>
llvm debugger is actually worse than gdb currently
<RX14>
because it decided to treat all unknown DWARF languages as unusable
<RX14>
whereas gdb falls back to C
<RX14>
which means you can see some local vars using gdb but not lldb
<FromGitter>
<sdogruyol> i mean we got great people here
<FromGitter>
<sdogruyol> how about we all join forces and improve Crystal in every way
<FromGitter>
<sdogruyol> we already have people PRing to compiler also
<FromGitter>
<akzhan> Multithreading support issues arent not described well. It’s a half of work.
<RX14>
the design and implementation in the multithreading branch has been discussed internally at manas meaning everyone outside doesn't really know what's going on
<RX14>
that would be fine if there was progress
<RX14>
but there isn't and because the design hasn't been documented it's very difficult to continue work
<FromGitter>
<sdogruyol> i also think that it should be public as much as possible ofc
<FromGitter>
<sdogruyol> i'm aware that not everything is ready-to share state e.g
<Groogy>
also don't think multithreading is most important feature to finish
<Groogy>
it is good to attract people I guess but it's more important to get the "rough edges" done in my opinion
<Groogy>
like Windows support
<FromGitter>
<martincsimpson> For me, the only blocker to using crystal is multi-threading
<Groogy>
yeah but you are coming from an enterprise/server perspective right?
<FromGitter>
<martincsimpson> Once I have that, we're going to steam ahead and through our developers on it - hopefully for the betterment of the language as a whole
<RX14>
@martincsimpson what usecase?
<FromGitter>
<martincsimpson> Yes, you're right @FromIRC
<Groogy>
your consumer won't be buying directly your product
<FromGitter>
<martincsimpson> correct
<FromGitter>
<martincsimpson> @RX14, as i said earlier, we process around 12,000,000 searches a day (similar to booking.com)
<FromGitter>
<martincsimpson> This has a very heavy CPU load, and right now most of the services are single-threaded and in ruby.
<FromGitter>
<martincsimpson> Crystal is already a speed-gain for us, but adding on proper multithreading would really increase our efficiency
<RX14>
anything request-based and stateless can be scaled out without parallelism
<Groogy>
not saying multi-threading shouldn't be done, and I think even if let's say current work on supporting that dies. Someone will take that torch eventually
<FromGitter>
<martincsimpson> We're currently using java for all our multi-threading needs.
<FromGitter>
<martincsimpson> @RX14, you are correct - and we scale heavily with 1000's of instances
<FromGitter>
<martincsimpson> (this is why we use microservices - so we can scale individual services)
<FromGitter>
<martincsimpson> However, there's one part that we're struggling with - and that's the itemization component (turning a list of prices into a quote)
<FromGitter>
<martincsimpson> and we're using a java microservice for this, as the multi-threading gives us a massive advantage.
<RX14>
if you can scale out to multiple machines then you can already scale out to multiple cores
<Groogy>
I think what martin wants is to just unify as much as possible under crystal
<FromGitter>
<martincsimpson> @groogy is correct
<FromGitter>
<martincsimpson> However @RX14 what you are saying about scaling out to multiple cores is a half-truth
<FromGitter>
<martincsimpson> We can scale out our searches to the point where a single hotel search can take 1-2 seconds, 4 seconds at the worst case
<FromGitter>
<martincsimpson> And we can run those massively parallel - we process thousands per second... but they never really go under 1 second
<FromGitter>
<martincsimpson> Why? Because there is one component in the search flow that needs to be multi-threaded, and if we split that out into many parallel services it gets slowed down by network IO
<FromGitter>
<martincsimpson> So, our testing by using a java app instead of a ruby app shows that using multithreading we can reduce the time for a single search to around 300ms
<RX14>
i see, that amkes sense
<FromGitter>
<martincsimpson> It's been a long road I can tell you that ;)
<FromGitter>
<martincsimpson> that's why i even started looking for crystal.
<FromGitter>
<martincsimpson> Because i really dont like java :)
<FromGitter>
<bew> :+1:
<Groogy>
I am split about Java, their technology behind the virtual machine is pretty cool and it enables up a lot of awesome stuff like jruby
<Groogy>
but Java as a language, meeeeeeh....
hightower4 has quit [Ping timeout: 240 seconds]
<RX14>
i really don't fine java 8 that bad
<RX14>
it's not great and it's not exciting but it's a solid language to do things in
<Groogy>
oh it's been a solid language for long
<RX14>
it's got a great ecosystem and the tooling is fantastic
<Groogy>
but it's not like... Ruby where I fell in love
<Groogy>
etc.
<Groogy>
no passion :P
<Groogy>
every relationship needs some excitement
<FromGitter>
<martincsimpson> @groogy, you're exactly right
<FromGitter>
<martincsimpson> Java is a SOLID language, it's tooling, it's speed, it's absolutely great
<FromGitter>
<martincsimpson> but its not a joy to use, and the syntax hurts my eyes....
<FromGitter>
<martincsimpson> Thats why crystal was so attractive. It's like having a smart and hot girlfriend
<FromGitter>
<martincsimpson> hahaha
<Groogy>
but that smart and hot girlfriend is a bit socially awkward and needs to "grow up a little" ;D
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter>
<martincsimpson> Yes, exactly hahaha
<FromGitter>
<martincsimpson> She falls over things quite frequently
bjz has joined #crystal-lang
<Groogy>
so I guess C++ is then that teacher, a bit to the years but still looks pretty good, gotten some "upgrades"
<FromGitter>
<akzhan> @martincsimpson look at Kotlin. It’s great for JVM
<FromGitter>
<martincsimpson> Well, the good news is that's definitely on the cards
<FromGitter>
<martincsimpson> Justification is there - but we need parallelism
<FromGitter>
<sdogruyol> that's great to hear :)
<FromGitter>
<sdogruyol> yeah
<FromGitter>
<sdogruyol> you know what
<FromGitter>
<sdogruyol> i actually compiled Crystal with parallelism support @martincsimpson
<FromGitter>
<sdogruyol> it worked like a charm but the throughput wasn't that great
<FromGitter>
<bararchy> btw @sdogruyol are you bussnessly (how do i spell that ?!) connected to Crystal ?
<FromGitter>
<martincsimpson> Really? @sdogruyol why was that?
<FromGitter>
<sdogruyol> @bararchy nope, why did you ask that :P
<FromGitter>
<sdogruyol> @martincsimpson because it's an ongoing effort
<FromGitter>
<martincsimpson> Oh I see, well fingers crossed.
<FromGitter>
<akzhan> @sdogruyol can you write an issue to get current state, design and implementation of multi threading, detailed roadmap? ⏎ ⏎ It’s easy to develop with good roadmap.
<FromGitter>
<martincsimpson> If we're able to get parallism out the door, and stop the breaking changes I don't see why we cant contribute both time and money to further the cause :)
<FromGitter>
<sdogruyol> @akzhan there's actually a wiki page for that
<Groogy>
wondering if it's in a state for me to use it to process several agents at same time
<FromGitter>
<sdogruyol> well i think you can compile that branch with Crystal 0.21.0
<RX14>
why would being IO bound mean parallelism helps?
<FromGitter>
<martincsimpson> @sdogruyol I wonder if I can compile crystalmq with the multi-threaded branch, it is only handling message IO after all. What do you think?
<RX14>
surely if you're IO bound you spend your time waiting and have low CPU usage because you're waiting for IO
<FromGitter>
<sdogruyol> Gustavo is the lead on multi-thread support @ggiraldez
<FromGitter>
<martincsimpson> @RX14 - Network IO bound (if we implement a non-multithreaded solution)
<FromGitter>
<sdogruyol> @martincsimpson if it's 0.21.0 compatible, you can. But you need a custom version of libgc
<FromGitter>
<martincsimpson> @RX14 - CPU bound currently
<FromGitter>
<martincsimpson> @sdogruyol I saw, no problem with the custom version of libc. Would be great if i could get this to work though. I'll have a play around with it. Thanks for the info
<FromGitter>
<sdogruyol> @martincsimpson i'm sure you can compile :) You're welcome
<FromGitter>
<martincsimpson> That's interesting. Looks like we might be able to use it
<FromGitter>
<martincsimpson> well, if there's a plan for Couchbase would be good too - because we can migrate our stack immediately. But I'll check out CouchDB see if its something we can utilise
<Groogy>
Yay new computer parts today! Can reinstall Linux now and properly start playing around with Crystal instead of faking stuff through a X server on Windows
<hightower2>
sdogruyol: these days it's a common pattern that someone creates a basic web-oriented service, whatever the specific that service/feature is, and then they create a web portal for accessing/using it. Are you aware of some "stock" portal projects that support standard things like user database, OAuth login, profile/settings page etc., which can then quickly be modified/upgraded to provide a specific service?
<Groogy>
Martin are you also calculating for training time for your programmers though?
<Groogy>
that was my biggest problem in getting my programmers switching to Git was motivating the time needed to train people
<Groogy>
or well mine and mine, the companies programmers
<Groogy>
but they're like my children ;D
<FromGitter>
<martincsimpson> @groogy, we're allocating sprints to learn crystal, they're really excited about it. Their task is to build whatever the hell they want that will push the business forward.
splitty__ has joined #crystal-lang
<FromGitter>
<martincsimpson> Luckily, I'm the one that get's to make the IT decisions around here (being a small company rocks)
<FromGitter>
<martincsimpson> so as long as business needs are met its all good
<Groogy>
ah nice, we had the seniors at paradox go "Well it's like SVN innit?"
<FromGitter>
<martincsimpson> That's a paddlin'
<Groogy>
so I spent a lot of effort of setting stuff up so people could learn it properly
<Groogy>
though we are way more people than 30
<FromGitter>
<martincsimpson> Yeah, I mean 30 is the entire company - the IT team is just 10 of those 30
<FromGitter>
<martincsimpson> Right, I've got to run - home time.
<Groogy>
When I started our entire company was 30 people :P
<Groogy>
or well both companies, since we are split in two, development and publishing
<FromGitter>
<martincsimpson> ah makes sense
<Groogy>
cya!
<FromGitter>
<martincsimpson> we're about to split in two actually :)
<FromGitter>
<martincsimpson> anyone want a job in thailand? ahaha
<Groogy>
As a summer job?
<Groogy>
Favorite spot for Swedes during summer :P
<FromGitter>
<martincsimpson> No summer jobs here ;)
<FromGitter>
<martincsimpson> anyway, see you later
splitty___ has quit [Ping timeout: 240 seconds]
<Groogy>
ah dang
<Groogy>
cya
<FromGitter>
<sdogruyol> @martincsimpson full time Crystal :P? That sounds awesome
<FromGitter>
<sdogruyol> @Groogy cya
<FromGitter>
<sdogruyol> @hightower sorry, i'm not sure if i understand that
sz0 has joined #crystal-lang
<Groogy>
no I was saying bye to martin
<Groogy>
:P
<Groogy>
I'm still stuck at work
<FromGitter>
<sdogruyol> oh sorry :D
<FromGitter>
<sdogruyol> just remembered that you're a Swede, so there's still time to work :D
Philpax_ has quit [Ping timeout: 240 seconds]
<FromGitter>
<tarvit> @faustinoaq Thank you
Philpax has joined #crystal-lang
Philpax has quit [Ping timeout: 260 seconds]
Philpax has joined #crystal-lang
<jokke>
RX14: java tooling is fantastic? :D
<jokke>
yeah. gotta love ant! :D
<RX14>
ant is shit
<RX14>
but there's a lot of great tooling
<RX14>
not all of it is great
<Groogy>
ow yeah how is Cmake with crystal? Imagine not that good yet since there isn't really any ide/build system besides shard?
<RX14>
crystal shouldn't really need a build system in any way
<RX14>
only if you bundle extensions with your shard
<RX14>
in which case you use shard's post install hook to execute make/cmake/a script of your choice
<Groogy>
Well you have the whole "init" n stuff to setup a project structure to comply with what shards expect I guess?
<RX14>
shards at it's core only really created the lib folder
<RX14>
and crystal expects a lib folder in the cwd to look up shard requires
<Groogy>
How does your workflow look like? I do: write code -> 'shards build' -> 'bin/run_exe'
<RX14>
crystal spec expects a spec folder
<RX14>
shards build is configurable
<RX14>
the standard is src
<RX14>
and i expect everyone to use src
<RX14>
but it's the least enforced dir out of lib/spec/src
<RX14>
oh actually nvm
<RX14>
with the new require scheme you need to use src yes
<RX14>
actually with the old one too
<RX14>
never mind yeah you need to use src or shards won't work
<Groogy>
could you describe how your workflow is so I can get a sense of what other more experienced crystaline people do?
<RX14>
just crystal run myfile.cr
<RX14>
and I use entr to automate rebuilding on source changes
<Groogy>
and crystal just find dependencies by itself there?
<Groogy>
oh I just used shards build to be sure that it could find the correct paths
<RX14>
Groogy, shards places shards under lib/shard_name
<RX14>
crystal always includes lib under the require path
<RX14>
shards doesn't do any magic
<Groogy>
yeah but I require them not relatively but just like require "glfw"
<Groogy>
so crystal looks at ../lib always?
<RX14>
no just lib
<RX14>
you can't run the crystal compiler in a different directory to the project root
<Groogy>
oh right so since I am building from root directory it finds it even if it is crystal run src/main.cer
<RX14>
because thats the directory where the lib folder is placed
<Groogy>
.cr*
<RX14>
yes it's always relativce to your current directory
<RX14>
it's really simple
<jokke>
kiss :)
<Groogy>
ugh I am so used to super big projects with over engineerd Cmake configurations
<Groogy>
so I just assumed it can't be that convenient
<Groogy>
for some dumb reason
<jokke>
Groogy: well. crystal has a long way to go as well
<jokke>
no support for compiled libs for instance
<RX14>
that'll never happen jokke
<jokke>
RX14: you think?
<jokke>
that sucks
<RX14>
it's fundamentally impossible
<FromGitter>
<bew> what do you mean?
<jokke>
RX14: no it's not.
vifino has joined #crystal-lang
<RX14>
without changing the type system, it's impossible
<FromGitter>
<bew> nvm I get it
<Groogy>
Well it would need that you have an "extern" keyword which enforces you to specify the types
<jokke>
RX14: why? if you'd specify a sort of header file acompanying the compiled lib
<Groogy>
then it would work
<RX14>
sure but that's really ugly
<Groogy>
but think that goes against the spirit of what the devs want as well
<RX14>
it's much better to simply design an incremental compiler
<RX14>
and solve the problem in the compiler instead of pushing the problem to the devs
<jokke>
RX14: but it's necessary to be able to build projects of the size of firefox or similar
<Groogy>
but that means that eeeh.. .what is the word
<Groogy>
libraries you pay for
<Groogy>
becomes impossible to do
<RX14>
thats crystal's main attraction
<RX14>
a *really* smart compiler
<jokke>
that's true
<RX14>
Groogy, yup
<RX14>
closed-source crystal libs are impossible
<jokke>
i don't see why it shouldn't be possible
<FromGitter>
<bew> note sure it's good, but I like it
<jokke>
RX14: and not _quite_ true :D
<RX14>
you can bind to a propriatery C library
<jokke>
RX14: you can expose c functions from crystal code
<jokke>
:)
<RX14>
sure but then it's not a closed source crystal lib
<jokke>
which you can then bind to in your application
<RX14>
it's a closed source C lib
<RX14>
with open source crystal bindings
<RX14>
well maybe not open source
<RX14>
but visible source
<jokke>
yeah but what's wrong with visible bindings?
<RX14>
nothing
<RX14>
i'm just nitpicking and saying i'm technically correct ;)
<Groogy>
nah that works
<Groogy>
but it means you can't write it purely in Crystal
<jokke>
you could publish a closed source crystal library which exposes c functions for which you write an open source interface in crystal
<jokke>
sure it's a pain
<oprypin>
you can write a lib in Crystal and export some C ABI and provide Crystal bindings
<oprypin>
yay jokke was quicker
<jokke>
but i'm sure that it could even be automated
<RX14>
it's an absolutely massive pain
<oprypin>
it's mostly a joke yeah
<Groogy>
I mean you could potentially do it the good old COM way
<RX14>
it's impossible to use crystal types at the interface, only structs
<RX14>
no blocks
<Groogy>
and provide definitions that are all abstract
<jokke>
RX14: yeah
<RX14>
no unions
<Groogy>
and have a factory that fills them
<jokke>
it's a crippled lib
<Groogy>
that would kind of work right?
<jokke>
RX14: well.. you would have to put some work into the bindings
<hightower2>
When using YAML::PullParser, can I somehow "peek" into the upcoming content, or if value can be of different types I need to read it as string and then test that string for certain properties and convert to appropriate object?
<RX14>
Groogy, you mean binary patching?
<jokke>
so that it would feel "crystal-like" to use it
<RX14>
the crystal compiler needs all code available to compile binaries
<Groogy>
just empty abstract classes that define an interface and a creator creates the actual implemented object
<RX14>
you can't have an ImpCore without the compiler knowing about it
<Groogy>
yeah but InitFramework is a C exposed funciton
<Groogy>
like someone said before
<RX14>
but then it can only return C objects
<RX14>
and you're back where you started
<Groogy>
Oooooh
<FromGitter>
<bew> RX14 yes you can, I did it :p
<FromGitter>
<bew> (with a shared lib)
<Groogy>
Well the original COM model used Structs with callbacks
<RX14>
no unions no types no crystal
<Groogy>
so that would work
<jokke>
Groogy: you would have to put a lot of work to the bindings
<FromGitter>
<bew> yeah, the hard stuff is to generated the bindings
<jokke>
And it would probably be very much less performant since llvm can't optimize anything inbetween the app and the lib
<RX14>
and there would still be no inlining
<RX14>
and you have to invent your own stable ABI for crystal
<Groogy>
a lot of properitary libraries still do this in c++
<Groogy>
like Steamworks that I work with
<RX14>
every crystal class stores an ID
<Groogy>
So it wouldn't be that much different
<RX14>
these ids are assigned sequentially based on the order of requires
bjz has joined #crystal-lang
<Groogy>
most of the time, companies don't care about performance here and just cares about protecting their intellectual property
<RX14>
crystal's internal abi is SO dynamic it's essentially impossible to do easilly
<Groogy>
Yeah but then just do C structs that gets its members filled with callbacks back to Crystal code in the shared lib
<Groogy>
that would technically work wouldn't it?
<RX14>
still you can't pass crystal objects through the callback anythings
<Groogy>
you can as long as it comes from the shared library
<RX14>
there is no way to escape marshalling every data object to C
<RX14>
nope Groogy
bastelfreak has joined #crystal-lang
<RX14>
only primitives that exist in C
<RX14>
ints, pointers, structs
<RX14>
and not crystal structs, lib structs
fiete has joined #crystal-lang
<RX14>
what do people do with propriatery ruby libs?
<RX14>
you need to distribute ruby by source too
<RX14>
the problem can't be that important
<Groogy>
Nah it's possible, as long as the same data gets passed around and is wrapped properly. For instance so you have a Struct to represent the object in client code. That struct exists in the shared library as well, but it has a referenceis defined actually with the object type, while in the client code it is just a Void*
<jokke>
RX14: i don't see the closed/open source problem but that it makes _really_ large projects very tedious to build
<jokke>
since you will have to build everything
<Groogy>
and the callbacks refer back to code in the Crystal code where it will just translate into a call o nthat object
<Groogy>
and voila you can make a macro that populates this probably
<RX14>
jokke, yeah but that's what the incremental compiler would be for
<Groogy>
in Ruby they either write it in C or they scramble the source
<FromGitter>
<bew> Groogy that works, yes
<RX14>
Groogy, well the same obviously applies in crystal
<RX14>
it's no worse at least
<Groogy>
no but "these people doing it badly" doesn't mean that we should use that as an excuse :P
<Groogy>
but I think as it is right now, you can work around it
<Groogy>
as long as you can link against a Crystal lib
<jokke>
RX14: i see so that _is_ possible?
<jokke>
it tracks what source files are changed etc?
<RX14>
yes it would do an AST diff ideally
<jokke>
i see
<RX14>
parsing files into the AST really really doesn't take much time at all
<jokke>
rieally?
<jokke>
*really
<RX14>
like
<RX14>
10ms
<RX14>
lol
<jokke>
wow
<jokke>
ok
<jokke>
that's nothing
<RX14>
the values never sound right to me
<RX14>
but thats what --stats sayd
<Groogy>
but the AST being compiled into a lib would be enough
<Groogy>
I mean libs are just a collection of object files
<Groogy>
zipped together
<Groogy>
to put it bluntly
<RX14>
what do you mean?
<Groogy>
.a files are an archive of .o files
<jokke>
Groogy: you mean *.a files?
<jokke>
yeah
<Groogy>
yeah
<Groogy>
and object code is not finalized code
<RX14>
a lib comprised of a serialised AST would be pointless
<RX14>
if it takes 10ms to go from crystal source to the AST
<jokke>
Groogy: it's not that easy though. crystal ignores everything that isn't being used for example
<RX14>
and that the AST is so good that it can be turned back into crystal source using to_s
<RX14>
which is done every time you use {{}} in macros
<Groogy>
@jokke that's also why you have to do the extra lib declaration in Win compiler
<jokke>
mmh
<Groogy>
so it doesn't optimize away the stuff and generate proper symbols for them
<RX14>
there's very very little ebnefit to storing an AST instead of crystal source
<jokke>
RX14: except for making closed source libs possible :)
<jokke>
but
<RX14>
no
<jokke>
you're right
<Groogy>
well you can reverse engineer any binary
<RX14>
you could still serialise the source out so easilly
<jokke>
it's like "closed source java libs"
<Groogy>
if there is enough debug information you can pretty much get the original source
<Groogy>
but that extra step is usually "enough"
<RX14>
i guess jokke
<RX14>
yeah you're right
<RX14>
there would be a procyon which would take a crystal AST and obfuscate it
<Groogy>
like decompilers on C++ and C are so sophisticated nowdays
<jokke>
RX14: :D
<RX14>
oh procyon is a decompiler
<RX14>
i forgot the name of that one java obfuscator
<RX14>
darnit
<Groogy>
there is also one for Ruby I remember
<Groogy>
think there even exists for C/C++
<RX14>
but then
<RX14>
you could take the same obfuscator
<RX14>
and serialise the obfuscated source to crystal source files
<RX14>
and then you avoid the need for a stable binary AST format
<RX14>
which means it's again pointless
<Groogy>
oh right
<jokke>
:)
<Groogy>
the obfuscators for Ruby are the ones that make it into an exe
<RX14>
ah yes but thats for obfuscating applications
<RX14>
which is SUPER easy in crystal
<RX14>
just add --release
<Groogy>
yeah but that doesn't work for libs
<RX14>
but neither does your link :)
<Groogy>
no but just meant the one I was thinking of for Ruby
<Groogy>
wasn't really what we were talking about
<jokke>
RX14: i've noticed that --release sometimes (probably) optimizes too much, so that the app won't run correctly
<Groogy>
I said "oh right" as in "ah crap"
<RX14>
jokke, well then it's a bug
<jokke>
same code works without --release
<jokke>
yeah
<RX14>
have you reported it?
<jokke>
but it reminds me of gcc -O3
<jokke>
:D
<Groogy>
do you have a minimal example?
<jokke>
no
<jokke>
and no
<RX14>
it doesn't optimise too much
<RX14>
the problem is that the IR is wrong
<RX14>
lol
<Groogy>
I do remember an optimization bug which caused a constructor to completly break in Microsoft C++ V100 that just trashed the entire command list
<Groogy>
that was a bitch to track down
<RX14>
well at least i'd assume it's a crystal bug not a llvm bug
<Groogy>
oh hey RX14, the TypeLiteral in a macro, that I put into a const array, does that after the macro run turn into the actual type I put in there?
<Groogy>
i.e is it useful data after that point or is it just... "sometihng"?
<Groogy>
i.e what happens to the AST data in the macro that I put into the array after that part of the compilation is done
<RX14>
it expands i guess
<Groogy>
so it would be WRAPPED_METHODS.first[0] # => the class that I got from @type
<Groogy>
?
<Groogy>
or no idea
<FromGitter>
<straight-shoota> yes, it should
<Groogy>
ah if I try to access the constant then I get "Error in line 1: can't use underscore as generic type argument"
<Groogy>
and as far as I know I have to use underscore to get the correct type for the tuple/array
TheGillies has quit [Ping timeout: 255 seconds]
krigare[m] has quit [Ping timeout: 246 seconds]
sija[m] has quit [Ping timeout: 240 seconds]
werthen[m] has quit [Ping timeout: 246 seconds]
braidn[m] has quit [Ping timeout: 246 seconds]
vegai has quit [Ping timeout: 255 seconds]
Lex[m] has quit [Ping timeout: 264 seconds]
thelonelyghost has quit [Ping timeout: 255 seconds]
davidbe[m] has quit [Ping timeout: 276 seconds]
MatrixTraveler[m has quit [Ping timeout: 276 seconds]
<FromGitter>
<straight-shoota> you can use underscore only when the constant is used by macros only. when it is also accessed at runtime you need to specify a concrete type
<Groogy>
and what type would that be so that it works both in runtime and macro when I provide it with a TypeLiteral?
<Groogy>
since Class seems to be forbidden to use as a generic argument
<FromGitter>
<straight-shoota> ah, right :/
<Groogy>
don't really need it, just want to learn more
<Groogy>
want to know every single in and out of the language
<Groogy>
every single quirk ;D
<FromGitter>
<straight-shoota> yeah
<FromGitter>
<straight-shoota> I don't think it is currently possible
<FromGitter>
<straight-shoota> You can use a specific class as type (like `CLASSES = [] of Foo.class`) but there of course is little value in that :D
jamesho287 has joined #crystal-lang
<Groogy>
yeah, only reason I would use that for my contracts would be for debug information
<Groogy>
like recording what class/function broke a contract etc
<Groogy>
"toggle off the exception throwing but it still records broken contracts" kind of thing
<FromGitter>
<straight-shoota> ok, so this would also work if you just save the class names as string
<Groogy>
Yeah will probably figure out something
<Groogy>
one array for macro info and one for simply runtime info
jamesho287 has quit [Client Quit]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
_whitelogger has joined #crystal-lang
MatrixTraveler[m has joined #crystal-lang
Philpax has quit [Ping timeout: 276 seconds]
MatrixTraveler[m has quit [Remote host closed the connection]
MatrixTraveler[m has joined #crystal-lang
<FromGitter>
<straight-shoota> In Kemal is there a way to make path `/*` also match `/`? @sdogruyol
<FromGitter>
<sdogruyol> nice question
<FromGitter>
<sdogruyol> /** should match all routes including / but i'm not sure need to try first :)
<crystal-gh>
[crystal] ysbaddaden opened pull request #4669: OpenSSL: use proper factories over direct allocation (master...cleanup-openssl-ssl-context-initializers) https://git.io/vQgsJ
<FromGitter>
<crisward> @sdogruyol it doesn't.
<FromGitter>
<crisward> Radix doesn't work like that, though I wish it did
<FromGitter>
<renich> @hugoabonizio hey man, I am using scheduler. Bu, the main example, doesn't seem to work. https://play.crystal-lang.org/#/r/2aw1. Also, if I remove the exception handler, nothing happens. It just runs through it.
<FromGitter>
<hugoabonizio> Error output ⏎ ⏎ /home/carcin/carcin/sandboxes/crystal/sandboxed_crystal0.22.0: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory
<FromGitter>
<straight-shoota> @jhass around?
mark_66 has quit [Remote host closed the connection]
<FromGitter>
<renich> How can I retry within a begin/rescue statement?
<FromGitter>
<renich> is there a retry keyword?
<FromGitter>
<renich> btw, if you want to have a convenient google-chrome search for the Crystal docs, just add a custom search engines (right click bar > Edit search engines) and use this as URL: https://www.google.com/#q=site:https://crystal-lang.org/docs/ %s
<FromGitter>
<renich> I use crdoc as keyword, so I can type: crdoc<tab>some search term
<FromGitter>
<straight-shoota> for the search url you could also take `https://crystal-lang.org/api/latest/%s.html` which brings you directly to the doc page. ⏎ But it's not really a search, so you need to type the type name exactly.
<FromGitter>
<straight-shoota> yes, my suggestion does not include Google search, but takes you directly to the doc page instead
<FromGitter>
<renich> hmm... it doesn't work well with latest... it worked fine with 0.23.0... odd
<FromGitter>
<straight-shoota> depends on preference or what you require more, fast access to type docs where you know the name, or a fuzzy search in all the docs
<FromGitter>
<renich> Well, maybe you're more familiar with the docs and the API. In my case, I still struggle to find File.write examples :D
<FromGitter>
<hugoabonizio> I miss retry keyword too :pensive:
<FromGitter>
<renich> @straight-shoota back to the retry thing... It is an RFC but not implemented yet, right?
<FromGitter>
<straight-shoota> yeah, Google does not index paths in `/api/latest/*` because they're just redirects to the path where `latest` is replaces with the actual latest version
<FromGitter>
<straight-shoota> So for the search, you need to skip the `/latest` and if you only want results from the latest version, replace it with `0.23` - you'll need to update this on subsequent releases
<FromGitter>
<straight-shoota> correct, it is not implemented in the stdlib. But you can just copy the `retry` method from @lbguilherme's post to your codebase
AckZ has left #crystal-lang [#crystal-lang]
<FromGitter>
<bararchy> How can I turn Array(Char) into a String ?
<oprypin>
bararchy, .join
<FromGitter>
<straight-shoota> wouldn't there be a more efficient way?
<FromGitter>
<bararchy> .join is quite nice :)
<oprypin>
straight-shoota, probably not. each char is a variable number of bytes. this operation has to be expensive
<DeBot>
oprypin: /home/carcin/carcin/sandboxes/crystal/sandboxed_crystal0.22.0: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory - https://carc.in/#/r/2axg
<oprypin>
right
<FromGitter>
<sdogruyol> lol
<FromGitter>
<bararchy> XD
<FromGitter>
<sdogruyol> however join seems a bit slow
<oprypin>
the result of that is "OW"
<FromGitter>
<sdogruyol> 1) 65 microseconds per join
<FromGitter>
<straight-shoota> yeah, this should only work with 8-bit characters
<FromGitter>
<straight-shoota> @sdogruyol the absolute speed is very slow because of the VM where I am running the benchmarks
<FromGitter>
<straight-shoota> Dunno why. If you try on your machine, it's probably gonna be much faster
<FromGitter>
<azzuwan> I'm really honestly want to know how you guys able to get involved in this like almost all the time. I barely have the time after work at the office. I am a bit jealous to be honest.
<FromGitter>
<raydf> Hello everyone
<FromGitter>
<raydf> How can i convert Array(JSON::Type) to Array(String)?
<oprypin>
raydf, `that.map &.as(String)
<FromGitter>
<raydf> @oprypin thanks
<FromGitter>
<sdogruyol> @azzuwan it's all about being efficient i guess :P
<FromGitter>
<sdogruyol> i'm working in a super busy startup + just got married
<FromGitter>
<sdogruyol> yet somehow i figure out how to dedicate some time to Crystal :)
<FromGitter>
<schoening> Pardon my ignorance but what happens if I set a property of a class to be a struct? Will that struct live in memory while the rest of the class lives on the heap?
<oprypin>
schoening, think of it like this. by default data is stored contiguously with whatever other data is in the type. value types (e.g. structs) start off in the stack. a reference type (e.g. class) is always a pointer to the heap.
<oprypin>
if a struct is inside a class, it means the class is a pointer to the heap, and the struct is stored in the heap contiguously with other data of the class
<FromGitter>
<schoening> I think I get it. Because it got allocated the way it did its part of the heap memory because it's just part of the object? It gets malloc'ed like a struct in c would
<FromGitter>
<schoening> @oprypin
<oprypin>
i'm not sure
<oprypin>
structs are stored "right here" and classes only store the pointer "right here", their data is always on the heap
<oprypin>
"right here" is the stack by default
<oprypin>
but once you've made the jump to the heap there's no going back to the stack
<FromGitter>
<schoening> Ok. That "right here" explaination helped :p . If it wasnt obvious enough I have never had the option of stack and heap before :D
<FromGitter>
<schoening> Thank you very much for the help
<oprypin>
by the way malloc means get a pointer to newly allocated memory on the heap
<FromGitter>
<schoening> gotcha
bjz has joined #crystal-lang
<crystal-gh>
[crystal] chastell opened pull request #4674: Implement HTML.escape(string) in terms of HTML.escape(string, io) (master...io-based_HTML.escape) https://git.io/vQgHz
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter>
<delef> Hi, help me with a union types, please. ⏎ ⏎ I have Hash(MapValue, MapValue)? ⏎ MapValue is alias: ⏎ alias MapValue = Nil | Bool | UInt16 | Int32 | UInt32 | Float32 | Float64 | String | Hash(MapValue, MapValue) | Array(MapValue) ... [https://gitter.im/crystal-lang/crystal?at=595c10dfbf7e6af22ca48fc1]
<oprypin>
delef, hashtables should not store arbitrary data types. you will always get this kind of pain if you abuse them.
<oprypin>
so you need to either deal with type casting pain or implement something like JSON.mapping
<FromGitter>
<straight-shoota> for starters, you could alias the map type for example `alias MapType = Hash(MapValue, MapValue)` and use `MapType` (or whatever) instead of `Hash(MapValue, MapValue)`
<oprypin>
i think it's totally fine.
<oprypin>
delef, what's the problem you're getting with that code? looks great!
<oprypin>
you must do the type casts as you're doing now, there is no other way
<oprypin>
you're basically running into the same problems as https://crystal-lang.org/api/latest/JSON.html - please carefully study all the options it provides, you need to pick one of them
<oprypin>
they are: using type casts everywhere, or implementing JSON::Any, or implementing JSON.mapping
<oprypin>
delef, you are getting runtime values and the compiler has absolutely no way of telling whether the thing you're calling right now is a Hash or an Int or anything else, you can't call [] on it, that's it :(
<FromGitter>
<johnjansen> seems like jumping right to YAML builder is a bit of a stretch, unless you really need to
bjz has joined #crystal-lang
<FromGitter>
<renich> Ah, it didn't work. One of the members is JSON::Any
<FromGitter>
<renich> @straight-shoota paying the price of inexperience and urgency... :S
<FromGitter>
<renich> After this, I am gonna dive into it, I swear
<FromGitter>
<renich> works now. Just added .to_s in the JSON::Any assignment
<oprypin>
renich, you should call .as_* on JSON::Any
<FromGitter>
<renich> changed it to .as_s
<oprypin>
to_s is hacky
<oprypin>
:)
<FromGitter>
<renich> I am learning ;)
<FromGitter>
<renich> Thanks oprypin
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<hightower4>
When using YAML::PullParser, can I somehow "peek" into the upcoming content, or if value can be of different types I need to read it as string and then test that string for certain properties and convert to appropriate object?
<oprypin>
btw never used pull parser and there are no docs, im just looking at source and guessing
bjz has joined #crystal-lang
<hightower4>
oprypin, oh right, I was looking at Json's pullparser and expected that yaml had the same methods
<hightower4>
Ok, that simplifies my task, thanks
<hightower4>
so funny how devs have chosen "kind" instead of "type" or other more appropriate/less ambiguous word
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<hightower4>
Ok great, have it working, thanks
<hightower4>
I would like the app to have a configurable database store (e.g. files, Pg, etc.). The choice is set in the config file. Where do I see examples of this modular/plugin architecture?
<oprypin>
hightower4, don't know anything close to it