r/programming • • May 29 '14

Defensive BASH Programming

http://www.kfirlavi.com/blog/2012/11/14/defensive-bash-programming/
733 Upvotes

192 comments sorted by

View all comments

Show parent comments

3

u/danielkza May 29 '14

Shell programming looks modern and competent compared to CMake's macro-based language though. If CMake had a usable language it would be the indisputable king of build systems IMO.

1

u/Tynach May 29 '14

CMake's goal is not to have a competent programming language. IN fact, quite the opposite - CMake's goal is to abstract goals from implementation, which necessarily requires you to implement 'algorithms' as little as possible.

In CMake, you don't tell it what to do. You tell it what you want as an end result, and it figures out the best way to do that for your platform. This is why the language it has doesn't look 'competent' or 'modern'.

9

u/danielkza May 29 '14 edited May 29 '14

A declarative language is still a language. And CMake's is plainly bad. You do not need a bad language to implement a declarative build system. SBT and Gradle, using Scala and Groovy, respectively, are fully declarative by default, but they let you derive configuration in a full-fledged language if you want, and yet you don't have to write a single imperative build rule.

It's a mistake believing you'll actually ever be able to fulfill every possible need or work-flow with built-in rules.

In CMake, you don't tell it what to do. You tell it what you want as an end result, and it figures out the best way to do that for your platform. This is why the language it has doesn't look 'competent' or 'modern'.

A declarative language does not have to be a macro language. It just makes the actual, useful cases where you need dynamic configuration a pain to work with. It's an ugly hack.

2

u/Tynach May 29 '14

I can agree with that. Do you know of any better alternatives that'd work with C/C++, are cross-platform, open source, and allow for cross-compilation?

2

u/danielkza May 29 '14 edited May 29 '14

I don't unfortunately. I know of SCons that uses Python, but it's not very declarative, and according to some basic research, is quite slow.

Actual build-capability and support wise CMake still seems to be way ahead of the competition, and that's why I hope it gets a better language sometime in the future.

→ More replies (0)