9 ms·
A different take on the matter: I write code mainly artistically, and I found that C is one of the best languages available to code as a form of art. It allows
by antirez 4y ago
A different take on the matter: I write code mainly artistically, and I found that C is one of the best languages available to code as a form of art. It allows to be both brutal and honest, or abstract and deceiving. Not many languages are so semantically powerful.
- xigoi 4y agoCan you expand on that?
- nikbackm 4y agoC++ should be even better in those categories.
- siftrics 4y agoThis shouldn't be downvoted. C++ is a superset of C; it must be capable of being at least as "brutal and honest" and "abstract and deceiving" as C. I would argue that C++ can be dramatically more deceiving than C --- see inheritance and operator overloading, just to name two.
- AlexeyBrin 4y agoC++ is not a superset of C, there are plenty of legal C constructs that will trigger errors when compiled with a C++ compiler.
- wiseowise 4y agoC++ is a sane defaults superset of C.
- 3836293648 4y agoC is not a superset of C either. C++ is a superset of a C version, even if they then went on to add stuff that wasn't added to the other
- kazinator 4y agoBut most of them are new constructs, not found in the venerable C90.
- Koshkin 4y agoOperator overloading is the one thing that makes C++ strictly better than any language that does not allow it.
- camel-cdr 4y agoHow so? To me, operator overloading seems like a non feature, that at best create more ambiguity.
- Conscat 4y agoWithout it, you cannot express arithmetic wrappers or simd wrappers. So far, no language with any users has managed to provide adequate arithmetic and simd types built in, despite several attempts like Odin and CosmiC/HolyC. I'm not sure it's even possible to design such types that satisfy everyone, and they must be extensible somehow because satisfying anyone is a moving target. Note how terrible doing any amount of math is in C.
- menaerus 4y agoAlso without operator overloading, it wouldn't be possible to implement lazy evaluation, which along with the use of expression templates happens to be one of the most crucial aspects that any linear algebra library will want to take advantage of in order to generate the most optimal code.
- Someone 4y ago> without operator overloading, it wouldn't be possible to implement lazy evaluation I don’t understand that. You can have functions that return promises that then can get passed to other functions returning promises, and leave it either to the compiler or to an expression evaluator you write (that ideally runs at compilation time as much as possible) to optimize away anything not needed. For example (pseudo-code) vector3D a = … vector3D b = … promise<vector3D> c = addLazily(a,b) print c.x in the end, could do the equivalent of print a.x + b.x I think you could make a modern C++ compiler do that for this simple example.
- colanderman 4y agoArt is often about constraint, and mastery of simple tools. I identify with @antirez's sentiment. I know both C and C++ very well. I find C definitely more artistic. C++ is utilitarian. Prolog is the other language I code in "artistically". It too is quite simple and constrained, though it is on the opposite end of the high/low-level spectrum as C.
- bakuninsbart 4y agoWhat is your take on Perl and Ruby? They seem to be the two languages where the communities themselves talk the most about poetry and elegance.
- sph 4y agoPerl and Ruby are very expressive. Python on the other hand feels like a scripting language designed by a 1990s corporate Java developer. /unpopular-hot-take
- MrLeap 4y agoI mostly agree with this. I'll come to python's defense though. Python is a gorgeous language wearing an ugly hat. The hat has __multiple out of place brims__, all of which are about two underscores wide.
- sph 4y agoIt's not a hat, it's a snake that swallowed a Java engineer :)
- tuatoru 4y agoThe name came from the author's love of Monty Python's Flying Circus, so perhaps it's an experiment in low-key absurdist humor or surrealist art. Like chindōgu[1]. 1. https://en.wikipedia.org/wiki/Chind%C5%8Dgu https://en.wikipedia.org/wiki/Chind%C5%8Dgu
- 4y ago
- Koshkin 4y agoTrue; on the other hand, personally, I think that normally C and C++ shouldn't be even mentioned in the same context. (My C++ code bears virtually no resemblance to my C code.)
- low_common 4y agoCan you share some examples of your "art"? I'm trying to wrap my brain around the concept of writing code for any reason other than work or trying to build something.
- antirez 4y agoSome background here: http://antirez.com/news/133 http://antirez.com/news/133
- WastingMyTime89 4y agoIt’s mostly semantically very poor to be honest. C really is a nicer assembly in a lot of way. It’s extremely limited. You have branching logic, functions call, pointer arithmetic, a way to define data structures which are really memory layouts and that’s pretty much it. I guess you can appreciate that as an aesthetic statement but what you wrote would apply equally to any language with more complex semantics.
- sn41 4y ago> that’s pretty much it. Only if you ignore 1. variadic arguments as in printf, 2. function pointers which are a very elementary (type-unsafe) form of closures, 3. a nice way of casting to void 4. setjmp and longjmp goodies (?) which allow you to code up co-routine libraries and exception handling mechanisms I'm sure there are more such facets I am missing. The elegance of the specification may be questionable, but the scope of what C tried to achieve is breathtaking. It actually is superior to most of its improvements.
- WastingMyTime89 4y agoThere is no elegance there. Casting to void is not a plus. That’s just C having no proper type system. Function pointers as an elementary form of closures, come on, what’s next? Closures are defined by capture. It’s nearly as fun as pretending C as coroutines because of setjmp. How can a statement like C being semantically poor even be seen as controversial? For god sake, we are talking about a language which semantically doesn’t even have proper arrays. > The elegance of the specification may be questionable, but the scope of what C tried to achieve is breathtaking. It actually is superior to most of its improvements. Seriously? It wasn’t even a good language when it was released. Lisp and Pascal were far better. It won because of compiler availability and adequate performance on limited platforms. HN really is a joke sometimes.
- youarethejoke 4y agoYou really don't understand, but that's okay. C is a wonderful language, and that's the end of it really. You just try to think C as a language that SHOULD HAVE all the stupid bells and whistles you find convenient. Many of us more advanced coders have found that those stupid bells and whistles are, in fact, inconvenient. Casting to void is a powerful technique and the limits are literally endless. C is semantically rich, way beyond your dull imagination.
- antoniuschan99 4y agoWhat are your goto sources of knowledge for C? I’m learning it to write embedded stuff and so far it’s mainly the k&r book, one from no starch press, and a udemy course. Thanks!
- colanderman 4y agoNot the GP, but cppreference.com [1] is the best reference I've found for C (and C++) in 20+ years, short of just reading the standards themselves. [1] https://en.cppreference.com/w/c https://en.cppreference.com/w/c
- antoniuschan99 4y agoThank you!
- Emigre_ 4y agoI think you’ll like Fluent C: Principles, Practices, and Patterns by Christopher Preschern (O’Reilly, 2022). The books you have are excellent ways to learn the language, and this one complements them in that it lists common practices around, for example, error handling, and other common topics. It shows different approaches and mentions practices from real-world open-source C projects that follow them. It seems like a good book to continue exploring C after learning the language.
- antoniuschan99 4y agoThank you!