Talk:C (programming language): Difference between revisions

Content deleted Content added
m Energy Usage: Copyedit (minor)
 
(38 intermediate revisions by 11 users not shown)
Line 24:
}}
{{archives|bot=MiszaBot I|search=yes|age=100|dounreplied=yes}}
 
== Mention of C allowing various memory allocations schemes ==
 
{{u|Jochen Burghardt}} [https://en.wikipedia.org/w/index.php?title=C_(programming_language)&diff=prev&oldid=1183993545 removed] this section on C allowing various memory allocation implementations:
 
:{{tq|C permits the use and implementation of different [[C dynamic memory allocation|memory allocation]] schemes, including a typical {{code |lang=c |malloc}} and {{code |lang=c |free}}; a more sophisticated mechanism with [[Region-based memory management|''arenas'']]; or a version for an [[kernel (operating system)|OS kernel]] that may suit [[direct memory access|DMA]], use within [[interrupt handler]]s, or integrated with the [[virtual memory]] system.}}
 
With the edit summary {{tq|"malloc is not built in in C, but a library function, and could be provided for every other language in a similar way"}}. It's actually not true that you can do this in every other language, it depends on directly manipulating and storing pointers for one thing, which most languages do not do. The passage doesn't say malloc is part of C itself, in fact it implies the opposite - it lists malloc as one possibility. I disagree with this removal. [[User:DIYeditor|—DIYeditor]] ([[User talk:DIYeditor|talk]]) 19:49, 7 November 2023 (UTC)
 
:As I understand the title of this article, it is about the C programming language itself; there is a different article [[C standard library]]. "{{tq|The passage doesn't say malloc is part of C itself}}" - this is the reason why I think it shouldn't be discussed here, but at [[C standard library]]. As a side remark, <code>malloc</code> can be implemented as is in every language that supports pointers, and with slight modifications in every language that supports arrays (having arbitrary type casts in the language will increase user convenience). - [[User:Jochen Burghardt|Jochen Burghardt]] ([[User talk:Jochen Burghardt|talk]]) 11:58, 8 November 2023 (UTC)
::Please stop edit warring to restore your preferred version.
::We can wait for input from more people. [[User:DIYeditor|—DIYeditor]] ([[User talk:DIYeditor|talk]]) 13:17, 8 November 2023 (UTC)
:::I didn't edit [[C (programming language)]] after my above reply. The anonymous IP 193.162.48.193 vandalized an article part that is unrelated to our above discussion, and I assure that it wasn't me. Admittedly, my 2nd revert might have violated a strict interpretation of [[WP:BRD]]; however, I gave a long justification in my edit summary. Waiting for opinions from other people is ok for me. - [[User:Jochen Burghardt|Jochen Burghardt]] ([[User talk:Jochen Burghardt|talk]]) 14:05, 8 November 2023 (UTC)
::The goal of this the overall section is to explain and justify the wide adoption of C as a systems programming language. The section in question states that C permits choice in dynamic memory allocators - a good justification, since operating systems and similar often control memory for other processes. Options range from the usual {{code|stdlib.h}} to very machine-specific ones. This flexibility is a feature of the language. Only one of the choices pertains to the standard library and its {{code|malloc}} - the others do not - and indeed there is already a link in the debated section to [[C dynamic memory allocation]].
::If there are improvements to be made, then let's make them! But I agree with {{u|DIYeditor}} and disagree with the removal. [[User:Chumpih|<span style="text-shadow: 2px 2.5px 3px #448811bb">Chumpih</span>]] <sup>[[User talk:Chumpih|t]]</sup> 20:18, 8 November 2023 (UTC)
 
== Duplicate sections on related languages - merge? ==
Line 65 ⟶ 50:
::::Compilation is about code generation. If machine code is never generated, then the implementation is interpreted. If machine code is generated while the program is running, then the implementation is JIT compiled. If machine code is generated before the program is ran, then the implementation is AoT compiled.
::::Most interpreted languages can be implemented with a JIT compiler, for example, Javascript. However, AoT compilation and JIT compilation are very different. [[User:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO]] ([[User talk:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|talk]]) 23:24, 19 July 2025 (UTC)
:::::Compilation is the process of converting a program from one representation to another - if source code is turned into bytecode, that is still compilation. [[User:MrOllie|MrOllie]] ([[User talk:MrOllie|talk]]) 00:05, 20 July 2025 (UTC)
::::::Yes, and even machine code of an actual processor is interpreted, either in hardware by the processor itself or in software by an emulator. — [[User:Vincent Lefèvre|Vincent Lefèvre]] ([[User talk:Vincent Lefèvre|talk]]) 14:04, 20 July 2025 (UTC)
 
== Remove <nowiki>{{harvtxt}}</nowiki> templates? ==
Line 94 ⟶ 81:
:But what are "standard Cites"? 😀 There is no such thing in Wikipedia and everyone does what they want anyway. [[User:Elrondil|Elrondil]] ([[User talk:Elrondil|talk]]) 02:58, 13 June 2025 (UTC)
::Ah, true, true! [[User:Chumpih|<span style="text-shadow: 2px 2.5px 3px #448811bb">Chumpih</span>]] <sup>[[User talk:Chumpih|t]]</sup> 06:39, 13 June 2025 (UTC)
 
== Holy c needs to be added as a dialect ==
 
. [[User:Tankfarter|Tankfarter]] ([[User talk:Tankfarter|talk]]) 05:38, 28 July 2025 (UTC)
 
== Energy Usage ==
 
This whole section is absolutely bizarre:
 
Originally, C was popular mostly due to being easier to use than other programming languages.[citation needed] Currently, C is popular mostly due to speed, efficiency, low memory usage, and simplicity.[citation needed] C uses approximately one-eightieth the energy that Python, Perl, and PHP do.[17] On average, C uses less energy than Fortran, despite Fortran being faster on average.[citation needed]
 
But this line in particular:
 
C uses approximately one-eightieth the energy that Python, Perl, and PHP do.[17]
 
Is particularly problematic, as it gives the reader the understanding that C always uses 1/80 of the energy of the other listed languages, when in fact, it uses this while running these specific benchmarks, which have very little (if anything) to do with the real-world use of a language.
Let's take Python for example. Which Python? Python 3.13? Python 2.6? CPython 3.13? Pypy 3.8? C as compiled with what? A "typical" C implementation of a given program probably does use substantially less energy than a "typical" Perl equivalent, but stating 1/80 based on some benchmarks makes no sense.
 
The entire section reads as something you would read on a website comparing Linux distros where it's clear the author has no idea what they're talking about. [[Special:Contributions/196.211.140.249|196.211.140.249]] ([[User talk:196.211.140.249|talk]]) 08:55, 21 August 2025 (UTC)
:That was added at [[Special:Diff/1301098576|02:36, 18 July 2025]] and should probably be removed. I doubt sites.google.com is a [[WP:RS|reliable source]]. Also, the [[WP:LEAD]] is supposed to be a summary of what is in the article. The lead should not be used to add ideas. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 09:13, 21 August 2025 (UTC)
:Lets not pretend that C uses the same energy usage as Python. The Cython website claims benchmarks where Cython beat the reference implementation of Python in speed by a factor of 95. Even Cython, which few Python users use, uses more energy than typical C program equivalents. Almost all Python users use the reference implementation, which is well known for wasting CPU time, RAM, electricity, etc. Obviously, 95 is higher than the 80 times energy usage increase stated; however, the difference between 95 and 80 can be attributed to the fact that speed is not the same as energy usage.
:Somewhere else on the internet, I saw something where someone got a 75 times speedup in the training of a neural network by rewriting their Python to C, while using the same machine learning library. However, I do not remember where I saw that. [[User:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO]] ([[User talk:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|talk]]) 20:07, 24 August 2025 (UTC)
::The point, which has not been acknowledged, is we don't cite [[WP:USERGENERATED|user-generated sources]] in any instance. <span style="border-radius:2px;padding:3px;background:#1E816F">[[User:Remsense|<span style="color:#fff">'''Remsense'''</span>]]<span style="color:#fff">&nbsp;🌈&nbsp;</span>[[User talk:Remsense|<span lang="zh" style="color:#fff">'''论'''</span>]]</span> 20:11, 24 August 2025 (UTC)
::This was returned with a [[WP:ARXIV]] preprint, which is another kind of user-generated source, so that's not any better. Kindly secure agreement on this talk page before reinserting any variation of this claim. [[User:MrOllie|MrOllie]] ([[User talk:MrOllie|talk]]) 21:29, 24 August 2025 (UTC)
:::@[[User:MrOllie|MrOllie]], I looked via Google Scholar and thought I saw another version of the paper published somewhere on Harvard's webspace, but I clicked in and saw it was just another arXiv portal or something, whoops. Sorry for the confusion. <span style="border-radius:2px;padding:3px;background:#1E816F">[[User:Remsense|<span style="color:#fff">'''Remsense'''</span>]]<span style="color:#fff">&nbsp;🌈&nbsp;</span>[[User talk:Remsense|<span lang="zh" style="color:#fff">'''论'''</span>]]</span> 01:05, 25 August 2025 (UTC)
:::MIT did a study, as well; however, the paper was paywalled. However, a table of the results was posted to facebook by MIT. https://www.facebook.com/MITCSAIL/posts/the-energy-consumption-of-different-programming-languages-vandriy-burkov-httpsbi/890853283077184/ Does this count as a reliable source? Or is it unreliable because it is on Facebook? Since it is written by an official MIT facebook account, does that override the fact that it is a social media site? [[User:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO]] ([[User talk:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|talk]]) 22:35, 28 August 2025 (UTC)
::::I know that citing paywalled studies is against Wikipedia policy, and, thus, despite there being many reliable sources, it seems that you will not accept any of them. [[User:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO]] ([[User talk:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|talk]]) 22:36, 28 August 2025 (UTC)
:::::I found a large quantity of blogs with similar statistics on the energy usage. If I have enough similar sources, can that count as reliable? [[User:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO]] ([[User talk:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|talk]]) 22:37, 28 August 2025 (UTC)
::::::So, you haven't really looked at [[WP:RS]] at all yet, unfortunately. Please do that. Could you explain how that would work, though? Why would that matter? <span style="border-radius:2px;padding:3px;background:#1E816F">[[User:Remsense|<span style="color:#fff">'''Remsense'''</span>]]<span style="color:#fff">&nbsp;🌈&nbsp;</span>[[User talk:Remsense|<span lang="zh" style="color:#fff">'''论'''</span>]]</span> 22:40, 28 August 2025 (UTC)
::::::The facebook post contains a dead link. As to there being {{tq|many reliable sources}}, you still haven't presented one here. No number of unreliable sources such as pre-prints, social media posts, and blogs add up to a reliable source. [[User:MrOllie|MrOllie]] ([[User talk:MrOllie|talk]]) 22:42, 28 August 2025 (UTC)
:::::::I am 100% certain that the statistic is accurate. However, it seems that there is no way that you will accept for sourcing it. If I were to do benchmarks myself, then it would be original research. If I cite blogs with similar statistics, then they are considered "unreliable". According to Wikipedia policy, I cannot cite a paywalled study. The MIT Facebook post is "user generated", so I cannot cite that, even if it is from an official MIT account. Apparently, the similar paper on arXix is considered "unreliable" and "user generated".
:::::::You are gatekeeping legitimate information from being on Wikipedia. [[User:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO]] ([[User talk:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|talk]]) 22:44, 28 August 2025 (UTC)
::::::::{{xt|I am 100% certain that the statistic is accurate}}
::::::::Sorry, but who the hell are you? Do you at least get that the point of these policies is so readers don't have to take a perfect internet stranger's word for everything they read? <span style="border-radius:2px;padding:3px;background:#1E816F">[[User:Remsense|<span style="color:#fff">'''Remsense'''</span>]]<span style="color:#fff">&nbsp;🌈&nbsp;</span>[[User talk:Remsense|<span lang="zh" style="color:#fff">'''论'''</span>]]</span> 22:46, 28 August 2025 (UTC)
:::::::::I am not important.
:::::::::However, I have found many sources to support the fact about energy usage. Yall are merely dismissing them all as "unreliable". [[User:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO]] ([[User talk:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|talk]]) 22:50, 28 August 2025 (UTC)
::::::::::Because they are unreliable. Blogs and social media take unverified results from each other, which spreads around the internet. This is how false statistics get their legs these days. This is the Wikipedia system working as it is intended to work. [[User:MrOllie|MrOllie]] ([[User talk:MrOllie|talk]]) 22:58, 28 August 2025 (UTC)
:::::No, you don't know that, because that's not true at all. You would know this if you skimmed the [[WP:RS]] policy for any amount of time, so the least you can do is not confuse others by implying you have done this when you did not. <span style="border-radius:2px;padding:3px;background:#1E816F">[[User:Remsense|<span style="color:#fff">'''Remsense'''</span>]]<span style="color:#fff">&nbsp;🌈&nbsp;</span>[[User talk:Remsense|<span lang="zh" style="color:#fff">'''论'''</span>]]</span> 22:42, 28 August 2025 (UTC)
::::::I have seen the fact that pay-walled studies is against policies before on Wikipedia. I do not remember where on Wikipedia.
::::::Besides, I do not even know where the actual study is located on the internet. A quick search is not returning any links to the pay-walled study, despite the fact that it exists. [[User:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO]] ([[User talk:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|talk]]) 22:47, 28 August 2025 (UTC)
:::::::The policy is to allow sourcing of things behind a paywalled stuff, per [[WP:PAYWALL]]. To be blunt, getting to grips with [[WP:RS]] is a rite of passage that many Editors go through (I know I did). So in many ways: ''Welcome abord''. [[User:Chumpih|<span style="text-shadow: 2px 2.5px 3px #448811bb">Chumpih</span>]] <sup>[[User talk:Chumpih|t]]</sup> 23:00, 28 August 2025 (UTC)
::::::If the policies are to prevent needing to take an internet stranger's word, then why would pay-walled studies be citable? Pay-walled studies are not verifiable by normal people. [[User:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO]] ([[User talk:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|talk]]) 22:52, 28 August 2025 (UTC)
:::::::See [[WP:PAYWALL]]. You've got this backward. What are the full citation details of this paywalled study? [[User:MrOllie|MrOllie]] ([[User talk:MrOllie|talk]]) 22:56, 28 August 2025 (UTC)
::::::::I am not sure about the details of the study. I found a post online that claimed that the MIT study about energy usage of programming languages was published in 2021. However, I do not know the name of the study, or where to find it. [[User:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO]] ([[User talk:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|talk]]) 00:45, 29 August 2025 (UTC)
:::::::::If the post you're referring to is the facebook post, it does not state that they're the ones who came up with the table originally. Indeed, I have found screenshots of the same table on other blogs dating to before 2021. [[User:MrOllie|MrOllie]] ([[User talk:MrOllie|talk]]) 02:27, 29 August 2025 (UTC)
:::What about this, I found a paper on both https://nyuscholars.nyu.edu/en/publications/ranking-programming-languages-by-energy-efficiency and https://www.iro.umontreal.ca/~mignotte/IFT2425/Documents/RankingProgrammingLanguagesByEnergyEfficiency.pdf about the energy usage of programming languages, and it has a similar statistic. Are these reliable sources? [[User:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO]] ([[User talk:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|talk]]) 00:47, 29 August 2025 (UTC)
::If::Great therepaper, arepublished improvementsin to[[Science beof made,Computer thenProgramming]] let'sand makeit them!appears to Butsupport Iclaims agreefor withC's {{u|DIYeditor}}relative andefficiency. disagreeThumbs withup thefrom removalme. [[User:Chumpih|<span style="text-shadow: 2px 2.5px 3px #448811bb">Chumpih</span>]] <sup>[[User talk:Chumpih|t]]</sup> 2021:1825, 829 NovemberAugust 20232025 (UTC)
:In many implementations, C compiles directly to machine code that runs directly on the target procsssor. Many other languages are either JITting, or use bytecodes which are considerably less efficient. While C is far from unique in producing machine code, it is totemic in doing so, and engineers choose C for its close-to-machine output. Perhaps words should go in the lede (or elsewhere) to extol this close-to-machine benefit of the language, perhaps alongside comparisons to other compiled languages. I don't think citing 80x or similar is wise, given how context-dependent such figures will be. [[User:Chumpih|<span style="text-shadow: 2px 2.5px 3px #448811bb">Chumpih</span>]] <sup>[[User talk:Chumpih|t]]</sup> 22:48, 24 August 2025 (UTC)
::That's more or less what the third paragraph of the lead is doing. [[User:MrOllie|MrOllie]] ([[User talk:MrOllie|talk]]) 01:10, 25 August 2025 (UTC)
:::Yes, sort of. The 'designed to be compiled' part in lede para 3 is fine, but perhaps we should have words that spell out what that implies in terms of efficiency. This would be alongside other compiled languages, and in contrast to other languages which rely on interpreters, JIT, bytecodes, etc. [[User:Chumpih|<span style="text-shadow: 2px 2.5px 3px #448811bb">Chumpih</span>]] <sup>[[User talk:Chumpih|t]]</sup> 05:21, 25 August 2025 (UTC)
:::I have heard before that unoptimizing compilers tend to run approximately 10 times faster than interpreters. I do not think that a 80 times difference is that unreasonable given that consideration. Besides, the [[Cython]] Wikipedia page cites a 95 times speedup over CPython on a given benchmark, when using fixed witdth types.
:::Since Cython only partially converts to C, it is never going to speed up as much as a rewrite in C would. [[User:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO]] ([[User talk:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|talk]]) 01:28, 29 August 2025 (UTC)
 
== Efficiency ==
 
The high efficiency of C deserves more of a mention in the article, despite the efforts of a certain pair of Wikipedia editors who want to hide the fact that C is much more efficient than Python. However, since I am outnumbered, there does not seem to be anything that I can do about it. [[User:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO]] ([[User talk:Lxvgu5petXUJZmqXsVUn2FV8aZyqwKnO|talk]]) 02:57, 29 August 2025 (UTC)
 
:I won't speak for anyone else, but all I want is for the sourcing requirements to be followed. Come up with a proper source and I will have no further objections. [[User:MrOllie|MrOllie]] ([[User talk:MrOllie|talk]]) 02:58, 29 August 2025 (UTC)