Startups doing hardware projects which use embedded controllers: I think most 'firmware' as its called is written in C. Also, a bit unrelated but 'Verilog' and 'VHDL' are C-like low level hardware description languages used especially for prototyping via FPGAs.
In the embedded world C is the dominating language, for sure, and VHDL or Verilog are used, not only for prototyping but for regular FPGA code.
But it looks completely different from C:
---- C example ----
int main(int argc,char argv){
int i;
for(i=0;i<argc;i++)
printf("argv[%d]=%s\n",i,argv[i]);
return 0;
}
---- VHDL example (from de.wikipedia) ----
ENTITY DFlipflop IS
PORT(D,Clk: IN Bit;
Q: OUT Bit);
END DFlipflop;
ARCHITECTURE Behav OF DFlipflop IS
CONSTANT T_Clk_Q: time := 4.23 ns;
BEGIN
PROCESS
BEGIN
WAIT UNTIL Clk'EVENT AND Clk='1';
Q <= D AFTER T_Clk_Q;
END PROCESS;
END Behav;
Large scale environments where real performance matters.
I wrote a system the has to handle 4 Billion transactions a day and a peak of 45,000 per second. And has to respond in 10ms or else the results of the transaction are discarded.
I wrote it in PHP so it would be easier for my team to maintain but it would not scale beyond 4,500qps then I re-wrote it in C as an apache module and it now scales to 25,000qps per server.
Sometimes you just have to write stuff in C. I've been writing in C for 28 years. I write other languages as often as I can but once in a while I have to go back to C to get something done. Right tool for the right job!
Did you investigate writing a PHP extension at all? I'm not sure what the speed difference would be, but most people I know say that the PHP interpreter is too hairy to really work with.
In fairness, there are probably a lot of languages that could have handled that load without too much trouble — C, C++, Java, OCaml, Haskell, maybe Erlang. But C does make high performance fairly easy.
I work at Kiip, where we write primarily in Python, Erlang and C. We have built several in-house analytics systems than can handle upwards of 300K qps. We are hiring too: http://kiip.me/jobs
10 comments
[ 17.0 ms ] story [ 846 ms ] threadBut it looks completely different from C:
---- C example ----
int main(int argc,char argv){ int i; for(i=0;i<argc;i++) printf("argv[%d]=%s\n",i,argv[i]); return 0; }
---- VHDL example (from de.wikipedia) ----
I wrote a system the has to handle 4 Billion transactions a day and a peak of 45,000 per second. And has to respond in 10ms or else the results of the transaction are discarded.
I wrote it in PHP so it would be easier for my team to maintain but it would not scale beyond 4,500qps then I re-wrote it in C as an apache module and it now scales to 25,000qps per server.
Sometimes you just have to write stuff in C. I've been writing in C for 28 years. I write other languages as often as I can but once in a while I have to go back to C to get something done. Right tool for the right job!