KLiC C , C++, & JAVA Programming
COURTESY :- vrindawan.in
Wikipedia
C (pronounced like the letter c) is a general-purpose computer programming language. It was created in the 1970s by Dennis Ritchie, and remains very widely used and influential. By design, C’s features cleanly reflect the capabilities of the targeted CPUs. It has found lasting use in operating systems, device drivers, protocol stacks, though decreasingly for application software. C is commonly used on computer architectures that range from the largest supercomputers to the smallest micro controllers and embedded systems.
A successor to the programming language B, C was originally developed at Bell Labs by Ritchie between 1972 and 1973 to construct utilities running on Unix. It was applied to re-implementing the kernel of the Unix operating system. During the 1980s, C gradually gained popularity. It has become one of the most widely used programming languages, with C compilers available for almost all modern computer architectures and operating systems. C has been standardized by ANSI since 1989 (ANSI C) and by the International Organization for Standardization (ISO).
C is an imperative procedural language supporting structured programming, lexical variable scope, and recursion, with a static type system. It was designed to be compiled to provide low-level access to memory and language constructs that map efficiently to machine instructions, all with minimal runtime support. Despite its low-level capabilities, the language was designed to encourage cross-platform programming. A standards-compliant C program written with portability in mind can be compiled for a wide variety of computer platforms and operating systems with few changes to its source code.
Since 2000, C has consistently ranked among the top two languages in the TIOBE index, a measure of the popularity of programming languages.
C is an imperative, procedural language in the ALGOL tradition. It has a static type system. In C, all executable code is contained within subroutines (also called “functions”, though not in the sense of functional programming). Function parameters are passed by value, although arrays are passed as pointers, i.e. the address of the first item in the array. Pass-by-reference is simulated in C by explicitly passing pointers to the thing being referenced.
C program source text is free-format, using the semicolon as a statement separator and curly braces for grouping blocks of statements.
The C language also exhibits the following characteristics:
- The language has a small, fixed number of keywords, including a full set of control flow primitives:
if/else
,for
,do/while
,while
, andswitch
. User-defined names are not distinguished from keywords by any kind of sigil. - It has a large number of arithmetic, bitwise, and logic operators:
+
,+=
,++
,&
,||
, etc. - More than one assignment may be performed in a single statement.
- Functions:
- Function return values can be ignored, when not needed.
- Function and data pointers permit ad hoc run-time polymorphism.
- Functions may not be defined within the lexical scope of other functions.
- Variables may be defined within a function, with scope.
- A function may call itself, so recursion is supported.
- Data typing is static, but weakly enforced; all data has a type, but implicit conversions are possible.
- User-defined (typedef) and compound types are possible.
- Heterogeneous aggregate data types (
struct
) allow related data elements to be accessed and assigned as a unit. - Union is a structure with overlapping members; only the last member stored is valid.
- Array indexing is a secondary notation, defined in terms of pointer arithmetic. Unlike structs, arrays are not first-class objects: they cannot be assigned or compared using single built-in operators. There is no “array” keyword in use or definition; instead, square brackets indicate arrays syntactically, for example
month[11]
. - Enumerated types are possible with the
enum
keyword. They are freely interconvertible with integers. - Strings are not a distinct data type, but are conventionally implemented as null-terminated character arrays.
- Heterogeneous aggregate data types (
- Low-level access to computer memory is possible by converting machine addresses to pointers.
- Procedures (subroutines not returning values) are a special case of function, with an untyped return type
void
. - Memory can be allocated to a program with calls to library routines.
- A preprocessor performs macro definition, source code file inclusion, and conditional compilation.
- There is a basic form of modularity: files can be compiled separately and linked together, with control over which functions and data objects are visible to other files via
static
andextern
attributes. - Complex functionality such as I/O, string manipulation, and mathematical functions are consistently delegated to library routines.
- The generated code after compilation has relatively straightforward needs on the underlying platform, which makes it suitable for creating operating systems and for use in embedded systems.
While C does not include certain features found in other languages (such as object orientation and garbage collection), these can be implemented or emulated, often through the use of external libraries (e.g., the GLib Object System or the Boehm garbage collector).
C++ (pronounced “C plus plus”) is a general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or “C with Classes”. The language has expanded significantly over time, and modern C++ now has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation. It is almost always implemented as a compiled language, and many vendors provide C++ compilers, including the Free Software Foundation, LLVM, Microsoft, Intel, Ember cadero, Oracle, and IBM, so it is available on many platforms.
C++ was designed with systems programming and embedded, resource-constrained software and large systems in mind, with performance, efficiency, and flexibility of use as its design highlights. C++ has also been found useful in many other contexts, with key strengths being software infrastructure and resource-constrained applications, including desktop applications, video games, servers (e.g. e-commerce, web search, or databases), and performance-critical applications (e.g. telephone switches or space probes).
C++ is standardized by the International Organization for Standardization (ISO), with the latest standard version ratified and published by ISO in December 2020 as ISO/IEC 14882:2020 (informally known as C++20). The C++ programming language was initially standardized in 1998 as ISO/IEC 14882:1998, which was then amended by the C++03, C++11, C++14, and C++17 standards. The current C++20 standard supersedes these with new features and an enlarged standard library. Before the initial standardization in 1998, C++ was developed by Stroustrup at Bell Labs since 1979 as an extension of the C language; he wanted an efficient and flexible language similar to C that also provided high-level features for program organization. Since 2012, C++ has been on a three-year release schedule with C++23 as the next planned standard.
In 1979, Bjarne Stroustrup, a Danish computer scientist, began work on “C with Classes“, the predecessor to C++. The motivation for creating a new language originated from Stroustrup’s experience in programming for his PhD thesis. Stroustrup found that Simula had features that were very helpful for large software development, but the language was too slow for practical use, while BCPL was fast but too low-level to be suitable for large software development. When Stroustrup started working in AT&T Bell Labs, he had the problem of analyzing the UNIX kernel with respect to distributed computing. Remembering his PhD experience, Stroustrup set out to enhance the C language with Simula-like features. C was chosen because it was general-purpose, fast, portable and widely used. As well as C and Simula’s influences, other languages also influenced this new language, including ALGOL 68, Ada, CLU and ML.
Initially, Stroustrup’s “C with Classes” added features to the C compiler, Cpre, including classes, derived classes, strong typing, inlining and default arguments.
Java is the name of a programming language created by Sun Microsystems. This company was bought out by Oracle Corporation, which continues to keep it up to date. As of September 2022, Java 19 is the latest version, released in September 2022 (will be supported until March 2023) while Java 17, 11 and 8 are the current long-term support (LTS) versions, with Java 17 released on September 14th, 2021. Being an LTS version means that it will continue getting updates for multiple years. The next planned LTS version is Java 21 (LTS), planned for September 2023.
Being an open-source platform, Java isn’t just supported by Oracle, e.g. Eclipse Adoptium also supports Java, to at least May 2026 for Java 8, and at least September 2027 for Java 17.
Java, which was called Oak when it was still being developed, is object oriented, meaning it is based on objects that work together to make programs do their jobs. Java code looks like C, C++, or C#, but code written in those languages will not work in Java in most cases without being changed.
Java runs on many different operating systems, including Android, the world’s most popular mobile operating system (while Java continues to be used on Android, even by its maker Google, they no longer prefer Java; now Kotlin is their preferred language, though it can also be used with all Java code). This makes Java platform independent. It does this by making the Java compiler turn code into Java bytecode instead of machine code. This means that when the program is executed, the Java Virtual Machine interprets the bytecode and translates it into machine code.
Java was developed to achieve five main goals. These are:
- Java should be easy to learn, object-oriented, and distributed.
- Java should be safe and strong.
- Java should not depend on any computer architecture or platform.
- Java should function well.
- Java should be able to have an interpreter written for it (for better portability), support parallelism, and use dynamic typing.
The Java platform refers to a group of software products from Sun Microsystems. The platform is used to develop and run Java programs. The platform includes the execution engine (called a Java Virtual Machine) that allows Java programs to do the same thing on different computer systems.
This capability of being able to develop software on one platform and running it on other platforms is called “cross-platform capability”.