<BlaXpirit>
stereosteve, sure. but you're normally not supposed to concurrently access the same data structure
<Yxhuvud>
I imagine people will build threadsafe versions of certain classes.
<FromGitter>
<stereosteve> yeah makes sense… it comes up when there's an http server, like the TimeCache example
xmonader has quit [Ping timeout: 260 seconds]
<BlaXpirit>
ok what the hell.. i'm running my program, it takes 0m13.580s, then I remove an expensive and frequent print to screen operation and then it takes 0m14.578s
<BlaXpirit>
so has anyone tried threaded crystal on linux? i'm having trouble compiling
<BlaXpirit>
ah of course, so you need a custom libgc
<BlaXpirit>
that's annoying :/
<Yxhuvud>
they are using a new one or what?
<BlaXpirit>
Yxhuvud, as i understand it, libgc has a compiletime flag for thread support and distros don't set it
<FromGitter>
<eliasjpr> @codenoid just need to create an class that includes HTTP::Handler and then do your CORS checks. If you look through the crystal frameworks there are some implementations that have this https://crystal-lang.org/api/0.21.1/HTTP/Handler.html
<BlaXpirit>
in Python world we do it like `n.setdefault(value, []).append(key)`
<FromGitter>
<KCreate> The `||=` operator always confuses the hell out of me
<FromGitter>
<fridgerator> its great, one of my fav features of ruby / crystal
<BlaXpirit>
yeah now that i think about it, im not sure how this even works
<FromGitter>
<KCreate> I always explain it to myself like this: if the left side is truthy, do nothing, else set left to the right side
<BlaXpirit>
thats good
<Yxhuvud>
that paste would be easier to read if the ||= line part was split out to its own line
_whitelogger has joined #crystal-lang
<BlaXpirit>
yeah but the ||= thing still remains a mystery
<BlaXpirit>
cuz logically it's supposed to expand to `n[value] || (n[value] = [] of String)` but apparently it expands to `n[value]? || (n[value] = [] of String)` or something like that
<FromGitter>
<KCreate> doesn't `a ||= b` expand to `a = a || b`
<FromGitter>
<KCreate> same as `+=` or `*=`
<FromGitter>
<bew> no, it's as BlaXpirit described
<Yxhuvud>
kcreate: well. in the case of []= or method= then it won't as it would evaluate the LHS twice.
<Yxhuvud>
and the LHS could have side effects
<FromGitter>
<KCreate> I remember a commit by @asterite which fixed that exact problem
<FromGitter>
<KCreate> or some else i don't remember
<FromGitter>
<KCreate> it would put the left side into a temporary variable and thus only evaluate once
<FromGitter>
<KCreate> also, you can't use macro arguments as regular arguments. These arguments contain AST nodes. If you want to "paste" them you should use `{{ valve }}` as you did with `{{ pipe }}`
<FromGitter>
<eliasjpr> @bew thank you! I wont abuse it
<FromGitter>
<eliasjpr> :)
<FromGitter>
<KCreate> Is it not possible for `plug` and `pipeline` to be normal methods?
<FromGitter>
<KCreate> `block` will pass it as a proc (regular argument), `&block` will try it as a block (available to yield)
<FromGitter>
<eliasjpr> yes this is better more modular, I've been having too much fun with macros
<FromGitter>
<bew> very nice, I'm not used to inline things like that ( *always sth to learn* )
<FromGitter>
<eliasjpr> I would have created this inline method calls in ruby fairly easy, maybe as design guidelines we should state when to use macros
<FromGitter>
<bew> @eliasjpr did you see the video from Ary on macros, and how/when to use them?
<FromGitter>
<bew> yeah I like to ask before sending the link because it juste paste the player in gitter, and when you're in fullscreen, it just takes the all screen :stuck_out_tongue:
<FromGitter>
<KCreate> lol
<FromGitter>
<KCreate> yea that's way too big
<FromGitter>
<KCreate> i always have it minimized in the corner somewhere
<FromGitter>
<KCreate> sry bout that
<Papierkorb>
I wish the gitterbot would turn stuff like `: stuck_out_tongue:` into something actually readable, like :P
<FromGitter>
<KCreate> isn't the gitterbot also written in crystal?
<FromGitter>
<bew> no, gitter is an independant thing
<FromGitter>
<bew> it not only exist for crystal
<FromGitter>
<KCreate> i know
<FromGitter>
<KCreate> i meant the bot
zipR4ND has quit [Ping timeout: 240 seconds]
<FromGitter>
<KCreate> which channels all the messages from irc to gitter and back
<FromGitter>
<bew> same thing, but yeah it could be cool to have a custom gitter/irc bot in crystal
<FromGitter>
<bew> if I write `{% puts "hello" %}` it prints `"hello"` (with the quotes) do you know how to get ride of the quotes without boilerplates ?
<FromGitter>
<bew> I know that `{% puts "hello".id %}` but I find it kinda ugly to have to put id everytime..
<FromGitter>
<Sija> that’s how it is
<FromGitter>
<Sija> u can define the var with `id` if u use it moar than once, like `{% var = “hello”.id %}` and then l8r on `{{ var }}`
<FromGitter>
<bew> hmm I can understand the "how it is", because it allows to distinguish between compile-time puts and run-time puts, but... yeah ok, it's how it is
<FromGitter>
<bew> thanks @Sija
<FromGitter>
<Sija> yw
<FromGitter>
<Sija> btw, `id` distinguishes between `StringLiteral` and `MacroId` inside macro code
<FromGitter>
<Sija> `puts` have nuffin’ to do with it, even tho’ there r two of ‘em: top-level method and macro
<FromGitter>
<bew> yeah I just understood that variable assignation in macro system assign ast nodes, like when passing args to a macro, I understand know :)
<FromGitter>
<Sija> that’s the thing, over & out ;)
<FromGitter>
<bew> yeah I know the diff btw puts and `{% puts %}`
<FromGitter>
<bew> nice ty!
tzekid has quit [Quit: tzekid]
<cerulean>
woohoo, i'm compiling crystal with crystal on OS X !!!!
<cerulean>
if im smart enough and can help with any PRs, i will. dont expect nothin
<cerulean>
i DO know ruby and C
<cerulean>
;)
<FromGitter>
<codingphasedotcom> for those that want to a look at the ROCKY Stack
<FromGitter>
<sdogruyol> it's a great paper from tony hoare and you should read it :P
<cerulean>
OK I will
<cerulean>
:)
<cerulean>
give me some time
<cerulean>
im a busy dude with my own business (on ruby)
<FromGitter>
<sdogruyol> hehe it's ok :D
<cerulean>
i discovered crystal-lang
<cerulean>
just last night
<FromGitter>
<sdogruyol> i'm a rubyist too
<cerulean>
a friend told me
<cerulean>
nice
<FromGitter>
<sdogruyol> that's great
<cerulean>
ruby gave birth to many languages that MATTER and i view crystal as one
<FromGitter>
<sdogruyol> we need more people getting into crystal
<cerulean>
:D you have a good ally in me
<RX14>
just to add some more perspective, for IO bound workloads, it's faster to implement evented IO on top of fibers than just use OS threads, which is why we have one before the other
<cerulean>
crystal/ruby for life !!
<cerulean>
i fixed RX14
<FromGitter>
<sdogruyol> :)
<cerulean>
i use nginx and event machine in my site/bot
<cerulean>
im no stranger to it ;)
<cerulean>
apache cant even do websockets lmao
<FromGitter>
<sdogruyol> then you'll love `spawn`
<cerulean>
threads are a relic from the time asynchronous wasn't as good. but i think maybe a thread pool wouldn't be a bad idea. just not 1,000 threads at once
<FromGitter>
<sdogruyol> crystal has event driven stuff built-into
<cerulean>
what does 'spawn' do? i saw it on the site
<RX14>
well thats what we're working on
<FromGitter>
<sdogruyol> pretty simple
<cerulean>
yeah I figure. I could tell because of the channels stuff
<RX14>
crystal will just schedule fibers across a thread pool
<cerulean>
yeah thats what event machine does basically
<FromGitter>
<sdogruyol> yeah
<cerulean>
EM.defer { } isnt that basically a fiber? it happens in another thread after main or something
<RX14>
I really think that evented IO should be built into the stdlib though
<cerulean>
so your blocking code hangs in a thread properly
<cerulean>
i think that should be in crystal probably
<cerulean>
are you doing that?
<RX14>
the problem with evented io in ruby and python is library support is very hard
<cerulean>
to create ? or use? or both
<FromGitter>
<sdogruyol> both
<cerulean>
i can use EM just fine ... i use it in my IRC bot. it runs a multithreaded IRC connection, Live Twitter Feed API and HTTP server.. i needed help to figure out the syntax. i dont think EM is that complicated. this WOULD be faster in crystal
<cerulean>
i know it's got it's drawbacks but i'm happy with the concurrency you can get. but the more complicated and bigger in memory it gets, the slower it gets
<FromGitter>
<sdogruyol> this FromIrc bot is written in Crystal btw :P
<cerulean>
has anyone done a ruby->crystal translator?
<cerulean>
yeah i noticed the bot is very fast
<cerulean>
I can come to gitter at any time. I'm @jsilvermdx on github if you wanna look me up
<cerulean>
the bot is well done. ive had the idea of this kinda bridge but never did it. i forget it's even a bot. i look at your bolded names
<FromGitter>
<sdogruyol> that's cool
<cerulean>
is the IRC and Gitter components in the same .cs program?
<cerulean>
.cr ?
<FromGitter>
<sdogruyol> i think so
<RX14>
yeah it's 1 process
<cerulean>
incredible
<cerulean>
crystal is already insanely good at 0.20
<cerulean>
;D
<RX14>
well
<cerulean>
i have a versioning system i can apply to your repo and tell you your "true version"
<RX14>
evented IO wasn't *that* hard to be honest
<cerulean>
also i'm tripping. i could have sworn RX14 you were in Gitter
<RX14>
for the amount of gain you get it was relatively trivial
<RX14>
i'm on both, I use IRC 99% of the time though
<cerulean>
yeah but nobody else has what crystal has. i dont care about evented blahblah. every language has that. but i love the real mission of crystal: ruby syntax, C speed
<cerulean>
i've never had a good way to compile my ruby scripts. then crystal showed up im so happy
<cerulean>
may the god bless Manas
<cerulean>
i'm an LLVM fan as well. i wouldn't use it with no LLVM
<RX14>
honestly the evented IO and static typing is what draws me to crystal
<FromGitter>
<sdogruyol> @cerulean yeah that's what got me into crystal
<RX14>
if it wasn't compiled or was a JVM language... eh I would still use it
<RX14>
it's better this way though
<FromGitter>
<sdogruyol> it's the best of both worlds
<cerulean>
yeah
<cerulean>
well combine all of those and its hard to beat
<cerulean>
i like the idea of dynamic-style static typing too
<cerulean>
Int Cerulean String Cerulean;; Hash Cerulean{arg1, arg2};; /#/ (comment) hey guys use cerulean-lang
<FromGitter>
<sdogruyol> yeah, type inference really saves you a lot of time
<cerulean>
that was my main draw to ruby and other things
<cerulean>
ruby just has really great features, a cut above the rest
<cerulean>
the languages above it aren't better, they're just more popular for different reasons like older, more corporate support, exists in all browsers, etc
<RX14>
type inference + union types are really the only thing i've ever experienced which gets you close to duck typing but in a statically typed language
<cerulean>
without getting into x vs x
<cerulean>
RX14: yeah ive never seen it anywhere else
<RX14>
the thing I like most aboput ruby is the way it was designed to be read by humans not machines
<FromGitter>
<sdogruyol> yeah i forgot union types
<FromGitter>
<sdogruyol> i really like union types and they enlightened me about better type systems
<cerulean>
it gets past the idea that "Boolean" can't be set to "Nil" because "Nil" is a type, so that's good
<cerulean>
beyond that, idk
<cerulean>
im new
<cerulean>
haha
<RX14>
Union types are really the "new" thing in crystal
<cerulean>
ruby can still be hard for some programmers because it's very complex in other ways
<FromGitter>
<sdogruyol> i love it and also alias <3
<cerulean>
capturing the soul of it without implementing EVERYthing was a good design decision
<RX14>
everything else in crystal has been "done before" in some language or another I think
<cerulean>
has anyone made a program to scan ruby code and help convert it to crystal?
<RX14>
i don't think so
<cerulean>
i think i might try it after i finish working on my projects and get money
<cerulean>
im not thinking auto-convert
<cerulean>
im thinking, rubo-cop style, i tell you what in your code won't work for Crystal
<cerulean>
ruby can parse ruby. parse it, walk it. look for unsupported stuff. output warning or fix.
<cerulean>
well that's good
<cerulean>
cause im never touching ruby C api
<cerulean>
;)
<cerulean>
Hokkiado can be modified for Crystal
<cerulean>
when i figure out the exact feature reduction
<FromGitter>
<sdogruyol> cool
<FromGitter>
<eliasjpr> @sdogruyol hey hello Eli here. Curious to know if the 60k kemal benchmarks was using multiple processes?
<FromGitter>
<sdogruyol> nope that was single process
<FromGitter>
<eliasjpr> Mmm... interesting the only way I can get camel to perform over 24k on my machine is if I turn off logging it otherwise I don't get close to your benchmark i know it can definitely be my Dev machine specs
<FromGitter>
<eliasjpr> But that's impressive.
<FromGitter>
<sdogruyol> it's Kemal :P
<FromGitter>
<sdogruyol> for now it's really CPU dependent as there's no multi-threading yet
<FromGitter>
<sdogruyol> and that benchmark was for websockets
<FromGitter>
<sdogruyol> you need to tweak a lot os specific stuff
<FromGitter>
<eliasjpr> ok good to know, I was wondering if I was delusional or something
<FromGitter>
<eliasjpr> :)
<FromGitter>
<sdogruyol> benchmarking is hard
<RX14>
I get about 110k HTTP requests per second per core on my desktop
<FromGitter>
<sdogruyol> yeah if you have a high ghz cpu-core
<RX14>
so once we get multithreading that should be way better for an average 4 core server
<FromGitter>
<eliasjpr> any comparisons against phoenix?
<FromGitter>
<eliasjpr> :)
<RX14>
i'm not sure how phoenix performs
<RX14>
but I would guess that it's slower on a single core but would scale better
<FromGitter>
<eliasjpr> Slower because is not multithreaded at the moment correct?
<RX14>
we'll see
<RX14>
erlang has had many many years to tun it's performance
<FromGitter>
<sdogruyol> @eliasjpr it's pretty much close
<RX14>
@eliasjpr I got 500,000 HTTP requests per second on 7 crystal processes once so you can scale up to multiple cores on crystal just as easilly as nodejs
<RX14>
ofc that will improve to be even better than node
<RX14>
once we have the new multithread support
<FromGitter>
<eliasjpr> 😍
<FromGitter>
<eliasjpr> That's awesome
<BlaXpirit>
RX14, have u ever tried the multithread branch? do u know how to compile eit?
<FromGitter>
<eliasjpr> You guys are doing a fenomenal job with crystal. I can see so many rubyists flooding over to crystal. I was reading the roadmap and it is planned to have a version 1 real ease by the end of the year. How is that looking? Still on target?
<RX14>
no I havent BlaXpirit
<RX14>
I doubt we'll have v1 by the end of the year, I think it's an unrealistic target. But I'd love to be proven wrong.
<RX14>
I'd say maybe 50/50 right now.
<FromGitter>
<eliasjpr> where you guys need help?
<RX14>
V1 will be released when it's ready
<RX14>
@eliasjpr most importantly we need to land parallelism *soon* so that we have loads of time to test it in production.
<FromGitter>
<eliasjpr> well if there is anyway I can help let me know, I can make some time to contribute, I also dropped some :hearts:
<FromGitter>
<fridgerator> Sounds like they need help with windows support too
xmonader3 has joined #crystal-lang
<FromGitter>
<eliasjpr> @fridgerator looking at the github issues
<FromGitter>
<KCreate> Maybe a stupid question: Does crystal support returning struct from a method?
<Yxhuvud>
yes, but be aware that structs are passed by value.
<FromGitter>
<KCreate> yep
tzekid has quit [Quit: tzekid]
xmonader3 has quit [Read error: Connection reset by peer]
xmonader3 has joined #crystal-lang
<FromGitter>
<bew> awesome talks since 21h :)
<FromGitter>
<fridgerator> ^
xmonader2 has joined #crystal-lang
xmonader3 has quit [Ping timeout: 252 seconds]
xmonader3 has joined #crystal-lang
<FromGitter>
<bew> `String#each_line` gives each line of a text WITHOUT the ending `\n` or `\n\r`, is there a way to get the size of the real line (is it `line.size + 1` or `+2` ?)
xmonader2 has quit [Ping timeout: 260 seconds]
xmonader3 has quit [Ping timeout: 260 seconds]
<FromGitter>
<KCreate> I don't think so
<FromGitter>
<KCreate> you can't possibly be sure if `\n` or `\r\n` was used
<FromGitter>
<KCreate> only if you're not the author of the data of course
<FromGitter>
<bew> in this case, I'm not
<FromGitter>
<bew> I could check before, but wouldn't work for a data stream..
<FromGitter>
<bew> do you think it'd be a good idea to have a`String#size_with_endline` that could give this info (I'll open an issue to scan others too)
<cerulean>
good news. i have crystal-lang head compiled and sublime crystal highlighter installed
<FromGitter>
<bew> @cerulean You're read to get to work :)
<FromGitter>
<bew> ready*
<cerulean>
@bew weeewwwhooo
<cerulean>
@bew im just reading crystal files. my main work is still on ruby now but i'm invested. Get in the game !!!
<cerulean>
crystal is the unicorn i always wanted
<cerulean>
glad to see tech getting truely pushed forward
<FromGitter>
<bew> yeaaah me too, I've almost read the all compiler source code, I love the crystal more and more :)
<FromGitter>
<bew> -the
xmonader3 has joined #crystal-lang
<cerulean>
i should maybe make my own documents on the differences between the languages of ruby and crystal. i really wanna do my gem translator. it would add a huge body of shard to crystal. it was already successful for rubymotion
<cerulean>
don't tell me my 18,000 hokkaido downloads are all bots
<cerulean>
lol
<cerulean>
im reading the samples
<FromGitter>
<bew> I wont tell ^^
<cerulean>
lol thanks :)
<cerulean>
my friend's gem, is a simple CI, it has 29,000 downloads
<cerulean>
we figure it really isn't all bots and the bot traffic is minimal
<cerulean>
even at 60% bots, its still an impressive amount of downloads
<cerulean>
anyway
<cerulean>
coming soon to crystal: hokkaido gem translator
<cerulean>
i like how brainfuck.cr says fuck in the filename but f*ck in the output.
<FromGitter>
<bew> about tech going forward, some people around me are saying that the language won't go up after some time... I just tell them that if it does, I'll do everything needed to keep crystal up, and rule the world, and as I'm quite good in my school, they already know they're wrong :P
<cerulean>
they are wrong because at 10,000 commits, it's already "up"
<FromGitter>
<bew> and reaaaaly going forward!
<cerulean>
ofc you're good in school man. just watch out for druggies and idiots
<FromGitter>
<bew> ahah
<cerulean>
i have a versioning system of my own
<cerulean>
every 100 comits = +1.0
<cerulean>
9,000 commits is really version 90.0
<cerulean>
;)
<FromGitter>
<bew> nice, you just need to commit every line you add :P
<cerulean>
rails is truely version 620.0
<FromGitter>
<bew> ahah and linux?
<cerulean>
version 6330.0
xmonader3 has quit [Ping timeout: 260 seconds]
<FromGitter>
<bew> looool
<cerulean>
lol
<FromGitter>
<bew> the `.0` is important even though it can't change
<FromGitter>
<bew> or you did'nt mention how?
<cerulean>
can you tell me what "spawn" does again or should i rtfm
<cerulean>
run that inside the project directory to get my special version number
<FromGitter>
<bew> `spawn` creates a new fiber with the block you pass and schedule it, bu you should still rtfm for details :)
<cerulean>
kk
<cerulean>
thats easy
<cerulean>
every commit is actually 0.01 on that scale
<FromGitter>
<bew> quite easy^^ go make your first 'awesome' crystal binary for that formula!
<cerulean>
this is the real version of linux: 6334.41
<cerulean>
lol does crystal support `shel_cmd` style
<cerulean>
yes I will
<FromGitter>
<bew> make it so that you either exec it in a repo directory, or pass a github url (`user/repo`) still and grab commits info from github api :)
<FromGitter>
<bew> s/still/style
<cerulean>
is shard a seperate command? i cant locate it
<cerulean>
alright
<FromGitter>
<bew> yes you have to install it
<cerulean>
sounds good :)
<cerulean>
how do i install
<FromGitter>
<bew> well whats your package manager?
<FromGitter>
<bew> it's 1am here, I'll go soon but I still have some ideas I need to write down if I want to sleep (otherwise I just think... until breakfirst ^^)
<cerulean>
alright
<FromGitter>
<jsilverMDX> i needed my eyes checked - cerulean
<FromGitter>
<jsilverMDX> yes, it'strue, my name is Jon
<FromGitter>
<jsilverMDX> lol
<FromGitter>
<bew> cerulean === @jsilverMDX ?
<FromGitter>
<jsilverMDX> yes
<FromGitter>
<bew> K
ragmaanir has joined #crystal-lang
<ragmaanir>
how do i check whether a class is descended from another or whether a class includes a module?
<FromGitter>
<bew> a class ? or an instance of a class?
<ragmaanir>
a class
<FromGitter>
<bew> at compile time?
<ragmaanir>
no
<ragmaanir>
runtime is fine
<FromGitter>
<jsilverMDX> my guess would be use responds_to? to identify the parent methods. but maybe theres a better way
<FromGitter>
<bew> you can't check that at runtime
<FromGitter>
<bew> this is compile-time @jsilverMDX
<FromGitter>
<jsilverMDX> oh
<ragmaanir>
is there a reason for that or is it just not implemented yet?
<FromGitter>
<bew> @RX14 I remember that __wrap_last_expression, it's actually in use (?!) when writing `>> some_crystal`, right? Is there other easter eggs here? :)
<cerulean>
i just wrote and ran my first line of crystal
<FromGitter>
<bew> *clap* *clap* *clap* !!
<FromGitter>
<jsilverMDX> :D ⏎ that code is getting made @bew
<FromGitter>
<jsilverMDX> the scope you defined is already written in readme