Jump to content

Wikipedia:Reference desk/Archives/Computing/2018 November 21

From Wikipedia, the free encyclopedia
Computing desk
< November 20 << Oct | November | Dec >> Current desk >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


November 21

[edit]

Elementary sort question

[edit]

I haven't consciously done anything to alter the behaviour of GNU sort on my computer. If not given any options, this sorts to the order of (for example)

          IST
          :IT 
          .IT 
          IT

-- it simply ignores colons, periods, and other junk. This may very well be helpful for many purposes, but it frustrates what happens to be my own purpose. I'm sure that there's an option via which it will not ignore colons, etc (and thus, for these four, list IT immediately after IST), but I can't find it. I did skimRTFM, but I am mentally challenged. What do I need (aside from an improved brain)? -- Hoary (talk) 00:06, 21 November 2018 (UTC)[reply]

Well when I sort I get this order:
.IT
:IT
IST
IT

There are quite a few sort options and I wonder if you have a default set somewhere such as -d which means dictionary order. (I get a slightly different result with -d). Graeme Bartlett (talk) 05:23, 21 November 2018 (UTC)[reply]

‘LC_CTYPE’ locale can set sort order. LC_ALL is also relevant
man sort
info '(coreutils) sort invocation'

add --debug will tell you the sorting rules used:

$ sort --debug <test33
sort: using ‘en_US.UTF-8’ sorting rules
.IT
____
:IT
____
IST
___
IT
__

Graeme Bartlett (talk) 05:52, 21 November 2018 (UTC)[reply]

I can reproduce your output order by using sort -d -s ; and removing the trailing spaces on the end of each line. So check your data for trailing spaces. -s for stable retains original order if the keys are identical. (my sort version is sort (GNU coreutils) 8.26) Graeme Bartlett (talk) 07:42, 21 November 2018 (UTC)[reply]
Thank you, Graeme Bartlett! I'd utterly forgot about the matter of trailing spaces, for a start. -- Hoary (talk) 13:37, 21 November 2018 (UTC)[reply]

What kind of mode conditioning patch chord/cable or other fix will make GLC SX MMD work /interface between Cisco CATALYST 2960S Switch and single mode fiber optic cable

[edit]

We have single mode OFC network and CAT 6 CAT5 LAN with ethernet and gigabit Ethernet switches and ordered for "GE SFP, LC CONNECTOR LX/LH TRANSCEIVER FOR SINGLE MODE FIBER OF CISCO CATALYST 2960 S" SWITCH but the supplier has delivered "GE GLC SX MMD" Now what to do with this because the switch is not working with this transceiver What type of mode conditioning patch cable or other cost effective fix and all possible alternatives to make GLC SX MMD work with CATALYST 2960S SWITCH and single mode OFC .What will be the configuration.Please help and advice.122.15.54.25 (talk) 05:10, 21 November 2018 (UTC)[reply]

The SX is a short haul transceiver running on 850 nm infrared light, and the LX will be around 1320 nm, so they are totally incompatible. Not only that, SX is used for multimode fibre and will have a broad output beam that will hardly couple any energy into the single mode fibre. Your cheapest option will be to purchase the LX transceiver. You can get third party transceivers for a tiny fraction of the cost of Cisco branded product. An alternative is to buy a SX transceiver the the other end of the link, but as mentioned it may not function at all on SM fibre. (It might work but don't trust your chances.) Graeme Bartlett (talk) 06:01, 21 November 2018 (UTC)[reply]

C Language

[edit]
  • Transferred from talk page

which types of problems can be solved using C Language? 39.41.177.138 (talk) 14:07, 21 November 2018 (UTC) — Preceding unsigned comment added by 92.19.170.212 (talk) [reply]

This is an extraordinarily broad question! Here is my effort to distill my ideas on a very important topic and to point our reader(s) toward other resources with greater depth.
The C programming language is intended to be a medium used by humans to express instructions for machines. Any scenario that requires a machine to accept instruction can be formulated and expressed in the C language. This is the core of how we create computer software - everything from "apps" on smart-phones to control-systems for industrial robots. We build software by breaking any large task into smaller problems, and then we express solutions to those small problems. We can express those solutions using the C language; therefore, we can use it to build "apps", or to control industrial robots, and so on. But this is also generally true of most other programming languages. So, let me narrow the original question to a more specific one: "How do solutions expressed in the C language compare to similar solutions expressed using other programming languages?"
The C language permits, and often requires, the explicit specification of very important implementation-details about how and where the machine must store its information. In particular, the C language requires the human to be aware of how temporary or intermediate information is stored and processed by the machine. The C language allows - and requires - explicitness about many operational details. This permits a highly skilled programmer to express solutions that are very efficient - so the C language is useful for solving problems very quickly, often using very specialized types of computer machinery. For this reason, the C language is commonly used to develop system software, firmware, high performance computing, embedded systems, and hardware accelerators.
Many programmers - like many other humans - are initially only familiar with fairly abstract languages. The C language is not very abstract, so many new users initially find that the C language requires a relatively high degree of pedantic precision. This can lead to resentment: the C language requires more work to express important minor details about each instruction in a tasks.
Reciprocally, humans and others who are proficient in the C language often find that other, more abstract, languages preclude the precise specification of such important minor details.
For example: if you wish to express instructions to alphabetize a list of text items, you may wish to write a simple sorting algorithm. But the C language will additionally permit - and require - that you manage the storage, format, size, and location, of individual text strings. You must concern yourself with memory allocation, or stack memory usage; with null termination; with character data types; with details of the text encoding; and you must additionally concern yourself with the sorting algorithm. In a programming language like Python or Java, you do not need to worry about those intermediate details - in fact, those languages prevent you from expressing such concerns. There is no "word" in the Java language to do some of those steps: by design, a machine that understands Java is free to make up its own mind about the implementation-details. That machine may use a very efficient method to implement these details, or it may choose a very inefficient method to implement these details. Either way, you cannot instruct the machine to be either more or less efficient: it is up to the machine, and those languages do not have any words for you to tell it how to do things differently. In the C language, you have the words to tell the machine how to do things, and you must use them.
Simon Tatham, an esteemed programmer and creator of many famous software tools, wrote an excellent essay called The Descent Into C, circa 2013. That essay presents useful insights if you are a novice programmer with some experience in other languages, and you would like to begin developing with the C language.
Another excellent reference is the original book that was written by the original creators and users of the language, Dennis Ritchie, Brian Kernighan, and at least a little inspired by the insights of Ken Thompson: The C Programming Language.
Nimur (talk) 17:49, 21 November 2018 (UTC)[reply]
The article Computability addresses the types of problem that can be solved by a computer, historically building on the Church–Turing thesis. To be calculable, a solution must be expressed in the form of symbolic variables to be handled by an Algorithm which when executed by the computer will succeed in halting at the required solution. The article C (programming language) describes the features that contribute to this language's long-lived popularity. They include its widespread standardization, its use in computers ranging from supercomputers to personal computers to embedded systems, and its demand on the programmer to make static type declarations that help the C compiler deliver efficient executable code for the intended Computing platform (hardware). C is a prime example of a general-purpose computer language that is broadly applicable across application domains, has a rich set of in-built math and logic functions (extendable by function libraries) that save programming effort but lacks features for problems that require Parallel computing or critical real-time responses to event interrupt handling. Such problems are better addressed by SIMD techniques e.g. CUDA used to program a GPU or by task scheduling in a RTOS respectively. DroneB (talk) 13:39, 22 November 2018 (UTC)[reply]