charlesroddie / MathAtom

Structural representations of visual mathematics expressions for use in .Net rendering libraries
MIT License
7 stars 0 forks source link

Initial code review #9

Closed charlesroddie closed 5 years ago

charlesroddie commented 5 years ago

Can we move to a PR system as it exposes good commenting functionality?

In lieu of this some initial comments:

Re: value vs refernce types, I expect there will be some threshold below which value types will perform better (e.g. ValueOption<char*char>) and above which passing by reference will be more efficient. Not sure where that theshold is exactly though.

Happypig375 commented 5 years ago
charlesroddie commented 5 years ago

Please explain "PR system" a bit.

Perhaps a dev branch, with a PR from this into master allowing comments, merged from time to time?

Agreed on no-inline for larger helper functions. However, I still think inline would be appropriate for one-liners as they provide eliminations of allocations of e.g. FSharpFuncs.

Interesting performance tweak which we could consider and test if we are running into these hundreds of millions of times a second.

Pattern matching with Alphabet and NonAlphabets just look nicer than when clauses. ((NonAlphabet & c)::cs)

It's a more complex object: greater cognitive load, higher threshold for library contributions if we have these where more concrete approaches work equally well. I think we should allow active patterns selectively when they reduce complexity by expressing a concept that would be more complex to express concretely.

They are primarily used for LaTeX command parsing, so Greek wouldn't apply here.

OK

I'm still thinking of a reason to deviate from the F# naming convention. Thoughts?

Your annotation indicates you want to deviate from it. Just do it. Lower case convention is not important and being C#-friendly is a good enough reason to deviate from it. Having different compiled and used names creates unnecessary complexity.

Options will include more maps like CustomLaTeXCommands and Colors, so it shouldn't be flattened now.

OK

I remember I read that a Microsoft recommendation is to limit value types to 8 bytes or less. I think all struct types in MathDisplay don't exceed that. Correct me if I'm wrong.

This seems reasonable. That comment of mine wasn't advice to change anything, only an observation as you are using the new F# struct features and it's not that well understood when they help and when they don't.

Happypig375 commented 5 years ago

The benchmark results are out! https://github.com/charlesroddie/MathAtom/blob/e93d3dc9337541326d59f47bb024829a1bf6713d/MathDisplay.Tests.Benchmarks/AliasMapBenchmark.fs#L43-L52 I think some of the difference might be from Map vs Dictionary differences, so I tried it out: https://github.com/charlesroddie/MathAtom/blob/91b846fee49a9ca2d58d27cb36d6acbe81e0dda1/MathDisplay.Tests.Benchmarks/MapBenchmark.fs#L57-L74 Maps perform worse than Dictionaries. Does this mean that Maps should be always avoided?

charlesroddie commented 5 years ago

Does this mean that Maps should be always avoided?

In this case you have a mutable API so backing it with a mutable structure makes sense.

When you want an immutable structure you can consider Map (balanced search tree) and dict (hash table, I think an immutable wrapper around Dictionary). BST vs hash table

Happypig375 commented 5 years ago

So Dictionary is for inserting, deleting and searching, while Map is for sorting. Got it.