So you can create PHP extensions with C++ or just C?
You could use a mixture of both, except when defining the interfaces PHP expects, if you wrapped those up in a class you would have problems because the 'this' pointer. You could however, build a parsing extension you and use Spirit parser framework and/or Boost libraries, etc.
PCspectra can you link me up or explain what language bindings are exactly?
Essentially they are wrappers or adapters.
Function parameters at a low level, are passed in using several methods, each with it's pro/con of course. Knowing when to use one over the other is mostly a matter of convention but also performance.
http://www.programmersheaven.com/2/Calling-conventions
http://www.openwatcom.org/index.php/Calling_Conventions
Because of these conventions, if you wanted to use a library written in C, in your favorite language B, B would need a wrapper to essentially accept parameters in it's native language/calling convention and then the adapter would then call the library function using the required calling convention.
For instance, Google mysql_query:
[cpp]int mysql_query(MYSQL *mysql, const char *stmt_str) [/cpp]
Then compare that to:
Code: Select all
resource mysql_query ( string $query [, resource $link_identifier ] )
PHP needs a wrapper/adapter in order to communicate with the C API. I don't like the term wrapper/adapter as there are some technical differences, but conceptually that is what a language binding usually is.
I'd like to get a book that just explains the high level stuff I can't learn on my own, I'm sure most of us like to learn new languages by writing them not reading about them.. any book suggestions then? I already have a head first java book that will be a good reference if I get into Pig / Hadoop
High level stuff? Do you have any experience in C/C++? A good starting book would be a learn C in 21 days type book. Yes they go over in great detail the basics on programming, like explaining what control structures are (IF, WHILE, etc) but they often include little annotated tips.
I cannot think of any books that start you off as an intermediate developer (assume some programming experience) for C as most books are either:
1. Assume you know nothing and just started programming 20 years ago when C was the only serious language so there was no "experience from something else"
2. Advanced C programming, covering algorithms like qsort, pointer arithmetic, matricies, etc.
Your best bet would be to start programming and get a feel for what compiling, building, etc is all about.
Bloodshed is a decent C/C++ IDE which will get you started fast. Alternatively you could use the Borland C/C++ compiler (which produces the smallest/fastest machine code -- Intel I have heard is really good as well -- better than M$).
The best IDE for writting C/C++ is Visual C++/studio but it's not free and will only compile on Windows. GNU C compiler would be better choice if you plan on converting the code into an extension.
The problem with using the CLI is you will grow very tired of trying C/C++ without having the entire build process automated, at least to some degree.
If you want a book that really covers ground for C++ I would check out Thinking in C++:
http://www.mindview.net/Books/TICPP/Thi ... CPP2e.html
One of the best books I have ever read, period, not just programming. His writing style, detailed approach, no non-sense, etc. He has a book for Java as well, but I'd stick to C/C++ if your ready to get your feet wet with a lower level language.
C/C++ are cross platform, more so than any other language, so you get natively compiled applications that run as fast as possible. You can use C++ libraries like STL to essentially emulate all the pointer-less/GC facilities like in Java so it's really the better language to learn IMHO.
What Java might have over C++ is a better runtime model. But there are "apparently" compiler hacks which introduce RTT facilities like reflection, etc into C++ so...if you look hard enough...who knows.
PS. spectra, I started out w/ VB4, you were 1 version ahead of me
Lucky you. I started with a Commodore Vic-20 and a built-in BASIC interpreter on a blistering 1Mhz processor and 5KB of memory.
I still have the book with the source code that I entered into the computer for the very first time:
Code: Select all
1: FOR H = 1 TO 505
2: PRINT "*";
3: NEXT
4: FORC = 8 to 255 STEP 17
5: POKE 36879, C
6: FOR T = 1 TO 500: NEXT
7: NEXT
8: GOTO 4
RUN
I remember it like it was 819936000 seconds ago.
