tag:blogger.com,1999:blog-5246987755651065286.post7676297664165891992..comments2024-02-22T16:15:42.388-08:00Comments on cbloom rants: 06-14-12 - API Design with Auto-Completecbloomhttp://www.blogger.com/profile/10714564834899413045noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-5246987755651065286.post-75353626724414011012012-06-25T10:28:26.633-07:002012-06-25T10:28:26.633-07:00i wish more tools will copy from visual assist ide...i wish more tools will copy from visual assist idea that user types not first completion symbols but unique ones. I never got to the point when VA would work for me so i miss that feature terribly.<br />I also wish someone could start scratching that threading api dead end where we are now. Sure its not profitable enough for say your company but any progress would be great. There are lots of apis and they are impossible to change and impose vendor lock-in on you.Miroslavhttps://www.blogger.com/profile/08682508835432008058noreply@blogger.comtag:blogger.com,1999:blog-5246987755651065286.post-68191353041586291142012-06-20T13:18:16.609-07:002012-06-20T13:18:16.609-07:00@cbloom
Yeah, I definitely agree. I should have sp...@cbloom<br />Yeah, I definitely agree. I should have split internal from external behavior. External behavior should be, like you said, exactly the same across platforms, but it isn't always possible to have the same performance/memory/whatever characteristics. Sometimes the difference is enough to require an algorithm change internally, but the user of the API shouldn't care.syntaxerrorhttps://www.blogger.com/profile/13873039723686992499noreply@blogger.comtag:blogger.com,1999:blog-5246987755651065286.post-18124627223881373552012-06-19T14:16:16.753-07:002012-06-19T14:16:16.753-07:00@Per - back when I did GIS software we used "...@Per - back when I did GIS software we used "Soundex Codes" for name matching. Soundex is basically only consonants, with double consonants removed (and also grouping of consonants that sound the same). It provides a very reliably match and is somewhat immune to common spelling mistakes.<br /><br />So for example "klbf" would match "KillBuffer" reliably.cbloomhttps://www.blogger.com/profile/10714564834899413045noreply@blogger.comtag:blogger.com,1999:blog-5246987755651065286.post-36163005709752208962012-06-19T14:06:25.719-07:002012-06-19T14:06:25.719-07:00@ Rhett - the real nono IMO is making API's wi...@ Rhett - the real nono IMO is making API's with the same name that don't have the same behavior. If you have to make the behavior different, then I'd rather see the function just not exist and other one with a different name.<br /><br />Like say you have an IO_Cancel() and some platform doesn't support cancelling, then just make that proto disappear so that it's a compile error.<br /><br />The other option that I think is sort of okay is to document the fallback behavior in the name, like :<br /><br />IO_CancelOrWait()<br /><br />to indicate it will cancel if possible or fallback to blocking.<br /><br />In general I think almost everyone gets cross-platform wrong. There should be a core set of functions and data types which are *exactly* the same across platforms, and then fancier stuff which is platform-specific, just make it not exist on the platforms that can't do it.cbloomhttps://www.blogger.com/profile/10714564834899413045noreply@blogger.comtag:blogger.com,1999:blog-5246987755651065286.post-42623464421022042392012-06-19T09:56:39.775-07:002012-06-19T09:56:39.775-07:00A bit of an aside: For Emacs I've long used au...A bit of an aside: For Emacs I've long used auto-complete modes that understand separators. For the mini-buffer and other Lisp-based modes that would be dashes, as in kill-buffer. That means I can just type kb and it knows I mean kill-buffer (or another command with those initials, but it sorts by popularity). I wish auto-complete modes in IDEs would understand natural identifier separators in a similar way. Natural ones for C would be underscores (as in kill_buffer or Kill_Buffer) and case boundaries (as in killBuffer or KillBuffer). One subtle benefit of this approach is that most word initials are consonants, so even a two-letter sequence (never mind longer sequences) like 'kb' is unlikely to clash with a prefix of a genuine identifier, which means you can have this initials-based auto-complete mode peacefully coexist with more traditional prefix-based auto-completion, which in turn can peacefully coexist with the usual type-whatever-you-want input mode.Per Vognsenhttps://www.blogger.com/profile/06042681400980641198noreply@blogger.comtag:blogger.com,1999:blog-5246987755651065286.post-40262035898429787022012-06-19T07:33:12.705-07:002012-06-19T07:33:12.705-07:00This might be a little off topic, but I think it s...This might be a little off topic, but I think it still adds to what you are already saying. I think a lot of APIs get the wrong idea about what it means to be cross-platform. Just wrapping up functions so that they have the same name isn't good enough, they also need to have the same behavior, or as close as possible on each platform. Java does this everywhere in their JDK. If I have to special case my code per OS, on top of an API that is already supposed to be cross-platform it almost defeats the point of using that API.<br /><br />(this is Rhett btw)syntaxerrorhttps://www.blogger.com/profile/13873039723686992499noreply@blogger.comtag:blogger.com,1999:blog-5246987755651065286.post-6494910004936707172012-06-19T06:33:03.592-07:002012-06-19T06:33:03.592-07:00Yeah, I agree with many of these ideas. (You need ...Yeah, I agree with many of these ideas. (You need to include the convenience wrappers in your APIs, though, even though it sucks.)<br /><br />A few years ago I learned to put the units into function argument names to maximize no-header-lookup:<br /><br />buffer_size_in_bytes<br />stride_in_pixels<br />wait_time_in_secondsAnonymousnoreply@blogger.com