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
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<FromGitter> <j8r> I was reading about LLVM ARC https://en.m.wikipedia.org/wiki/Automatic_Reference_Counting
snsei has quit [Ping timeout: 252 seconds]
<FromGitter> <j8r> What do you think about this technology? Can it have a place in Crystal?
snsei has joined #crystal-lang
<FromGitter> <j8r> The main issue of ARC vs GC is the handling of retain cycles
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 264 seconds]
return0e has joined #crystal-lang
Guest93774 is now known as lemur
lemur has quit [Changing host]
lemur has joined #crystal-lang
lemur is now known as baweaver
snsei has quit [Remote host closed the connection]
<FromGitter> <faustinoaq> @j8r Oh, nice, I found this: ⏎ ⏎ > modern GC's are usually much more advanced using an object generation system, tri-color sets etc, and also perform other tasks such as defragmentation of the program's memory space by moving the objects to a contiguous storage space, this is the reason why GC'ed languages such as C# and Java do not allow pointers. One significant weakness of tracing garbage collectors
<FromGitter> ... is that class destructors are no longer deterministic, that is the programmer cannot tell when an object is going to be garbage collected in-fact GC'ed languages do not even allow the programmer to specify a class destructor, thus classes can no longer be used to encapsulate the management of resources such as file handles, da ... [https://gitter.im/crystal-lang/crystal?at=5aab0f0b27c509a77469e7aa]
snsei has joined #crystal-lang
<FromGitter> <faustinoaq> ^ So, that's why RX14 and some other advanced crystal developers warning us about using Pointer and unsafe things 😅
<FromGitter> <faustinoaq> limiting those features for binding c stuff
<RX14> i think you attribute far too much foresight to us
<RX14> it was always for the stated reason: not even experienced C devs can use pointers without introducing security issues
<RX14> so it's exremely unelike that you can either
<RX14> unlikely*
<FromGitter> <faustinoaq> 👍
<FromGitter> <faustinoaq> Hey, RX14 how is going your in college? :)
<RX14> OK
snsei has quit [Ping timeout: 245 seconds]
<FromGitter> <faustinoaq> Have you tried to use crystal on some college projects? I convinced some of my professors to try it 😅
<RX14> no
<RX14> our projects aren't done in a way where that's possible
<RX14> and thats not a criticism
<FromGitter> <faustinoaq> Oh, My concurrent programming professor tried to use crystal and He returned back to Java after some days XD
jxv has joined #crystal-lang
ic_asm has left #crystal-lang [#crystal-lang]
jxv has quit [Quit: string can snapped]
hightower2 has quit [Ping timeout: 246 seconds]
hightower2 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
<FromGitter> <aisrael> ☝️ Maybe because Crystal *can't* do *real* concurrency at all, yet?
<FromGitter> <bew> it does concurrency very well, just not parallelism
<FromGitter> <aisrael> Ok, point taken :)
andrewzah has joined #crystal-lang
Disrecollection has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <Blacksmoke16> o/
<FromGitter> <Blacksmoke16> is there a constant for infinity?
<FromGitter> <Blacksmoke16> im thinking no
andrewzah is now known as andreizah
<FromGitter> <bew> there is `Float32::INFINITY` (same for `Float64`), why do you need this?
<FromGitter> <PlayLights_twitter> Yes why would somebody need that?
toxedvirus is now known as txdv
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <watzon> @PlayLights_twitter https://carc.in/#/r/3qje
<FromGitter> <watzon> Basically the same as with Ruby http://nithinbekal.com/posts/ruby-infinity/
<FromGitter> <watzon> You can also do fun stuff like thishttps://carc.in/#/r/3qjh
<FromGitter> <watzon> Although why you'd do that I don't really know
<FromGitter> <ezrast> The latter is useful-ish for things like `(0..Float64::INFINITY).find{ |n| some_condition(n) }`
rohitpaulk has joined #crystal-lang
<FromGitter> <watzon> This is true
rohitpaulk has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 246 seconds]
<FromGitter> <bararchy> rand(0..Float64::INFINITY)
<FromGitter> <bararchy> Haha
Groogy has quit [Disconnected by services]
Groogy_ is now known as Groogy
Groogy2 has joined #crystal-lang
<Groogy> Morning! o/
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
DTZUZO has quit [Ping timeout: 264 seconds]
<FromGitter> <bararchy> Morning Groovy
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 246 seconds]
early has quit [Quit: Leaving]
alex`` has joined #crystal-lang
early has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter> <KINGSABRI> Hello guys
<FromGitter> <KINGSABRI> Is there anyone here works in information security field?
<FromGitter> <watzon> Wooo
<FromGitter> <KINGSABRI> I wanna introduce Crystal to information security community and I might need more help
<FromGitter> <KINGSABRI> @watzon URL plz
<FromGitter> <KINGSABRI> @watzon 👍
rohitpaulk has quit [Ping timeout: 256 seconds]
<FromGitter> <j8r> I've found an issue: `puts "\ta\tb\t".squeeze('\t') #=> "ab" ` - normal?
<FromGitter> <j8r> i `squeeze` when i`File.read` a file, no problem. But from a string, niet. I think it's an encoding problem
<FromGitter> <straight-shoota> what's the issue?
<FromGitter> <straight-shoota> `squeeze` replaces consecutive occurences of a character with a single one
<FromGitter> <straight-shoota> if the string has only single occurences, it will not change
<FromGitter> <straight-shoota> ```"\t\t\ta\tb".squeeze("\t") # => "\ta\tb" ⏎ "\ta\tb".squeeze("\t") # => "\ta\tb"``` [https://gitter.im/crystal-lang/crystal?at=5aab9c936f8b4b994632f8f0]
<FromGitter> <j8r> I'haven't undertand this, ok thanks!
rohitpaulk has joined #crystal-lang
<FromGitter> <KINGSABRI> guys, this first script in Crystal , very simple and ported from Ruby ⏎ https://gist.github.com/KINGSABRI/cf45e054d91ff8821acd99561c42c9d2
<FromGitter> <KINGSABRI> during compiling `crystal build file.cr` ⏎ I'm getting error ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aab9ef56f8b4b994633053d]
<FromGitter> <straight-shoota> @watzon have you seen https://github.com/olbat/icu.cr ?
rohitpaulk has quit [Ping timeout: 256 seconds]
<FromGitter> <j8r> I've used `delete` ans then `squeeze` :)
<FromGitter> <straight-shoota> It's similar to cadmium, but not a native Crystal implementation
<FromGitter> <straight-shoota> @KINGSABRI `payload` is a JSON::Any which can't be used as an argument to `Base64.encode`
<FromGitter> <straight-shoota> you should probably use `payload.as_s`
<FromGitter> <KINGSABRI> Ahaaa
<FromGitter> <KINGSABRI> is there any thing list Pry in crystal ?
<FromGitter> <KINGSABRI> this will make things easier
<FromGitter> <straight-shoota> not really
<FromGitter> <straight-shoota> crystal is compiled so you can't modify the code at runtime
<FromGitter> <KINGSABRI> I understand, and thanks for clarify this ⏎ but it can be something list instant compilation or so, correct me
<FromGitter> <straight-shoota> there is ICR but it essentially recompiles and reruns the code every time you run a command. so it's not instantly and can have unexpected results
<FromGitter> <straight-shoota> theoretically, yes. but a compiled crystal program doesn't have any reference of classes, methods, variable names etc. the high-level structure is all gone
<FromGitter> <KINGSABRI> I see, I have to figure an easy way to do so. ⏎ and yeah I have to adapt with compiled langauge more, I use Ruby all the time so I should not trade Crystal as Ruby
<FromGitter> <straight-shoota> usually you can get quite far with `pp`
<FromGitter> <alex-lairan> `gdb` working with crystal? if yes, it could be a cool trade off
<FromGitter> <straight-shoota> yes
<FromGitter> <straight-shoota> I never really had to use it though
<FromGitter> <alex-lairan> ok, @KINGSABRI you can learn `gdb`, it's had in a first time, but it's a good tool
<FromGitter> <KINGSABRI> I know gdb but I never had to use it for coding, only for security research
<FromGitter> <KINGSABRI> good point though
<FromGitter> <KINGSABRI> does visual studio code has compile option for crystal ?
<FromGitter> <KINGSABRI> I installed the crystal plugin but I can see any different it works as text editor more than IDE in crystal
rohitpaulk has joined #crystal-lang
return0e has quit [Ping timeout: 264 seconds]
rohitpaulk has quit [Ping timeout: 246 seconds]
alex`` has quit [Quit: WeeChat 2.0.1]
rohitpaulk has joined #crystal-lang
<FromGitter> <Blacksmoke16> @bew Thanks i must have missed that
yargl has joined #crystal-lang
yargl has quit [Client Quit]
<FromGitter> <Blacksmoke16> im doing a crystal implementation of the Simplex LP algorithm, and i use infinity to show that the the RHS value is either negative or 0, i.e. unsolvable, so that i can have an easy `raise "Problem has no solution with given criteria" if ratios.all?(&.infinite?)`
<FromGitter> <Blacksmoke16> is there a reason why `.infinite?` is only on Float, and not Number so it can be used with Ints?
Disrecollection has joined #crystal-lang
<FromGitter> <KINGSABRI> @bew yes
DTZUZO has joined #crystal-lang
<RX14> @Blacksmoke16 integers don't have a concept of infinity...
<FromGitter> <KINGSABRI> ```code paste, see link``` ⏎ ⏎ Why expecting array? [https://gitter.im/crystal-lang/crystal?at=5aabbdfca60157d62ff40af5]
<FromGitter> <KINGSABRI> I already convert it to hash
<RX14> it's not to_h
<RX14> it's as_h
<RX14> to_h is defined by Enumerable, which thankfully isn't implemented by JSON::Any any more
<RX14> so next release you just would have gotten a undefined method error
<FromGitter> <KINGSABRI> would explain why it's better to be `.as_h` ?
<FromGitter> <KINGSABRI> trying to understand how the language thinks , not the syntax
<RX14> because it's already a hash
<RX14> so you're just asserting that it's a hash
<RX14> not converting
<RX14> so it's called as_h not to_h
<RX14> it's clearly not the right method
Disrecollection has quit [Ping timeout: 276 seconds]
<FromGitter> <KINGSABRI> I see
<FromGitter> <KINGSABRI> thanks @RX14
<FromGitter> <KINGSABRI> @RX14 but when I do ⏎ ⏎ ```json["payload"] = "1111"``` ⏎ ⏎ it returns an error bcz json is `JSON::Any` not hash [https://gitter.im/crystal-lang/crystal?at=5aabc390458cbde5573ff5df]
<RX14> yeah
<RX14> JSON::Any itself isn't mutable
<RX14> but you can do json.as_h["payload"] = "1111"
<FromGitter> <KINGSABRI> aha , I see
<RX14> typically you'd want to avoid JSON::Any where possible though
<FromGitter> <KINGSABRI> I was confused because in Ruby, JSON.parse returns a hash be default
<RX14> JSON::Any is just a hack to enable JSON.parse in crystal to be usable
<RX14> but for faster and more robust parsing you usually use JSON.mapping and from_json on various objects
<FromGitter> <KINGSABRI> > **<RX14>** typically you'd want to avoid JSON::Any where possible though ⏎ I do `JSON.parse(ARGV[0])` and it returns `JSON::Any` already
<RX14> yes
<ilovezfs_> wtf
<RX14> most people don't use JSON.parse
<FromGitter> <KINGSABRI> > **<RX14>** most people don't use JSON.parse ⏎ Sorry no arguing here, but I do see most of people are using JSON.parse, in Ruby
<RX14> in ruby sure
<RX14> but not crystal
<RX14> they're very different languages
<FromGitter> <alex-lairan> 👍
<FromGitter> <alex-lairan> You can build schema, it's more efficient, and sure :)
<RX14> typically you already know the structure of your JSON before you parse
<FromGitter> <KINGSABRI> I agree, maybe I still didn't see a lot of Crystal code out there to change my behavior
<FromGitter> <KINGSABRI> > **<RX14>** typically you already know the structure of your JSON before you parse ⏎ ⏎ Typically, yes, but is't not the case all the time since most of my code for security proposes
<RX14> no it's not the case all the time
<RX14> that's why I said typically :)
<RX14> if JSON::Any was useless we'd remove it from the language
<RX14> but if you can use JSON.mapping instead it's usually better
<RX14> it's far more type safe and easy to use
<RX14> since you just define your objects and get a bunch of objects out instead of JSON::Any
Disrecollection has joined #crystal-lang
duane has quit [Ping timeout: 264 seconds]
<FromGitter> <j8r> Would be nice an auto mapping :)
<RX14> someone write a tool for that
<FromGitter> <j8r> Oh yes he has spoken to me about this, but not exactly what we need: it's written in Javascript, we will need to rewrite it in Crystal
<RX14> why
<FromGitter> <j8r> to modify unknown in advance/changing jsons
<RX14> But how
<RX14> You can't eval the generated crystal code
<FromGitter> <j8r> yes :/
<RX14> Besides it doesn't matter because you can generate the mapping but that's useless without any code to use the mapping
<RX14> And that code still needs to be written by a human
<RX14> And is dependant on the mapping
<RX14> So it's pointless
<RX14> A web tool is fine
alex`` has joined #crystal-lang
<FromGitter> <j8r> you're right. I was finding a way to avoid writing huge mappings that constantly change
<RX14> but why do they constantly change??
<FromGitter> <j8r> I was exaggerating a bit , but I take a bunch of upstream projects, that have their JSON configurations/API. They often do micro changes here and here
rohitpaulk has quit [Ping timeout: 240 seconds]
Disrecollection has quit [Ping timeout: 252 seconds]
<FromGitter> <picatz> This is really awesome @watzon ! https://watzon.me/projects/json-to-crystal
Disrecollection has joined #crystal-lang
<FromGitter> <fridgerator> ^
DTZUZO has quit [Ping timeout: 245 seconds]
duane has joined #crystal-lang
<FromGitter> <alex-lairan> awesome :o
Disrecollection has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <KINGSABRI> > **<RX14>** https://watzon.me/projects/json-to-crystal
<FromGitter> <KINGSABRI> I mean the language is new and we fix some the things that people think is hard/suffering from the begging
<FromGitter> <faustinoaq> > rand(0..Float64::INFINITY) ⏎ > Haha ⏎ ⏎ haha XD [https://gitter.im/crystal-lang/crystal?at=5aabcfb68f1c77ef3ac9fa1a]
<FromGitter> <alex-lairan> @KINGSABRI it's a tool like any other tool. ⏎ ⏎ If you have to get a huge JSON (from facebook or AWS for example), it's cool to have a tool who generate this for you.
<FromGitter> <faustinoaq> > I installed the crystal plugin but I can see any different it works as text editor more than IDE in crystal ⏎ ⏎ @KINGSABRI The vscode-crystal-lang extension is just for highlighting, formatting, diagnostics and some other code writing capabilities. ⏎ ⏎ Debugging crystal generated binaries isn't supported yet, so you should use other debugging extensions like native-debug
<FromGitter> <faustinoaq> https://amberframework.org/guides/recipes/debugging/vs-code-debug.md#vs-code-debug ⏎ ⏎ ^ Also I wrote a mini guide to debug amber projects using GDB
<FromGitter> <faustinoaq> ...and VSCode
<FromGitter> <faustinoaq> You can use only `gdb` via terminal as well
<FromGitter> <KINGSABRI> @alex-lairan thanks man!
<FromGitter> <faustinoaq> Oh, check supported features here: https://github.com/crystal-lang-tools/vscode-crystal-lang/wiki/Features
<FromGitter> <KINGSABRI> 👍 ✨
<FromGitter> <KINGSABRI> @faustinoaq amber framework seeps interesting too!
<FromGitter> <faustinoaq> BTW, some nice crystal developers and me are working on scry (https://github.com/crystal-lang-tools/scry) ⏎ ⏎ Scry is an implementation of Language Server Protocol (https://microsoft.github.io/language-server-protocol/) ⏎ ⏎ That will allow us to give crystal support to almost all popular editors and IDEs ... [https://gitter.im/crystal-lang/crystal?at=5aabd839a60157d62ff49ced]
<FromGitter> <KINGSABRI> 😍
<FromGitter> <faustinoaq> You also can use scry on vscode-crystal-lang ⏎ ⏎ See: https://github.com/crystal-lang-tools/vscode-crystal-lang/wiki/Settings#server ⏎ ⏎ ^ ( ⚠️ experimental yet ) [https://gitter.im/crystal-lang/crystal?at=5aabd8cc6f8b4b99463440ec]
<FromGitter> <KINGSABRI> I'll try it, I would love to see this while learning Crystal
<FromGitter> <KINGSABRI> Just need more time before I introduce it to the info sec community
<FromGitter> <faustinoaq> Currently vscode-crystal-lang is implemented on Node.js ⏎ I think in the future I can replace it by scry ⏎ Actually scry is pretty small (aprox. 1MB with stripped symbols), so I can try to embed it on the extension, providing new awesome features without user intervention required 🎉
<FromGitter> <KINGSABRI> i love that
<FromGitter> <faustinoaq> > Just need more time before I introduce it to the info sec community ⏎ ⏎ Oh, nice, if they want to see a fast introduction try https://learnxinyminutes.com/docs/crystal/ ⏎ ⏎ BTW, There is NeuralLegion (https://www.neuralegion.com/) (ping @bararchy) a company about security that uses nextploit, their core tool/product made in crystal ... [https://gitter.im/c
<FromGitter> ... rystal-lang/crystal?at=5aabdbd5a60157d62ff4b331]
<FromGitter> <KINGSABRI> general question here, is Windows support is close? no close plan,yet?
<FromGitter> <faustinoaq> Windows support is on going, mainly by community (RX14 @straight-shoota, @txe and other enthusiast ) ⏎ ⏎ Windows port is hard and requires a lot of time and work, see progress here: https://github.com/crystal-lang/crystal/issues/5430
<FromGitter> <KINGSABRI> of course, all respect to their efforts
benharri has quit [Quit: The Lounge - https://thelounge.github.io]
benharri has joined #crystal-lang
<FromGitter> <bararchy> @KINGSABRI hi dude, awesome to see more infosec people coming to Crystal, seeing your answer regarding gdb I guess you're an exploit developer?
<FromGitter> <bararchy> Oh, you're the author of rubyfu, mad respect then :)
Disrecollection has joined #crystal-lang
<FromGitter> <KINGSABRI> @bararchy hello there! yes, and I want to make something like Rubyfu book for Crystal ⏎ But I need to know the language first
<FromGitter> <KINGSABRI> @bararchy thanks man, glad you like it. ❤️
<FromGitter> <bararchy> That would be great indeed
<FromGitter> <KINGSABRI> yeah, I think Go is going viral in infosec community due it's speed. But when I found Crystal I think there is no way to go with Golang
<FromGitter> <Sevensidedmarble> I think windows supports going to be a huge boon to crystals adoption
<FromGitter> <KINGSABRI> Crystal is so fast as much as I understand I saw from benchmarks
<FromGitter> <KINGSABRI> @Sevensidedmarble yeah indeed , as this community still young, I really encourage the community to do spread the language and not stay humble
<FromGitter> <KINGSABRI> I hope crystal community support each other like Python, see python community they just love to contribute to each other projects ⏎ ⏎ It's cultural thing
<FromGitter> <KINGSABRI> @bararchy that's why I asked if someone is working in infosec here to work together
<FromGitter> <Sevensidedmarble> also probably the improving the garbage collector I'd imagine must be a pretty high priority for the maintainers...
<FromGitter> <KINGSABRI> yeah, that's right
<FromGitter> <Blacksmoke16> Did a benchmark of solving an LP problem 10,000 times in Ruby vs Crystal
<FromGitter> <Blacksmoke16> Ruby - 217.25 seconds ⏎ Crystal - 5 seconds
<FromGitter> <Blacksmoke16> gg
<FromGitter> <Sevensidedmarble> I think the possibility of more interop between crystal and ruby, like writing ruby extensions in crystal also has the possibility to boost the language tremendously
<FromGitter> <Blacksmoke16> biggest roadblock coming from Ruby was having to deal with the Typings, but that is to be expected
<FromGitter> <Sevensidedmarble> Is crystal your first statically typed language?
<FromGitter> <Blacksmoke16> officially yea
<FromGitter> <KINGSABRI> for me, you can say yes
<FromGitter> <faustinoaq> > also probably improving the garbage collector I'd imagine must be a pretty high priority for the maintainers... ⏎ ⏎ @Sevensidedmarble Check this: https://github.com/ysbaddaden/gc
<FromGitter> <KINGSABRI> C++ and Java were long long time a go
<FromGitter> <Blacksmoke16> only other is TypeScript but thats not really officially statically typed
<FromGitter> <Blacksmoke16> best you can do in js i guess
<FromGitter> <Sevensidedmarble> that's very interesting @faustinoaq
<FromGitter> <faustinoaq> https://github.com/crystal-lang/crystal/issues/5271 as well 😉
<FromGitter> <Sevensidedmarble> wow that looks impressive
<FromGitter> <Sevensidedmarble> that would be awesome
<FromGitter> <Sevensidedmarble> that's the only performance concern
<FromGitter> <KINGSABRI> guys, why single quotes is not like double quotes in Crystal? eg `require 'json'` = error but `require "json"` is fine ?
<FromGitter> <Sevensidedmarble> strings are always " "
<FromGitter> <Sevensidedmarble> ' ' is reserved for chars
<FromGitter> <faustinoaq> > I think the possibility of more interop between crystal and ruby, like writing ruby extensions in crystal also has the possibility to boost the language tremendously ⏎ ⏎ I think the possibility of more interop between crystal and ruby, like writing ruby extensions in crystal also has the possibility to boost the language tremendously
<FromGitter> <faustinoaq> ^ Pretty old slides, but still relevant 😄
<FromGitter> <Sevensidedmarble> yeah I saw a project on github that was doing that too...
<FromGitter> <Sevensidedmarble> it looked amazing
<FromGitter> <faustinoaq> 👍
knight_ has joined #crystal-lang
<FromGitter> <Sevensidedmarble> plus I suck at writing C
<FromGitter> <Sevensidedmarble> so I'd never want to subject myself to extending ruby with c
<FromGitter> <faustinoaq> > guys, why single quotes is not like double quotes in Crystal? ⏎ ⏎ @KINGSABRI Check https://crystal-lang.org/docs/conventions/coding_style.html and https://github.com/veelenga/ameba
DTZUZO has joined #crystal-lang
knight__ has quit [*.net *.split]
badeball has quit [*.net *.split]
gewo has quit [*.net *.split]
<FromGitter> <bararchy> @KINGSABRI cool to hear, as currently there isn't much infosec community around Crystal one of my few OS project is this https://github.com/bararchy/sslscanner the more relevant one are sadly commercial and close. Though we do try to export stuff out as OS
<FromGitter> <faustinoaq> > so I'd never want to subject myself to extending ruby with c ⏎ ⏎ There is also the option to write Ruby extensions using Rust https://usehelix.com/ 😜
badeball has joined #crystal-lang
<FromGitter> <KINGSABRI> > @KINGSABRI cool to hear, as currently there isn't much infosec community around Crystal one of my few OS project is this https://github.com/bararchy/sslscanner the more relevant one are sadly commercial and close. Though we do try to export stuff out as OS ⏎ ⏎ I like the idea
<FromGitter> <faustinoaq> > more relevant one are sadly commercial and close ⏎ ⏎ @bararchy I think that's not an issue, open source is good, but private projects will make crystal more enterprise alike 😄
<FromGitter> <faustinoaq> I hope to make some products using crystal in the future, with free options and paid licenses with support 😉
gewo has joined #crystal-lang
<FromGitter> <KINGSABRI> > > more relevant one are sadly commercial and close ⏎ @bararchy I think that's not an issue, open source is good, but private projects will make crystal more enterprise alike 😄 ⏎ ⏎ I agree ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5aabed07458cbde55740eee5]
<FromGitter> <KINGSABRI> Build system level services, Learning machine, desktop applications , and of course web framework but don't let people know you as a framework's language like Ruby
<FromGitter> <KINGSABRI> Golang was smart at this point
<FromGitter> <KINGSABRI> the way they introduced them self to the market
<FromGitter> <bararchy> @KINGSABRI I would love seeing Metasploit using Crystal :) its so much easier working with low level data, writing exploits is really fun with Crystal using Bytes and not storing everything inside a string
<FromGitter> <Sevensidedmarble> well being google definitely helps
<FromGitter> <Sevensidedmarble> they could probably make Google Brainfuck and people would love it
<FromGitter> <KINGSABRI> @Sevensidedmarble , no doubt. But google was even smart in introducing the language. ⏎ I really belive that Crystal is much nicer and make sense that Golang (ugly code)
<FromGitter> <KINGSABRI> @bararchy Ruby is awesome in the way of usage to me. However, speed is sometimes un-negotiable thing when you talk with business
<FromGitter> <KINGSABRI> I wish Crystal provide some cool low level play ground to use it in heavy duties task in security
<FromGitter> <KINGSABRI> and yeah native compilation like Golang was great selling point for many project, as much as I understand
<FromGitter> <KINGSABRI> https://github.com/crystal-community << is this will like Rubygems ?
<RX14> @KINGSABRI crystal's package manager is https://github.com/crystal-lang/shards
greenbagels_ has quit [Quit: WeeChat 2.0.1]
rohitpaulk has quit [Ping timeout: 264 seconds]
<FromGitter> <jlebray> Someone know how to setup Scry (https://github.com/crystal-lang-tools/scry) on Vim(NeoVim)? I’m trying to use vim-lsp (https://github.com/prabirshrestha/vim-lsp) but I have no idea how to configure it with Scry.
Yxhuvud has quit [Remote host closed the connection]
Yxhuvud has joined #crystal-lang
rohitpaulk has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.0.1]
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <keplersj> @jlebray You're definitely going to want to talk to @faustinoaq. We also have a gitter channel here: https://gitter.im/crystal-scry/Lobby
rohitpaulk has joined #crystal-lang
<FromGitter> <jlebray> @keplersj Thanks
<FromGitter> <keplersj> @jlebray Looking at `vim-lsp`'s documentation. I'd have to guess you could get it to work by installing scry to your path and configuring like so:
<FromGitter> <KINGSABRI> > **<RX14>** @KINGSABRI crystal's package manager is https://github.com/crystal-lang/shards ⏎ ⏎ I mean as repository? because from description "Crystal projects managed by the community" what kind of projects?
<RX14> mostly shards or tools
<RX14> like
<RX14> misc stuff
<RX14> all sorts
<FromGitter> <bararchy> @KINGSABRI shards are basically ruby gems, just instead of sitting in the rubygems website they sit in github repos. You can find lots of shards using awesome crystal or using the search site which in turn filter out crystal results
<FromGitter> <bararchy> https://crystalshards.xyz/
<FromGitter> <KINGSABRI> Cool, that's pretty much like Go which is good, can't say it's a better option but it's cool
<RX14> it means less centralization
<RX14> and no cost to the core team
<FromGitter> <bararchy> Hmm https://github.com/dippersauce/NightFire
<RX14> the shards hosting provider bears all the costs
<FromGitter> <bararchy> randomly found
<FromGitter> <KINGSABRI> yeah, less cost is a pro, but still couldn't figure no cerntralization is a pro or con
<RX14> pro
<RX14> no name squatting
<RX14> more namespaces
<RX14> because everything is user/repo
<RX14> instead of just named
DTZUZO has quit [Ping timeout: 240 seconds]
DTZUZU has quit [Ping timeout: 246 seconds]
<RX14> and it's easy enough to dump the list from github
<RX14> which together with awesome-crystal solves discoverability
<RX14> although it does kinda discriminate against shards hosted on not-github
<FromGitter> <KINGSABRI> I see, however there's naming duplication possibility, ⏎ in Ruby, there's DNS-Ruby and Ruby-dns because of rubygem we know that but if 2 awesome dudes built a DNS shard then called it DNS.cr then which one is which ?
<RX14> whichever you put in your shard.yml
<FromGitter> <KINGSABRI> I see, so I have to know the full url. I can't do like crystall install my-shard
<RX14> nope
<RX14> it'd be shards add user/repo
<RX14> in the normal case of the shard being on github
rohitpaulk has quit [Quit: Ping timeout (120 seconds)]
<RX14> and it'd fetch the shard at user/repo and then get the same from it's shard.yml and add it to your shard.yml
<FromGitter> <KINGSABRI> I see
rohitpaulk has joined #crystal-lang
<FromGitter> <KINGSABRI> I'm sorry, but I remember there was something like ⏎ ⏎ crystal install url-from-github
<FromGitter> <KINGSABRI> @bararchy I need to install your tool to test it
<FromGitter> <bew> huh not really
<FromGitter> <bew> just `git clone ...`
<FromGitter> <bew> for a shard, you can add it as a dependancy in `shards.yml`, then run `shards install`
<FromGitter> <KINGSABRI> hmm, @RX14 now that's a con! ⏎ in Go we can just do go get RepoURI
<RX14> no
<RX14> in go you add dependencies to your imports
<RX14> inside the sourcefile
<RX14> not use go get
<RX14> go get is for commandline tools
<RX14> iirc
<FromGitter> <KINGSABRI> I see your point,
<FromGitter> <bararchy> @KINGSABRI basically you can do this
<FromGitter> <bararchy> git clone https://github.com/bararchy/sslscanner ⏎ cd sslscanner ⏎ make
<FromGitter> <bararchy> Or look at the readme on how to use it as a shard
DTZUZU has joined #crystal-lang
<FromGitter> <KINGSABRI> ok
<FromGitter> <bew> @bararchy there's a typo in your readme: `binery` => `binary`
<FromGitter> <bararchy> Will fix :)
<FromGitter> <bew> 👏 :)
<FromGitter> <KINGSABRI> @bararchy it seems you'll get some open issues :D
<FromGitter> <bararchy> LOL go for it
<FromGitter> <bararchy> It was one of the first ones I did, tried to port the idea behind my other project in ruby
DTZUZO has joined #crystal-lang
<FromGitter> <KINGSABRI> which is good, to do
<FromGitter> <KINGSABRI> I'll try to build some ideas that need speed in crystal
<FromGitter> <KINGSABRI> hopefuly windows support doesn't take long time since it's really important
<FromGitter> <KINGSABRI> sending some tools for customers to do some tasks should be on windows and painless
alex`` has joined #crystal-lang
<FromGitter> <KINGSABRI> for me, first use for Crystal is here ⏎ https://github.com/KINGSABRI/sqlmap-tamper-api
Disrecollection has quit [Ping timeout: 248 seconds]
<FromGitter> <bararchy> @KINGSABRI it's a nice idea, for sqlmap languge agnostic scripting
<FromGitter> <KINGSABRI> yeah, the maintainer refused to support other languages. The reason was Python is easy to learn and manipulate string. I respect that but some times you need complex processing and your language is your friend regardless which lang you use. so I made an api for that and made proof of concept for many languages even javascript
<FromGitter> <KINGSABRI> I'll use crystal for speed based applications and I really want to test it's multithreading (I'm sucks already in it)
<FromGitter> <KINGSABRI> but a first look, it seems Crystal much nicer that Ruby at this part
<FromGitter> <bew> no multithreading for now, we have concurrency, which works great if you have lot of I/O bounded thing to do
<FromGitter> <KINGSABRI> yeah, I saw that's but managing threads in general seems nicer, never work with Channels so I've to try it
<RX14> but you can't use threads in crystal
rohitpaulk has quit [Ping timeout: 260 seconds]
<RX14> only spawn
<FromGitter> <KINGSABRI> Aha, so just a subprocess?
<FromGitter> <bew> no, not process, we have user-space threads, we call them fibers
<FromGitter> <bew> with `spawn` you can create a fiber and schedule it to execute later
<FromGitter> <bararchy> @KINGSABRI As someone coming from Ruby I get the "Thread.new" attidute ⏎ ⏎ Just do this ⏎ ⏎ ```# Crystal ⏎ spawn do ⏎ code ⏎ end ⏎ ``` ... [https://gitter.im/crystal-lang/crystal?at=5aac21b86f8b4b994635d777]
<FromGitter> <KINGSABRI> I'll try it, best way to build something like web crawler to see how to deal with all scenario
<FromGitter> <KINGSABRI> I still don't know what's the difference between Thread and span, yet
<FromGitter> <KINGSABRI> the concept is missing from my side :)
<FromGitter> <bew> basically we have N fiber on 1 thread
<FromGitter> <bararchy> Yes it is! ⏎ you can use https://github.com/madeindjs/Crystagiri to help handle the HTML and extract links
<FromGitter> <KINGSABRI> Nice!!
<FromGitter> <bararchy> @KINGSABRI Something like a loop with ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aac23188f1c77ef3acbd4e5]
<FromGitter> <KINGSABRI> yeah that's so close to Nokogiri
benharri is now known as bhh
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 246 seconds]
<FromGitter> <straight-shoota> You can do pretty much the same with stdlib's XML class ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aac2a41f3f6d24c68828b91]
<FromGitter> <straight-shoota> It's actually even shorter
<FromGitter> <straight-shoota> I don't understand what you would need Crystagiri for
<FromGitter> <KINGSABRI> cool, I might need to test both on more complex scenarios ⏎ Thanks @straight-shoota
<FromGitter> <straight-shoota> Crystagiri just wraps XML, so they do exactly the same thing. It adds a few methods, but IMO that's mostly just bloating the API
<FromGitter> <bararchy> @straight-shoota good point, maybe it's not really needed
<FromGitter> <straight-shoota> using `css` selectors instead of xpath is nice, but everything else is not really useful
<FromGitter> <KINGSABRI> 👍
<FromGitter> <bew> Also the css selector language is not complete, and you have more precise control with raw xpath
<FromGitter> <straight-shoota> yes
<FromGitter> <straight-shoota> but honestly, most use cases don't need such precise control and everyone working with HTML knows CSS selectors
<FromGitter> <KINGSABRI> Ok, the `io/hexdump` is so sexy thing to me 😍
<FromGitter> <KINGSABRI> I'm just reading the documentation not even writing code right now
<FromGitter> <straight-shoota> xpath is obviously better, but I'd have to look up about the complex stuff before using it
<FromGitter> <bew> Good point too
<FromGitter> <bararchy> @KINGSABRI https://crystal-lang.org/api/0.24.2/IO/Hexdump.html ?
<FromGitter> <KINGSABRI> From today, I use devdocs for documentation it's nicer than anything I ever seen ⏎ https://devdocs.io/crystal/api/0.24.1/io/hexdump
bhh is now known as benharri
<RX14> yeah
<RX14> crystagiri I really don't like
<RX14> a shard that monkeypatches in a css selector to XML::Node would be way better
alex`` has quit [Quit: WeeChat 2.0.1]
<RX14> and the rest is just useless method renaming
<RX14> and the code is uhh
<RX14> "intereting"
<oprypin> :>
<FromGitter> <bararchy> XD
<FromGitter> <KINGSABRI> Does documentation need more examples, or it's just bcz I'm new?
<FromGitter> <KINGSABRI> :D
<RX14> which documentation?
<RX14> crystal is pretty new and the documentation is quite rough in many areas
<FromGitter> <KINGSABRI> trying to hexdump a binary file, didn't go well
<FromGitter> <KINGSABRI> btw, vs-code still works as text editor here even after installing all crystal extensions/plugins
<RX14> File.open(path) do |file|; IO::Hexdump.new(file).skip_to_end; end
<FromGitter> <bararchy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aac33abc3c5f8b90d7e66dd]
<RX14> eww, always use File with block
<RX14> ok
<RX14> as much as possible :)
<FromGitter> <bararchy> XD
<FromGitter> <bararchy> you can also just remmber to `.close`
<RX14> "you can also just remember to free()" says the C people
<FromGitter> <bararchy> oh no
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
<FromGitter> <straight-shoota> @RX14 or just add a css selector to XML::Node in the stdlib..
<RX14> how
<RX14> "just add"
<FromGitter> <KINGSABRI> ok I just tested @RX14 code an it returns ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aac38f8f3f6d24c6882ced4]
<RX14> thats not my code
<FromGitter> <straight-shoota> If you can do it in a shard, it can also be done in stdlib
<RX14> IO::Hexdump is a wrapper
<RX14> @straight-shoota thing is that it's not really done
<RX14> nokogiri has a full css parser and xpath emitter
duane has quit [Ping timeout: 264 seconds]
<RX14> crystagiri has a few regexes that don't really work
<RX14> certainly not stdlib quality
<FromGitter> <straight-shoota> it needs to be implemented, of course
<FromGitter> <bararchy> @KINGSABRI ⏎ ⏎ ```File.open(path) do |file| ⏎ IO::Hexdump.new(file).skip_to_end ⏎ end``` ⏎ ⏎ That's RX14 code ^ [https://gitter.im/crystal-lang/crystal?at=5aac394fbb1018b37af1ff42]
<FromGitter> <KINGSABRI> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aac3964bb1018b37af1ff6f]
<FromGitter> <KINGSABRI> that's the code
<FromGitter> <straight-shoota> I assume you don't want to just copy crystagiri's css translator to a new shard either
<RX14> @KINGSABRI IO::Hexdump is a wrapper IO that prints the data flowing through it to STDERR
<FromGitter> <KINGSABRI> @bararchy I'll try yous
<RX14> @KINGSABRI the code you just pasted was @bararchy's
<FromGitter> <bararchy> XD
<RX14> IO::Hexdump isn't really a very good way to generate a hexdump
<FromGitter> <bararchy> @KINGSABRI ⏎ Try doing file.gets_to_end before the file.close
<RX14> it's meant to be used "inline"
<FromGitter> <KINGSABRI> tried this ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=5aac3aaebb1018b37af207b5]
<FromGitter> <KINGSABRI> doesn't work :D
unknowner has joined #crystal-lang
<RX14> add read: true to the ctor args of IO::Hexdump
<FromGitter> <KINGSABRI> oh , forgot that
<RX14> but thats not how you use IO::Hexdump anyway
<FromGitter> <bararchy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aac3b01e4d1c636040aed03]
alex`` has joined #crystal-lang
<RX14> IO::Hexdump is meant as a debugging tool
<FromGitter> <bararchy> this works ^
<RX14> for humans
<RX14> you're not really mwant to get the hexdump in code
<RX14> it's meant to be shown to humans
<FromGitter> <KINGSABRI> ok, it works with `ARGV`
<RX14> ???
<FromGitter> <KINGSABRI> but It has I think there's a way to read from code
<FromGitter> <KINGSABRI> @RX14 your last code works
<FromGitter> <bararchy> I added ARGV just so you can use it like `./hexdump /path/to/file`
<FromGitter> <KINGSABRI> yeah got it now
<FromGitter> <bararchy> btw, Crystal binaries seems to have lots of bloat
<FromGitter> <KINGSABRI> @bararchy what do you mean?
duane has joined #crystal-lang
<FromGitter> <bararchy> I mean size wize
<FromGitter> <bararchy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aac3ca08f1c77ef3acc4aca]
<RX14> thats uhh
<RX14> about right
<FromGitter> <bararchy> it's 4 lines of code, not "require"ing anything etc..
<FromGitter> <bew> did you tried with `--no-debug`
<RX14> what 4 lines
<RX14> @bew that's more than --no-debug
<RX14> thats stripped
<FromGitter> <bew> ah yeah didn't read x)
<FromGitter> <bararchy> got one no_debug and one no_debug_strip
<RX14> @bararchy depending on the OS you're using there might be a statically linmked libgc in there
<FromGitter> <bararchy> that's the code ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aac3cfb8f1c77ef3acc4d44]
<FromGitter> <bararchy> It's Arch Linux
<FromGitter> <bararchy> no static stuff here
<RX14> ok there probably isnt then
<RX14> well that's just the size of crystal's runtime
<RX14> the whole event loop code
<RX14> signal handling
<RX14> there's a lot there even in an "empty" program
<FromGitter> <bararchy> can't I "disclude" irelevant parts ?
<RX14> no
<RX14> because they're not irrelevant
<RX14> disinclude fibers? can't do anything
<RX14> disinclude event loop? can't do IO
<RX14> disinclude signal handlers? well they're tiny anyway and are pretty useful so why bother
<RX14> 144K is t i n y
<RX14> go devs would love a 144K executable
<FromGitter> <bararchy> Go has big exe?
<RX14> well you can always use --prlude=empty :)
<RX14> badeball, idk like 50+MiB
<RX14> oops
<RX14> @bararchy
<RX14> average go executable
<FromGitter> <bararchy> Oo
<FromGitter> <bararchy> wow
<FromGitter> <bararchy> a "print hello world" is 50mb ?
<RX14> @bararchy hello world in go is 2MiB
<FromGitter> <bararchy> damn
<FromGitter> <bararchy> huge stdlib ?
<RX14> and it gets waay larger
<RX14> @bararchy remember that go is statically linked by default
<RX14> EVERY go executable needs:
<RX14> a scheduler
<RX14> a whole libc
<RX14> a whole gc
<RX14> everything
<RX14> it's crazy they can do it in 2MiB
<FromGitter> <KINGSABRI> Hello in crystal is 1.1M
<FromGitter> <bew> an empty file, in release, no debug, stipped is 128K (crystal)
<FromGitter> <KINGSABRI> hello world
<FromGitter> <bararchy> @KINGSABRI do `--release --no-debug`
<FromGitter> <bararchy> you can also call `strip filename` on it
<FromGitter> <bararchy> to make it smaller
<FromGitter> <KINGSABRI> what release mode is?
<FromGitter> <bararchy> it's an option to tell LLVM to optemize the hell out of your program
<FromGitter> <bararchy> making it faster
<RX14> @bararchy hello world in go stripped with no debug info is 1MiB
<FromGitter> <KINGSABRI> @bararchy lol , I like how to describe it :D
<FromGitter> <bararchy> RX14 same in crystal ⏎ ⏎ ```-rwxr-xr-x 1 unshadow users 128K Mar 17 00:01 hello ⏎ ``` [https://gitter.im/crystal-lang/crystal?at=5aac3eeae4ff28713a3f41db]
<FromGitter> <bararchy> same as @bew 's emtpy file
<RX14> ??
<FromGitter> <bararchy> I mean, the same thing in crystal is 128k
<FromGitter> <bararchy> Go 1Mib, Crystal 128k
<RX14> yeah
<RX14> so 1/10th
<FromGitter> <bararchy> but it's not static linked
<RX14> ish
<FromGitter> <KINGSABRI> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aac3f4ebb1018b37af22038]
<RX14> @bararchy yes
<FromGitter> <bararchy> @KINGSABRI run `strip hello` on the binary file
<RX14> I wouldn't worry about binary size
<FromGitter> <bararchy> it should cut some of the top ;)
<RX14> the go guys deal with it
<RX14> and they're far worse than crystal
<FromGitter> <KINGSABRI> it's `280K` now
<FromGitter> <bararchy> what OS are you using?
<FromGitter> <KINGSABRI> Kubuntu 17.10
<FromGitter> <bararchy> does your file have "puts hello world" inside?
<FromGitter> <bararchy> or the hexdump stuff ?
<FromGitter> <KINGSABRI> oneline `puts "Hello world"`
<FromGitter> <bararchy> hmm
<FromGitter> <bararchy> wierd
<RX14> it's debian-based
<FromGitter> <bararchy> what architecrure?
<RX14> it has gc inside
<FromGitter> <bararchy> oh
<RX14> the .deb package includes a static libgc
<FromGitter> <bararchy> @KINGSABRI can you paste `lld hello` here ?
sevensidedmarble has quit [*.net *.split]
oz has quit [*.net *.split]
ssvb has quit [*.net *.split]
p0p0pr37 has quit [*.net *.split]
justinmcp has quit [*.net *.split]
<FromGitter> <bew> `ldd`*
<FromGitter> <bararchy> ^ yeha
<FromGitter> <bararchy> my bad
ssvb has joined #crystal-lang
oz has joined #crystal-lang
p0p0pr37 has joined #crystal-lang
sevensidedmarble has joined #crystal-lang
justinmcp has joined #crystal-lang
<FromGitter> <bararchy> for me it's fully dynamic ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aac407be4ff28713a3f4a04]
<RX14> lol I did that too
<RX14> lld is too close to ldd
<FromGitter> <bararchy> yeha hahah
<FromGitter> <bararchy> whay does it need libcrypto for puts hello world
<RX14> uhh
<RX14> what
<FromGitter> <KINGSABRI> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aac40dc27c509a7746f9fc7]
vivus has joined #crystal-lang
<FromGitter> <bararchy> RX14 it seems to also dynamic link gcc
<RX14> no
<FromGitter> <bararchy> in debian
<RX14> libgcc is like
vivus has left #crystal-lang [#crystal-lang]
<RX14> part of libc
<FromGitter> <bararchy> but when you static link something ldd wont show it
<RX14> @bararchy libcrypto comes from ldd /usr/lib/libevent-2.1.so.6
<RX14> @bararchy libc isn't statically linked lib
<RX14> there's libc right in the output right there
rohitpaulk has joined #crystal-lang
<FromGitter> <bararchy> whats libatomic_ops ?
<RX14> for libgc
<FromGitter> <bararchy> and why my example need it and @KINGSABRI doesn't ?
<FromGitter> <bararchy> beacuse of the static\dynamic thing ?
<RX14> libatomic_ops is inside the libgc static lib
<RX14> since it's compiled with libgc
<FromGitter> <bararchy> oh
<RX14> note that ldd shows transitive dependencies too
<RX14> if you did a static link the linker could know what symbols aren't used from the .a file and it'd be smaller than the binary+the size of all the so files
<RX14> i think at least
<RX14> hmm
rohitpaulk has quit [Ping timeout: 256 seconds]
<FromGitter> <KINGSABRI> is there a compilation option for most optimization ?
<RX14> ... --release
<FromGitter> <KINGSABRI> great , what does `--release` other than the optimization?
<FromGitter> <bararchy> GCC allows -o 1-3, I think Crystal goes to 3 automatically
<FromGitter> <bararchy> I meant LLVM
<RX14> yeah
<RX14> crystal is just on or off
<RX14> @KINGSABRI nothing really
<RX14> --release is just LLVM optimization
<FromGitter> <straight-shoota> `--release` is just a super fancy switch to disable annoying warnings when using `benchmark`:D
<RX14> yeah
<RX14> and its not useful for much else unless you're actually mazing out a CPU
<RX14> I prefer to deploy --debug in production until the point where I actually need --release mode
<RX14> since with --debug you get better backtraces
<RX14> well
<RX14> not with -d specifically
<RX14> just leaving off the inlining makes for far better backtraces
<FromGitter> <KINGSABRI> thanks!
<FromGitter> <KINGSABRI> another thing, what spawn in Crystal still didn't get the user space thing
<RX14> read that @keplersj
<RX14> oops
<RX14> @KINGSABRI
<FromGitter> <straight-shoota> it's essentially the same concept with spawn and channels as Go's concurrency
<FromGitter> <KINGSABRI> I know Concurrency vs. Parallelism ⏎ but fibes and channel concepts are new to me
<RX14> yes
<RX14> that document expands on that
<RX14> if you read on
<FromGitter> <KINGSABRI> yeah, I'm reading. I like how it simplify the concepts
<FromGitter> <KINGSABRI> thanks for the writer of couse
<FromGitter> <straight-shoota> yeah
<FromGitter> <straight-shoota> it doesn't get right to the point but when it does, the guide is pretty neat
<FromGitter> <KINGSABRI> fibers explanation wasn't really informative to me
<RX14> well the details of exactly what fibers are aren't what that guide tries to convey
<RX14> it just tries to tell you how they can be used
<RX14> oh no nvm
<RX14> it goes into detail
<FromGitter> <KINGSABRI> I'll finish the whole page to get the full picture
alex`` has quit [Ping timeout: 256 seconds]
<FromGitter> <bararchy> @KINGSABRI take a look here https://stackoverflow.com/questions/30853566/crystal-convert-the-idea-behind-thread-pool-to-fibers-spawn my question and see @waj response , that's what made my mind click regarding Fibers
<FromGitter> <KINGSABRI> omg! the answer is so neat, so have successfully insulted Ruby :D
<RX14> the idea of fibers and channels is just that you could be communicating between fibers using queues
<RX14> channels are like queues but they block the fiber when you run out of items
<RX14> (ish)
<RX14> fibers themselves are just like threads in ruby
<RX14> except we implement channels as a standard easy to use way of communicating between fibers safely
<RX14> instead of dealing with locks etxc
<RX14> etc*
<FromGitter> <KINGSABRI> I see
<FromGitter> <KINGSABRI> the socket example is really good
<FromGitter> <KINGSABRI> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aac49efe4d1c636040b2eba]
<FromGitter> <KINGSABRI> a question here, why `Channel(TCPSocket).new` not `Channel.new`
<FromGitter> <bew> because you send a pecific type of object (here `TCPSocket`) through the channel
<FromGitter> <bew> also, `Channel` is a generic class
<FromGitter> <KINGSABRI> so `ch` sends `socket` object to `ch` which is basically a `TCPSocket` object through Channel object?
<FromGitter> <straight-shoota> exactly
<RX14> socket is a TCPSocket
<FromGitter> <straight-shoota> `ch.send` puts `socket` on `ch`'s queue and `ch.receive`takes the first item in the queue
<RX14> ch needs to be a Channel(TCPSocket) because you're sending a TCPSocket through the channel
<FromGitter> <KINGSABRI> yeah I think I really getting better now and I understand it at least the main idea
<FromGitter> <KINGSABRI> really it's easier than Threads in Ruby
<RX14> you could implement Channel in ruby just fine
<RX14> with locks
<RX14> fibers aren't easier than threads per se
<RX14> it's channel that's the real innovation
<FromGitter> <KINGSABRI> never tried
<RX14> great thing about crystal is you can read the implementation of channel whenever you want
<RX14> it probably won't make sense hough
<FromGitter> <KINGSABRI> channel actually wraps many manual work
<RX14> since it dives into some of the event loop details
<RX14> fibers are a speed innovation over threads mainly
<RX14> channels are an ease of use innovation
<FromGitter> <KINGSABRI> I see
<FromGitter> <KINGSABRI> another thing I grepped my attention which is not related to out topic is , `typeof` ⏎ I feel it's a bit ugly and none OOP style. why not `object.type`
<RX14> well there's 2 concepts
<RX14> object.class which returns the runtime type of the class
<FromGitter> <KINGSABRI> like `"Crystal".type`
<RX14> i.e. what concrete real type is this at the moment
<RX14> and then there's typeof(object)
<RX14> which is the type of the variable
<RX14> the type that the compiler knows
<RX14> the object can't answer the question of what type the compiler thinks it is
<RX14> it's not it's job
<RX14> it can answer what it is specifically
<FromGitter> <bew> `obj.class` => runtime type
<RX14> that's why
<FromGitter> <straight-shoota> typeof receives an expression
<FromGitter> <KINGSABRI> I see, in Ruby I use `object.class`
<FromGitter> <straight-shoota> you can't call a method `type` on an expression because it's only a compiler concept
<RX14> in effect
<RX14> because runtime type is a property of the object
<RX14> compile-time type is a property of the variable
<RX14> when you call methods on a variable you're following the pointer and sending a message to the actual object
<RX14> (in theorry, not practice)
<RX14> so it doesn't really make sense to have compile-time type be a method call
rohitpaulk has joined #crystal-lang
<RX14> @KINGSABRI do you understand the difference between runtime and compile-time type
<FromGitter> <straight-shoota> an example why you can't just call a method on the value is `typeof(raise "foo")` =)
<FromGitter> <KINGSABRI> not really, I'm not a core developer. But I code a lot for security related things
<RX14> @KINGSABRI https://carc.in/#/r/3qo7
<RX14> @KINGSABRI you need to know this to really be able to code in crystal
<FromGitter> <KINGSABRI> and Ruby was my first real programming lang
<RX14> it's a fundamental property of all statically typed languages
<RX14> I personally think that if you ONLY know ruby then crystal is a really really hard language for rubyists to learn
<RX14> because crystal is a hard language to learn static typing in
<FromGitter> <straight-shoota> why do you think it's especially hard?
<RX14> because it hides the types
<FromGitter> <straight-shoota> true
<RX14> you need to KNOW the compile-time types of each variable
<RX14> in java they're sitting right there
<FromGitter> <KINGSABRI> I've not issue to learn as much as I enjoy the language, that's why I ran from Go
<RX14> by the variable definition
<RX14> in crystal they're hidden
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <straight-shoota> but yes, if you only know a dynamic language like Ruby it's difficult anyway
unknowner has quit [Quit: unknowner]
<FromGitter> <straight-shoota> at least more difficult than having experience with a statically typed language, say Java
<FromGitter> <KINGSABRI> I have Basic java knowledge though
<FromGitter> <KINGSABRI> enough to understand the code and known security issues
<RX14> well the best way to learn is to do
<RX14> just start writing crystal and you'll work it out
<FromGitter> <straight-shoota> an example in java: `Object foo = new Foo()`
return0e has joined #crystal-lang
<FromGitter> <straight-shoota> a bit simplified, Object is the compile type, Foo the runtime type
<FromGitter> <straight-shoota> `foo` can have any `Object` as value, but in this case it is assigned an instance of `Foo`
<FromGitter> <straight-shoota> when executed
<FromGitter> <KINGSABRI> I see
<FromGitter> <KINGSABRI> @straight-shoota thanks man it's really fruitful discussion with
<FromGitter> <KINGSABRI> working with scripting language for long time let you not care about many details
<FromGitter> <aisrael> This is why am now telling our new hires to learn Crystal first before Ruby. Easier to go that way, then the other way around
<FromGitter> <bew> Crystal is the new C :p
<FromGitter> <bew> well to discover static typing at least
<FromGitter> <KINGSABRI> @bew I hope so I even hope Crystal beats Golang 😎
<FromGitter> <KINGSABRI> btw, in which case I'll be forced to explicitly use static type with a new object?
<FromGitter> <KINGSABRI> till now I never static type any object
<FromGitter> <bew> new languages can coexist I think, no need 'to beat another lang'
<FromGitter> <KINGSABRI> I mean in speed
<FromGitter> <aisrael> @KINGSABRI What I love about Crystal (over other, new, statically typed languages) is that it does type inferencing for you. So, no, you don't have to declare types all the time, everywhere
<FromGitter> <bew> @KINGSABRI you mean when do you need to specify the types? (it's always static typed)
<FromGitter> <bew> you need to specify types in classes for the instance variables
<FromGitter> <KINGSABRI> @aisrael thanks ⏎ @bew in variable declaration for example, I don't static type till now
<FromGitter> <bew> for local variable you never need them (I never needed them)
<FromGitter> <aisrael> There are some cases when the compiler can't infer the type of something, so it'll complain and you have to specify it. In most cases, though, I consider it a best practice to add the type annotations. In some cases thoug, it makes your method more 'generic'
<FromGitter> <aisrael> @bew is right. I don't ever recall declaring local var types
<FromGitter> <aisrael> I like to declare method return types (added safety e.g. if I forget a possible `nil` return path)
<FromGitter> <KINGSABRI> I see
return0e has quit [Ping timeout: 264 seconds]
<FromGitter> <KINGSABRI> guys, don't you think `Lazy` is important to `Enumerable` ?
<FromGitter> <bew> what do you mean be `Lazy`?
<FromGitter> <KINGSABRI> in Ruby, there is lazy enumerator I generally use to not load a hole file I want to readlines it
<FromGitter> <bew> you mean an iterator maybe?
return0e has joined #crystal-lang
<FromGitter> <KINGSABRI> it's enumerator
<FromGitter> <KINGSABRI> eg. `File.readlines('/etc/passwd')` this will directly loads the etc/passwd in an array ⏎ but when you do `File.readlines('/etc/passwd').lazy` it returns Enumerator::Lazy
<FromGitter> <bew> for example, in case of a file (or any IO objects), `IO#each_line` will return an iterator that will lazily consume the IO as needed
<FromGitter> <KINGSABRI> it doesnt load the file to memory until you enumerate it like ⏎ ⏎ file = File.readlines('/etc/passwd').lazy # file not loaded to memory ⏎ file.each {|l| puts l} [https://gitter.im/crystal-lang/crystal?at=5aac5976e4d1c636040b6c94]
<FromGitter> <KINGSABRI> @bew each_line requires the file to be loaded so you have to `File.open('/etc/passwd').each_line` so the file is open and loaded already
<FromGitter> <bew> open doesn't mean loaded
<FromGitter> <bew> or read
<FromGitter> <KINGSABRI> `#lazy` helps me in huge files
<FromGitter> <KINGSABRI> yes I mean read
<FromGitter> <bew> `File.open` won't read anything from the file
<FromGitter> <bew> just creates a `File` object, that you can read/write from/to
<FromGitter> <KINGSABRI> yeah, I just checked that, you're right
<FromGitter> <bew> `File` is an `IO`
<FromGitter> <KINGSABRI> correct