Created by Clay Dowling
The language is older than you.
50 years of language developments
It's Dead Sexy
Small and easy to understand
Rich ecosystem
50 years of language evolution
Real development with minimal tools
Functional - Functions are first class objects
Object Oriented - Data and logic separated by default
Test Driven Development - Built in test features and robust libraries
Web Native - Libraries for easy self hosted web apps
Distributed - Libraries for remote interaction
A small language means fewer options
Fewer options ⇒ Focus on getting stuff done
Getting Stuff Done ⇒ Happy Developers
Different build tools exist to make the job easier
Build tools are their own programming language
PROGNAME=myprogram
OBJS=$(patsubst %.c, %.o, $(wildcard *.c))
.PHONY: all
$(PROGNAME):
$(CC) -o $@ $^
clean:
rm -f $(PROGNAME)
rm -f *.o
cmake_minimum_required(VERSION 2.8)
file(GLOB program_SRC
"*.c"
)
add_executable(myprogram ${program_SRC})
// Sorry, it's a beautiful
// mystery to me as well.
“Programming is like playing with a loaded gun. C cocks the hammer for you.”
Prefer
struct stat sb;
if (stat("file.txt", &sb))
Over
struct stat *sb = calloc(1, sizeof(struct stat));
if (stat("file.txt", sb))
If You Write... | Also Write... |
---|---|
malloc/calloc | free |
myobject_create | myobject_destroy |
Write automated tests for all of your code
Use valgrind on your tests
Do not ignore valgrind errors
I am a mere mortal, and that's okay.
START_TEST(skillcmp_givenAandB_returnsNegativeOne) {
skill_t *a = skill_create("A", 0, S_CATEGORY, S_ATTRIBUTE);
skill_t *b = skill_create("B", 0, S_CATEGORY, S_ATTRIBUTE);
ck_assert_int_eq(-1, skill_cmp(a, b));
skill_destroy(a);
skill_destroy(b);
}
END_TEST
./test-changelog
Unity test run 1 of 1
.....
-----------------------
5 Tests 0 Failures 0 Ignored
OK
all: test product
product: $(OBJECTS) main.o
$(CC) -o $@ $^
test: test-product
./test-product
valgrind test-product
test-product: $(TEST_OBJECTS) $(OBJECTS)
$(CC) -o $@ $^ $(TEST_LIBS)
Many common problems, with common solutions.
If it's a network protocol, libcurl speaks it.
Easy to mock/test code using libcurl.
Easy to test without mocking.
Can have a server doing useful work in under an hour.
Native, fast clients available for:
Further reading at ClayDowling.com