4 ms·
C is horrible for exploratory programming but is acceptable if you already know how to solve the problem. If one uses enums for errors, then the compiler can ch
by norir 3y ago
C is horrible for exploratory programming but is acceptable if you already know how to solve the problem. If one uses enums for errors, then the compiler can check for you that all edge cases are handled. You can log an error and exit(1) for unhandled cases during development which makes it feasible to turn on -Werror but not have to implement every edge case up front.
You can do the same thing with tagged unions to implement a poor man's sum types. It is significantly more verbose than in a language that has syntactic support for this, but you get similar compile time safety guarantees.
- whiterknight 3y ago> C is horrible for exploratory programming Completely disagree. The lack of screwing around selecting abstractions forces you to make something productive right away and not stress about refactor.
- theyinwhy 3y agoIsn't "forced to make sth productive right away" the opposite of "exploratory programming"?
- GuestHNUser 3y agoNo, I think exploratory programming is exactly that. Solutions to a problem is the very thing to be explored.
- tored 3y agoWho is stressing you to refactor when doing exploratory programming? Yourself? OOP languages? Society?
- deleted 3y ago[deleted]
- insomagent 3y agoIf you're talking about something like a web server, then sure. If you're talking about kernel hacking, then I completely disagree.
- flohofwoe 3y ago> C is horrible for exploratory programming... Completely opposite experience here. C is great for explorative coding because it's just structs and functions. There's no agonizing about whether some piece of code should go here or better there, wrapped in this or that concept or high level abstraction. Instead you start with an empty screen and incrementally build your ideas from small building blocks, much like in Lisp or Forth.
- tored 3y agoWhat is stopping you from only using functions and structures in any language?
- flohofwoe 3y agoJava or C# required me to wrap every piece of code into class boilerplate (I think that has changed in the meantime, but just as an example). In C++, Visual Studio will bombard you with all sorts of silly C++ Core Guideline advice if you try to write simple and straightforward code. Finally, the standard libraries and 3rd party libraries might also get in the way if 'simple and straightforward' clashes with the idiomatic style of the language.
- tored 3y agoProbably even better to pick PHP then, large standard library included, open foo.php to code, no main function required, just start writing, no build step, can output to stdout or http without effort
- flohofwoe 3y agoSure, but it depends on the task. For instance if I need to talk to operating system APIs directly then C (or ObjC on Mac) might still be the better choice. Best tool for the job etc... I guess the gist is that languages that are built around the idea of high level abstractions and enforcing a specific coding style on large teams might not be the best language for exploring and prototyping.