Treffer: Generics in Java and parallels with templates in C++ ; Generiki v jeziku java in vzporednice s predlogami v jeziku C++
Weitere Informationen
Generics are a powerful tool in object-oriented programming languages, especially in the Java programming language. They play an important role in software development, since they enable the programmer to write typeindependent code in a type-safe way. In a nutshell, a generic Java class (or method) is a class (or method) parameterized with an arbitrary number of types. When using a generic class or method, we specify concrete values for the type parameters, effectively tailoring the code of the class or method for concrete types. Another benefit of Java generics is that type safety is enforced during compilation rather than execution. The C++ programming language has a concept parallel to Java generics ; these are templates. C++ templates and Java generics are similar to one another in terms of code syntax, the provided support for parameterizing types, and the most frequent use cases. However, they are actually implemented in a significantly different way, and there are important differences in their use and background semantics. In this thesis, we will show examples for both Java generics and C++ templates. We will discuss their similarities and differences, as well as advantages and disadvantages. ; Generiki so močno orodje v objektno usmerjenih programskih jezikih, še zlasti v jeziku java. Pri razvoju programske opreme igrajo pomembno vlogo, saj omogočajo programerju, da piše kodo, ki je neodvisna od konkretnih tipov, a kljub temu jamči pravilno rabo tipov. Generični javanski razred (oz. metoda) je v osnovi razred (oz. metoda), ki je parametriziran(a) s poljubnim številom tipov. Pri uporabi generičnega razreda oz. metode podamo konkretne vrednosti za tipne parametre in tako prilagodimo kodo razreda oz. metode za konkretne tipe. Druga prednost javanskih generikov je, da se skladnost tipov preverja že v času prevajanja, ne šele v času izvajanja. Koncept, podoben generikom v javi, obstaja tudi v jeziku C++: to so t.i. predloge. Predloge v C++ in generiki v javi so si med seboj podobni po sintaksi, po podpori ...