-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Understand Evan's example #2
Comments
|
Friend of mine.
The problem comes down to doing this: def call_target_method_with_data(bytes, method):
args = somehow_parse_bytes_into_python_objects(bytes)
method(*args) in a staticly typed language. That
No way, it's awesome! I started learning it during the Christmas break and already found it pretty intuitive in many ways. As with most languages, the hardest part is learning how to set up a build system, but you're in luck because I made a repo with some examples and instructions for how to get started. I'd be very happy to add explanatory notes etc. to that repo. Pull requests are most welcome. |
Cool, Scala examples! I'll set up the dev environment on my work PC and start tinkering with it. |
Doing the conversion is actually not that hard, even in a language with static types. Suppose my wire format is something like
Then I can parse the bytes like this: def somehow_parse_bytes_into_python_objects(bytes):
"""Get the method name and argument from an array of bytes.
Args:
bytes (str): Byte string which came in over the wire, i.e. via TCP
or whatever. Note that in python 2 a str is really just an array
of bytes.
"""
separator_index = bytes.find(':')
method_name_bytes = bytes[0:separator_index]
arg_bytes = bytes[separator_index:]
arg = float(arg_bytes)
return method_name, arg In a static language you can do the conversion from text to float too, that's not python specific at all.
Yeah go for it. The examples all work but they're not particularly well explained. I bet you can figure out most of it. Search online for "Scala by Example" for a somewhat nice introduction. Now, beware: a lot of Scala tutorials focus rather heavily on the functional aspects of the language. That's all well and good, but to a large extent Scala is an object oriented language which is just a hell of a lot nicer to use than Java for a lot of reasons. Don't get too hung up on monads and folding etc. etc. |
I'm not sure what this is for yet, but Evan said it would be helpful :D
The text was updated successfully, but these errors were encountered: