RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.1 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
<FromGitter> <watzon> GC can be turned off right?
<RX14> @watzon depends what you think we mean by "turned off"
<FromGitter> <watzon> Lol I don't really know. I just get comments from people saying that GC should be optional and I feel like I remember seeing somewhere that it can be disabled at compile time
<RX14> @watzon we mean by GC turned off, that your memory usage just grows.
<RX14> forever.
<RX14> that's what "no GC" means
<RX14> not Rust
<RX14> it means you're fucked
<FromGitter> <watzon> Ahh, so there's no way to handle garbage collection yourself
<FromGitter> <watzon> Is that planned?
<FromGitter> <bew> do you mean "make your own GC" ?
<RX14> the point of having the "no gc" option is ONLY to allow ysbaddaden to work on his new GC out-of-tree
<FromGitter> <watzon> I see haha. I mean the same way that you'd program in C++ with no GC. Handle memory de-allocation yourself.
<FromGitter> <watzon> Not that I'd ever want to do that
<RX14> thing is
<FromGitter> <watzon> But some people see GC as the evil in the world
<RX14> in C++ you know what you're allocating
<FromGitter> <watzon> This is true
<RX14> well no
<RX14> let me phrase that a lot better
<RX14> in Crystal the stdlib is built around GC
<RX14> we use classes everywhere
<FromGitter> <watzon> Right
<RX14> we never deallocate memory manually
<RX14> so no GC will never work
<RX14> because you can't use the stdlib
<RX14> you have to start from scratch
<RX14> and then is it even really crystal without the crystal stdlib?
<RX14> you're programming with half of crystal
<FromGitter> <watzon> So for use to be able to make GC optional we'd need a complete rewrite of the stdlib without GC
<FromGitter> <watzon> Which isn't going to happen obviously
<FromGitter> <aisrael> I like how Rust does it with “ownership” and “borrowing”, except that its syntax became extra verbose (and the whole thing a little more complicated) because of that...
<RX14> that's the limit technically
<FromGitter> <watzon> I do too
<RX14> it's not going to happen on a human basis
<RX14> because the core team won't let it happen
<RX14> @aisrael as I said earlier it's all about the goal of the language
<RX14> crystal doesn't aim to be fast
<RX14> it aims to, in order of importance
<RX14> 1) be safe
<RX14> 2) feel like a dynamic language
<RX14> 3) be fast
<RX14> thats the goals
<RX14> rust's goals are different
<RX14> 1) be safe
<RX14> 2) no runtime/gc
<RX14> 3) be fast
<FromGitter> <watzon> Is @ysbaddaden 's garbage collector being written in C?
<RX14> yes
<FromGitter> <aisrael> I understand. Just saying. I wanted to like Rust, but then it started feeling too much like C++
<RX14> lol
<RX14> making people install 2 toolchains to compile crystal would be a pain
<RX14> so you want to work on crystal
<RX14> oh no
<RX14> you need to install rust AND the crystal compiler
<RX14> that sucks
<RX14> nobody wants that
<RX14> in 5 years if rust compilers come installed as standard
<RX14> sure we can use rust
<RX14> for now? portability and ease of use heavily favours C
jokke has quit [Quit: WeeChat 2.0.1]
<FromGitter> <watzon> Unfortunately. I'm rooting for Rust and Crystal
<FromGitter> <watzon> I'd love to live in a world without C++
<RX14> yeah me too
<FromGitter> <watzon> Will it ever happen? Probably not
<FromGitter> <watzon> But a dev can dream
<RX14> rust's more probable haha
<FromGitter> <watzon> Definitely haha. Although Crystal would make me happier. Such a beautiful language
<FromGitter> <watzon> Especially compared to Rust and C++
cremes has joined #crystal-lang
hightower has quit [Ping timeout: 246 seconds]
cremes has quit [Quit: cremes]
cremes has joined #crystal-lang
cremes has quit [Quit: cremes]
cremes has joined #crystal-lang
cremes has quit [Quit: cremes]
DTZUZU has quit [Ping timeout: 252 seconds]
qard has joined #crystal-lang
<FromGitter> <Dillybob1992> @watzon i did a couple ROT26 rotations today with my users table. worked great! passwords are safely secure
cremes has joined #crystal-lang
cremes has quit [Client Quit]
_whitelogger has joined #crystal-lang
<FromGitter> <fridgerator> hey
aroaminggeek has joined #crystal-lang
qard has quit [Quit: qard]
DTZUZU has joined #crystal-lang
jnyw has joined #crystal-lang
aroaminggeek has left #crystal-lang ["Textual IRC Client: www.textualapp.com"]
ua has quit [Ping timeout: 240 seconds]
ua has joined #crystal-lang
<FromGitter> <bararchy> RX14 did you tweet about compiling the compiler for windows ?
hightower has joined #crystal-lang
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
hightower has quit [Ping timeout: 252 seconds]
jnyw has quit [Ping timeout: 276 seconds]
<livcd> Crystal does not aim to be fast ?
<oprypin> livcd, where did that come from
<livcd> oprypin: RX14 :)..but taken out of the context of that discussion
<oprypin> so pls dont take it out of context
<livcd> oprypin: he said it does not aim to be fast the most important things are 1) safety 2) feeling like dynamic lang 3) being fast
<oprypin> ok well that's just badly worded even with context "crystal doesn't aim to be fast"
<oprypin> feel free to ignore that line. i'm sure it was meant as "it's not #1 priority"
<oprypin> which is expanded upon in the 3-point list
hightower has joined #crystal-lang
alex`` has joined #crystal-lang
alex`` is now known as alexherbo2
alexherbo2 is now known as alex``
hightower has quit [Ping timeout: 248 seconds]
jnyw has joined #crystal-lang
<FromGitter> <asterite> Hmm... Crystal is designed around being able to be fast. But it doesn't always succeed (many memory allocations in some cases). But there's always an (uglier) way to avoid those memory allocations
<FromGitter> <asterite> And maybe no_gc should be called leak_mode to avoid confusion. Crystal will always have a GC, that will never change
hightower2 has joined #crystal-lang
jnyw has quit [Quit: WeeChat 2.0.1]
hightower3 has quit [Ping timeout: 246 seconds]
<RX14> Well I've always said that I'd use crystal even if it was the same speed as ruby
<RX14> I'm glad it's not
<RX14> But I value the design and safety far far more than the speed
<RX14> Plus most of our effective speed for io bound applications comes from the concurrency design, not the speed of executing code itself
<RX14> There are evented io frameworks for ruby that showcase such a speed gain
<RX14> Just in crystal its the default
<FromGitter> <bramhaag> I'm getting an interesting error https://hastebin.com/alidoxomur.cr
<FromGitter> <bramhaag> It says there is no overload with type `IO::ByteIterator(TCPSocket)`, but there is?
<FromGitter> <drosehn> "leak mode" doesn't sound too scary. Maybe "memory skyrockets mode" or "memory out-of-control mode".
<FromGitter> <drosehn> @bramhaag At first glance that does seem strange. I think we need to see more of the code. disclaimer: I'm not really awake yet...
<FromGitter> <bramhaag> https://hastebin.com/ogomulisuy.rb, it works when removing the explicit type hint though so not that big of a deal anymore
_whitelogger has joined #crystal-lang
<crystal-gh> [crystal] chris-huxtable closed pull request #5629: Adds `Array#prepend` and `Array#append`. (master...append-prepend) https://git.io/vNV8P
<FromGitter> <sptorin_twitter> Hello to all. Exist some good tutorial or Crystal-Book with examples?
cremes has joined #crystal-lang
Ven`` has joined #crystal-lang
cremes has quit [Quit: cremes]
<FromGitter> <vrinek> hi, I'm trying to write a `from_json` for an object that gets deserialized from a tuple-like array which looks like `[1455528030,500.0,600.0,510.0,550.0,120.0]` (the `to_json` was easy). Does anyone have some time to lend a hand?
<FromGitter> <vrinek> check https://gist.github.com/vrinek/d032b59a16e4369b95ccef5a87beace9 if you wanna check my progress
<Papierkorb> Why are you writing your own from_json?
<FromGitter> <vrinek> I tried with `JSON.mapping` but I could not figure out how to express a tuple-like array in it
<Papierkorb> `def to_json(b); { @low, @high, ...}.to_json(b); end`
<Papierkorb> `def new(pull); t = Tuple(Float64, ...).new(pull); @low, @high, ... = t; end`
<Papierkorb> *def initialize
<FromGitter> <vrinek> thx Papierkorb! how should I add the `time` to `to_json` which has to use the Time::EpochConverter?
<FromGitter> <vrinek> actually, nvm about the `to_json`, `from_json` is being difficult :-(
<Papierkorb> I'd probably just do the ISO8601 conversion myself
<FromGitter> <vrinek> I agree, but the JSON is coming from an API I have no control over ;-)
<FromGitter> <vrinek> ok, I had a typo in my `def initialize` now it works just fine
<Papierkorb> Yeah, so? Just do what the epoch converter would do
<Papierkorb> shouldn't be more than a one liner
sc0per31 has joined #crystal-lang
<FromGitter> <vrinek> ok, got it working, not exactly a one-liner but gets the job done and it's pretty simple to understand https://gist.github.com/vrinek/d032b59a16e4369b95ccef5a87beace9
<Papierkorb> You can shorten later parts to `@low, @high, ... = t[1..-1]`
<sc0per31> hello. I have a problem. I want to define a variable which contains Time.now in the first line of my program. And I want to use this variable then in my initialize() in my class. (thats the point where the actuall program starts). But it says the variable I defined in the first line of the program undefined when I use it in the initialize(). What should I do? Im trying to measure the time how long it has taken to start.
<Papierkorb> sc0per31: Use a constant
<sc0per31> huh? Why is a constant working?
<RX14> because they have different scopes
<sc0per31> and what if i want to change the value? Is there no way then?
<RX14> top-level constants are available anywhere
<Papierkorb> Constants are runtime constant, not necessarily compile-time constant.
<RX14> top-level lcoa vars are available only in the top-level
<RX14> local vars*
<sc0per31> so theres no way if I want to change this value? thats really bad.. i hope crystal will change that. So that you can define instance variables and class variables at top level
<sc0per31> because limitation are never good for a dev
<Papierkorb> That'll hopefully never change.
<Papierkorb> Because writing `class_property` in any class is really easy.
<FromGitter> <vrinek> @Papierkorb: Tuple does not seem to like ranges: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5a6df24cae53c159034638fc]
<sc0per31> you mean its possible with class_property? I will look at it
<Papierkorb> vrinek, oh yeah right.
<sc0per31> Papierkorb: hm it doesnt looks like you can use top level vars in classes with "property"
<Papierkorb> No, cause that'd be weird.
<Papierkorb> You can't even do that in Ruby
<sc0per31> ah.. so its impossible.. thats sad man
<Papierkorb> > "in any class"
<Papierkorb> toplevel is not a class.
<sc0per31> i know
<sc0per31> it would be really weird if toplevel is a class
<Yxhuvud> Why?
<Yxhuvud> It is a design choice just as any other. I wouldn't find it weird, just different to the current choice.
<FromGitter> <asterite> Define a class, use class_property and you are done. In Ruby you would use a global variable. Also, to measure elapsed time, use Benchmark, or at_exit (and there you can use the top level variable because it's captured in the block)
<FromGitter> <asterite> There are many ways to do what you want
<dragonkh> hey - what is Crystals version of string append from Ruby - e.g. name = "dragon" ; name << "kh"
<dragonkh> I gues name = name + "kh" - works just fine
<Yxhuvud> strings in crystal are immutable, so << is out.
sc0per31 has quit [Ping timeout: 260 seconds]
<dragonkh> ok thanks
<Papierkorb> Also see `String.build`
<dragonkh> I'm converting some ruby to crystal - but stuck again with pack
<dragonkh> bytes = self.pbkdf2_sha256(password, salt, 1, p * 128 * r) ; b = bytes.unpack("V*")
<dragonkh> how would I do that in Crystal ?
<Papierkorb> What is 'V'?
<dragonkh> V | Integer | 32-bit unsigned, VAX (little-endian) byte order
moei has joined #crystal-lang
hightower has joined #crystal-lang
vivus has joined #crystal-lang
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
[spoiler] has joined #crystal-lang
duane has quit [Ping timeout: 256 seconds]
<FromGitter> <MrSorcus> Hi all. Little question. How to send http request via socks5 proxy? ⏎ https://gist.github.com/MrSorcus/23afc3e34c4f0f06ab93986dc8973002 - here simple socks5 client and looks like that's working... ⏎ But i understand how to use this with `HTTP::Client` X-) ⏎ Thanks. [https://gitter.im/crystal-lang/crystal?at=5a6e23a65a9ebe4f75e735ff]
<FromGitter> <codenoid> morning
<FromGitter> <MrSorcus> @codenoid evening :-D
<FromGitter> <codenoid> :D 02:31 here (GMT 7)
<FromGitter> <MrSorcus> @codenoid 22:33 (UTC+3) :-D
alex`` has quit [Quit: WeeChat 1.9]
alex`` has joined #crystal-lang
thews has quit [Ping timeout: 256 seconds]
thews has joined #crystal-lang
thews has quit [Changing host]
thews has joined #crystal-lang
dragonkh has quit [Quit: Textual IRC Client: www.textualapp.com]
ua_ has joined #crystal-lang
ua has quit [Read error: Connection reset by peer]
dragonkh has joined #crystal-lang
<FromGitter> <codenoid> hi, is crystal support to do this https://gist.github.com/codenoid/941be6a0f7f46f28b372afe0e0c62e29
alex`` has quit [Quit: WeeChat 1.9]
cremes has joined #crystal-lang
dragonkh has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
Ven`` has joined #crystal-lang
Ven`` has quit [Read error: Connection reset by peer]
Ven`` has joined #crystal-lang
thews has quit [Ping timeout: 264 seconds]
thews has joined #crystal-lang
thews has joined #crystal-lang
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <watzon> Sorry @codenoid I'm not understanding your question. Are you asking if you can do what that Python code is doing in Crystal?
<FromGitter> <watzon> If so the answer is definitely yes. If you want an API similar to Python's Requests library I'd recommend Halite (https://github.com/icyleaf/halite)
<oprypin> nice
<FromGitter> <watzon> What's the crystal app that helps with generating bindings for C libraries?
<RX14> there's like
<RX14> 4
<FromGitter> <watzon> I can never find it when I need it
<FromGitter> <watzon> Lol. Well name one or two if you could
<FromGitter> <watzon> I need some mother loving ffmpeg bindings in Crystal
<RX14> there's bindgen by papierkorb
<RX14> I consider that the most featureful
<RX14> and Papierkorb will probably help you when you get stuck
<RX14> and then theres another one
<FromGitter> <watzon> Damn. Papierkorb knows how to write a README
<RX14> which is more
<RX14> it's simpler
<RX14> it's for C
<RX14> and it's easier to get started with
<RX14> but less features
<FromGitter> <watzon> Yeah I think I'll go with bindgen. ffmpeg is going to be a bitch, but it's worth it
<RX14> actually i'm not sure if bindgen ever works completely without a generated wrapper script
<RX14> Papierkorb?
<RX14> well actually I hope Papierkorb's asleep
<RX14> try it out
<FromGitter> <watzon> What do you mean by a generated wrapper scrypt?
<FromGitter> <watzon> script* fuck I've been doing too much crypto stuff lately
<FromGitter> <MrSorcus> https://gitter.im/crystal-lang/crystal?at=5a6e23a65a9ebe4f75e735ff - can someone help please?