Labels

_fuxi (75) _IV (146) _misc (5) {610610 (30) algo (1) automatedTrading (8) banking/economy (3) book (14) c++misc (125) c++real (15) c++STL/java_container (7) cppTemplate (1) db (13) DB_tuning (4) deepUnder (1) dotnet (69) eTip (17) excelVBA (12) finance+sys (34) financeMisc (24) financeRisk (2) financeTechMisc (4) financeVol (21) finmath (17) fixedIncome (25) forex (16) IDE (24) invest (1) java (43) latency (4) LinearAlgebra (3) math (30) matlab (24) memoryMgmt (11) metaPrograming (2) MOM (15) msfm (1) murex (4) nofx (11) nosql (3) OO_Design (1) original_content (4) scriptUnixAutosys (19) SOA (7) socket/stream (15) sticky (1) subquery+join (2) swing (32) sybase (6) tech_orphan (12) tech+fin_career (30) telco (11) thread (21) timeSaver (13) tune (10) US_imm (2) US_misc (2) windoz (20) z_algo+dataStructure (4) z_arch (2) z_c#GUI (30) z_career (10) z_career]US^Asia (2) z_careerBig20 (1) z_careerFinanceTech (11) z_FIX (6) z_forex (31) z_hib (2) z_ikm (7) z_inMemDB (3) z_j2ee (10) z_oq (14) z_php (1) z_py (26) z_quant (4) z_skillist (3) z_spr (5)

Sunday, April 19, 2015

AOC c++ iv (Jens/Ruban)

Q: buffer overflow?
%%A: avoid arrays, use vector

Q: XOR usage?
AA: usages? easy to google

Q: why bitwise shift?
%%A: mostly an optimization as far as I know, but the compiler probably translates integer multiply/divide already.
AA: usages? easy to google

what's wrong with pointers?
dangling pointer?

Q3: what are the common exceptions in c++?
%%A: c++ has a few standard exceptions and a lot of UB; java has lots of standard exceptions and no UB.
A: http://google-styleguide.googlecode.com/svn/trunk/cppguide.html?showone=Exceptions#Exceptions

Q3b: undefined behavior?
%%A: much worse than exceptions or error codes
%%A: perhaps fairly consistent on one platform, but I know writing beyond an array's limit is indeterminate. See [[c++ debugging)]

Q: exceptions – why do you not want to use it in your API?
%%A: can of worm. If I throw I can't control how clients use this API. What if it's thrown in a dtor? What if they don't catch by reference? What if they catch a sliced one or a copy rather than the original exception object I want them to get? What if they catch by pointer and try to delete or forget to delete? Java cleaned it up.
%%A: I don't see a lot of well-regarded API's exposing exceptions
%%A: there's performance cost
A: now I think we should be consistent throughout – either throw exceptions consistently or never.

Q: memory leak – what is it and how do you deal with it?
%%A: valgrind replaces malloc with ...?
%%A: provide class-specific op-new (and delete), which is safer (see effC++) than a customized global op-new. Add your own house keeping code therein...

Q: how is semaphore different from a mutex
%%A: I think a mutex is more basic and usually provided by the kernel (For a userland thread the thread library not the kernel must provide the mutex). I guess the counting semaphore is implemented using mutex + condition variables, since the semephore may need to inform the waiting threads.

Q: preprocessors?
%%A: 3 usages in my projects – includes, macros and conditional compile. Now I think template meta programming also uses a lot of macros.

Q: stack trace?
%%A: very useful, that's why java, c#, python, perl provide it, and GDB too.
A: [[safe c++]] shows simple and robust technique to build a stack trace upon assertion failure

I said many times "I'm philosophical about that" – meaning "it's controversial IMO and I have my views which may look naive or extreme or eccentric"