BCHS

BSD, C, httpd, SQLite.
>BCHS (pronounced /biːtʃəz/, beaches) is an open source software stack for web applications. To prepare a BCHS environment, install OpenBSD, start your editor of choice, and get to work.
Thoughts on this wet dream, Jow Forums?

Attached: Screenshot_2018-10-23 BCHS BSD, C, httpd, SQLite.png (822x748, 52K)

Other urls found in this thread:

nginx-c-function.github.io/
sqlite.org/codeofconduct.html
tree-board.net/
wapp.tcl-lang.org
github.com/Taymindis/nginx-c-function
github.com/jorisvink/kore
github.com/h2o/h2o
github.com/TechEmpower/FrameworkBenchmarks/tree/master/frameworks/C/h2o
queue.acm.org/detail.cfm?id=3212479
twitter.com/AnonBabble

It seems pretty neat. I've been curious about using C for backend development for a while now. One of the things I'm confused about is how your C code and httpd are integrated. Do you compile your code and link it to httpd as an add on module or do you just use httpd as a HTTP reverse proxy and communicate between the two with Unix sockets.

Attached: 1509399481995.jpg (350x410, 18K)

I think you'll use slowcgi to attach you "cgi script" written in C to httpd (that understands only fastcgi).

Ok cool. That makes sense. Is there anything comparable that uses Nginx instead of Apache? Also, how does this compare to something like the onion server C library? I've fallen back in love with C lately so the idea of making a backend entirely in C makes me moist.

Attached: 1521933632761.jpg (944x1066, 361K)

Online retail beck-end dev here for a multi-million-dollar company. It is just that: a wet dream. If you want me to elaborate I can tonight.

PHP is C inside of HTML. Why not use that?

Note that BCHS does not require openbsd but it was originally intended for it.
Either fastcgi or slowcgi
Openbsd doesn't use Apache. It's literally just called httpd. It's a recent project. It's a lot more simple and easy to configure. It's also more secure as usual.
Wut. No it's not. I wouldn't even quite call PHP C like imo.

here httpd refers to openbsd's webserver, not apache or nginx

PHP was written by a guy who admitted he didn't know what he was doing.

Is this the white cis male web stack?

>If you want me to elaborate I can tonight.
Please do.

he said retail. anything involving credit card payments has incredibly shitty and oppressive regulations that make something like bchs a non-starter. i'd totally use it for other projects though, it's not like cgi webapps are uncommon, especially in the corporate world.

amazon uses c++ , pretty sure ebay does as well... at least they did about 10 years ago

Exposing your backend written in the least secure popular language still used in the industry... what could possibly go wrong?

here's another way
nginx-c-function.github.io/

My understanding is that the problem is that CGI is just not very good. C is fast, but not CGI.
NodeJS and dotnet core outperform CGI on handled requests per minute because they have the advantage of always running. CGI has a lot of overhead because it has to start and stop an application. I would recommend dotnet core.

>not using NodeJS inside Docker running on Kubernetes on AWS
it's like you hate money

Attached: 1332655790142.jpg (388x387, 34K)

FastCGI is the answer and using it in C and C++ is fairly easy.

web developement without undefined access but with segfaults.

cool, but not very pratical

You can write backend in literally anything that can print to stdout, just throw the http request as argument to the backend interpreter uri lmao. I actually did this with my webserver.

Well to be fair, he didn't want PHP to turn out the way it did. PHP started out as a templating language for C, but people started adding more logic to the front end that it eventually turned into what it is today. He said if he could choose what PHP would be, it would just be the templating language for C.

>int
>main(void)

why do ppl do this?
isnt int main(void) 100x times more readable?

I assume that httpd/CGI will spin up multiple processes to handle concurrent requests, right?

How does that play with sqlite? Sqlite won't do concurrent writers. So is there locking of some sort that you're supposed to implement?

Tradition.

This also supports fastcgi. fastcgi is how php runs.
BCHS tools automatically handle compression and extra http options. It's a bit more advanced than just writing to stdout in this case.
Depends on what your used to. That style is common among kernel devs.
Incorrect.
Not sure about regular CGI but fastcgi can handle many connections at a time. With fastcgi you handle your own thread pool if you want one.

Nothing like java tier verbosity to write what would be two lines of php7

>Bee jizz

Attached: bee-yourself-2713479.png (500x663, 29K)

Looks breddy gud. I've written a couple small sites in python/flask and it's getting tiresome, definitely gonna try this out

Oh okay. I didn't realize httpd meant something else besides Apache in this context. Thanks for the explanation.

It's for greppability.
This way you can just grep -Rn '^functionname' * and find the function you're looking for instead of using some bloated IDE or ctags.

I use grep for searching. Didn't know about this. Thanks user

It's obviously supposed to be pronounced "bitches".

I wish I was smart/brave enough to write C safely.

YIKES

I know that Jow Forums is on the autism spectrum but learnbchs is a joke website.

sqlite.org/codeofconduct.html

also this is a C web app or whatever tree-board.net/

Look, man, I write C. A lot of C. A lot of things in C that have no place being written in C.
But fuck that. Lots of strings + C = yikes.

Seems really nice but I'm a bit invested on Go for web stuff

I thought he developed it as a templating engine for perl

Php for brainlets

This sounds retarded as fuck

Just use perl if you want something in openbsd base

This. At least use C++

I think the problem with BCHS in context of an online retail backend is that the level of abstraction is incredibly low compared to something you can write in .NET, Node, etc. You will be spending 2 weeks just figuring out how to pass session cookies around without fucking your own ass. Don't even get me started on JSON serialization. That said, the simplicity and zero-assumption principles of BCHS could be great for developing smaller-scale 100% custom backends that perform exactly as desired without MVC/API frameworks getting in the way. I also question the throughput and latency possible with BCHS. What are the performance figures and considerations?

>bright green on bright yellow
I literally can't look at it.

I like this because I'm a backend C dev who hasn't done direct web server work ever but I feel like it's a joke at my expense

It's retarded.
C has no string support whatsoever. It has arrays of chars, except that... C actually has no array support whatsoever either. Just pointers + length.
Does that sound like a good language to write web stuff in?

Anything else would be better, really. If you really love C, use C++ which can be used to build better high-level abstractions. Or even better would be Java. You still have nice C-like syntax, but much better support from the language.

>c has no string support
>he's to much of a brainlet to use a library or create his own

linux port of pledge() when

Are you kidding? This has trans girl written all over it.

This. Use the right tool for the job. C is not the right tool for the job here, not even close.

Seems neat for IoT stuff. There are loads of devices that are network enabled but putting python or java for web stuff would be bloat.

great, now I have to worry about stupid web devs writing in buffer overflows everywhere

>IoT programmers using something like this

fucking NO

>write your own library for strings or y-you're a brainlet!
This is how vulnerabilities are born. Yet another idiot cowboy rolling his own buggy solutions not for learning purposes or legal compliance, but a misplaced sense of pride.

>in b4 just don't be a brainlet and you wont write buggy code
It's not that simple dunning kruger autist. If even the most seasoned linux kernel programmer occasionally inadvertantly introduces null pointer dereferences into their code base, what hope do the rest of us have?

I have never met a programmer in my life who has never produced a bug. Even if such people did exist, they are sure as fuck not wasting their time shitposting about programming language religious wars on an anime imageboard

Attached: 1492085644340.png (387x550, 339K)

>httpd
>SQLite
No thanks, I like things that scale.

To clarify: don't get me wrong, SQLite is one of the most based pieces of software in existence. But it's just not going to work for most web workloads.

>I'm too stupid to use C strings, so they don't exist

>At least use C++
Fuck off. If you're stuck with a low level language, you have 3 legitimate choices: C, Go, or Rust. C++ is shit.

Then again, most people have no business writing low-level code, because most people are tards. 99.99% of people will write faster applications by writing them in something like Java, because all of the hard things to get right are handled for them.

>hurr lets use C strings guys. Null termination is a good idea and definitely doesn't have non-linear performance characteristics.

Attached: 1513555713174.jpg (588x823, 109K)

struct SafeString {
char *nonNullTerminatedString;
int length;
};
/**
* coding style:
* 1. SafeStrings are NOT null terminated.
* 2. Do NOT use pointer arithmetic. Indexing only.
* 3. Always check for the length before indexing.
**/


fixed 100% of your buffer overrun problems! No need to me but you do need to pay ke

>take a week off of work to go hunting up north
>come back
>all 3 rules are violated everywhere as far as the eye can see
No thanks. Not everybody has the luxury of working with intelligent coworkers.

>PascalCase garbage
>int instead of size_t
>Not defining it like struct string_for_people_who_dont_know_C {
size_t len;
char str[];
}

Nice job, brainlet.
Is it the length in bytes? Or in characters? How do you support Unicode?

If your argument that C is safe for web development is that you need to write your own string library, you might as well go all the way and write your own language. Fortunately, other people did that for you.

There is nothing wrong with PascalCase. A lot of C libraries like SDL use PascalCase.

A lot of people thought Hitler was pretty good too.

>Do NOT use pointer arithmetic. Indexing only
Indexing is literally defined with pointer arithmetic in C. There is no difference between the two.

There are a lot of fancy things you can do with pointer arithmetic to squeeze performance.
while(*dest++ = *++src)...

Basically don't increment or decrement pointers because you can easily fuck up.

Nobody claims that pointer arithmetic increases performance.
It's just how the language fundamentally works.

Are you implying that your snippet showcases an example of using pointer arithmetic to squeeze performance?

Yes, I am. Equivalent with indexing. Indexing is slower than arithmetic:
for(int i = 0; src[i]; i++) dest[i] = src[i]

You're a role-playing monkey without a CS degree. This is the dumbest post I've seen all week on here.

>beaches
>not bitches

missed opportunity

while(*dest++ = *++src)
is equivalent to
while (dest[i++] = src[++j]), not that piece of shit you just wrote.

Reread whatever intro to C book that you read.

They do the same thing in the end and also mine uses 1 less variable than

>uses 1 less variable
AHAHAHAHAHAHAHA
That's right user, the version using another variable must be 33% slower.

In case you are being serious: literally just compile the code and compare the code generated.

>They do the same thing in the end
That's the point, dumbass. Pointer arithmetic does not allow one to "squeeze performance".

Protip: they will both use the same amount of lexemes once evaluated by the lexical analyzer, so neither of which will use more space than the other at actual runtime (in this case, having the variables is for humans)

try it yourself

I prefer CentOS, C++, nginx, Postgres

>tranny
>using C instead of some shit like Rust or Go
>using OpenBSD, a project that does not and will not have a CoC

HAHAHAHAHAHA I FARTED I FARTED OOOOH MOM I FARTED LOOK
HAHAHAJ HAR HAR HAR HEH HEH HOR TOOT
TOOOOOOOOOT

OOOOPS I MADE A POOPY

don't ever reply to my posts again.

wapp.tcl-lang.org

Attached: mr sqlite.jpg (1120x998, 118K)

Attached: 1538068292820.jpg (442x500, 8K)

Now that loudmouth Linus is out of the picture probably soon.

Attached: Screenshot_20181023_220728.png (1050x726, 607K)

What's the deal with *BSDfags and picking horrible fonts?

We've all been brainlets about C at one point or another, learn from your mistakes instead of being butthurt.

It's a troll.

Alright everyone, gather round. Here are the easy options for a c backend.

Nginx: with nginx-c-func, it supports aio threads/thread pooling and you can do upstream requests to avoid bogging shit down. nginx third party modules compiled in make this objectively the best choice due to support and flexibility.
github.com/Taymindis/nginx-c-function

Kore.io, faster than the above option but it's smaller project. secure and fucking easy to set up. lots of examples, secure, has a state machine (for long running ops) and postgres connection built in. Also supports python if you need to mix shit up.
github.com/jorisvink/kore

Then there's libh2o.
This is the fastest, like, fucking fast. If my laptop actually had a nic that could support it it would saturate a 3gbps connection. ON A LAPTOP. It's fucking sexy but it's harder to set up than both of the above.
github.com/h2o/h2o
You should use the techempower benchmark example for a shortcut on getting your project up to speed.
github.com/TechEmpower/FrameworkBenchmarks/tree/master/frameworks/C/h2o

There are others but these are the top picks. If you just want something that works then kore is your best bet. if you want ultimate ease + easy integration with a bunch of other shit plus lots of stackoverflow help then use the nginx option. If you want max speed then use h2o. I'll open source my redis/postgres/json project in a couple of weeks after I test it out.

Good luck guys. Fuck Rust/Go.

>Fuck Rust/Go

"Guys, here's what you need to cross the Atlantic on a cardboard box. Fuck the guys using barrels and bathtubs!"

so basically if you can't use grep properly?

This seems cool, but I can't justify using it when Apache and PHP just work, and are probably a lot less time. If I'm only making a personal webapp, then how does the performance benefit me?

>using libraries is unsafe
Sure thing rust shill

suckless.org and OpenBSD fags are all /b/tards.

t. someone who used to lurk the channels

>Writing web applications in C. What could possibly go wrong?

>go
>low level with gc
>no generics
The only thing going for go is coroutines.

>every library creates their own string
>you are stuck writing brittle glue code forever

>C programmer recognizes the value of an abstraction (2018, colorized)

>c
Fucked up on the second one already.

>any of those languages you listed
>low level languages
queue.acm.org/detail.cfm?id=3212479

Not for long c++ is getting those

is there is LAMP, BCHS, what stack called if I use Windows, ASP.net, IIS, and SQL server

Based