I think i might be producing WTF code



  • To everyone sorry for the long absence. I am surprised by the amount of responses this thread is getting

    @Gąska
    Great point!
    In this particular case you have to know how the JSON library being used performs. The toString method is going to fiddle down to just giving a ref char array where the expression is being held in this case. The lib pays the price in memory usage. There are only minimal transformations going on



  • @Bulb
    Thank you for the suggestion. I will deffinetly make that a priority as for scaling up it would be critical. Currently for the proof-of-concept phase i wont waste board-gaming time to make it happen, but hopefully in the future ^^

    @Gribnit
    Wish my dad was as cool as yours

    @Bulb said in I think i might be producing WTF code:

    @Zecc Also, this is one of the cases where prototyping without a database and later refactoring to use it might be a waste of effort. If you need some kind of spatial index, at least PostgreSQL (PostGIS extension) and SQLite (SpatiaLite extension) support them (other databases have similar extensions implementing this Simple Features standard), so it would be easier to just use them from the start instead of writing a prototype in C# just to replace it with the SQL version later anyway.

    did not know about postGIS. THANK YOU! still had great fun coming up with my own solution.


  • Banned

    @Heikki-Artiainen said in I think i might be producing WTF code:

    To everyone sorry for the long absence. I am surprised by the amount of responses this thread is getting

    Your OP was the only programming-adjacent thing that happened on this forum in months. If you take away funny cats, shitting on Microsoft and politics, this forum is pretty dead.

    @Gąska
    Great point!
    In this particular case you have to know how the JSON library being used performs. The toString method is going to fiddle down to just giving a ref char array where the expression is being held in this case. The lib pays the price in memory usage. There are only minimal transformations going on

    The array has to get its content somewhere first. Regardless of how it happens, your IEEE-754-encoded floats have to be converted to text somewhere, and your dynamically-populated JArray has to concatenate its elements into a single block of text somewhere. And even if it really turned out to not be a problem, operating on that string is itself very expensive performance-wise, and 9 times out of 10 completely unnecessary. Every time you compare strings and every time you hash them, you iterate over all characters. That adds up fast if you're not careful.


  • Considered Harmful

    @dkf modules in 9+ help with the massive holes in nonhierarchical package scoping


  • Discourse touched me in a no-no place

    @Gribnit said in I think i might be producing WTF code:

    modules in 9+

    Ah, we're using 8 as our target language profile as that's easy to deploy even in the weirder scenarios we use. So no modules for me!


Log in to reply