What does it mean by hard and soft coding?

Is this really exist in programming?

2 Answers

  • oyubir
    Lv 6
    1 month ago

    Hard means "material", so, electronic.

    Hardware are the physical components of a computer (or of anything for that matter).

    Solfware are the "intellectual", "immaterial" components.

    So, "soft coding" would be a pleonasm. "Hard coding" an oxymoron.

    That being said, I can see different possible meanings to those expression.

    * "Hard coding" could refer to the fact that nowadays even the hard is coded (and I am not referring to microcode here — code embedded in the cpu, in charge of interpreting machine language, since, no, machine language is not really the lowest level language). For example you can "code" a FPGA. But even ad-hoc CPU (ASICS). Nobody design those by hand. They are coded, for example in a language like VHDL, which looks a lot like a programming language (it inherit from ADA syntax).

    So coding in VHDL could qualify as "hard coding". And someone who does that may use the term "soft coding" to distinguish the activity of coding software that will run on the CPU he/she is hard coding.

    * Likewise, the past participle "hard coded" refers to the fact that a given feature is not up to the choice of software developper, because it is hard coded. It is a feature of the hardware you are using, and cannot be changed.

    You could say for example that 64 bits size of integers of your CPU is hard coded. You cannot change it to 48 bits in a program by just writing "intSize=48;".

    * Then, there is a semantic shift here. People often use the word "hard coded" in the same spirit, when a parameter is not modifiable in a configuration file of a settings interface, but is coded directly in the code.

    That is not litterally hard (it is not material. It is still code, so still soft). But since, from the point of view of the user of a software (so someone who considers that he/she cannot modify the code, either because he/she has no competence to do it, or because it would be bad practice to modify an external code — you would have to redo it at each update), the consequence is the same: you cannot modify this parameter. So by analogy, it is the same problem as a feature that comes from the electronic: you have to use it as is, and cannot change it.

    So, by extension, it context when it is not ambiguous (when nobody expect you to think of the hardware), "hard coded" means "coded directly at the design of the thing, so we can't change it".

    * A new usage that emerge with AI, is the difference between explicit and impiicit coding of an algorithm.

    If you want, say, to sort a list (and I choose and example that would be a very bad idea to treat with AI, but that is just an example), you can do it two ways

    - You code a sorting algorithm. That is you specify a list of actions that, when executed, leads to a sorted list.

    - You just code a fitness function (a function that qualifies how happy you are with the sorting list. 0 being perfect, higher values being less sorted. So for example, just count number of elements that are not greater than their predecessor). And run a planing algorithm on it, that will try to find the path from initial state of the list to a state where it is sorted.

    - Or, even better, you use reinforcement learning to learn automatically, from zillions of examples, how to sort a list.

    So, in first case, sequence of actions that leads to the list being sorted is "hard coded" (you coded it your self. It won't ever change. Each time the algorithm will be executed that will be with this sequence of actions)

    In the two other cases, sequence of actions is the result of a "reflection" of an AI. The AI has the opportunity to find an easier way than the one you would have coded. The software is no stuck with a non changeable, "hard coded", sequence of actions.

    So, that is something we begin to see. People, in AI/ML field, using the words "hard coded"/"soft coded" to distinguish behaviour of the algorithms that were coded by the human, and the one that are the result of an AI (my 2nd example) /  ML (my 3rd) process

    But, well, strictly speaking, "hard" is the electronics (how the transistors are connected to each other), and "soft" is the content of the memory that electronics use to "know" what to do (so a sequence of instructions)

  • JJ
    Lv 7
    1 month ago

    Yes - 

    Angular is hard

    PHP is easy ( therefore soft)

Still have questions? Get answers by asking now.