<FromGitter>
<monouser7dig> > it is not possible to choose ? β β you can have a pointer to some resource thus the pointer gets past by value but the resource is a reference, like if you'd really really need to
<FromGitter>
<imonmyown> Morning!
_whitelogger has joined #crystal-lang
claudiuinberlin has joined #crystal-lang
_whitelogger has joined #crystal-lang
Philpax has joined #crystal-lang
<FromGitter>
<ekremkaraca> Morning guys
rohitpaulk has quit [Ping timeout: 255 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter>
<imonmyown> Guys, would anyone care to mentor not a complete noob on a small project (and perhaps further on)?
<watzon>
imonmyown: What kind of project? Feel free to ask all the questions you need
<watzon>
Oh and hi everyone :) It's been a while
<FromGitter>
<imonmyown> @watzon I want to implement a touch typing tutor, perhaps, I should PM you?
<FromGitter>
<imonmyown> Would be easy if you were on gitter :)
rohitpaulk has quit [Ping timeout: 248 seconds]
<Papierkorb>
Morning
<watzon>
I have gitter, but prefer irc. Anyway, I a touch typing tutor sounds like quite a project and something I doubt I'd have time for
<watzon>
But feel free to ask questions here. This community is pretty active
<FromGitter>
<imonmyown> Oh, ok
<FromGitter>
<bararchy> Morning all :)
rohitpaulk has joined #crystal-lang
<FromGitter>
<imonmyown> The code (https://github.com/imonmyown/y-type) is pretty sloppy, I didn't get to polishing yet. The foundation was derived from CrSFML typing example, just added random text generation so far
<FromGitter>
<imonmyown> I will mark my question with \[Typing Tutor\] tag further on
<FromGitter>
<imonmyown> Would be grateful for suggestions on further work and improvements. As the next step I plan on adding character distribution change based on the delays of the input characters
Philpax has quit [Read error: Connection reset by peer]
unshadow has joined #crystal-lang
<oprypin>
imonmyown, nice to see it being useful. though usually you write a comment where you copied code from :p
ShalokShalom has joined #crystal-lang
ShalokShalom_ has quit [Ping timeout: 248 seconds]
<FromGitter>
<imonmyown> @oprypin, oh, sorry about that man, will fix that :)
<FromGitter>
<imonmyown> I was thinking about a rewrite of most of the functionality, so it didn't occur to me. Sorry again!
<FromGitter>
<monouser7dig> morning π , is there a way of issuing a bash command like rubys 'system' but ideally also getting back the response?
<FromGitter>
<bararchy> @imonmyown but you can't juse it in a var
<FromGitter>
<bararchy> it will just return true\false
<oprypin>
monouser7dig, the hacky way is: a = \`ls\` , the proper way is https://crystal-lang.org/api/0.23.1/Process.html#run%28command%3AString%2Cargs%3Dnil%2Cenv%3AEnv%3Dnil%2Cclear_env%3ABool%3Dfalse%2Cshell%3ABool%3Dfalse%2Cinput%3AStdio%3Dnil%2Coutput%3AStdio%3Dnil%2Cerror%3AStdio%3Dnil%2Cchdir%3AString%3F%3Dnil%2C%26block%29-class-method
<FromGitter>
<monouser7dig> in that case what IO would I set as the output to get it back into the program?
<FromGitter>
<bararchy> @monouser7dig look at my example
<FromGitter>
<monouser7dig> beat me π just in time, thanks
<FromGitter>
<bararchy> keep in mind the size of IO::Memory
<FromGitter>
<bararchy> as in expected output size
<FromGitter>
<monouser7dig> how does %x handle this? (I do not plane to go insane though so it's probably fine)
<FromGitter>
<bararchy> %x will return both STDERR and STDOUT back to the var
<FromGitter>
<bararchy> AFAIK
<FromGitter>
<bararchy> need to test it though :)
<oprypin>
what the hell is %x
<FromGitter>
<bararchy> same as system() but returns output and error back instead of true\false
<FromGitter>
<bararchy> :)
<FromGitter>
<bararchy> it's from Ruby
<FromGitter>
<monouser7dig> I once had two C programs, one was outputting some letters and it was | piped into another which was reading them, and I was also wondering how this even worked in terms of buffer cause the consumer program was definitely slower than the producer, but it worked
<FromGitter>
<bararchy> I agree :) it's just left overs from Ruby
<FromGitter>
<bararchy> like $1
<FromGitter>
<bararchy> etc..
<FromGitter>
<monouser7dig> π lol, it's just hard to read if one is not used to, the ruby people enjoy it for creating arrays afaik
<FromGitter>
<bararchy> all are inturn leftovers frmo perl
<oprypin>
%x is not documented or used anywhere, so there's that
<FromGitter>
<monouser7dig> but I like its output, please keep something like that π it is actually nice and easy
<oprypin>
monouser7dig, instead of %q() use ``
<oprypin>
monouser7dig, instead of %x() use ``
<livcd>
unrelated to crystal...but anyone follows truffleruby ?
rohitpaulk has quit [Ping timeout: 255 seconds]
<FromGitter>
<imonmyown> @livcd who's that?
<livcd>
github.com/graalvm/truffleruby
<FromGitter>
<imonmyown> I see it mentiones Rubinius at the bottom, used to look forward to it...
<FromGitter>
<monouser7dig> yeah will do so β β I think there was something about truffle or graal that was more proprietary than usual?
<livcd>
uh i honestly do not care if smh is proprietary :)
<Papierkorb>
Looked pretty OSS to me
<livcd>
though Oracle being behind it
<livcd>
it's a bit meh
<FromGitter>
<monouser7dig> looking at it again seems pretty normal but I had in mind it was closed + paid
<Papierkorb>
Yeah they'll try to milk it if it ever takes off
<livcd>
nothing wrong with milking it
<livcd>
but oracle is known for screwing up with axing staff and closing projects because they do not sell to fortune100
<Papierkorb>
that's milking to me
<Papierkorb>
Just like they tried with OpenOffice
<Papierkorb>
Just like they tried with MySQL
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzzβ¦]
<Papierkorb>
Look how well those went
<livcd>
Papierkorb: ah ok
<FromGitter>
<monouser7dig> in some video the manas devs left a sentence on running crystal on the JVM and it was like, it's not a really big problem in itself to get that running for some if statements but mainly all libraries just won't work
<Papierkorb>
That'd be switching out the LLVM backend with a JVM one
<livcd>
for me screwing up would be making it too expensive / unaffordable and losing momentum if it ever takes off
<livcd>
i still cant wrap my head around how did they kill solaris and the entire ecosystem
<FromGitter>
<imonmyown> @livcd I believe they screwed up too many things to be trusted again
<livcd>
imonmyown: is there a corporation / medium sized company you trust ? :)
<RX14>
well i trust oracle, it's just that i trust them to do the worst possible thing
<livcd>
Papierkorb: you mean that red hat that refuses to support you if you run centos along rhel in one DC ?
<FromGitter>
<imonmyown> I feel it's okay while it's a medium sized company, but once it goes corporate, it's doomed to turn into pile of shit
<Papierkorb>
monouser7dig, how you do it doesn't matter. Also, JVM, as in: Uses way too many resources and start time is abysmal. So "nah"
<RX14>
the jvm isn't bad
<Papierkorb>
"But the JVM uses memory!" Yeah as does my kernel, thanks a lot
<RX14>
but if you simply replaced llvm with the jvm for crystal
<RX14>
you'd get none of it's benefits
<RX14>
except maybe a better debugger
<RX14>
and java interop
<RX14>
but who cares
<FromGitter>
<bararchy> JIT ?
<Papierkorb>
The benefit being?
<RX14>
LLVM isn't even half the compile time unless --release
<RX14>
so theres no point
<FromGitter>
<bararchy> I'm not for it, just naming Java fetures :)
<RX14>
naming java features doesn't really mean anything...
<FromGitter>
<bararchy> also, would not like to be jailed to "can run on anything which already has java installed"
<RX14>
once LLVM becomes the bottleneck then maybe JIT would be worth looking into for compile times
<RX14>
but it's currently not really one
<RX14>
the complexity needs to be reduced in the typecheck and codegen
<RX14>
and once we reduce the number of instantiations, LLVM compile times will reduce a lot too
<RX14>
since it has less work to do
<FromGitter>
<bararchy> can crystl have JIT ? from my understanding JIT works only for programs running in a VM (ruby, python, java, etc..)
<RX14>
LLVM has a JIT
<RX14>
which is a LVM for interpreting it's IR
<RX14>
VM*
<RX14>
and JIT
<RX14>
like all jits it has an interpreter and a compiler part
<RX14>
the JIT is actually used in the compiler specs
<RX14>
to speed up some of the compiler tests
<RX14>
it just breaks when you require the prelude
<FromGitter>
<bararchy> Oh, didn;t know that, will it means if used, that crystal will only run where LLVM is installed ?
<RX14>
yes
<RX14>
because it'd run inside the compiler process
<RX14>
well
<RX14>
maybe after a fork
<FromGitter>
<monouser7dig> https://www.quora.com/Why-is-there-no-effort-for-making-a-VM-for-LLVM-IR β β > LLVM IR is able to be used for various targets, but the IR itself is not portable. When it is generated, it has hard coded assumptions about the architecture, the OS, and the libraries that it will be used with. β β so JIT would bring no improvements cause the type inference effort is spend in both cases
<FromGitter>
<monouser7dig> the list of files is because system outputs to...the terminal?, in any case your variable does not hold that data, if you remove the print, everything works the same, except the true is missing
<FromGitter>
<imonmyown> @monouser7dig not very clear what you're trying to say
<Papierkorb>
Huh `crystal tool implementations` doesn't support `-`, nor `/dev/stdin` nor a fd path
<Papierkorb>
Always "file does not exist"
<Papierkorb>
I mean, the latter two look like files to me
<FromGitter>
<monouser7dig> how does regex work to extract a match? I used β β ```match = /\w+/.match(some_string) β β branch = match.try &.to_a[0]``` β β but I don't think this is the right way [https://gitter.im/crystal-lang/crystal?at=59da2064f7299e8f53c081e7]
go|dfish has quit [Quit: SIGQUIT]
<Groogy>
is there a nice method on enumerables that lets me test a block on every element? i.e if all of them are true it returns true?
<Groogy>
need to convert this invariant from C++ INVARIANT(std::all_of(self.myTiles.begin(), self.myTiles.end(), [&self](const TileData& tile) { return tile.typeIndex >= 0 && tile.typeIndex < self.myTileTypes.size(); }))
<FromGitter>
<monouser7dig> .each_with_object, a bool and ||= ?
<oprypin>
vegai, all that akzhan is saying is that you have not implemented a hashing method on your type
<vegai>
so what is it using? I'm able to make a hash with BigDecimal keys already
<vegai>
or is this something else
<FromGitter>
<monouser7dig> that is a nice catch π
<oprypin>
vegai, hm that's true, the default hash implementation might actually work
<oprypin>
though ideally you must ensure this invariant: `if a==b then a.hash==b.hash`
<oprypin>
looking at the equality method, that is NOT currently ensured because it is possible for two bigdecimals with diferent bytes in them to be equal
<vegai>
might there be a default hasher that does to_s or something?
<vegai>
ah, I see
<oprypin>
default hasher on Struct just combines .hash of all member variables
<oprypin>
it may be a very difficult task to ensure that but it's really important
<vegai>
yes
<Papierkorb>
oprypin: Update both bindgen & qt.cr, fixed it for me
<oprypin>
thx will try soon
<vegai>
oprypin: thank you
<vegai>
seems to me like a simple correct hasher would be one that first does to_s and hashes from that
<vegai>
even if not very performant
<Papierkorb>
... no?
<vegai>
why not?
<Papierkorb>
#to_s is in no way guaranteed to be a stable, unambigous machine-readable string
<oprypin>
well vegai knows better what this type's to_s does
<oprypin>
i think it's acceptable
<Papierkorb>
What about `def_equals_and_hash`
<oprypin>
Papierkorb, that's just selecting which members to use individually.
<Papierkorb>
Are all sources compiled by the same compiler?
<oprypin>
Papierkorb, qt is precompiled by the compiler that's part of the path, you can see it
<oprypin>
i'm using "Visual C++ 2015 x86 Native Build Tools Command Prompt"
<oprypin>
so hopefully same compiler
<Papierkorb>
Not sure, but there may have been one or two mandatory defines for windows
<Papierkorb>
For Qt
<oprypin>
nvm actually using Visual C++ 2015 x64 Native Build Tools Command Prompt
<Papierkorb>
Do you have qmake around?
<oprypin>
Papierkorb, yeah it's got to be in one of those folders
<Papierkorb>
create a new project with `qmake -project`, add `gui widgets` to the QT variable in the .pro file (if not already in there), then `qmake`, and see the Makefile (or w/e) it created
<Papierkorb>
Try adding these defines to the c++ generator build step: `-DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED`
<Papierkorb>
Dunno if these are required on windows
<Papierkorb>
Mh should I add a default maping from `const char *` to String in bindgen?
<Groogy>
no, since a lot of libs use it as a "any kind of data" sort of pointer
<Papierkorb>
Yeah that's what I'm thinking too
<Groogy>
i.e it should really be void*^but they don't
<Groogy>
and a String is 4 bytes per character
<Groogy>
while char* is only one
<Papierkorb>
Huh it's UTF-8
<Groogy>
isn't char 4 bytes big?
<Papierkorb>
Anyway, don't worry, bindgen does all those conversions :P
<Groogy>
in Crystal
<Papierkorb>
Yes Char is, but String isn't Char*, it's based on UInt8*
<RX14>
Groogy, you seem to misunderstand what utf-8 is
<Groogy>
ah okay nvm then
<RX14>
is a variable length encoding for 4-byte unicode codepoints
<RX14>
char is an expanded codepoint
<Groogy>
I know what it is
<RX14>
string encodes those codepoints as utf-8
<Groogy>
I just assumed because of other languages that String used Char
<Groogy>
internally
<Groogy>
becuase I am dumb
<Papierkorb>
Now, what happens when I bind the whole fucking glibc?
<oprypin>
error
<Papierkorb>
Except for those functions taking a function pointer .. and varargs
<Groogy>
oh also there's an interesting problem and wonder how bindgen would solve it
<Papierkorb>
?
<Groogy>
soooo glVertexAttribPointer have an interesting argument
<Groogy>
the last argument is a void* but it is supposed to be used as a number
<Papierkorb>
I'll try to bind ioctl() and its #defines though. That always annoyed me not having.
<Papierkorb>
You're f'd. Though I was thinking about class- and method local type configuration
<Papierkorb>
Because of such insanity
<Groogy>
but I think it also supportes pointers?
<Groogy>
i.e it is the offset to the data
<Groogy>
and any normal human being specifies an interval
<Papierkorb>
Groogy: Though what I'd actually do is provide a method of the same name manually in Crystal, which calls its sister function, doing a Pointer(Void).new(the_int_value) as conversion
<Papierkorb>
Which is probably the most sane solution to it. That locality feature would be for insane APIs where this is not easily possible from Crystal alone.
rohitpaulk has quit [Read error: Connection reset by peer]
rohitpaulk has joined #crystal-lang
sz0 has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
<oprypin>
Papierkorb, agh i have no idea what i'm doing, appears i have moved the linking error from that stage of compilation to the final stage.
<Papierkorb>
Though if qmake is in the path, iirc you can simply -query it to tell you
<oprypin>
Papierkorb, well the fix is probably on you, but i dont even know a workaround
<Papierkorb>
It's an oversight, it should've tried $QTDIR
<Papierkorb>
l1meon, You can generate the binding by setting the `QTDIR` environment variable to the installation path of Qt5. That won't fix compilation though. For that, in this moment, you'll have to patch ext/Makefile, line 1, the -I, to the correct path
<FromGitter>
<l1meon> Papierkorb, ok, I'll change the line 1. Thx
<FromGitter>
<alex-lairan> Hi, I have compiled Crystal on local to use different LLVM version, but when I compile hello world, I get β β ```code paste, see link``` β β Someone have an idea? :) [https://gitter.im/crystal-lang/crystal?at=59da6bb2210ac26920c00079]
<FromGitter>
<alex-lairan> With the `apt` version, no problems
<oprypin>
alex-lairan, tried installing libpcre-dev and libgc-dev?
<Papierkorb>
platforms is simple enough, just generate it on the target platform. But I can't fake a MSVC in clang
<Papierkorb>
Lol no chrono? What year is it?
<Papierkorb>
oprypin: Platform specific configuration is a solved issue
<oprypin>
cool
<Papierkorb>
`if_os_is_windows: ...`
<Papierkorb>
As far bindgen configuration is concerned
<Papierkorb>
And missing stuff like chrono could be easily emulated for the user with some custom code
<Papierkorb>
in Qt
<oprypin>
yeah but you actually can't generate a Windows-only abstract method, can you
<Papierkorb>
Why not? If you generate on windows?
<oprypin>
sure then
<oprypin>
but how do you then solve "just works"
<Papierkorb>
With some platform detection logic to choose the correctly pre-generated sources
claudiuinberlin has joined #crystal-lang
claudiuinberlin has quit [Client Quit]
<FromGitter>
<HCLarsen> @faustinoaq that's some great info, thanks.
claudiuinberlin has joined #crystal-lang
<FromGitter>
<zyriuse75> i would want to check if the script running is by root or not . i try to use Process.run without sucess :( do you have an idea how i can do that ?
<FromGitter>
<georgeu2000> Does Crystal typically use symbols for keys like Ruby?
<Papierkorb>
You use classes much more often than random hashes as compared to ruby
<Papierkorb>
At least I barely use hashes (only if really required). I can still count the times I used a symbol. There's barely a need
<FromGitter>
<monouser7dig> if you want to use a string as key, then use a symbol cause it's not going to be modified and is smaller but apart from that...depends I'd say
<Papierkorb>
Erm .. a string can't be modified either in Crystal
<Papierkorb>
The distinction made when to use a string vs symbol is the same as in ruby. it's just that crystal code prefers different paradigms to ruby code
<FromGitter>
<georgeu2000> In this use case, I think I may want a "random hash"...
<FromGitter>
<georgeu2000> But I see why Structs are better.
<FromGitter>
<monouser7dig> lol, hadn't even looked at it cause I took it for granted
<FromGitter>
<monouser7dig> still a symbol would be smaller
<Papierkorb>
georgeu2000, do you come from a ruby background?
<FromGitter>
<georgeu2000> Yes.
<FromGitter>
<georgeu2000> That's all I know...
<FromGitter>
<georgeu2000> Hence all the stupid questions...
<Papierkorb>
Then as I said, the decision when to use string vs symbol is the same in Crystal as in Ruby :)
<FromGitter>
<georgeu2000> Got it. Thanks.
<FromGitter>
<georgeu2000> The use case is parsing the response from the JSON API in the specs. I guess the question is, do the specs know about the Structure of the JSON response...
<FromGitter>
<georgeu2000> And they do...so maybe they can use the Struct...
<Papierkorb>
spec is short for specification. You can't specify what you don't know
<Papierkorb>
They absolutely can
<FromGitter>
<monouser7dig> > **<Papierkorb>** Erm .. a string can't be modified either in Crystal β β String#camelcase ?
<Papierkorb>
doens't modify the string itself
rohitpaulk has quit [Remote host closed the connection]
<FromGitter>
<monouser7dig> your right, `Converts underscores to camelcase boundaries.` does not say it though, the other methods say `returns a new string`, good lesson though
<FromGitter>
<HCLarsen> Wait, strings are immutable in crystal?
<Groogy>
GAH WHERE ARE MY WALLS ENDING UP ;_;, I've added so the vertices should be generated and I can see the mbe added but I can't see them
<FromGitter>
<zyriuse75> i would want to check if the script running is by root or not . i try to use Process.run without sucess π do you have an idea how i can do that ?
<Papierkorb>
Groogy: Even if simple, looks like a decent FPS for that scene
<Papierkorb>
HCLarsen, one of the best features of getter must be the block version. Free lazy-initialized values :)
<oprypin>
wait what
<oprypin>
yeah i always forget about that one
<Groogy>
Papierkorb, yeah similar in Ruby would be way way lower
<Papierkorb>
Groogy: And compared to C/C++?
<Groogy>
about the same is my gut feeling
<Groogy>
It is not GPU bound here but CPU bound since it is minimal amount of vertices and only like 1 draw call
<Papierkorb>
yayβ’
<Groogy>
I would also guess that Crystal is doing an excellent job deducing types so most calls doesn't become virtual
<Groogy>
no stats on that though but looking at how some parts with the renderer behaves its what I think
<Papierkorb>
thank you llvm
<Groogy>
typeof(obj) will give me the compile time type right? Not the runtime one?
<Papierkorb>
typeof is compile time, .class is runtime
<Groogy>
huh color me wrong, it seems like this evaluates to the base class, hmm then what was that error I got before....
<Papierkorb>
good night
<Groogy>
good night!
zeno_ has joined #crystal-lang
zeno_ has left #crystal-lang [#crystal-lang]
wazzeno has joined #crystal-lang
<wazzeno>
Hello everyone! I was wondering if anyone could tell me how to use "crystal docs" with the embedded source code snippets like in crystal lang's API docs. Is there anywhere this is documented? (crystal docs --help doesn't seem to do the trick) Thanks!