Write More Classes
lucumr.pocoo.org
Write More Classes
1–10 of 150 posts
Re: Write More Classes
#2Try this:
packer = msgpack.Packer()
serialized = packer.pack('stuff you wanna pack')
unpacker = msgpack.Unpacker()
unpacker.feed(serialized)
print unpacker.unpack()
I had originally used this, but then as my API scope extended to more than just using msgpack, having a common API interface for json (i.e. the .loads() and .dumps() method) was found to be more useful.And while I agree with most of the article, I don't think writing more classes is a one-size-fits-all solution. Classes IMO, only makes sense from a heavily OOP point of view.
Re: Write More Classes
#3You can do the same with python's msgpack as the C# version Try this: packer = msgpack.Packer() serialized = packer.pack('stuff you wanna pack') unpacker = msgpack.Unpacker() unpacker.feed(serialized) print unpacker.unpack() I had originally used this, but then as my API scope extended to more than just using msgpack, having a common API interface for json (i.e. the .loads() and .dumps() method) was found to be more…
A better way to phrase the OP's salient point while sidestepping the polemic of OOP is "Standardize and use protocols".
Re: Write More Classes
#4Re: Write More Classes
#5in java, c++, or c#, to add a variable to a class, you have to repeat its name 4 times. once to declare, once in the constructor parameters, and once on each side of the assignment. why am i writing the same thing 4 times for what should be a core part of the language?
in haskell, you write it once (i'm not saying haskell's records are nice, but they got that part right). same with rust.
and with a function, you write it once.
Re: Write More Classes
#6Re: Write More Classes
#7if classes didn't have such a terribly verbose syntax in basically every language that has them, i'd be less opposed to using them. in java, c++, or c#, to add a variable to a class, you have to repeat its name 4 times. once to declare, once in the constructor parameters, and once on each side of the assignment. why am i writing the same thing 4 times for what should be a core part of the language? in haskell, you wr…
public class Foo
{
public string Bar { get; set;}
}
var foo = new Foo { Bar = "Hey there" };Re: Write More Classes
#8On the streaming verus resident working set argument... Most of what most programmers deal with doesn't have to scale to deal with huge streaming datasets, so it doesn't get the attention.
Re: Write More Classes
#9 Some libraries manage to skip the token part. (I'm looking at you
simplejson, a library that even with the best intentions in mind
is impossible to teach stream processing)Re: Write More Classes
#10But yes, in the JSON cases, having more flexibility than a single 'loads' is clearly justified.