<FromGitter>
<picatz> You can put them in a module in a file and then require that file with the module with the variables in another file I'd imagine.
<FromGitter>
<picatz> Not even sure you need to put them in a module. Or if that's what you're going for :O
<_tsound>
really I want to interpolate the require file, but you can't do that
<FromGitter>
<mgarciaisaia> Not sure if Ruby bindings are the best starting point for porting to Crystal. Ruby has all the RubyObject<-->C struct interop that Crystal doesn't need at all. Take a look at crystal_lib, use any existing Ruby binding as API interface "guidance", but think in Crystal - not Ruby :)
Philpax_ has joined #crystal-lang
<FromGitter>
<faustinoaq> @mgarciaisaia Would be posible to do a Ruby implementation in Crystal?
<FromGitter>
<mgarciaisaia> What do you mean?
<FromGitter>
<mgarciaisaia> Implementing a Ruby interpreter in Crystal?
<FromGitter>
<faustinoaq> yeah
<FromGitter>
<mgarciaisaia> Isn't it enough work to do *one* language? RLY? :P
<FromGitter>
<faustinoaq> Would be funny, ruby -> crystal, crystal -> crystal, crystal -> ruby π
<FromGitter>
<mgarciaisaia> I don't see why it would be different from doing, say, JRuby or any other non-MRI implementation
<FromGitter>
<mgarciaisaia> I *think* I've read there's no formal Ruby spec, so basicaly "Do what MRI does" is the spec. That usually gives implementors soooooo many headaches... β But you *could* do it if you wanted, I think
<_tsound>
so does this crystal_lib work with ruby bindings?
<FromGitter>
<faustinoaq> Could be named CrRuby π
<Papierkorb>
Sure it's possible to build a ruby interpret in Crystal.
<Papierkorb>
But ruby is completely insane
<Papierkorb>
Fun is something else
<FromGitter>
<mgarciaisaia> I'd rather have you invest that effort in Crystal itself - but I'm not your boss Β―\\\_(γ)\_/Β―
<FromGitter>
<mgarciaisaia> "_Disney_'s fun" says a friend
<_tsound>
i dont like it all that much either, but that native C gtk looks daunting :(
<FromGitter>
<mgarciaisaia> @_tsound crystal_lib generates the boilerplate for exposing C functions (from their `.h`s) to Crystal syntax. Basically, the `lib` and `fun` declarations.
<FromGitter>
<mgarciaisaia> But I think it's always been a messy project, so it may work or not
<_tsound>
i'll try, but I doubt it would handle the entire gtk3 lib
<FromGitter>
<mgarciaisaia> I'd give it a try anyway, at least - maybe it doesn't work, maybe it produces wrong Crystal code that's easy to fix, maybe it does the whole project for you...
<FromGitter>
<mgarciaisaia> (Spoiler: it'll *most probably* won't do the whole project for you)
<FromGitter>
<picatz> :P
<_tsound>
:P that's a given, if that was the case it would've been done already
<FromGitter>
<picatz> *Only one way to find out!*
<FromGitter>
<mgarciaisaia> But it used to generate the boilerplate reeeeaaaaaaaaaly well. You only needed to fix some names here and there, and then write your own convenience wrappers to give a more OOP approach to the C libraries
<FromGitter>
<mgarciaisaia> > @mgarciaisaia How is going internal crystal team with parallelism? β If I tould you, then I had to _silence_ you... π
<FromGitter>
<codenoid> :shipit:
<FromGitter>
<mgarciaisaia> I really don't know - I've been out of the office for a couple of weeks, so I've lost track of that. But I can try to get you an answer next week (assuming I recall actually doing it).
<FromGitter>
<codenoid> β¨
<FromGitter>
<mgarciaisaia> That T-Shirt Serdar is wearing on the video is the ones we've made for the CodeCamp. I think we're not selling them *yet*, but its one of the things we'll probably do soon-ish.
<FromGitter>
<mgarciaisaia> I hope you could get that very same logo from crystal-lang.org - maybe even with that text?
<FromGitter>
<mgarciaisaia> If you print one for yourself, *please* make the URL https for us :P
<FromGitter>
<codenoid> okkk ^^ π
deep-book-gk_ has joined #crystal-lang
deep-book-gk_ has left #crystal-lang [#crystal-lang]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
w-p has quit [Ping timeout: 240 seconds]
deep-book-gk_ has joined #crystal-lang
deep-book-gk_ has left #crystal-lang [#crystal-lang]
snsei_ has joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
_tsound has quit [Quit: WeeChat 1.9]
snsei_ has quit [Remote host closed the connection]
<FromGitter>
<Qwerp-Derp> Well yeah @sdogruyol, but `["abcd", ["abcd"]]` should work under what I want to achieve, as well as any nesting of strings and arrays containing strings
<FromGitter>
<Qwerp-Derp> With your implementation I can only have `Array(String)` nested 2 layers deep, not arbitrarily deep (which is what I want)
<FromGitter>
<sdogruyol> then you need to specify those too
<FromGitter>
<sdogruyol> without knowing what you're going to put into array the compiler can't infer
<FromGitter>
<watzon> Thinking of a new shard. Who would be down to help with bindings to libgit2 (https://libgit2.github.com/) in the future?
<FromGitter>
<watzon> I'm going to need it for a project I'm getting ready to start on
<FromGitter>
<watzon> There's already bindings in a ton of other languages
<FromGitter>
<sdogruyol> it's pretty much functional and would be great if you contribute :P
<FromGitter>
<watzon> I didn't! Looks like it already exists haha
<FromGitter>
<watzon> I will definitely be contributing
<FromGitter>
<sdogruyol> great π
<FromGitter>
<watzon> I'm going to, hopefully, be starting a pretty large Crystal-backed project this week
<FromGitter>
<sdogruyol> Awesome. Please feel to reach out for any issue
<FromGitter>
<watzon> It's going to basically manage docker containers and allow code uploads via git-push, so libgit2 bindings are going to be a huge help
<FromGitter>
<watzon> And of course!
<FromGitter>
<watzon> Also thinking about starting a local Crystal meetup here in Phoenix, but I'd need to find people around here that are interested
<FromGitter>
<watzon> Btw @sdogruyol , I will most likely be using Kemal as well. Thanks for the awesomeness!
<FromGitter>
<sdogruyol> Thank you @watzon, I'd like to make Kemal better for everyone :) Hopefully we got some great PRs soon to be merged for that purpose π―
<FromGitter>
<watzon> @sdogruyol what would you suggest as a good ORM for Postgres?
hightower3 has quit [Ping timeout: 260 seconds]
<FromGitter>
<sdogruyol> crecto by @fridgerator
<FromGitter>
<watzon> Awesome I was just looking at that
<FromGitter>
<watzon> Is it possible to reinstall crystal on ubuntu with LLVM 4 instead of 3?
<FromGitter>
<watzon> Or would I have to compile it myself?
tzekid has joined #crystal-lang
tzekid has quit [Remote host closed the connection]
tzekid has joined #crystal-lang
<FromGitter>
<Qwerp-Derp> I'm thinking of making a `RecursiveArray` thing, which addresses the problem I want to solve, but I don't have much of an idea where to start :P
hightower3 has joined #crystal-lang
<hightower3>
sdogruyol: if I am to connect from Kemal to postgres as each individual user who is logged in (rather than having a single/common connection to the DB), how would I best approach this?
<FromGitter>
<sdogruyol> @hightower3 use a connection pool and dynamically connect to different dbs
<FromGitter>
<sdogruyol> or preallocate the connection pool
<hightower3>
Modules for this exist or I should hack a simple prototype myself?
<hightower3>
sdogruyol: ok so I can use 'get' within a class, but the problem is I can't use instance variables in it, since I'm in the class, outside of any method. What's the way to make that possible?
alibby1 has quit [Ping timeout: 276 seconds]
alibby has joined #crystal-lang
<FromGitter>
<sdogruyol> well your scope is within request - response lifecycle
<FromGitter>
<sdogruyol> check out `env.context.set` and `env.context.get`
alibby has quit [Ping timeout: 240 seconds]
alibby has joined #crystal-lang
<hightower3>
you mean env.set/env.get? I don't see env.context mentioned anywhere in kemal checkout
<hightower3>
sdogruyol: what I am trying to do is have a "before_all" block in which I take a DB connection from the pool, set user on it, and save it in context. But I can't do that since the connection is of type DB::Connection
<hightower3>
(so I can't save it in context)
<FromGitter>
<mgarciaisaia> > @mgarciaisaia you are some kind of community manager from Manas right ? β β @bararchy I was supposed to be something like that, but I'm not sure I've taken care of that role enough. β I'll try and help with whatever I can if you need something, though :) [https://gitter.im/crystal-lang/crystal?at=597c955242d2f61025883fa6]
<hightower3>
I am trying to pass a block with 1 arg to a method. I call accepts_block(){ |arg| puts arg}, where accepts_block is defined as def accepts_block( *block) block.call( argument) end. But when I run this, in the call to accepts_block() I get an error wrong number of block arguments (given 1, expected 0)
<hightower3>
What am I missing?
pabs has joined #crystal-lang
Yxhuvud has quit [Remote host closed the connection]
Yxhuvud has joined #crystal-lang
tzekid has quit [Ping timeout: 258 seconds]
alibby1 has joined #crystal-lang
<FromGitter>
<bararchy> @mgarciaisaia Well, TBH I was just wandering, as a long time member of the community it sometimes feel like there is not enough comunication between the core team (mostly manas) and the other contributers\users, One part that really helped was the bi-weekly blog posts that Ary used to write, I know he is no longer part of the core team , but maybe someone who is good in that aspec can take this role ? I would
<FromGitter>
... nomine @sdogruyol If it was my choise hahah as he already does much in the regards of pushing Crystal forward via PR's (not the github kind) and blogs\posts\tweets etc .. β β Anyway, regardless of who will do that, I feel that It's a "hole" that is being felt by more then only me
alibby has quit [Ping timeout: 240 seconds]
<FromGitter>
<bararchy> Just a quick disclaimer though, I know you guys are super busy, I know you need to run a company with Crystal as a "side project" , it's just that I really wan to see the project floruish
<FromGitter>
<bararchy> (Also, using Crystal in prod and want to be sure at where it's headed)
tzekid has joined #crystal-lang
cyberarm has quit [Ping timeout: 248 seconds]
<FromGitter>
<bararchy> I hope I didn't send any "bad vibes" with that, It's was really a question in "good faith"
<Papierkorb>
A lack of communication is sure noticable. As far the state of information is concerned, no one in the community knows if Crystal as manas project will be around in a year, or not. Which is terrifying, and a much bigger issue than getting to v1.0 - for me, that is. I completely understand that comms take a huge time investment: But I'm also pretty sure that instead of a super polished article every 6 months, something less polished would
<Papierkorb>
do the job pretty well. I'm pretty sure that there are a few in the community who would love to take that task of writing polished articles for you.
<FromGitter>
<bararchy> I would even agree to a "support plan" for production Crystal users that will give more info regarding advancments, tasks , people whos working on ... , etc..
cyberarm has joined #crystal-lang
<FromGitter>
<bararchy> Just so I can tell my co-workers that "you see, this project is stable and going forward, we should use it for X"
<Papierkorb>
^ Exactly that
<Papierkorb>
I can't blame someone for looking at the project page and thinking "it's dead, better use something else". Community content on there, written by .. err .. "Community ambassadors" or whatever .. about Crystal, challenges, improvements, etc., would change that picture completely, for except some quality control (Those publishers should be hand picked in any case), shouldn't be too costly time-wise.
<FromGitter>
<bararchy> I know that some in the comunity fear that an "IO.js" will happen (https://iojs.org/en/faq.html)
<FromGitter>
<faustinoaq> I agree with you @bararchy
<FromGitter>
<faustinoaq> We should take as example the sucess of languages as Elixir
<Papierkorb>
Would actually make it kinda interesting, cause people would focus on many different things you can do with crystal. Sure lots of webdev, but tons of other things too. I'd wager there are more than a few seriously interesting (from a technology POV) weekend-projects: We had operating systems, bunch of emulators, tons of arcane hacks. We had people in here doing stuff on Bitcoin. What people already do today with crystal is great, and we
<Papierkorb>
could show-case that
<Papierkorb>
bararchy, wasn't that just a fork of nodejs, cause of a enterprise vs community "battle"? Didn't they merge already soon afterwards?
<FromGitter>
<faustinoaq> Plataformatec (the company behind elixir) now is a Professional Consulting for Elixir.
<FromGitter>
<sdogruyol> Thanks @bararchy I totally agree
<FromGitter>
<sdogruyol> And also @papierkorb there are already great things built with Crystal which are not web
<Papierkorb>
sdogruyol, yeah I listed a few I think ;)
<FromGitter>
<sdogruyol> Hopefully we'll have one more Crystal book :)
<FromGitter>
<faustinoaq> We can give some ideas to Ivo Balbaert
<FromGitter>
<sdogruyol> It's not official yet but I will also start writing a Crystal book
<Papierkorb>
Fixed: <sdogruyol> It's official yet, I will also start writing a Crystal book
<Papierkorb>
Anyone in here ever used Qt/QML?
<FromGitter>
<sdogruyol> What?
<FromGitter>
<faustinoaq> Also, I know Ary is very busy, I'm ok with that. But I wish to see him talking about Crystal at least time a time. The creators of a language are people that inspire.
<w-p>
how does one differentiate between, for example, a local module struct and Crystal class of the same name imported into the same file? using just the local module name doesn't seem to work.
<w-p>
for example, MyModule::JSON vs the Crystal JSON type
<Papierkorb>
Leading `::` forces the lookup to start at the top-level, as opposed to the current level. So, `JSON` from inside that MyModule would be `::JSON` w-p
<w-p>
Oh, man - excellent. Is that documented anywhere?
<FromGitter>
<sdogruyol> that's actually a Ruby-ism :P
<FromGitter>
<sdogruyol> should be documented though
<Papierkorb>
Can't find an explicit mention of it in the docs. "The Program" uses it for a method, and type grammar uses it casually for Nil
<w-p>
I'm finding a few of those so I usually google for 'how to do x in Ruby'.
<Papierkorb>
Yeah, erm .. for better or worse, the origin from Ruby is quite apparent
<oprypin>
i mean it's noise but he's also not wrong
<Papierkorb>
for a moment, I wasn't sure if you intended to write 'nice' or not
<FromGitter>
<bararchy> Well, this kind of discussion is not meant for Github
<FromGitter>
<bararchy> Maybe google-groups is better for it
<Papierkorb>
Most will see it there though
<FromGitter>
<bararchy> True
<FromGitter>
<sdogruyol> IMHO it's to be somewhere
<FromGitter>
<sdogruyol> GH is good for visibility
<w-p>
hackernews, reddit, medium ...
<hightower3>
sdogruyol: do you have a suggestion for my question from earlier:
<hightower3>
sdogruyol: what I am trying to do is have a "before_all" block in which I take a DB connection from the pool, set user on it, and save it in context. But I can't do that since the connection is of type DB::Connection (so I can't save it to context hash)
<FromGitter>
<sdogruyol> you can use custom context types for that
<FromGitter>
<sdogruyol> hold on
<FromGitter>
<sdogruyol> @hightower3 to register a custom type to Context storage use `add_context_storage_type(YourType)`
<FromGitter>
<sdogruyol> this needs documentation though
<FromGitter>
<sdogruyol> Hope the Github issue doesn't go flame war
<Papierkorb>
Time to drink some tea @sdogruyol
<FromGitter>
<sdogruyol> Thanks @papierkorb :)
<Papierkorb>
Mh how on earth do I now bind to C++. I could write the name mangling into a macro. That's insane. So maybe I do that. Or I write/auto-gen a C wrapper lib and bind to that. Choices >_>
<Papierkorb>
not to mention Qt's event loop. that will be fun to integrate into the crystal world.
<FromGitter>
<bararchy> Papierkorb, When you get an idea, tell me because there are a few C++ libs I want to bind over also
<Papierkorb>
bararchy, well the macro would be kinda fun, but the c glue lib is easier to port. Though completely auto-generating it through libClang isn't fun. Even with Clang, parsing C++ is a clusterfuck. But maybe it could work by auto-generating from a simpler declaration file. Could be interesting as one needs to rewrite some things in any case (E.g., crystals String <-> QString)
<Papierkorb>
In any case, as far Qt is concerned, I'm mostly/only interested in the GUI parts. using stuff like QNetworkAccessManager (what a name) from non C++/Qt just doesn't feel right.
<FromGitter>
<bararchy> How does Python binds to C++ ? I see that Ruby has issues with it also, but it seems that Python is really ok with it
<Papierkorb>
The C-glue way is the usual approach. Though Python is kinda special in that many C++ users really like Python, so it has actually good bindings both ways.
<Papierkorb>
Well, it's arguably easier to bind from Py compared to Ruby
<hightower3>
A C short is what? Int4?
<Papierkorb>
bararchy, even better, memory management. In Qt, QObjects can have a parent. In that case, they're not controlled through GC anymore. So, one major thing to look out for is that the non-GC and GC worlds play nice. The Crystal proxy class may have to take this into account. Bonus points for modern-ish C++11 libs, which mostly use std::unique_ptr or references, which is even worse w.r.t to binding
<Papierkorb>
hightower3: `Int4` doesn't exist. on many platforms (most likely, all you care about), a short is 2 bytes.
<hightower3>
ah thanks, yeah
<hightower3>
What would 'unsigned char' in C map to in Crystal?
<Papierkorb>
`LibC::UChar`
<Papierkorb>
and all other types analogue to that
<hightower3>
awesome, thanks
<hightower3>
So am I encouraged to convert e.g. ints to LibC::Int or Int32?
<Papierkorb>
the former
<Papierkorb>
that'll always be correct
<hightower3>
ok great, thanks
<hightower3>
How do I specify that something's return value is void*?
<Papierkorb>
literally `Void*`
<hightower3>
If I have "typedef int Handler(Event *event, void *clientdata);", how do I convert that to Crystal? I see there is 'type', but I'm unsure how to apply it here
<Papierkorb>
that typedef looks broken
<Papierkorb>
if it were correct, it'd break down to `alias Handler = Event*, Void* -> LibC::Int`
<hightower3>
It is found in /usr/include/gpm.h line 154
<Papierkorb>
oh they're using a weird notation where they put the * at the use-site
<hightower3>
What's the best way to convert #defines to Crystal? Using macros?
<FromGitter>
<bew> If it's a C macro, then a Crystal macro or method. If it's a C constant, then a Crystal constant is enough
<hightower3>
Right, C macro. Ok great, thanks
<hightower3>
Ok so I now have a fun which takes a pointer to C structure as argument. I've converted that structure to Crystal. Now with the function and with the appropriate struct, how do I make use of it from Crystal; specifically, how do I create/allocate the structure to pass it to the function?
<hightower3>
And in the common case where the structure is used to return data from the C function, how would I convert func(struct*) into something that would allow me to write x = func() rather than func(x)?
<Papierkorb>
the front-end wrapper method allows you to.
<Papierkorb>
that you write
<hightower3>
Ok, sounds good. And how do I allocate the struct? Or how do I prepare the struct so that I can call a lib method with it as argument?
<oprypin>
Papierkorb, if you're serious about making Qt bindings, i'm interested in that
<oprypin>
though as i always say it's not c++ that scares me, but that it's not even simply c++
<Papierkorb>
I used C++/Qt for .. almost 3 years
<Papierkorb>
Has been 3 years since then, but eh, moc isn't that magic really.
<Papierkorb>
Except that it's just plain awful at parsing C++ lul
<oprypin>
when you say it feels wrong to use Qt's networking, well, so it does in Python, but what can you do, if integration for other stuff may not be doable
<hightower3>
Papierkorb, ah, I didn't know I could run #new on custom structs. Did that, used pointerof(), and got it working. Thanks!
<oprypin>
hightower3, when you pass a pointer for that function only to write something to it, that's when you use an `out` argument
<Papierkorb>
oprypin: the GUI stuff is just displaying. networking etc is completely separate from that. The important part is to correctly integrate Qts event loop for it to work properly.
<hightower3>
thanks oprypin
snsei has joined #crystal-lang
hightower3 has quit [Ping timeout: 248 seconds]
snsei_ has joined #crystal-lang
snsei has quit [Ping timeout: 260 seconds]
hightower3 has joined #crystal-lang
<Papierkorb>
Ah man, SWIG can't generate C++ -> C bindings :|
<Groogy>
It can't? that's kind of suprising
<Papierkorb>
indeed
<Groogy>
I mean it's super easy? You just have to make a struct containing reference to the object, wrap function calls on object that converts struct to non-obscured struct and then done?
<Groogy>
or am I missing something which put it way harder for SWIG to autogenerate?
<Groogy>
"In 2008, there was a GSoC project to write a C backend, but that was apparently never completed/incorporated into SWIG."
<Groogy>
maybe that one still works?
<hightower3>
I have \u0020 in a regex and it tells me that PCRE does not support \u. What alternative notation could I use?
saadq has joined #crystal-lang
<hightower3>
(\u being a match for a character with four hexadecimal digits)
<Papierkorb>
Groogy: maintaining swig yourself doesn't sound like a lot of fun
<Papierkorb>
Groogy: Well super easy and C++ isn't what I'd use in the same sentence. Beyond method overloading, just think of templates.
<Groogy>
Well the CSFML binding isn't that fancy
<Groogy>
and you can't bind templates anyway unless they are invoked so
<FromGitter>
<crisward> Is there any performance tooling for crystal, ie creating flamegraphs?
<Groogy>
well there is the Benchmark module? Though guessing you want more than that?
<FromGitter>
<crisward> Groogy, I'm trying to optimise my app. In node it was possible to create flame graphs at runtime, a bit like those in chrome, in fact they are viewable in webkit dev tools. Wasn't sure if LLVM had something similar.
<FromGitter>
<crisward> Thanks for mentioning benchmark, could be good for monitoring code speed during tests to check for speed regressions.
cyberarm has quit [Ping timeout: 260 seconds]
cyberarm has joined #crystal-lang
<FromGitter>
<crisward> Looks like it used to be possible with Mac Instruments... but not any longer.
<Papierkorb>
alex-lairan, what do you need to store?
<FromGitter>
<alex-lairan> I found how, I need to store multiples chars for a gramatical analyser
<FromGitter>
<alex-lairan> But I have a weird question, I need a pointer to know where I am β β How can I do β β ```class Foo β @foo : Int32 = 0 β @pfoo : Pointer(typeof(@foo)) = pointerof(@foo) β end``` ... [https://gitter.im/crystal-lang/crystal?at=597d0944f5b3458e30936e82]
<FromGitter>
<alex-lairan> Papierkorb you work for a GUI?
<Papierkorb>
It generates the C glue lib using an awful generator I wrote based on a YML specification. That same thing could also write the Crystal binding code
<Papierkorb>
alex-lairan, binding to Qt
<FromGitter>
<alex-lairan> Oh ok :)
<hightower3>
I have \u0020 in a regex and it tells me that PCRE does not support \u. What alternative notation could I use?
<Papierkorb>
a space
<hightower3>
Yeah I mean in general :)
<hightower3>
If I don't want to guess specific chars
<hightower3>
Strings do support \u...., so I can define all those chars in a string and then reference them from there
<Papierkorb>
Well .. have you tried the totally non-ugly, perfectly readable `/#{"\u0020"}/` ?
<hightower3>
hehe yeah, I wanted to have some reuse of the chars :-)
<hightower3>
Where do I find Math function floor?
<Papierkorb>
Float#floor
bradleyd has joined #crystal-lang
<hightower3>
Is there a way to pass 'g' flag to Regex.new?
<hightower3>
alex-lairan: before doing if/unless, you need to do something like value= @value, and then to a check/set on value instead of @value
<hightower3>
s/to/do/
<FromGitter>
<bew> you should use: `if @value`
<FromGitter>
<bew> oh true too: `if val = @value`
<hightower3>
and what bew says too... if value, or if value.nil?, depending on your case
<FromGitter>
<alex-lairan> okay, thank :)
<hightower3>
And you don't need []? when assigning. When assigning you need just []=
<FromGitter>
<crisward> I've been profiling my app and I've found one bottleneck is a String#sub I'm using on a large string (14kb). Is there a quicker alternative to sub?
<FromGitter>
<alex-lairan> I can't `pointerof()` an element in array?
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
<hightower3>
alex-lairan: Right, appears not
deep-book-gk_ has joined #crystal-lang
deep-book-gk_ has left #crystal-lang [#crystal-lang]