snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 246 seconds]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
A124 has quit [Ping timeout: 240 seconds]
A124 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
A124 has quit [Ping timeout: 240 seconds]
A124 has joined #crystal-lang
snsei has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
weston1 has joined #crystal-lang
<FromGitter>
<drosehn> [going back a few hours] linuksz -- for the specific case of one `initialize` method calling some other method to initialize some variables, there's a trick which will in *some* cases be helpful. Have that other method be another `initialize` method (one which takes different parameters) in the same class.
<FromGitter>
<drosehn> I know this came up in some issue in github, and asterite agreed it was a reasonable tactic to use. But I can't seem to find the issue at the moment, and I need to head home very soon.
<FromGitter>
<drosehn> so of course I find it immediately after I post that I have to give up looking for it. Check https://github.com/crystal-lang/crystal/issues/3334 , down around my comment on Oct 13, 2016.
<FromGitter>
<drosehn> I don't know if it would work for your case, but it's an interesting tactic to keep in mind.
rohitpaulk has quit [Ping timeout: 248 seconds]
weston1 has quit [Ping timeout: 252 seconds]
<FromGitter>
<kustom666> Hi everyone. I'm trying to force the OpenSSL library to use tls1.1 but it keeps on using SSLv3 despite me passing the no_ssl_v3 option to the context. Am I doing anything wrong?
rohitpaulk has joined #crystal-lang
baweaver is now known as baweaver_away
baweaver_away is now known as baweaver
<FromGitter>
<kustom666> so the flags are set but weirdly openssl insists on using sslv3 and I get the following error when connecting to a tls1.1 only server: ssl3_get_record:wrong version number
<FromGitter>
<codenoid> it was fixed @bew , it's funny playing with fork, with application flow, to keep the memory not exhausted ^^
snsei has quit [Remote host closed the connection]
rohitpaulk has quit [Ping timeout: 260 seconds]
bmcginty has quit [Ping timeout: 248 seconds]
bmcginty has joined #crystal-lang
zarianu has joined #crystal-lang
raz has quit [*.net *.split]
jplatte has quit [*.net *.split]
omninonsense has quit [*.net *.split]
salvor has quit [*.net *.split]
jwaldrip has quit [*.net *.split]
[spoiler] has joined #crystal-lang
raz has joined #crystal-lang
jwaldrip has joined #crystal-lang
Papierkorb has quit [Ping timeout: 240 seconds]
TheGillies has quit [Ping timeout: 240 seconds]
olbat[m]1 has quit [Ping timeout: 252 seconds]
sija[m] has quit [Ping timeout: 246 seconds]
byteflame has quit [Ping timeout: 246 seconds]
watzon has quit [Ping timeout: 255 seconds]
thelonelyghost has quit [Ping timeout: 255 seconds]
braidn[m] has quit [Ping timeout: 255 seconds]
A124 has quit [Ping timeout: 260 seconds]
cptaffe has quit [Ping timeout: 255 seconds]
weston_[m] has quit [Ping timeout: 252 seconds]
dtcristo has quit [Ping timeout: 276 seconds]
Papierkorb has joined #crystal-lang
A124 has joined #crystal-lang
salvor has joined #crystal-lang
A124 has joined #crystal-lang
A124 has quit [Changing host]
sz0 has joined #crystal-lang
tax has quit [Ping timeout: 255 seconds]
Papierkorb_ has joined #crystal-lang
<Papierkorb_>
Morning!
<Groogy>
Morning! o/
<Groogy>
Papier how is the bindgen going?
olbat[m] has joined #crystal-lang
<Papierkorb_>
Steadily. I'm working now though, so progress ain't as fast under the week
<Groogy>
Yeah been so tired last couple of days so no programming done for me either
<Papierkorb_>
what's gopher? I guess you're not referring to the network protocol?
<FromGitter>
<bararchy> Papierkorb_ Go fanboy
<FromGitter>
<sdogruyol> Go developer
<FromGitter>
<sdogruyol> hahua
<Papierkorb_>
bararchy, Oh the good old Java "reason" against operator overloading, because this isn't possible: `public bool equals(Object other) { return false; }`
<Papierkorb_>
sdogruyol, oh and of course the + - * / ** operators too
<FromGitter>
<sdogruyol> yeah
claudiuinberlin has joined #crystal-lang
<Groogy>
Any feature of a language can be abused
<FromGitter>
<bararchy> Oh, i'm not against at all, I like it, it gives you a much fine-grained control
<FromGitter>
<bararchy> coming from Ruby, I even expected it to be like that
<Groogy>
No I just mean like its dumb to remove some syntatic sugar because you worry developers will abuse it
<Papierkorb_>
bararchy, I saw your implicit /s ;)
<livcd>
well it's Go's philosophy :-)
<FromGitter>
<bararchy> Papierkorb_ lol , truly not, I'm a long time Ruby dev, I do like that
<FromGitter>
<bararchy> was just kiddin regarding the usual "it's bad" reasoning of people, as Groogy said, any feature can be abused
<FromGitter>
<bararchy> (storing bytes in String for exmaple)
<FromGitter>
<sdogruyol> now that's a Rubyist behaviour :P
<FromGitter>
<bararchy> In ruby "everything is a string", so, you dont have too much options
<Papierkorb_>
"But it could be abused!" "So? Get off my lawn" – Rubys philosophy in a nutshell
<Groogy>
Pff at least it ain't Lua
<Groogy>
where even types are strings
<Papierkorb_>
That part sucks
<Papierkorb_>
And wrapping arrays and maps back and forth
<Groogy>
yeh
<Papierkorb_>
someone have mercy
<Papierkorb_>
Their C API is superb though
<FromGitter>
<bararchy> Ruby's ??
<Papierkorb_>
Luas
<FromGitter>
<bararchy> haaa
<FromGitter>
<bararchy> makes sense hahaha
<Papierkorb_>
Rubys C API is more on the "meh" end of the range
<FromGitter>
<bararchy> FFI = eternal hate
<FromGitter>
<sdogruyol> I remember meeting Lua when I was playing World of Warcraft at 2003 :D
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<bararchy> XD for scripting ?
<FromGitter>
<sdogruyol> tried to write some WoW plugins haha
<FromGitter>
<bararchy> lol cool
<livcd>
Have you seen the analysis of reddit's prog. languages subreddits ? Funny like /r/Ruby is all about Rails and /r/elixir is also forming more and more about Phoenix
<FromGitter>
<sdogruyol> seemed pretty simple but you know :D
<FromGitter>
<sdogruyol> @livcd people needs to understand that Rails is not the only thing of doing web dev
<FromGitter>
<sdogruyol> I remember someone doing torrent stuff was that you @Papierkorb ?
<Papierkorb_>
livcd: Not that, but to be used for web stuff
<FromGitter>
<bararchy> livcd does Crystal even play there ? we have a few web frames, like Kamel, Amber , etc.. but I don't think Crystal is mainly web orianted
<FromGitter>
<bararchy> or at least, wont end there
<Papierkorb_>
sdogruyol, Correct.
<FromGitter>
<sdogruyol> that's super cool
<livcd>
well I do not think Crystal is even there yet
<Papierkorb_>
^
<FromGitter>
<sdogruyol> have you seen comments from Reddit yesterday
<livcd>
like in -> not that many people care about Crystal at all
<FromGitter>
<sdogruyol> Most of them won't ever gonna need that multithreading stuff
<Papierkorb_>
Yes?
<FromGitter>
<sdogruyol> I'm not sure about that
<Papierkorb_>
Honestly, higher traffic stuff will require multi core
<Groogy>
Huh I just got a mail on Github Constellation in Stockholm?
<Papierkorb_>
the other way would be fork stuff
<FromGitter>
<sdogruyol> Look how far Node has gone without it lol
<Papierkorb_>
fork sucks.
<Groogy>
Anyone know what that conferance is about and if it is worth going?
<FromGitter>
<sdogruyol> @Groogy what's that?
<livcd>
sdogruyol: hype creates a momentum where a lot of people (like big companies) start using it -> hence more people -> more libs -> more of everything
<Groogy>
no idea, my first impression is like buisness and entrepenour oriented
<FromGitter>
<sdogruyol> @livcd that's true
<Papierkorb_>
Yeah .. we can do better than Node. Web dev isn't the most processing demanding thing you can do
<FromGitter>
<sdogruyol> Yesterday, I used Yarn with Rails and it installed 999 packages just to compile CoffeeScript...
<FromGitter>
<sdogruyol> WTF
<Papierkorb_>
> Yarn
<FromGitter>
<sdogruyol> And had a 100MB node_modules folder for that...
<Papierkorb_>
> Yarn
<livcd>
Crystal 1.0 with paralellism can be a great start to attract people
<livcd>
but maybe not so much with half baked windows support
<FromGitter>
<sdogruyol> yeah it's a shit show out there
<FromGitter>
<sdogruyol> I just want to render some JSON..
<Papierkorb_>
The billionths packet manager for something from NodeJS. Innovative.
<Papierkorb_>
sdogruyol, I still like how some people "broke" filesystems with NodeJS. nodejs stuff uses so many small files, that it quickly fills up the max inode count.
<FromGitter>
<sdogruyol> yeah
<Papierkorb_>
Really a "what's wrong with the world" meoment
<FromGitter>
<sdogruyol> BTW, are constant always inlined or not?
<Papierkorb_>
-e
<Groogy>
Our external libs for our projects is +20gb big.....
<FromGitter>
<sdogruyol> @Groogy you do game dev and have tons of assets
<Papierkorb_>
Groogy: I guess it does more shit than your average node module
<livcd>
my personal humble analysis is that the reality will be people flocking to whatever platform is the most popular and active no matter the "quality"
<Papierkorb_>
livcd: Yes, cause who cares about it. To me, electron "desktop apps" NodeJS is the manifestation of that.
<Groogy>
Boost, which we barely use stand for only 200mb of that
<FromGitter>
<sdogruyol> how about constants with some complex expression initializers
<livcd>
Papierkorb_: honestly i understand why
claudiuinberlin has joined #crystal-lang
<oprypin>
sdogruyol, i dunno, the "integers that can be computed at compile-time," part seems promising
<oprypin>
but probably not more than that
<FromGitter>
<sdogruyol> i see thanks @oprypin
<Papierkorb_>
livcd: It's just awful, and those "rockstar UX designers" don't even give a hoot about the native look&feel at all. Cause their application is so special.
<livcd>
people are having fatigue from all the incremental 0.5% improvements
<Papierkorb_>
[10:15] <livcd> people are having fatigue from all the incremental 0.5% improvements <- ?
<livcd>
i say improvements
<Papierkorb_>
in which regard? Of your common "web app"?
<livcd>
as in here we have this great new framework or language that does this and that and it's "faster/better" but you have to learn completely new paradigm and lah lah lah
<livcd>
-> react/angular/jsframeworks
<Papierkorb_>
Well, the web dev community is just .. special
<Papierkorb_>
Web dev had the worst fragmentation I've ever seen yet. Completely insane.
<oprypin>
codenoid, it's "#{chicken - 4}"
<Papierkorb_>
And everyone sells their latest foobar.js as the next big thing in their blog, cause everything else sucks. Completely disregarding differing use-cases.
<livcd>
i have a strong feeling that any "technology" that is half baked unless it has a big community will sooner or later be abandoned (like RubyMotion eg)
<FromGitter>
<codenoid> i want make even loop with `5.times.each` @oprypin , `chicken` doesnt have relation with that number : /
sz0 has quit [Quit: Connection closed for inactivity]
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<oprypin>
[00:09:32] <oprypin> Papierkorb, I found the way that you include a table of all virtual methods in every object really inefficient. why not make the struct global?
<oprypin>
[00:28:42] <oprypin> and the default Crystal implementation calls the base C++ implementation
<oprypin>
uhh Papierkorb_, ^
claudiuinberlin has joined #crystal-lang
<Papierkorb_>
oprypin: One could do that on a per sub-class level.
<oprypin>
indeed that's what i mean (i think)
<Papierkorb_>
Except that it would require some more changes
<Papierkorb_>
Mh yeah but nothing too big all things considered
<Papierkorb_>
oprypin: But I'd do it the other way around than your proposal from 00:28:42. Throwing it over through crystal and back to C++ would be much less efficient
<oprypin>
just 1 function call instead of a conditional check
<Papierkorb_>
Lol no.
<Papierkorb_>
Conversions have to be done
<oprypin>
what conversions
<Papierkorb_>
From C++ only data?
<oprypin>
ok true
<oprypin>
not sure what you're thinking about. call the crystal function and let the default implementation return a sentinel or something'
<Papierkorb_>
Virtual overriding is crazy enough as it is. I don't want to add further complexity into the Crystal wrapper code for no visible gain
<oprypin>
but it's a huge memory overhead for every tiny object
<FromGitter>
<sdogruyol> can't you just inline the call?
<Papierkorb_>
What? The structure optimization I already agreed to. But not bouncing every C++ call over to Crystal. *That* would slow things down a lot.
<oprypin>
Papierkorb_, i wasnt forcing you to do that
<oprypin>
but you havent specified how you're going to do one but not the other
<Papierkorb_>
And even the structure optimization will be funky. Viva la inherited hook.
<Papierkorb_>
Then an #initialize only has to pass on `self` to the object for context
<oprypin>
yeah
<oprypin>
or like i used to do it, go 4 bytes to the left and you're at the Crystal object
<oprypin>
to the left of `this`
<Papierkorb_>
I don't think I want to rely on that without crystal guaranteeing me some memory layout
<oprypin>
nah it's nuts, i removed that code since
<oprypin>
i think i understand your idea, but it seems just messy enough to not do it for now
<Papierkorb_>
It's not much more messy than the whole thing already is (needs to be?). It'd actually reduce Crystal code size, and remove ton of macro code in the #initialize'rs, so it might actually speed up Crystal compilation
<Papierkorb_>
Replaced with a single macro in an included hook. So depending on how the compiler does it, it'll be a speedup, or stay as is.
<oprypin>
i dont like the `macro inherited` and the fact that you seem to want one c++ struct instance per subclass in crystal
<Papierkorb_>
What's wrong with it? That mirrors how C++ does it internally
<Papierkorb_>
Rather near the real vtable
<oprypin>
well if you're willing to do it, all for the better
<Papierkorb_>
The only other option is one-struct-per-object, which of course consumes memory.
<oprypin>
im just wary of some kind of desynchronization if macro inherited does something weird
<oprypin>
Papierkorb_, well not only, i told you the real elegant (but inefficient as you pointed out) alternative
<Papierkorb_>
Hopefully the all-new integration tests would catch that
<oprypin>
so u cant say "only" other option
<Papierkorb_>
Trading CPU cycles for saving a few bytes of memory is *not* an option.
<Papierkorb_>
The run-time overhead would be insane. It's already bad enough with strings.
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
weston1 has joined #crystal-lang
weston1 has quit [Ping timeout: 240 seconds]
<FromGitter>
<codenoid> just a loop and http client : / ⏎ ⏎ `SSL_shutdown: Interrupted system call (Errno)`
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<oshnix> Hello, guys. ⏎ I've seen an article about Crystal replacing Node.js in server backend. ⏎ This theme is quite interesting for me because I'm trying to develop backend app at the moment. ⏎ Can you tell me, where can I read about comparison between Crystal and Golang [https://gitter.im/crystal-lang/crystal?at=59c0e8f7cfeed2eb6528d1a9]
claudiuinberlin has joined #crystal-lang
<FromGitter>
<bararchy> @sdogruyol maybe you can help @oshnix ?
<FromGitter>
<bararchy> btw @oshnix the guy who did it is @crisward , if you want info about the article
<FromGitter>
<sdogruyol> well comparing with Go is a bit not fair
<FromGitter>
<sdogruyol> Crystal is not 1.0 yet
bmcginty has quit [Ping timeout: 248 seconds]
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bmcginty has joined #crystal-lang
<Groogy>
also I think "replacing" is a bit strong, complement the already lively Web ecosphere :P
<Groogy>
and eventually games (•_•) ( •_•)>⌐■-■ (⌐■_■)
<FromGitter>
<bararchy> and other stuff ;)
<FromGitter>
<oshnix> @sdogruyol I understand it, but If there're some things that can be done simpler on Crystal than Go? ⏎ I looked through docs on official site and wondering if Crystal syntax can be easy to use without Ruby knowledges? ⏎ Maybe some of you, guys, rewrote your applications on Crystal because it was simpler to develop and maintain. ⏎ So, I want to know more about strong and weak sides of language API that
<FromGitter>
<crisward> Personally I tried writing simple apps with every language I could get my hands on. I wanted something enjoyable, fast and with type checking (that uses less memory than node). Crystal has those three things. I had no real previous knowledge of Ruby, but I imagine it'd help.
<FromGitter>
<crisward> Weak sides are the missing bits. If you want to do 'x' and is doesn't exist, you may have to write it.
<FromGitter>
<crisward> @oshnix BTW glad the article made you consider crystal 😄
<Groogy>
on the "if x doesn't exist", yeah problem I have but thanks to how nice Crystal is to bind libraries with it isn't that horrible
<Groogy>
of course if implementation already exists in C or something easily accessible with C ABI
<FromGitter>
<crisward> I've had to submit some data types to the mysql lib. But I didn't mind that. Quite interesting to see how everything works.
<FromGitter>
<oshnix> @crisward yeah, I'm looking forward to trying crystal in some of my programs after I read the article.
<crystal-gh>
[crystal] RX14 closed pull request #4638: init: add TODO doc-comment for generated module (master...fix/crystal-init/todo-comment-for-doc) https://git.io/vQ4ie
DTZUZO has joined #crystal-lang
sz0 has joined #crystal-lang
<FromGitter>
<codenoid> "rewrote your applications on Crystal because it was simpler to develop and maintain." me (my site), from php (& javascript rendered page) to Crystal Kemal
<FromGitter>
<zyriuse75> someone last time give me an github address of crystal-book of someone who start to translate in french ?
<FromGitter>
<zyriuse75> i found thanks
<FromGitter>
<zyriuse75> oh no 😟
weston1 has joined #crystal-lang
weston1 has quit [Ping timeout: 246 seconds]
claudiuinberlin has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
ShalokShalom_ has joined #crystal-lang
<FromGitter>
<krypton97> There's a new website for deploying apps that claims to do better than heroku/azure
<FromGitter>
<krypton97> Has anyone here tried it?
<FromGitter>
<zyriuse75> no sorry
ShalokShalom has quit [Ping timeout: 255 seconds]
<FromGitter>
<krypton97> well, no reason to sorry :0)
<FromGitter>
<krypton97> :)
<FromGitter>
<krypton97> they seem pretty cool, finally a message support where there's no bots
<FromGitter>
<krypton97> btw, not trying to advertise or something like that
ShalokShalom_ is now known as ShalokShalom
DTZUZO has quit [Ping timeout: 255 seconds]
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
claudiuinberlin has quit [Client Quit]
claudiuinberlin has joined #crystal-lang
weston1 has joined #crystal-lang
weston1 has quit [Ping timeout: 240 seconds]
<FromGitter>
<schoening> I'm always using digital ocesn they are great
<FromGitter>
<schoening> Ocean*
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<crisward> We use digital ocean and linode, get a bit more for your money with linode, but not much in it.
claudiuinberlin has joined #crystal-lang
hightower4 has quit [Read error: Connection reset by peer]
hightower4 has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
LastWhisper____ has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
Philpax_ has joined #crystal-lang
Philpax__ has quit [Ping timeout: 255 seconds]
<FromGitter>
<krypton97> yeah, linode seems to offer more, haven't really heard of it so far
p0p0pr37_ has joined #crystal-lang
p0p0pr37_ has joined #crystal-lang
weston1 has joined #crystal-lang
<FromGitter>
<crisward> They've been around at lot longer than digital ocean. But used to be around twice as expensive, the competition forced them to lower there prices I think.
<FromGitter>
<krypton97> Do they offer some free sql? I've seen that digital offers like 10k rows, not that sure
p0p0pr37 has quit [Ping timeout: 264 seconds]
p0p0pr37_ is now known as p0p0pr37
weston1 has quit [Ping timeout: 240 seconds]
<FromGitter>
<krypton97> other than that, linode seems a solid choice
<FromGitter>
<bew> because `+` by itself is not valid, you need `a + b`. in your case you can make it work using `itself + Vector2.new(3, 4)`
Papierkorb_ has quit [Quit: Konversation terminated!]
<FromGitter>
<bew> @AlexanderChen1989 ^
<FromGitter>
<AlexanderChen1989> @bew operator is not a normal method?
<FromGitter>
<AlexanderChen1989> A yield expression can be modified, using the with keyword, to specify an object to use as the default receiver of method calls within the block
<FromGitter>
<bew> it's not *really* a normal method, it's an operator that can be overriden by defining a method with the name `+`, from my understanding you can't call directly `+` method as in `+ 1`. You must use the form `obj1 + other` to call the `+` method of `obj1`.
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<AlexanderChen1989> but i can do this `puts 1.+(2)`
<FromGitter>
<crisward> Crystal issues are one there way down nicely... they were at 400 when I last checked. Can't help thinking every closed issue is one step closer to v1. Good to see 👏
<FromGitter>
<sdogruyol> yeah @crisward
<FromGitter>
<sdogruyol> It's great to see @asterite rocking :metal:
mark_66 has quit [Remote host closed the connection]
<FromGitter>
<wwselleck> are there anyy examples of crystal apps using a plugin architecture?
<FromGitter>
<rufusroflpunch> is there an issue with sqlite3 shard and blobs? when I insert a blob into a table, it only inserts the first few characters
<FromGitter>
<rufusroflpunch> if this is a bug, I'll file a report, I just wanted to know if I'm doing it right
weston1 has joined #crystal-lang
weston1 has quit [Ping timeout: 240 seconds]
<Papierkorb>
Ah man, just as I hack into yamls pull parser, ary changes its code :(
<Papierkorb>
Shouldn't break it though, yay
<FromGitter>
<krypton97> Try to encode the blob in base64 before saving it
alex`` has quit [Quit: WeeChat 1.9]
snsei has joined #crystal-lang
<FromGitter>
<ziprandom> hey crystal friends! is there a way to instanciate a Class from a Hash just like it's possible with the json-mapping's `.from_json`?
<Papierkorb>
Have you tried it?
<FromGitter>
<rufusroflpunch> @krypton97 it works just fine if it's base64. the binary data appears to be screwing it up somehow
<FromGitter>
<rufusroflpunch> @ziprandom it might be a little strange, but if you convert the hash to json first with `.to_json` then run it through `.from_json` that will probably work
<FromGitter>
<rufusroflpunch> @ziprandom I just realize I think maybe I misread your question
<FromGitter>
<ziprandom> @krypton97 yeah, for sure :D was just wondering. no you didn't misread..
<FromGitter>
<bew> I didn't get what you wanted to do @zip
<FromGitter>
<ziprandom> these mapping macros exist for json, yaml and msgpack as far as I know. I wonder whether it can be more generalized ...
<FromGitter>
<rufusroflpunch> I looked at the code for the JSON mapping once, it's pretty straightforward. you can probably just write your own macro to take a hash an map it to attributes. it's not in the std lib as far as I know
<FromGitter>
<ziprandom> I have a hash (that actually is derived from a json) and was wondering whether I can instantiate a Class directly with smth. like `from_hash`. It's possible, I was just wondering whether a similar mechanism already exists for `Hash`
<FromGitter>
<bararchy> So that before_each actually injected the vars into the `it` scope
<Papierkorb>
bararchy: Just try it without :)
<FromGitter>
<bararchy> Papierkorb What do you mean ?
<Papierkorb>
You can have variables in the describe/context block, and you can access those from the it
<Papierkorb>
They're only created once though
<FromGitter>
<bew> @bararchy iirc `it` & `describe` are currently 2 methods so the scope of `it` is the same as `describe`.
<FromGitter>
<bew> Yeah they won't be reset before each `it`
<FromGitter>
<bararchy> Yeha, I need something that will re-initiate efore each
<FromGitter>
<bararchy> So, there is Spec.before_each, but it only effect in-scope ⏎ ⏎ maybe something like ⏎ ⏎ ```params = {} of Stuff ⏎ Spec.before_each do ⏎ params[:stuff_1] = Stuff.new ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=59c1539a1081499f1f4ed64d]
<FromGitter>
<bararchy> but it looks ugly XD
<Papierkorb>
I usually have one (or more) convenience builder methods
claudiuinberlin has joined #crystal-lang
linuksz has joined #crystal-lang
<Yxhuvud>
I wish we could place method defs in more places in specs, like how they can be anywhere in rspec but will be scoped to whichever describe it is defined in
<linuksz>
sorry, if first copied the paste url then the docs, then forgot the docs is on the clipboard
<Papierkorb>
The second fiber, once yielded to, will run forever
<linuksz>
why will it?
<Papierkorb>
Fibers are cooperative, not pre-emptive
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<linuksz>
what does it mean?
<FromGitter>
<bew> I know Ary wants to rework how Specs works, but I don't know what he has in mind (nobody knows ˆˆ)
<Yxhuvud>
that they stop only when they want to
<linuksz>
the scheduler will only switch when a fiber tell it?
<Papierkorb>
A fiber has to give up its execution time for another fiber to run
<FromGitter>
<asterite> @rufusroflpunch you can try passing `[contents.to_slice]`, I think with `contents.to_slice` just the first byte will be sent (not sure)
<linuksz>
so it must tell the scheduler to switch fiber
<Papierkorb>
Which usually happens implicitly (e.g., waiting for IO)
<linuksz>
what i don't understand is that the first fiber tells the scheduler: "come back 1 second later", then the scheduler executes the second fiber. why doesn't it go back to the first 1 second later?
<Yxhuvud>
linuksz: the first fiber tells the scheduler: "I won't do anything for a while. please wake me up at the earliest in one second"
<linuksz>
oh
<linuksz>
and what should i do if i have a long process in the second fiber, but wants to go back to the first in every 1 second?
<Papierkorb>
What long process?
<linuksz>
waiting for Termbox user input
<linuksz>
but Termbox is C binding
<linuksz>
and doesn't tell the scheduler
<Papierkorb>
Then it's blocked.
<linuksz>
How can i do it in a non blocking way?
<Papierkorb>
integrate it with libevent
<Papierkorb>
what is termbox?
alex`` has joined #crystal-lang
alex`` is now known as alexherbo2
claudiuinberlin has joined #crystal-lang
<linuksz>
an ncurses alternative github.com/nsf/termbox
alexherbo2 is now known as alex``
<Yxhuvud>
I wonder if fork could be an alternative to libevent, but either way, it will probably not be very nice
<Papierkorb>
Integrate it with libevent. Not an easy task.
<Papierkorb>
if it comes with integration you're lucky. if it has a proper indirection layer for all things IO, it's doable. If neither, effectively impossible.
<linuksz>
i am now reading about libevent
<FromGitter>
<bew> Or rewrite termbox in crystal (it's on my todolist since... too long ˆˆ)
<linuksz>
if i want to do it with libevent, i should write it into termbox's C code?
<linuksz>
the libevent integration should be done in Crystal binding of Termbox's C code?
<FromGitter>
<bew> @uSide no but I'd love to
<FromGitter>
<bew> But probably not for the same reason, for me I usually wants to add `{% debug() %}` to a macro to look at the generated code..
<Papierkorb>
macros aren't methods, it doesn't make sense to call `super`
<FromGitter>
<bew> And it should be ˋ{{super}}ˋ btw
<FromGitter>
<bew> Should *have be (if it xas possible )
<FromGitter>
<bew> Still not..
<FromGitter>
<bew> `{{previous_def}}`
<linuksz>
Is it possible to create an event loop in crystal for a custom event, with a timeout, or not until multithread support arrives?
<Papierkorb>
"custom event"?
<Papierkorb>
Something I/O?
<Papierkorb>
Yeah that's a fiber.
<linuksz>
Not i/o
<Papierkorb>
what else then?
<linuksz>
return of a function
<linuksz>
so run this function, if it returns in 1 sec, then return the return value of the function, else return the default
<linuksz>
then wait again for the return of the function for another 1 sec
<Papierkorb>
nope, not even with multithreading
<linuksz>
why not with multithreading?
<Papierkorb>
Because the language can't ensure you're not shooting yourself
<Papierkorb>
Killing a thread is not a sane thing to do
<linuksz>
why kill?
<linuksz>
wait for return in 1 sec. if doesn't return, don't kill it, but return the default value to the caller, then wait another second. if the function returns, then return its value, else the default
<linuksz>
then wait again
<linuksz>
the function now had 2 seconds to run, and the default value was returned by the loop 2 times
<linuksz>
i try to describe it a simpler way: return the default value in every 1 sec, until the function return, then return immediately its return value
weston1 has joined #crystal-lang
weston1 has quit [Ping timeout: 248 seconds]
<FromGitter>
<bew> You can't return multiple times linuksz
<FromGitter>
<bew> What would the caller look like when calling your method (which should have the described behavior)?
<linuksz>
the timer wouldn't return multiple times. I described it wrong. It would send a value over a channel, or call an event handler function.
<FromGitter>
<ezrast> I think he just wants a timeout on Channel receives/selects
<FromGitter>
<ezrast> Do we have those?
<linuksz>
i create two fibers. the first do a long job. until the job finishes, the fiber sends the default value over a channel. the second fiber receives it. when the long job started from the first fiber finishes, the fiber imediately sends its return value over the channel, and restart the job.
<FromGitter>
<bew> Without multithreading you cannot "send sth over the channel" during fiber1 execution (unless you put some breakpoints using `Fiber.yield` in it)
<FromGitter>
<ezrast> @linuksz you can roll your own timeouts like this: https://carc.in/#/r/2r9b
<FromGitter>
<ziprandom> from what @bararchy said about the `before_each`hook in specs, does it even exist atm?
<FromGitter>
<ziprandom> or is there something comparable? (I don't need to set variables, just some cleanup inbetween runs would be great=
<FromGitter>
<ziprandom> )
<FromGitter>
<rufusroflpunch> @asterite thinks, but it appears to be a bug in the sqlite crystal bindings. it's using sqlite's text binding method to bind slices, not the blob binding method. I have opened a PR for it
<FromGitter>
<ezrast> But bear in mind that only works because `concurrent_method` is explicitly sleeping; if it's doing busywork without yielding to other fibers it won't work until true parallelism is implemented.
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<rufusroflpunch> s/thinks/thanks
<FromGitter>
<ziprandom> ok found it: `Spec.before_each`
claudiuinberlin has joined #crystal-lang
<linuksz>
what does Channel.select do?
<FromGitter>
<bew> @ezrast indeed it doesn't really work (you can use the select syntax also https://carc.in/#/r/2r9o)
<linuksz>
what does select do?
<linuksz>
waiting for a signal in multiple channels?
<FromGitter>
<bew> @ziprandom be aware that `Spec.before_each` will set the thing globally (for ALL specs)
<FromGitter>
<bew> linuksz yes
<linuksz>
i want to do it with 'concurrent_channel' doing a job, not sleeping. so in this case isn't it possible to do without parallelism?
<FromGitter>
<bew> That's what I think, yes
<linuksz>
what do you think, when will parallelism be implemented in crystal?
<FromGitter>
<bew> yeah
<FromGitter>
<sdogruyol> that's like the most common question these days
<FromGitter>
<ziprandom> @bew thanks
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
linuksz has quit [Ping timeout: 248 seconds]
claudiuinberlin has joined #crystal-lang
<FromGitter>
<kustom666> @sdogruyol or most common complaint if you check Reddit
<FromGitter>
<kustom666> But Reddit is a giant circle jerk of people who are never happy
<Papierkorb>
Did you mean `/r/programming`?
weston1 has joined #crystal-lang
weston1 has quit [Ping timeout: 240 seconds]
<FromGitter>
<sdogruyol> probably
<FromGitter>
<sdogruyol> it's interesting that Crystal treads doesn't get that much flame wars
<RX14>
lol really
<RX14>
they do
<FromGitter>
<sdogruyol> compared to other threads it seems a bit low :P
tax has quit [Ping timeout: 246 seconds]
<FromGitter>
<sdogruyol> not sure if it's just my understanding lol
alex`` has quit [Quit: WeeChat 1.9]
<FromGitter>
<crisward> The crystal community seem a pretty good bunch... perhaps the language has a calming effect on those who use it?
<RX14>
except the people on the r/programming threads have very rarely used it
<RX14>
they critique it based on their impression of it
<RX14>
which does provide some good points of view in some cases
<FromGitter>
<sdogruyol> A programming language for humans™
<FromGitter>
<sdogruyol> @crisward
<RX14>
but sometimes their point of view is incorrect
<Papierkorb>
crisward, partially inherited that from Ruby, which is also a pretty chill community <3
<FromGitter>
<crisward> > hey critique it based on their impression of it
<FromGitter>
<crisward> like book reviews based on the back page?
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
greengriminal has joined #crystal-lang
<cerulean>
crystal definitely calms me down @crisward
<cerulean>
it's long lasting fun for the whole family!
<cerulean>
ruby is chill too, true
weston1 has joined #crystal-lang
weston1 has quit [Ping timeout: 240 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter>
<GurgDev_twitter> Quick question: The language seems cool, thinking of a project to learn it with, and with the language being new, are there missing libs or utils that would be nice? Like an irc lib?