3 ms·
> vectorization is one of the obvious ways to get better performance in a wide range of situations. Or, well, in a narrow range of situations where you have ce
by kazinator 3y ago
> vectorization is one of the obvious ways to get better performance in a wide range of situations.
Or, well, in a narrow range of situations where you have certain kinds of hardware with vectorization support.
> C has zilch
C has operating systems written in it which use parallel processing internally and make parallel processing available to applications. True, that may be done using techniques that are not described in ISO C.
Common Lisp has undefined behavior, a familiar example being (rplacd '(1 . 2) 3): clobbering a literal object.
Optimizations in Common Lisp are exactly like UB in C: you make declarations which specify that certain things hold true, and in an unsafe mode like (declare (optimize (safety 0) (speed 3))), the compiler blindly trusts your assertions and generates code accordingly. If you asserted that some variable is a fixnum, but it's actually a character string, that character string value's bit pattern will likely be treated as a fixnum. Or other consequences.
Common Lisp is nice in that you can control speed and safety tradeoffs on a fine granularity, but you do trade safety to get speed.
Common Lisps (not to mention Schemes) have extensions, just like C implementations. In plenty of code you see things like #+allegro (do this) #+sbcl (do that).
- crabbone 3y ago> certain kinds of hardware This certain kind of hardware exists on virtually all consumer-grade and server-grade CPUs produced in the last decade. This is where optimizations matter in the first place. It doesn't matter that operating system written in C: it has no concurrency in the language. Here are examples of concurrency in the language: in Java, you have "synchronized", in Go you have "select" in Erlang you have "receive", in Ada you have "task" and so on. These languages provide some way to deal with concurrency and language implementations must have concurrency primitives. There's nothing like that in C. You don't have to implement C in such a way that it supports concurrency in any way. No part of the standard requires it (unlike in C++, where you have threads since C++11). > Optimizations in Common Lisp are exactly like UB in C: My guess is that you have never even seen Common Lisp. You just wrote absolute nonsense.
- kazinator 3y ago> This is where optimizations matter in the first place. It's also where optimizations often don't matter. > My guess is that you have never even seen Common Lisp (invoke-restart 'next-guess) > C: it has no concurrency in the language. That is now literally false. ISO C now has threads and atomics. Also, C has supported signals for eons: C code can be interrupted to run a signal handler, which requires reentrancy. However, it is correct that concurrent systems have been written in C without support in the language. In C, concurrency can be in a library/module, and you can develop that as part of the system from the ground up. This has enabled OS researchers to explore new concurrency mechanisms. The stagnant backwaters of Eiffel and Ada would not have come up with the Futex, for instance. Or RCU. In C, when you write a function that works only with its local variables, that is understood to be reentrant (with pretty much every compiler on the planet except maybe something for an 8 bit microcontroller with a kilobyte of RAM.) So that is actually one very important, basic piece of language-level support for concurrency. Code can be written in C to run on bare hardware such that with only a minimal amount of glue, C functions can handle interrupts. When a C function accesses external resources, that is obvious, and those accesses can be protected using external means also. That's generally how it works.
- crabbone 3y agoIf optimization doesn't matter, then why are you talking about optimization? This is just plain stupid... Vectorization is a huge subject in many different kinds of software, RDBMs, scientific computing / HPC, even advertising... and then comes you and tells all those people spending billions of dollars a year on optimization that it... doesn't matter? How much does it have to matter before it "really" matters? Well, then you've never understood what you were dealing with. Or your reading-comprehension skills are so bad, that you cannot understand it when someone describes the difference between something that happens intentionally and something that happens through oversight... But, my guess is that you are just pretending to be stupid, because you enjoy trolling, and that's your way to do it. C signals aren't a required part of the language... (a "standard compliant" implementation doesn't have to have them) but C language is just poorly designed. There shouldn't have been a thing like "not required part of the language", but it happened out immediate convenience of someone who didn't want to apply themselves more to making a better design. Exactly the same is true for threads and atomics. A "standard compliant" implementation doesn't have to have them. Portable code shouldn't use this stuff. Read it again: this discussion is about language, not libraries. If you think that ability to make a system call makes a language concurrent, then it's a worthless definition, because this blurs the important distinction between languages that are designed to be concurrent and those which aren't. Everything short of stuff like HTML becomes a concurrent language, but you cannot have any meaningful discussion about benefits or downsides of an approach to concurrency, because it's "outsourced" to something outside the language. > C functions can handle interrupts. What... like processor interrupts? What on Earth are you talking about... Are you getting your text from a chatbot or something?