Skip to main content

Posts

Showing posts with the label json

Large scale ambitions

Learning new things is important for every developer. I've mentioned  this before, and in the spirit of doing just that, I've started a somewhat ambitious project. I want to do a large-scale simulation, using  Elixir  and Go , coupled with a physics simulation in C++. I've never done anything in Elixir before, and only played a little bit with Go, but I figure,  how hard can it be ? Exsim I've dubbed this project exsim - it's a simulation done in Elixir. Someday I'll think about a more catchy name - for now I'm just focusing on the technical bits. Here's an overview of the system as I see it today: exsim  sits at the heart of it - this is the main server, implemented in Elixir. exsim-physics  is the physics simulation. It is implemented in C++, using the Bullet physics library. exsim-physics-viewer  is a simple viewer for the state of the physics simulation, written in Go. exsim-bot  is a bot for testing exsim, written i...

More on JSON in Erlang

I've been digging deeper into my experiments with Erlang and have improved the JSON parser I discussed in a  previous blog . The code lives at  https://github.com/snorristurluson/erl-simple-json  in case you want to take a look. The project is now set up to take advantage of  rebar3 , the Erlang build system, and tests are run automatically on  Travis CI . Thanks,  Lou Xun ! The parser now does proper tokenizing, rather than the simple string split operations I did in my first pass. The parser itself is surprisingly simple when it's working with tokens - here it is in its entirety: parse_json ( Input ) -> { Value , <<>>} = parse_json_value ( Input ), Value . parse_json_value ( Input ) -> { Token , Rest } = tokens : tokenize ( Input ), case Token of open_brace -> populate_object ( dict : new (), Rest ); open_square_bracket -> populate_list ([], Rest ); { ...

Simple JSON parsing in Erlang

I've been playing around with Erlang . It's an interesting programming language - it forces you to think somewhat differently about how to solve problems. It's all about pattern matching and recursion, so it takes bit getting used to before you can follow the flow in an Erlang program. Back in college I did some projects with Prolog  so some of the concepts in Erlang were vaguely familiar. Supposedly, Erlang's main strength is support for concurrency. I haven't gotten that far in my experiments but wanted to start somewhere with writing actual code. OTP - the Erlang standard library doesn't have support for JSON so I wanted to see if I could parse a simple JSON representation into a dictionary object. The code is available on Github:  https://github.com/snorristurluson/erl-simple-json This is still very much a work in progress, but the  parse_simple_json/1 now handles a string like {"ExpiresOn":"2017-09-28T15:19:13", "Scopes":...