<c0c0> hey
<c0c0> what is the status of the GC implementation?
<waj> 404 - Not Found :)
<waj> we just started with very simple stuff to implement mark&sweep, but we'll probably delay the implementation until we have the compiler written in crystal itself running
<c0c0> hmm more like "is there already a plan on how to do it"?
<c0c0> to state my personal agenda: I always wanted to have a nice language to progam games in
<c0c0> now crystal obviously fits "nice language"
<waj> that's great! :)
<c0c0> But most GC implementations are completely unsuited for games
<waj> yup, actually the idea is to have a pluggable memory management model
<c0c0> *FUCKYEAH*
<c0c0> :]
<c0c0> you just made me very happy^^
<waj> so, in theory you'll be able to select if you want to use GC, reference counting or plain old new/free
<waj> :D
<c0c0> so what I would really love would be refcounting + occasional mark&sweep (manually triggered / only if space gets really rare)
<c0c0> have you considered using libgc?
<waj> libgc is not "accurate" gc... I'm not a big fan of it
<c0c0> it seems to play nicely with LLVM and implemnting GC seems to be quite painfull
<c0c0> yeah not accurate is a downside
<c0c0> but then if there is a layer of ref counting to begin with I'd expect that this woulnd hurt much
<waj> that's true
<waj> we're quite open to the discussion and nothing is written in stone yet
<c0c0> obivously ref counting wouldn't quite yield the best performance
<c0c0> awesome
<c0c0> I should definitively read into the sources then :]
<waj> absolutely!
<c0c0> on another note, the raytracing sample completely freezes my machine, I have no clue why^^
<asterite> Do you know which line freezes your machine?
<c0c0> nope
<c0c0> I really have no idea whats going one
<waj> are you running on mac? I didn't tried on linux
<c0c0> maybe something with my graphics card
<c0c0> htop doesn't even update befor my machine freezes
<c0c0> waj ubuntu
<c0c0> other samples work though
<waj> 64 bit?
<c0c0> yes
<c0c0> also great stuff using the carthesian product algorithm for an acctual type system
<c0c0> don't know any other language doing that
<waj> Julia actually uses a similar approach AFAIK
<asterite> :)
<c0c0> but the guy who published laser 2week before my bachelors thesis deadline...
<c0c0> (I was doing ruby type inference but with a stupid lattice based approach)
<c0c0> (laser is a carthesian product algorithm based type inference tool for ruby)
<c0c0> yeah
<waj> I'll take a look
<c0c0> yeah certainly some really nice work
<waj> CPA is quite simple actually. The biggest issue we had at the beginning was trying to have full support for polymorphic data structures.
<c0c0> (not really finished though)
<waj> Everything turns exponential very quickly
<c0c0> yeah CPA is a lot simpler then the lattice stuff I figured out - and faster in most cases as well..
<c0c0> well theoretically the lattice stuff can easily be constructed such that it is polynomialy bound
<c0c0> but in practise CPA is faster I thin
<c0c0> k
<c0c0> I read that you tried to do full CPA over classes
<c0c0> any particular reason you use 'a' as char and not as string withou special chars?
<waj> not really... but I don't like much the syntaxis in ruby for chars
<c0c0> hmm ruby doesn't have chars, has it?
<waj> well... no but you can write ?a to get "a"
<c0c0> ^^
<c0c0> awesome stuff to piss of people who started using ruby after 1.9^^
<waj> :P
<c0c0> also nice to cut of one char in codegolf
<c0c0> but thats about it
<c0c0> quite pointless acctually^^
<c0c0> yeah 'a' is certainly better then "a"
<c0c0> not so sure wether chars are necessary though - mostly performance reasons, no?
<waj> well... yes, strings are currently pointers to a struct with length and a buffer
<waj> chars are just value types in the stack
<waj> check lexer.cr and just think about how much slower that would be :)
<c0c0> they are converted to ints directly in lexing?
<c0c0> it does^^
<waj> yup, at least until we confront the encoding issues
<c0c0> hmm
<c0c0> thats why I thought len 1 strings are preferable^^
<c0c0> (also less leaking abstractions)
<c0c0> but I mean I'm not forced to use chars in first place
<waj> where do you see a leakage here?
<c0c0> hmm I want to treat strings as a sequence of symbols. I don't really care how they are represented in memory most of the time.
<c0c0> converting them into integers has a nice set of advantages at times
<c0c0> but most of the time I (and this I means "I" not "one") want to handle strings as abstract entities
<c0c0> honestly I rarly use .ord in ruby except for crappy encryption used in security exercises^^
<waj> String is often the most used class in almost any program. So it's important to make it fast.
<c0c0> thats true
<asterite> A string is a sequence of characters
<asterite> I think it makes sense to have characters as an entity in the language
<c0c0> sure does
<waj> yup, but if Srings were not so important, we could use just Array(Char)
<waj> and have mutable strings
<c0c0> waj: well that will fail catastrophically in the presence of different encodings, no?
<waj> but that would make any access to the string through an unnecessary extra indirection
<waj> we still didn't decided how to handle encodings
<c0c0> hmm whats your favourite option?
<waj> I don't have one yet
<waj> having C compatible strings in memory it's a big advantage
<c0c0> because one can link C libs without another indirection call?
<waj> yup
<c0c0> I kind of like the GO approach
<c0c0> But I understand that one might brush it of as to resource hungry
<waj> I'm not familiar with the go approach but I'll definitely take a look when we have to deal with encodings
<c0c0> It boils down to:
<c0c0> every string in memory is UTF32
<c0c0> there is binary blobs
<c0c0> and there are methods to convert binary blobs to UTF32 assuming they are strings encoded in different encodings
<c0c0> (and the other way around)
<c0c0> the big plus is obviously simplicity
<c0c0> but not everyone might be happy with 4 times bigger strings^^
<waj> no... but Go is very very efficient so maybe it's not a big deal
<waj> dunno... I'd like Crystal at least gives the choice
<c0c0> as an advantage you have O(1) access to the members
<c0c0> which might be quite usefull
<c0c0> compiler.rb line 121,
<c0c0> node = node ? Expressions.new([require_node, node]) : require_node
<c0c0> this replaces files that couldn't be parsed with an empty "require 'prelude'"?
<asterite> No, it adds a 'require "prelude"' to the program you are compiling
<asterite> so you don't have to do it
<c0c0> but only when node is truthy
<asterite> prelude has very basic stuff, but also Array, Regexp, etc. (but we don't load those automatically in the future if you don't use them)
<asterite> Ah, yes. But that is not obsolete, node will always be truthy
<c0c0> ok
<asterite> I'll write it down so later I change it
<asterite> :)
<c0c0> I'm trying to read the code top down
<c0c0> to get an overview
<c0c0> I'm also trying to document what I encounter
<asterite> Great :)
<c0c0> the last stages seem undocumented in the github developers link
<asterite> There's no documentation now, but we'll add it once the language is stable enough
<asterite> The developers docs are also outdated :(
<c0c0> I assume node ist the root of the AST?
<asterite> Where?
<asterite> in compiler.rb?
<c0c0> yes
<c0c0> and program.normalize(node) is normalizing the AST (e.g. normalizing different kinds of if .. then .. else) ?
<asterite> The normalization does many things
<asterite> It converts "unless" to "if"
<asterite> it converts "case" to a series of "if"
<asterite> It expands "require" (but that will change later, we think)
<asterite> It converts && and || to ifs
<asterite> And, most importantly, it does SSA
<c0c0> oha
<c0c0> SSA is good to know^^
<asterite> so when you do: a = 1; a = "hello"; a.length
<asterite> that works, because the second "a" is another variable, not the first one
<asterite> Before SSA a would be of type Int32 | String
<c0c0> hmm does this include building the SSA of loops etc?
<asterite> you can compile a program with SSA=1 in the environment and see it (but it produces a lot of garbage now)
<asterite> Yes, there's SSA for whiles and blocks
<c0c0> kk
<asterite> but it's very simple :)
<asterite> but works, hehe
<c0c0> I think I read somewhere in the LLVM docs that build small SSA is acctually pretty compilcated, never looked into it though
<asterite> Our SSA cheats, because sometimes we do assign more than once to a variable
<c0c0> ok
<c0c0> hmm btw it seems like the link to the CPA paper is broken
<c0c0> it points to
<asterite> Yes, we expect someone to write about it :-P
<asterite> Nah, just kidding
<asterite> Thanks for noticing it
<asterite> We actually do CPA, but when you have unions in the arguments we don't do the cross product unless there are restrictions. That makes it work faster, and it's more efficient in the generated code
<c0c0> cross = carthesian I assume?
<c0c0> what do you mean by "restrictions"?
<asterite> def foo(x : Int32)
<asterite> Int32 is a restriction
<asterite> there
<c0c0> In other words if I call f(Int), f(String) and f(Union(Int| String) ), you will generate 3 different versions of f
<c0c0> ah ok
<asterite> Yes
<c0c0> instead of 2 with a runtime switch that decides which of the former one to call
<waj> that topic probably deserves a blog post
<c0c0> I have to get some sleep, thanks for all the help :)
<c0c0> awesome project
<asterite> Good night :)
<c0c0> thanks
irclogger has joined #crystal-lang
<waj> testing...
<waj> testing 2
irclogger has joined #crystal-lang
waj has joined #crystal-lang