<FromGitter>
<fridgerator> I see the crystal release is on the front page of HN
<FromGitter>
<dscottboggs_gitlab> ...why? there's like, very little interesting in this release
<oprypin>
it is hinting towards concurrency and Windows
<FromGitter>
<fridgerator> @dscottboggs_gitlab who cares, its free pub
<FromGitter>
<dscottboggs_gitlab> just seemed strange to me.
<FromGitter>
<pitosalas> Hi... quick question...
<FromGitter>
<pitosalas> which cli library do you recommend for a simple cli?
<FromGitter>
<dscottboggs_gitlab> I usually use OptionParser since it's in the Stdlib
<FromGitter>
<dscottboggs_gitlab> I know there are some that offer nicer features though
<oprypin>
mosop/cli
<oprypin>
ehh nevermind
<FromGitter>
<pitosalas> do you have an example of option parser doing a two level command, e.g. like git?
<FromGitter>
<dscottboggs_gitlab> yeah, it wouldn't do that. If you wanted to use optionparser with a CLI with that feature you'd have to manually check `ARGV`
<FromGitter>
<pitosalas> I did read that crystal itself uses option_parser... but m reading of the doc made me think that it didn't easily do two level commands
<FromGitter>
<dscottboggs_gitlab> that's a good point
<FromGitter>
<pitosalas> anyone have a good codesample with commander that would be willing to share?
<FromGitter>
<dscottboggs_gitlab> that's the crystal command line interface
<FromGitter>
<pitosalas> I was looking for that but didn't know which of the many files!! thanks that's great!!
<FromGitter>
<dscottboggs_gitlab> they have a bunch of different OptionParser files for the different subcommands and they manually check ARGV for the commands with a `case...when`
<FromGitter>
<dscottboggs_gitlab> np, it took me a minute to find it too
<FromGitter>
<dscottboggs_gitlab> you wrote it! :p hahahaha
<FromGitter>
<j8r> Nope that's not me. Or do a `.each`
<FromGitter>
<dscottboggs_gitlab> I don't get what's wrong with it?
<FromGitter>
<j8r> I've extracted it from @ysbaddaden repo
<FromGitter>
<dscottboggs_gitlab> ah
<FromGitter>
<j8r> Because you can avoid having this `i` counter
<FromGitter>
<dscottboggs_gitlab> true
<FromGitter>
<dscottboggs_gitlab> but it's convenient
<FromGitter>
<dscottboggs_gitlab> for referencing the next and previous
<FromGitter>
<dscottboggs_gitlab> although if you do .shift then you can use absolute indexes and I agree that's more readable
<FromGitter>
<j8r> No need to previous :)
<FromGitter>
<dscottboggs_gitlab> what if I WANT to!? haha
rohitpaulk has quit [Ping timeout: 252 seconds]
<FromGitter>
<j8r> Store it
<FromGitter>
<j8r> But yeah, the problem with shift it it consumes the array
<FromGitter>
<j8r> But doing += 1 is not really optimized nor cute
<FromGitter>
<j8r> The autobind cli needs to be overhauled
_whitelogger has joined #crystal-lang
thews has quit [Ping timeout: 250 seconds]
thews has joined #crystal-lang
_ore has quit [Remote host closed the connection]
<FromGitter>
<bew> @bcardiff btw what is the `unstable` branch of crystal-website repo?
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 246 seconds]
akaiiro has quit [Remote host closed the connection]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 244 seconds]
rohitpaulk has joined #crystal-lang
I_Right_I has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
<I_Right_I>
Hi, I am new to crystal coming from languages like C,C# and a little Rust. I was wondering if anyone know any example code or tutorials using XML::Reader?
<I_Right_I>
Or would ruby tutorials be equivalent?
<FromGitter>
<swinSpo> hi all
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 246 seconds]
<FromGitter>
<swinSpo> crystal is so interesting..
<FromGitter>
<swinSpo> but the lack of stable v1 is sort of a deal breaker.. will we see a v1 release this year?
I_Right_I has quit [Remote host closed the connection]
<FromGitter>
<dscottboggs_gitlab> @swinSpo not likely. Concurrency works, but Windows and multiprocessing needs work, plus some polish. It's really not bad to use as is, depending on the workload. Would I try to develop a Windows desktop app in crystal righ now? hell no. It's definitely my first choice of language for back-end server-side stuff though.
_whitelogger has joined #crystal-lang
<FromGitter>
<Val> @bew thanks, I'll review your PRs today and fix 0.27 related issues
<FromGitter>
<pitosalas> @j8r Is Clicr yours? Do you have an example with simple subcommands? (Although I am just doing it easy argv/argc way like suggested above :)
<FromGitter>
<Val> Or else Homebrew not updating :-/
<FromGitter>
<kingsleyh> I'm also waiting for 0.27.0 for homebrew for Mac
<FromGitter>
<fusillicode_twitter> I know that is not a solution mates but in the meantime try to see if you can work in a dockerized environment :)
<FromGitter>
<fusillicode_twitter> I mean, try to see if you can test & run your applications in a docker container. There is already a 0.27.0 Crystal version ;)
<FromGitter>
<Val> I prefer to keep my `.travis.yml` as simple as possible
<FromGitter>
<Val> And wait, we are legion =)
<FromGitter>
<Val> tomorrow at work I will change my mind if needed
<FromGitter>
<kingsleyh> It would be nice if the release of binaries to platforms could happen at the same time and in an automated way - rather than some platforms getting it and others having to wait. I don't want to u/g my lib if it will cause Mac users a big pain to use my latest version - since they will have to do workarounds.
<FromGitter>
<j8r> the lib is quite minimal, it saves you the `while ARGV` and `case when` boilerplates :)
<FromGitter>
<j8r> maybe the README has to be improved?
rohitpaulk has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter>
<pitosalas> @j8r yes and no :) It's simple but I have to mentally reverse engineer, e.g. what is possible in that big hash and what each of the options mean. Also Don't see how to do a two level command from the examples.
<FromGitter>
<deansher> I want to create a heterogeneous map type. The idea (somewhat common in languages like Haskell or OCaml) is that the type of the key determines the type of the value: `set(k : HKey(T), v : T) : HMap forall T`. But to do this, I need a single `HMap` instance to be able to internally store any type, or at least any `Reference`. ⏎ ⏎ Unfortunately, the compiler complains when I try to use `Object` or
<FromGitter>
... `Reference`as a type parameter: `can't use Object as a generic type argument yet, use a more specific type`. Trying to wrap with `Pointer` or `Box` doesn't help because I just get the same compiler error at that level. Is there a way to do this in Crystal today?
<FromGitter>
<Blacksmoke16> are all your values custom classes?
<FromGitter>
<deansher> I want `HMap` to be entirely generic -- able to hold any type. Or at least any reference type.
<FromGitter>
<deansher> Hmm -- actually I guess I've also been expecting to be able to have value types as values. E.g. Int32.
<FromGitter>
<j8r> @pitosalas all should b explained in the `README`, there is a simple and complex example. There is also a reference explaining each key in the NamedTuple
<FromGitter>
<j8r> @pitosalas your `case` is reversed: do `case command; when .starts_with? "help"` for example
<FromGitter>
<j8r> Tell me what to do if something miss in the doc, happy to fix that 😄
<FromGitter>
<deansher> Ok, looks like my internal data structure needs to store `Void*`s, which I can create from `Object`s using `Box`. Is this right?
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
I_Right_I has quit [Remote host closed the connection]
<hightower2>
Hey, is there a sort of a guide for porting ruby apps to crystal? (Primarily focused on more advanced topics, of course, like recipes for working around Object#send and so on.)
<hightower2>
(Seems like topic needs updating to 0.27)
<FromGitter>
<j8r> @dscottboggs we can't avoid `!` in advanced conditions, but we can always avoid `unless`. Same for `while` vs. `until` and `loop`. So the beginner has to learn this classic syntax, and one more for `unless` since (s)he will see it. nvm, hat's not a big point,this is opinionated. Do as you wish.
<FromGitter>
<j8r> I prefer `!` than `not`, shorter, more expressive
<FromGitter>
<LtStaffel_gitlab> Hello, my Crystal program won't stop waiting for more input when I use this line of code: num = gets.not_nil!.chomp.to_s
<FromGitter>
<LtStaffel_gitlab> What am I doing wrong?
<FromGitter>
<j8r> what do you want @LtStaffel_gitlab ?
<FromGitter>
<j8r> what is "more input", you want to write something, press enter, write something again, press enter etc?
<FromGitter>
<LtStaffel_gitlab> @j8r I want to get user input as a string, stop at the first \n, and to discard the \n at the end
<FromGitter>
<LtStaffel_gitlab> so write something, press enter once and be done
<oprypin>
something is wrong with your terminal, that code is supposed to work
<FromGitter>
<LtStaffel_gitlab> right now with that line it will wait for input, I'll type something and press enter, and it will just put me on a newline in my terminal and not stop waiting for more
<FromGitter>
<j8r> not related, but you can `num = gets(chomp: true).not_nil!`
<FromGitter>
<LtStaffel_gitlab> Okay
<oprypin>
just use read_line and not gets.not_nil!
<FromGitter>
<LtStaffel_gitlab> Anything I can check with my terminal settings to try and fix it? I'm on Linux Mint 19
<oprypin>
how do you launch the program?
<oprypin>
and have you tried having only that piece of code alone?
<FromGitter>
<LtStaffel_gitlab> from the terminal, like this: "crystal <programename.cr>"
<FromGitter>
<LtStaffel_gitlab> also read_line works
<oprypin>
what do you mean by works?
<FromGitter>
<LtStaffel_gitlab> well now gets.not_nil! works as well, and my definition of works is that I have a line with: num = gets.not_nil! and then I puts num and it prints properly
<FromGitter>
<LtStaffel_gitlab> after I type something and press enter once
<FromGitter>
<LtStaffel_gitlab> what was wrong with that line I had previously?
<oprypin>
nothing. and i bet even that line will work now
<FromGitter>
<LtStaffel_gitlab> okay. Well thanks for being the cardboard programmer! lol
<FromGitter>
<j8r> any other remark :)? Still a draft
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
riceandbeans has joined #crystal-lang
<riceandbeans>
Random question, what would it take to get interest in porting this to other OSes?
<oprypin>
riceandbeans, "this"?
<riceandbeans>
crystal
<riceandbeans>
oprypin: Namely, DragonFly BSD
<riceandbeans>
There's a FreeBSD port, I don't personally have the time at the moment ( nor probably the required skill ), to successfully patch it
<oprypin>
riceandbeans, there is no process. people do it out of personal interest
<oprypin>
i suppose if you could pay full time wage that might also work
<riceandbeans>
:P That I can't quite afford, I'm but a lowly devops guy myself
<riceandbeans>
Truth be told I'd forgotten about the project for a while and someone reminded me
<riceandbeans>
I wouldn't mind donating small amount regularly but I can't afford to pay full time wage
<riceandbeans>
I'll tell you what though
<riceandbeans>
I'll try to figure out, if I can, how to unbreak FreeBSD port to get it on DragonFly
<riceandbeans>
Our ports are based on FreeBSD ports with patches to make it build on DragonFly
<riceandbeans>
If it gets too hairy though I'm probably not going to be able to do it
<FromGitter>
<dscottboggs_gitlab> afaik all you need is the right versions of a few libraries (libssl, libgc, etc) and a crystal binary, then it's just a matter of running `make`
<FromGitter>
<j8r> if it's a new arch you need to create LibC bindings
<FromGitter>
<j8r> then cross compile, then link in the new arch with the exact same library versions
<FromGitter>
<dscottboggs_gitlab> wait, why do you need to create LibC bindings, aren't they in the stdlib?
<FromGitter>
<j8r> i don't know, some may miss. I'm talking in general
<riceandbeans>
It's a new OS so it's more than just get a crystal binary, you can't just boostrap it, you have to be able to port the build
<riceandbeans>
I assume the FreeBSD port is actually able to do something beyond building crystal with crystal, because if it requires the bootstrap too then I have no way to build for my OS
<FromGitter>
<dscottboggs_gitlab> the only way to build crystal is from crystal. The only other way to do it is to build the original crystal version from ruby, then build each successive version until you're at the latest.
<FromGitter>
<dscottboggs_gitlab> I agree it's not ideal, but it's a nifty way of creating a compiled language without having to write a bunch of C.
return0e_ has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
<riceandbeans>
I mean, it's cool, but it's a miserable experience for porting to new OSes :P
<oprypin>
@dscottboggs_gitlab, the part that really sucks is you also have to travel in time through LLVM versions
<FromGitter>
<dscottboggs_gitlab> oh man
<FromGitter>
<dscottboggs_gitlab> I can't even imagine trying to do that. You'd need a couple dozen separate VMs with separate configurations from different time periods
<oprypin>
mm VMs, havent thought of that
<oprypin>
could be a fun project with a distro like ubuntu
<oprypin>
but most others would make it hell
<oprypin>
doesnt apply to non-linux anyway... there was no BSD support in initial versions
_ore has joined #crystal-lang
return0e has quit []
<riceandbeans>
Yeah, this is to target a fork of FreeBSD from like.....15 years ago?
<riceandbeans>
I mean, it's still actively developed but it forked I guess more like 11 years ago, not quite 15
<riceandbeans>
2007
<oprypin>
why is 2007 11 years ago
<riceandbeans>
2018-2007?
<riceandbeans>
Unless this flu has fried my brain more than I think it has.
<oprypin>
the math works out perfectly but i still cannot comprehend it
<riceandbeans>
Funny how age creeps up on you
<riceandbeans>
I realized I was old, but my kids showed me just how old I was
<riceandbeans>
They get hurt and bounce back, I get hurt and have a recovery period
moei has quit [Quit: Leaving...]
dostoyevsky has quit [Quit: leaving]
dostoyevsky has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
<FromGitter>
<dscottboggs_gitlab> so you would *need* to do the bootstrap method then?
<riceandbeans>
You can't bootstrap with something that doesn't exist
<FromGitter>
<dscottboggs_gitlab> why not a binary built for the same arch for linux, with the same versions?
<FromGitter>
<j8r> then cross-compile the compiler for the target triple you aim, then link on it
<FromGitter>
<j8r> but not easy :(
<FromGitter>
<dscottboggs_gitlab> it would be nice if the crystal binary were able to be self-contained, including the libraries.
return0e has joined #crystal-lang
<FromGitter>
<dscottboggs_gitlab> maybe someday
<FromGitter>
<j8r> It is already, statically linked
<FromGitter>
<dscottboggs_gitlab> so you could just drop a crystal binary into any X86 system which has the POSIX libc and it should be able to run, correct?
<FromGitter>
<j8r> the archives already embeds `libgc.a` IIRC
<FromGitter>
<dscottboggs_gitlab> then what makes it so difficult?
<FromGitter>
<j8r> And you need the same Kernel
<FromGitter>
<j8r> same kernel and arch
<FromGitter>
<dscottboggs_gitlab> oh
<FromGitter>
<dscottboggs_gitlab> oh
<FromGitter>
<j8r> you may still run it with degraded performance, through `qemu`
<FromGitter>
<dscottboggs_gitlab> I mean, if your kernel has qemu
<FromGitter>
<dscottboggs_gitlab> the point is trying to run it on a BSD
<FromGitter>
<dscottboggs_gitlab> which isn't a linux kernel, but is still a posix system
<FromGitter>
<j8r> but qemu is emulation, this defeat the purpose of native execution
<FromGitter>
<j8r> cross-compilation is a process done with the Windows port
<FromGitter>
<dscottboggs_gitlab> i see now
<FromGitter>
<dscottboggs_gitlab> So I have a weird thing that's happening to me
<FromGitter>
<dscottboggs_gitlab> I get ⏎ ⏎ ```wrong number of arguments for 'Hash(String, String)#initialize' (given 1, expected 2)``` ⏎ ⏎ when I try to compile a JSON::Serializable class. The error is at a line for a property of type `Hash(String, String)`. [https://gitter.im/crystal-lang/crystal?at=5bdf7fea076992347ab84bf1]
<FromGitter>
<dscottboggs_gitlab> I created a minimal example and the same thing didn't happen
rohitpaulk has joined #crystal-lang
<FromGitter>
<Blacksmoke16> got a same code pen?
rohitpaulk has quit [Ping timeout: 244 seconds]
<FromGitter>
<dscottboggs_gitlab> yeah I'll pastebin it the error alone is a couple thousand lines due to macro expansion
<FromGitter>
<Blacksmoke16> or just put the code in
<FromGitter>
<dscottboggs_gitlab> I think I'm going to go back to using JSON::Mappings. LIke I know you guys like the Serializable feature and want people to use it but the Mapping is just more flexible and useful. If I want to change the way things are handled, I can just replace JSON::Mapping with my own macro and not have to rewrite the whole class.
<FromGitter>
<Blacksmoke16> am semi afk eating atm, but the features should be the same
<FromGitter>
<dscottboggs_gitlab> although, JSON::Serializable would be useful inside a custom macro so it's nice to have both
<FromGitter>
<Blacksmoke16> i.e. afaik everything you can do with the mapping is doable with the Serializable stuff
<riceandbeans>
This isn't linux, this is a BSD, with a kernel that is not ABI compatible with Linux nor with other BSDs like FreeBSD, it's more of a pain than you're hoping for
<FromGitter>
<dscottboggs_gitlab> ouch
<FromGitter>
<Blacksmoke16> bk, also get some other features you dont get with mapping stuff