These are chat archives for ProtoDef-io/node-protodef

31st
Jan 2017
Romain Beaumont
@rom1504
Jan 31 2017 18:36
ok so I'm doing a node-protodef-validator which will define a class to make validator object. validator.addType(name,schema). Then validator.validateType(type) and validator.validateProtocol(protocol)
will be used in node-protodef and minecraft-data
and it will be possible to use it independantly to quickly check whether a protocol.json is correct
ah I'll put a small cli in the package
so you can npm install -g protodef-validator and then protodef-validator protocol.json and get errors
maybe protodef-validator protocol.json customTypes_schemas.json
one part of the protodef tooling
then I'll be able to merge these 3 PRs in 3 repos
Romain Beaumont
@rom1504
Jan 31 2017 18:50
someday we'll have node-protodef-doc which will generate html doc from a .json :d
I think I'll try to do the node protodef compiler once the validator is done though
having a 100x perf boost in flying-squid wouldn't hurt
Robin Lambertz
@roblabla
Jan 31 2017 22:51
ILY :D
:heart: :heart: :heart:
I've been wanting a validator for far too long now :P
Concerning the compiler. I'm considering using @hansihe's compiler as the basis for future compilers, or if we should write our own in every language. One of the cool thing about having one compiler for many languages is that we could then start doing fun stuff like a package and a centralized repository for protodef dependencies.
Take the current varint problem for instance. It'd be nice if we could have one "compiler plugin" that defines varint in the "Protodef Plugin Repo", that has an implementation for (say) nodejs, elixir and rust.
Then when we compile the .json, it references "varint", we get it from said repo, check if it supports the language currently targeted, and compile.
(A fun note: We need to be careful about arbitrary execution)
Romain Beaumont
@rom1504
Jan 31 2017 22:57
yes that would definitely be nice
it means having elixir as a dep dependency though
but that's not necessarily a problem
*dev
well
what I think is we can do both
whichever one gets done first wins :p
protobuf has a one compiler many backends approach
and it seems to work fine for them
it's c++ though
(the compiler)
Robin Lambertz
@roblabla
Jan 31 2017 23:00
does elixir require a runtime ? Can it be statically compiled ?
Looks like distillery can do what we want
I'm going to keep working on my rust compiler though. I need it to get a feel of how things work in a language I actually know :P
Romain Beaumont
@rom1504
Jan 31 2017 23:02
I think hansihe started the js backend and then he was a bit disapointed to have to do the sizeOfX in js, which he didn't have to do for elixir
Robin Lambertz
@roblabla
Jan 31 2017 23:02
but then I might rewrite it in elixir because I think having a consistent tooling is important.
wut ?
How did he avoid sizeOfX ?
or did he just take an out stream in his function ?
Romain Beaumont
@rom1504
Jan 31 2017 23:03
yeah I think it's a kind of stream
Robin Lambertz
@roblabla
Jan 31 2017 23:03
TBH, we could avoid sizeOfX in node-protodef.
we just have to pass an instance of a Write stream instead of a buffer to the writer.
Thing is, we need to make sure our Write is buffered, otherwise it'll make stuff slower by a significant margin.
yeah well
you know
I tried to do something like that last time
and well
okay I did the async thing at the same time
so it didn't all work out :d
anyway
I think if we do a compiler for js, it would be easier to experiment things
so yeah it might be possible to not have sizeOf in a js backend I guess
"Write stream" oh
you mean like a node write stream
hmm
yeah I guess it could be possible
Robin Lambertz
@roblabla
Jan 31 2017 23:08
yup, node write stream.
Romain Beaumont
@rom1504
Jan 31 2017 23:08
somehow I bet it would impact perf though
Robin Lambertz
@roblabla
Jan 31 2017 23:08
it would, especially if we don't buffer the writes
And also, we'd need to make sure we have enough to read before starting processing, cuz otherwise we'll mess up and re-write.
wait
actually that ain't a problem.
Obj->Write we have everything, and Read->Obj we already check we have enough to read anyway ^^
Romain Beaumont
@rom1504
Jan 31 2017 23:10
yeah anyway
I think these changes would be better in the result of a js compiler
I think I don't want to try to change the js interpreter again
or it's going to blow up again :p
Robin Lambertz
@roblabla
Jan 31 2017 23:11
haha yeah. Well it went way past its shelf life tbh.
Romain Beaumont
@rom1504
Jan 31 2017 23:11
roblabla: hmm do you have sizeOf in rust ?
Robin Lambertz
@roblabla
Jan 31 2017 23:11
I don't do write yet
Romain Beaumont
@rom1504
Jan 31 2017 23:12
ok
Robin Lambertz
@roblabla
Jan 31 2017 23:12
so no
I probably won't need it though, since I take std::io::{Read,Write} instances in my functions
IDK yet.
Romain Beaumont
@rom1504
Jan 31 2017 23:12
where are you at ?
Robin Lambertz
@roblabla
Jan 31 2017 23:14
Yesterday my brain blew up (it actually gave me a headache) after I tried to get subtyping working. Today I looked at the code, poked it with a stick, but mostly, nothing came from it.
Romain Beaumont
@rom1504
Jan 31 2017 23:14
what is subtyping ?
Robin Lambertz
@roblabla
Jan 31 2017 23:14
string is a subtype of cstring
Romain Beaumont
@rom1504
Jan 31 2017 23:14
you mean the "extendType" of node-protodef
Robin Lambertz
@roblabla
Jan 31 2017 23:14
this kind of thing.
Romain Beaumont
@rom1504
Jan 31 2017 23:14
yeah ok
Robin Lambertz
@roblabla
Jan 31 2017 23:14
yup
I lazily create new types as I go
It sounded like a good idea at first.
now I realize it wasn't :P
Also, I have a small problem with my design in the amount of heap allocation I have to do.
So I'll probably have to sit down and rethink how things interact with each other.
Romain Beaumont
@rom1504
Jan 31 2017 23:20
okay