Talk:C (programming language)
This is the talk page for discussing improvements to the C (programming language) article. This is not a forum for general discussion of the article's subject. |
Article policies
|
Find sources: Google (books · news · scholar · free images · WP refs) · FENS · JSTOR · TWL |
![]() | C Intermediate Language was nominated for deletion. The discussion was closed on 29 April 2013 with a consensus to merge. Its contents were merged into C (programming language). The original page is now a redirect to this page. For the contribution history and old versions of the redirected article, please see its history; for its talk page, see here. |
![]() | This article has not yet been rated on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||||||||||||||||||||||||||||||||||||
Please add the quality rating to the {{WikiProject banner shell}} template instead of this project banner. See WP:PIQA for details.
Please add the quality rating to the {{WikiProject banner shell}} template instead of this project banner. See WP:PIQA for details.
Please add the quality rating to the {{WikiProject banner shell}} template instead of this project banner. See WP:PIQA for details.
|
| ||||||||||||||||
|
|
|||||||||||||||||
This page has archives. Sections older than 100 days may be automatically archived by Lowercase sigmabot III when more than 4 sections are present. |
unsourced argument regarding encoding
Essentially each sentence in that comment lacks a WP:RS; some part of it is perhaps valid, but is essentially an opinion TEDickey (talk) 18:10, 7 June 2014 (UTC)
- Fixed. — DAGwyn (talk) 19:12, 7 June 2014 (UTC)
puts should be used instead of printf for the hello world example.
printf is not the appropriate function to use in this scenario. The string "hello, world\n" is not a formatted string so there is no need to use printf. Instead I suggest the puts function for this situation. The two main advantages for use puts instead of printf are 1. The newline is printed after the text removing the need for the newline at the end of the string 2. Using puts introduces less overhead in comparison to printf. I understand that in this instance the end result will be the same and in fact even old versions of gcc (and recent of course) will optimize the printf to become a call to puts when appropriate see http://www.ciselant.de/projects/gcc_printf/gcc_printf.html Just because gcc can optimize this example does not mean that all compilers can do such so it is important that we have a correct example. Also the fact that gcc optimizes (when appropriate) calls to printf making them puts furthers my argument that the examples could be better optimized. Another advantage for using puts instead of printf is that beginners may see the example and make the same mistake that this article does. Remember the goal of an encyclopedia is to teach and teaching suboptimal programming is going against that goal. Sonic12228 (talk) 23:47, 20 July 2014 (UTC)
- This comes up constantly. Everybody has a conflicting opinion as to the "correct" example. Best to just leave it alone. - Richfife (talk) 01:24, 21 July 2014 (UTC)
- It makes no difference except that printf is familiar and puts comparatively less so. There is no need to optimize how "hello, world" is printed here, and the historical significance of "which appeared in the first edition of K&R" overrides other considerations. Johnuniq (talk) 01:28, 21 July 2014 (UTC)
- Yeah, it's best to leave the example unchanged. However, we might consider adding a note somewhere that using puts() would produce the same results without potentially introducing additional overhead etc. — Dsimic (talk | contribs) 02:28, 21 July 2014 (UTC)
- That does seem like a good idea Dsimic. How about I add something like this: The reason printf was used in favor of the puts function was due to historical significant and not due to printf being the most suitable function. The puts function will print a newline character after the string has been printed thus removing the need for the newline character at the end of the string. In addition using printf introduces overhead owing to the fact that variable arguments have to be accounted for and the string checked for formatting. Some compilers such as GCC can replace calls to printf with calls to puts when this would produce the same end result.Sonic12228 (talk) 03:03, 21 July 2014 (UTC)
- That sounds good to me, though I'd suggest it to be just a bit less wordy. In addition, the reference you've already provided for the optimization performed by GCC should also be included. However, let's see first what Richfife, Johnuniq and other editors think about adding such a note, if you agree. — Dsimic (talk | contribs) 03:31, 21 July 2014 (UTC)
- I disagree. There are many ways you could write "Hello, world". We don't need a deep analysis of what the alternatives are. It's here because that's the way it was introduced in K&R (as noted in the article). So as a first issue, there is no justification whatsoever for changing the "original" version. And the second version is rightfully a minimally modified version conforming to modern C standards. Nor is the example "suboptimal" in any meaningful way. Wikipedia is not a programming tutorial, and notions of performance (and to what extent they might actually be real for this example - and if we actually cared about a form with the largest probability of being well optimized, a series of putc() macro invocations would probably be best), are far outside the scope of the article. "Hello, world" is meant to be illustrative of a fairly minimal program in a language, and it meets that requirement, and manages to illustrate a notable bit of history at the same time. That being said, if K&R had used puts(), it would have been slightly better, but they didn't. Rwessel (talk) 07:52, 21 July 2014 (UTC)
- K&R used printf because it is the correct function for a beginner—their next example uses the same printf with
"%d\t%d\n"
to print two integers. Telling a beginner to use puts for a string and printf for something else would generate pointless confusion. This article is not a text book with how-to advice and there is no need for a note—if a note were desirable, all code examples would need a similar note with optimization information. Johnuniq (talk) 09:36, 21 July 2014 (UTC)
- That does seem like a good idea Dsimic. How about I add something like this: The reason printf was used in favor of the puts function was due to historical significant and not due to printf being the most suitable function. The puts function will print a newline character after the string has been printed thus removing the need for the newline character at the end of the string. In addition using printf introduces overhead owing to the fact that variable arguments have to be accounted for and the string checked for formatting. Some compilers such as GCC can replace calls to printf with calls to puts when this would produce the same end result.Sonic12228 (talk) 03:03, 21 July 2014 (UTC)
Added References
I have added few citations to the Related Languages section. Please verify so that we can get the no references tag removed. Regards !! SlimShadyLFC (talk) 05:29, 9 August 2014 (UTC)
- Blogs are unfortunately not reliable sources. Rwessel (talk) 09:14, 9 August 2014 (UTC)
- OK Thank you for letting me know! SlimShadyLFC (talk) 17:05, 9 August 2014 (UTC)
The "standard-conforming" hello-world example is NOT standard-conforming!
It did not return with zero. — Preceding unsigned comment added by Dannyniu (talk • contribs)
- https://en.wikipedia.org/wiki/Special:Search?search=Hello+world&prefix=Talk%3AC+%28programming+language%29%2F&fulltext=Search&fulltext=Search - Richfife (talk) 03:09, 14 November 2014 (UTC)
this is a own idea of mine.my question is that whatever we type we should get output of that problem is that possible?
- All unassessed articles
- C-Class Computing articles
- High-importance Computing articles
- All Computing articles
- C-Class Computer science articles
- Mid-importance Computer science articles
- WikiProject Computer science articles
- C-Class C/C++ articles
- Top-importance C/C++ articles
- C articles
- WikiProject C/C++ articles
- Wikipedia former featured articles
- Former good article nominees