CSS is a strongly typed programming language

One way to classify programming languages ​​is by how strongly or weakly typed they are. In this case, "typed" means whether the variables are known at compile time. A good example would be a scenario where an integer 1 is added to a string containing "1".





A string containing an integer may have been inadvertently assembled from a complex set of logic with many moving parts. It could also be deliberately compiled from a single source of truth.





Despite the definitions of the terms weak and strong, a strongly typed programming language is not necessarily better than a weakly typed one. Scenarios where flexibility will be much more useful than stiffness, and vice versa, are perfectly acceptable. As with many aspects of programming, in this case the answer depends on different external contexts, i.e. "depends on…".





Another interesting point is that there is no formal definition of what strong or weak typing is.





TypeScript

JavaScript is considered a weakly typed language, and this flexibility has contributed to its early adoption on the Internet. However, the more mature and evolved the Internet has become, the more complex JavaScript use cases have become.





Extensions like TypeScript were created to help with this. Think of it as a JavaScript "plugin" that instills strong typing into the language. This helps programmers navigate complex settings. An example of this would be a data-intensive single page application used for an online store. TypeScript is currently very popular in the web development industry and many new projects use TypeScript by default.





Compilation

Compilation is the period of time when a programming language is translated into machine code. It is a harbinger of execution time - the amount of time it takes for a computer to execute machine code.





, . , TypeScript, JavaScript JavaScript .





- , . TypeScript , , .





An example of a TypeScript error in VS Code
TypeScript VS Code

JavaScript «» , . :





  • ,





  • ,





  • ,





TypeScript , . JavaScript . TypeScript , . JavaScript, , — , , JavaScript - -, .





CSS

CSS - , . . CSS . , .





CSS

CSS :





:





  • :





    • initial







    • inherit







    • unset







    • revert







  • ,  grid-area







  • "hello"







  • URL- https://css-tricks.com/







  • (--



    )





:





  • , 0-9





  • , 3.14







  • , 25%







  • , , 100px



    3s







  • , 16/9







  • Flex Grid





:





  • :





    • ,





    • , ems





    • , 200ms







  • , 250ms







  • , 15deg







  • , 16Hz







  • , 96dpi







() , , - .





:





  • :





    • ,  papayawhip







    • transparent







    • currentColor







  • RGB





    • ,  #FF8764







    • RGB/RGBa-, rgba(105, 221, 174, 0.5)







  • HSL/HSLA ,  hsl(287, 76%, 50%)







  • ,  ButtonText







:





  • , URL .





  • , .





  • «» .





  • , .





  • ( circle 



     ellipse



    ) .





:









    • top







    • right







    • bottom







    • left







    • center







  • , 25%







CSS

CSS - « – ». , , JavaScript .





CSS : , , , . CSS – CSS-. , fuzzbuzz- CSS.





, “”, CSS.





, , CSS . , , , , .





, CSS : /, .





1: /





“potato”  border-style



. , / .banner



, . , CSS.





border-style







  • ,





  • , .





border-style



  dotted



, !





2:





calc()



CSS , . , .





font-size



p



(, 1.5rem



). font-size. , calc ()



(«2rem»



), .





- - font-size



1,5 rem



, body



.





3:





JavaScript, . .





: root



--color-cyan



#953FE3



. .square --color-cyan, . top , , background-color.







, .square



, «Don’t play to type.». .square



, .





, , , .





, CSS , CSS .





, , CSS .





, , - , , , . , .





-, stylelint, , CSS CSS- . stylelint , , GitHub, CSS .





terminal output stylelint
stylelint

-, Firefox CSS . , CSS. , .





Firefox developer version
Firefox

CSS has been strongly typed ever since it was a programming language, and as a programming language it has been around for a long time. In addition, it has grown a lot lately. In case you haven't noticed yet, great new features are available .





As strongly typed JavaScript becomes more popular, I hope it helps developers get comfortable with the solid yet flexible CSS approach.








All Articles