55_pdfsam_cs2022_lectures - For writing portable code When...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Advantages of C Very good for writing fast code Usually much faster than Java, Matlab, etc. Simple syntax Portable and ubiquitous C compilers available on almost any platform Very powerful; programmer is in control C allows operations that other languages don’t (e.g. direct access to memory)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Disadvantages of C Difficult to learn Memory management is particularly frustrating Difficult to write bug-free, maintainable C code Memory errors are difficult to detect and locate Easy to inadvertently write insecure code C does not enforce good software engineering principles Missing some modern language features exceptions, packages, etc.
Background image of page 2
When to use C? When efficiency really matters computation-intensive applications memory-intensive applications For systems programming Operating systems, device drivers, embedded systems
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: For writing portable code When not to use C? For programs where efficiency isnt a concern Many user applications Prototyping new programs or new algorithms Use Matlab, C#, Java, Visual Basic instead For large non-systems software projects C++ is often a better choice For writing really portable code e.g. web applications When security is the foremost goal C programming style Good programming style helps prevent bugs C doesnt impose a programming style on you Both an advantage and a disadvantage Its up to you to develop a style that promotes efficient, safe, maintainable software Comment! Use comments Explain how non-trivial code works Very important: document functions Avoid useless comments x=x+1; // Add one to x...
View Full Document

Page1 / 6

55_pdfsam_cs2022_lectures - For writing portable code When...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online