CSC230 Getting Starting in C. Tyler Bletsch



Similar documents
6.S096 Lecture 1 Introduction to C

Embedded Software Development

Example of Standard API

Lesson 06: Basics of Software Development (W02D2

An Incomplete C++ Primer. University of Wyoming MA 5310

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

COS 217: Introduction to Programming Systems

9/11/15. What is Programming? CSCI 209: Software Development. Discussion: What Is Good Software? Characteristics of Good Software?

Virtual Servers. Virtual machines. Virtualization. Design of IBM s VM. Virtual machine systems can give everyone the OS (and hardware) that they want.

CS 103 Lab Linux and Virtual Machines

Outline. hardware components programming environments. installing Python executing Python code. decimal and binary notations running Sage

CPSC 226 Lab Nine Fall 2015

CS 106 Introduction to Computer Science I

Java Crash Course Part I

CS 3530 Operating Systems. L02 OS Intro Part 1 Dr. Ken Hoganson

ELEC 377. Operating Systems. Week 1 Class 3

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Programming Languages

Contents. Java - An Introduction. Java Milestones. Java and its Evolution

Easing embedded Linux software development for SBCs

The programming language C. sws1 1

Software. Programming Language. Software. Instructor Özgür ZEYDAN. Bülent Ecevit University Department of Environmental Engineering

Channel Access Client Programming. Andrew Johnson Computer Scientist, AES-SSG

Informatica e Sistemi in Tempo Reale

OPERATING SYSTEM SERVICES

Jonathan Worthington Scarborough Linux User Group

Tutorial 0A Programming on the command line

Chapter 2 System Structures

C# and Other Languages

Comp151. Definitions & Declarations

Lab 0 (Setting up your Development Environment) Week 1

Operating System Structure

1001ICT Introduction To Programming Lecture Notes

1/20/2016 INTRODUCTION

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1

Creating a Java application using Perfect Developer and the Java Develo...

CS3600 SYSTEMS AND NETWORKS

How To Run Linux On Windows 7 (For A Non-Privileged User) On A Windows 7 Computer (For Non-Patty) On Your Computer (Windows) On An Unix Computer (Unix) On Windows) On The Same

The BSN Hardware and Software Platform: Enabling Easy Development of Body Sensor Network Applications

Programming. Languages & Frameworks. Hans- Pe(er Halvorsen, M.Sc. h(p://home.hit.no/~hansha/?page=sodware_development

Survey of Filesystems for Embedded Linux. Presented by Gene Sally CELF

CS420: Operating Systems OS Services & System Calls

Embedded Linux development training 4 days session

Multi-core Programming System Overview

Andreas Burghart 6 October 2014 v1.0

ERIKA Enterprise pre-built Virtual Machine

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

FAME Operating Systems

System Structures. Services Interface Structure

Operating System Structures

STM32JAVA. Embedded Java Solutions for STM32

CSE 452: Programming Languages. Acknowledgements. Contents. Java and its Evolution

Waspmote IDE. User Guide

Keil C51 Cross Compiler

Intro to Intel Galileo - IoT Apps GERARDO CARMONA

Embedded Software development Process and Tools: Lesson-4 Linking and Locating Software

Week Overview. Installing Linux Linux on your Desktop Virtualization Basic Linux system administration

Running Windows on a Mac. Why?

CSCI 3136 Principles of Programming Languages

Components of a Computing System. What is an Operating System? Resources. Abstract Resources. Goals of an OS. System Software

LAB 1. Familiarization of Rational Rose Environment And UML for small Java Application Development

Installing Java (Windows) and Writing your First Program

Operating System Overview. Otto J. Anshus

VMware Virtualization and Software Development

Building Applications Using Micro Focus COBOL

Operating Systems and Networks

Surface and Volumetric Data Rendering and Visualisation

Chapter 3 Operating-System Structures

Android Architecture For Beginners

Ch. 10 Software Development. (Computer Programming)

Lecture 5: Java Fundamentals III

Overview. Open source toolchains. Buildroot features. Development process

Introducing PgOpenCL A New PostgreSQL Procedural Language Unlocking the Power of the GPU! By Tim Child

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

CSC 551: Web Programming. Spring 2004

SQLITE C/C++ TUTORIAL

Java Programming. Binnur Kurt Istanbul Technical University Computer Engineering Department. Java Programming. Version 0.0.

Lecture 22: C Programming 4 Embedded Systems

CSCE 665: Lab Basics. Virtual Machine. Guofei Gu

Programming in Python. Basic information. Teaching. Administration Organisation Contents of the Course. Jarkko Toivonen. Overview of Python

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

02 B The Java Virtual Machine

Intel Do-It-Yourself Challenge Lab 2: Intel Galileo s Linux side Nicolas Vailliet

NVIDIA CUDA GETTING STARTED GUIDE FOR MAC OS X

McAfee Product Entitlement Definitions

Introduction to programming

Fall Lecture 1. Operating Systems: Configuration & Use CIS345. Introduction to Operating Systems. Mostafa Z. Ali. mzali@just.edu.

NYU-Poly VLAB Introduction LAB 0

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

Objectives. Chapter 2: Operating-System Structures. Operating System Services (Cont.) Operating System Services. Operating System Services (Cont.

INTRODUCTION TO JAVA PROGRAMMING LANGUAGE

Research and Design of Universal and Open Software Development Platform for Digital Home

Embedded Software Development: Spottbillige Hardware + OSS = Zum Spielen zu Schade!

Required Virtual Interface Maps to... mgmt0. bridge network interface = mgmt0 wan0. bridge network interface = wan0 mgmt1

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C

An Overview of Java. overview-1

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C

GSM Click - Cross-Platform Development Quick Start Guide

Transcription:

CSC230 Getting Starting in C Tyler Bletsch

What is C? The language of UNIX Procedural language (no classes) Low-level access to memory Easy to map to machine language Not much run-time stuff needed Surprisingly cross-platform Why teach it now? To transition from basic programming to Operating Systems (CSC246), Software Engineering (CSC326), etc. 2

The Origin of C Hey, do you want to build a system that will become the gold standard of OS design for this century? We can call it UNIX. Okay, but only if we also invent a language to write it in, and only if that language becomes the default for all systems programming basically forever. We ll call it C! Ken Thompson AT&T Bell Labs, 1969-1972 Dennis Ritchie 3

Cool, it worked! Told ya. 4

What were they thinking? Main design considerations: Compiler size: needed to run on PDP-11 with 24KB of memory (Algol60 was too big to fit) Code size: needed to implement the whole OS and applications with little memory Performance Portability Little (if any consideration): Security, robustness, maintainability Legacy Code 5 Taken from CSC230: C and Software Tools NC State University Computer Science Faculty

C vs. other languages Most modern languages Develop applications Computer is an abstract logic engine Prevent unintended behavior, reduce impact of simple mistakes Runs on magic! (e.g. garbage collection) May run via VM or interpreter Smart, integrated toolchain (press button, receive EXE) Develop system code (and applications) (the two used to be the same thing) Near-direct control of the hardware Never doubts the programmer, subtle bugs can have crazy effects C Nothing happens without developer intent Compiles to native machine code Discrete, UNIX-style toolchain make gcc (compilation) gcc (linking) (even more discrete steps behind this) $ make gcc -o thing.o thing.c gcc -o thing thing.o 6

Why C? It s a portable assembly language Useful in Systems development: OS & Embedded Optimized routines for use with other languages Need for speed, size, or predictability Notable pure C software: UNIX and Linux kernel and most utilities NetApp Data ONTAP (most common storage OS) Python, Perl, PHP, Java*, Ruby* A bajillion applications: http://en.wikipedia.org/wiki/category:free_software_programmed_in_c 7 * With some C++ as well

Example C superpowers Task: Export a list of coordinates in memory to disk Most languages Develop file format Build routine to serialize data out to disk Build routine to read & parse data in Benchmark if performance is a concern C Read/write memory to disk directly Disk 8

Example C superpowers Task: Blink an LED Atmel ATTINY4 microcontroller : Entire computer (CPU, RAM, & storage)! 1024 bytes storage, 32 bytes RAM. led = 0 while (true): led = NOT led set_led(led) delay for 1 sec Language Size of executable Size of runtime (ignoring libraries) Java 410 B 13 MB (java + libjvm) Python 60 B (source code) Total size RAM used 13 MB 14 MB 2.9 MB 2.9 MB 5.4 MB Desktop C 8376 B None 8376 B 352 kb Embedded C (Arduino) 838 B None 838 B ~16 B Max: 1024 B Max: 32 B 9

What about C++? Originally called C with Classes (because that s all it is) All C programs are C++ programs, as C++ is an extension to C Adds stuff you might recognize from Java (only uglier): Classes (incl. abstract classes & virtual functions) Operator overloading Inheritance (incl. multiple inheritance) Exceptions Bjarne Stroustrup developed C++ in 1979 at Bell Labs 10

C and Java: A comparison C #include <stdio.h> #include <stdlib.h> int main(int argc, const char* argv[]) { int i; Java class Thing { static public void main (String[] args) { int i; printf("hello, world.\n"); System.out.printf("Hello, world.\n"); for (i=0; i<3; i++) { printf("%d\n", i); } for (i=0; i<3; i++) { System.out.printf("%d\n", i); } } return EXIT_SUCCESS; } } $ gcc -o thing thing.c &&./thing Hello, world. 0 1 2 $ javac Thing.java && java Thing Hello, world. 0 1 2 11

Common Platform for This Course Different platforms have different conventions for end of line, end of file, tabs, compiler output, Solution (for this class): compile and run all programs consistently on one platform Our common platform: Don t you gimme no it worked on my box nonsense! 12

Your Choices Option Use GUIbased Editor? Access to your unity Filespace? Matches grading environment? Use Unity Lab Computer Y Y Y ssh to VCL (linux) N** Y Y ssh to remote-linux.eos.ncsu.edu N** Y Y Use Mac OS X (+developer tools) Y sftp* N Use MS Windows + cygwin Y sftp* N Use Linux on your PC (dual boot or virtualized) Y sftp* N * direct if you install realm kit ** Yes if you run X windows server on your computer 13

Hello world C #include <stdio.h> #include <stdlib.h> File with library function declarations int main(int argc, const char* argv[]) { int i; printf("hello, world.\n"); Entry point of the program, with command line arguments } return EXIT_SUCCESS; Exit program and indicate successful completion Standard library function, with message argument $ gcc Wall std=c99 -o hello hello.c $./hello Hello, world. 14