Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

To me a big mistake in C is its multidimensional arrays. For example, it is not possible to write a function which multiplies two rectangular matrices, since the sizes cannot vary in that manner (m×n and n×k, with m, n, and k variable).

On the other hand, C has so many goodies which ought to be done right and better in modern languages, but often are not:

1. Variadic functions like printf. It sucks to wrap arguments into a list just for this.

2. Setjmp/longjmp and nonlocal returns

3. Union data types

4. Conditional macro directives to compile debug statement versions when needed.

It's easy to criticise C or patronise it saying that it was good for its time, the reality is that many of its features (or what they attempt) are futuristic even today.



I'm not sure what you mean. CBLAS includes this function to multiply two rectangular matrices:

  void cblas_dgemm(
     const CBLAS_LAYOUT Layout, 
     const CBLAS_TRANSPOSE transa, const CBLAS_TRANSPOSE transb, 
     const MKL_INT m, const MKL_INT n, const MKL_INT k,
     const double alpha, const double *a, const MKL_INT lda, 
     const double *b, const MKL_INT ldb, 
     const double beta,
     double *c, const MKL_INT ldc);
gsl has a higher-level interface:

  int gsl_blas_dgemm(CBLAS_TRANSPOSE_t TransA, CBLAS_TRANSPOSE_t TransB, 
     double alpha,
     const gsl_matrix * A,
     const gsl_matrix * B,
     double beta,
     gsl_matrix * C);


> Setjmp/longjmp and nonlocal returns

That has to be the first time I've seen those features of C described as a positive. I'm genuinely curious; would you be willing to explain further?


Maybe the parent uses jmps for coroutine style programming?


I don't think variadic functions are uncommon. Try Idris - not only it has them, but you can actually statically typecheck the arguments against the format string - all in regular code, with no special help from the compiler!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: