News for hackers. Stuff that matters.
Re:OpenBSD, C, httpd and SQLite – Web App stack by sbr464 on Saturday June 09, 2018 @08:45AM (#17272758)
The example says no mysticism but is using at least 4 undeclared variables. I’m not a C developer so I’m sure I’m completely wrong, but where do pledge, puts, EXIT SUCCESS/FAILURE come from?

I assume from importing stdlib etc, which probably give you additional variables to use, that you would need to know about explicitly. One thing I like about zeit.co’s micro server (js) was the argument about not using bodyparser and magically having res.body available, but using async/await and assigning it to a variable. This is popping up more with things like es module imports, render props in react, etc. They make it clear where variables come from and allow you to avoid stepping on existing variables. What other 10-100 variables can I step on potentially with global patterns as a new user?

Re:OpenBSD, C, httpd and SQLite – Web App stack by beefhash on Saturday June 09, 2018 @08:57AM (#17272797)
> I’m not a C developer so I’m sure I’m completely wrong, but where do pledge, puts, EXIT SUCCESS/FAILURE come from?

- pledge: unistd.h[1]

- puts: stdio.h[2]

- EXIT_SUCCESS and EXIT_FAILURE: stdlib.h[3]

You can probably safely assume a C programmer is familiar with puts and EXIT_SUCCESS/EXIT_FAILURE and that an OpenBSD programmer has heard of pledge(2).

[1] https://man.openbsd.org/pledge.2

[2] ISO C11, § 7.21.7.9 no. 1; https://man.openbsd.org/puts.3

[3] ISO C11, § 7.22 no. 3

Re:OpenBSD, C, httpd and SQLite – Web App stack by sbr464 on Saturday June 09, 2018 @09:30AM (#17272917)
Thanks for that info. I do need to learn C still.
Re:OpenBSD, C, httpd and SQLite – Web App stack by cpmouter on Saturday June 09, 2018 @08:59AM (#17272802)
It's surprising to me that someone could be a programmer without knowing anything about C.
Re:OpenBSD, C, httpd and SQLite – Web App stack by scandox on Saturday June 09, 2018 @11:01AM (#17273340)
The best programmer in the world may never have even seen a computer for all we know.
Re:OpenBSD, C, httpd and SQLite – Web App stack by carapace on Saturday June 09, 2018 @11:14AM (#17273403)
Dijkstra famously didn't use one until his friends and colleagues made him get a mac so they could email him.
Re:OpenBSD, C, httpd and SQLite – Web App stack by Senderman on Saturday June 09, 2018 @01:46PM (#17274074)
I was programming for a few years before I first encountered C, and that was almost 2 decades ago. I don't think it's that uncommon.