[–]▶ No.977547>>977651 >>979730 [Watch Thread][Show All Posts]
People always gave Jewsh shit for trying to program infinity never in PHP. If not PHP, then what?
inb4 c/c++
inb4 rust
▶ No.977548>>977549 >>977597 >>977645 >>977941
>inb4 fast compiled languages with some CGI frameworks available
Gas.
▶ No.977549>>977576
▶ No.977557>>977567
Why not C or C++? C and C++ are only unpopular for webshit because most websites are created by incompetent codemonkeys that can't be trusted with them. All of the important software those websites depend on is written in C or C++. Imageboards are essentially unchanged from what they were 10 years ago. There would be nothing wrong with putting in the extra effort to write one good, stable imageboard software that puts performance over flexibility.
That said Josh's incompetence and poor direction were the root of Next's failure, not PHP itself.
▶ No.977563
>>were too incompetent to use proper programming languages, oop or we cant do it
state of web developers
▶ No.977567>>977568 >>979116 >>979299
>>977557
They're unpopular because managing strings in those languages is fucking brain tumor inducing cancer. Any language used for webshit almost certainly has language-level syntax for string manipulation.
▶ No.977568>>977574
>>977567
And being able to smack strings (and thus, heap allocations) around like they're nothing is no doubt part of why programs written in such languages allocate garbage like crazy.
▶ No.977574
>>977568
That doesn't mean you couldn't have a better language for that purpose. But there isn't one and people prefer shit performance over shit programming experience.
Web stuff simply involves manipulating strings a lot when you query shit from databases and assemble the HTML/CSS and use pajeetquery to interact with the page elements etc.
▶ No.977575
And receive input from the user, which you may need to validate and reformat and shit.
▶ No.977576
>>977549
What this guy said. Why not pypy?
▶ No.977578>>977584
The only thing worse than PHP is nodejs, so literary anything else will do.
▶ No.977581
What about sds for string manipulation in C? It's supposed to be fast as well.
https://github.com/antirez/sds
▶ No.977584>>981321
>>977578
You are a meme parrot and have no fucking idea what you are saying.
▶ No.977585>>977586
https://learnbchs.org/
#include <err.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
int
main(void)
{
if (-1 == pledge("stdio", NULL))
err(EXIT_FAILURE, "pledge");
puts("Status: 200 OK\r");
puts("Content-Type: text/html\r");
puts("\r");
puts("Hello, world!\n");
return(EXIT_SUCCESS);
}
▶ No.977586>>977588
>>977585
>hurdurr C is good for web, watch me print a hardcoded http hello world!
/tech/ in a nutshell
▶ No.977593>>977595 >>977602 >>977603 >>977851
No one is mentioning Go?
Is Go unpopular here for some reason. I've found Go to be pleasant for webserver junk.
>inb4 muhgoogle
▶ No.977595
>>977593
I thought go was only marginally better than scripting languages like perl/PHP/python. I seem to remember it's benchmarks being pretty shit.
▶ No.977597>>977611 >>977612 >>977735
>>977548
CGI frameworks are actually pretty taxing upon a server, starting and stopping programs in memory takes a lot. Much better if you write a program to act as a web server, and then call various functions in memory. I've always wanted a server base written in C that does something like this, but nothing really exists for it.
Also, PHP isn't all that bad, even with zend and what not. What it looses in elegance, it makes up for in speed and scalability. Only node.js and ruby fags like to give it shit.
▶ No.977602
>>977593
I've never heard Go described as
>marginally better than scripting languages
Especially referenced to perl and perl-clones. Maybe that was an early version you remember regarding the GC.
Like most thing I guess it would depend on the application though.
Consider:
http://marcio.io/2015/07/handling-1-million-requests-per-minute-with-golang/
Where the application involves
>to be able to handle a large amount of POST requests from millions of endpoints
containing
>a JSON document that may contain a collection of many payloads that needed to be written to Amazon S3
▶ No.977603>>977604 >>977986
>>977593
Go has all the disadvantages of C, then some new ones, and no advantage.
The community is also insane and thinks copy-pasting code with minor changes is better than using libraries.
Also lol no generics so everything ends up using interfaces, aka fancy void pointers.
▶ No.977604>>977656
>>977603
>The community is also insane and thinks copy-pasting code with minor changes is better than using libraries.
I agree with that completely. The community is rather shit.
>interfaces, aka fancy void pointers
I feel you're a bit misinformed/inexperienced with Go interfaces.
▶ No.977611
▶ No.977612>>977639 >>977942
>>977597
But unless you're using php as an apache module, isn't it using cgi anyway?
▶ No.977639>>977643
>>977612
That's a pretty big "unless"
▶ No.977640
I've actually written a shell of multithreaded fastcgi server in C, which is able to parse multipart/form requests, but I haven't gotten further than demonstrating that the form is working. Really, the string manipulation is the hardest part.
==> form.h <==
#ifndef CCN_FORM_H
#define CCN_FORM_H
#include "multipart_form_parser.h"
#define INPUT_T_TEXT 0
#define INPUT_T_FILE 1
#define INPUT_T_SUBMIT 2
extern const char *FORM_TYPE_TEXT[];
typedef struct form_input FormInput;
typedef struct form_input {
char *name;
int type;
FormSegment *data;
FormInput *next;
};
#endif
==> macros.h <==
#ifndef CCHAN_MACROS
#define CCHAN_MACROS
#define FILE_LINE FILE_LINE_TO_STR(__FILE__, __LINE__)
#define FILE_LINE_TO_STR(file, line) FILE_LINE_TO_STR2(file, line)
#define FILE_LINE_TO_STR2(file, line) file ": " #line
#define UNUSED __attribute__((__unused__))
#endif
==> multipart_form_parser.h <==
#ifndef CCN_MULTIPART_FORM_PARSER_H
#define CCN_MULTIPART_FORM_PARSER_H
#include <stdlib.h>
typedef struct mform_segment FormSegment;
struct mform_segment{
char *part_name;
char *content_type;
char *content_fname;
size_t data_len;
void *data;
FormSegment *next;
};
FormSegment*
mform_parse(char *data, size_t len, char *boundary, char **err);
void
mform_segments_free_all(FormSegment *first);
#endif
==> board.c <==
#include "board.h"
==> form.c <==
#include "form.h"
const char *FORM_TYPE_TEXT[] = {
"text",
"file",
"submit",
NULL
};
▶ No.977643>>977736
>>977639
Is it? Who uses apache anymore? It seems everyone uses nginx. I'm partial to lighttpd, personally.
▶ No.977645>>977649
Python or something similar. The problem isn't that PHP is a scripting language, it's that it is a godawful scripting language. That said, Josh was a complete moron and would have fucked up INFINITY NEXT (trademark) no matter what he was using.
>>977548
>CGI for an imageboard the size of 8chan
The experts of /tech/.
▶ No.977649>>977655 >>977769
>>977645
>it's that it is a godawful scripting language.
What's godawful about it? I've never used it.
>The experts of /tech/.
What about the aforementioned fastCGI? Are you saying the only way to run a large site like 8chan is with mod_php (or mod_perl) in apache?
▶ No.977651>>977657
▶ No.977656
>>977604
>I feel you're a bit misinformed/inexperienced with Go interfaces.
I said fancy for a reason, they're not as insane as casting to void and back but the obvious issue of needing such boilerplate is still there.
▶ No.977657>>977661
▶ No.977661>>977664 >>977668 >>977775 >>981312
>>977657
Go on then. Show us the imageboard you wrote in x86 assembly. I can't wait to see how many features it has.
▶ No.977664
>>977661
Congratulations. You wrote an imageboard and I haven't. Now, what's the next step of your master plan?
▶ No.977668>>977851 >>979722
>inb4 Java bashing
How about Kotlin? I haven't used it much but it looks like a promising language. It can be compiled to native binaries through LLVM (beta), Javascript, Web Assembly, and the JVM. When targeting LLVM you can seamlessly call C code and when targeting JVM you can seamlessly call Java code including its standard library.
Using Kotlin with Vert.x looks like a real performance winner.
>>977661
Wew nothing like jumping to extremes right off the bat. Are you always that easily instigated?
▶ No.977680
But seriously, how does fastCGI compare to mod_php? Can it be used for a larger site like 8chan?
▶ No.977703>>977871
I'm actually writing an imageboard right now with Ruby on Rails. How about that?
▶ No.977735>>977756
>>977597
>I've always wanted a server base written in C that does something like this, but nothing really exists for it.
https://www.gnu.org/software/libmicrohttpd/
i'm going to write an api server using this.
the speed with any major website usually boils down to the database though. most websites exist as a pretty front-end to a database, like 8ch. it doesn't matter how fast your C website is if your database is slow as hell.
▶ No.977736
>>977643
nginx doesn't have all the features and bloat
some of the apache features are useful.
▶ No.977756
>>977735
What advantages are there compared to fcgiapp.h?
>the speed with any major website usually boils down to the database though.
How much space does the text/html need for the top ~10 boards? 10*10 threads * 50 posts & 500 chars/post gives 2.5MB/board. DB speed is going to matter a lot, if you render the page for each person or save the cached pages, but the top boards could probably have all posts rendered in memory (being saved to db in background), which would make changing the page very cheap, caching the whole page might not even be worth it, since you wouldn't need to rerender anything, just go through a thread structure and dump the posts to the output.
▶ No.977769
>>977649
I used mod_perl a long time ago to run an ecomerce site. It worked fine, but it makes the apache processes really big and you end up needing to run a reverse-proxy for static content in front of your app server so it doesn't get overwhelmed.
Also you probably don't need all the functionality that mod_perl provides. FastCGI will do the trick in most cases, and it works with any language you want, so you don't have to use only Perl. But if you are using Perl, you might look into this as it lets you switch between different backends, so you can compare the performance:
https://en.wikipedia.org/wiki/Plack_(software)
▶ No.977773>>977774
▶ No.977774
>>977773
It does seem to be an area where Go has caught on.
▶ No.977775
▶ No.977851
▶ No.977871
▶ No.977942
▶ No.977986
>>977603
Garbage collection is a clear advantage in some domains, and a clear disadvantage in others.
Webshit server stuff is certainly an area where garbage collection isn't unwelcome.
▶ No.978031>>978079
>implying you can inb4 in OP
GTFO newfag.
C/C++ ofc.
▶ No.978079
>>978031
OPs have been inb4ing since the beginning, despite whiners like you claiming it can't be done.
▶ No.978223>>978231
OP here with my next question. So IIRC. Vichan rebuild the entire site everytime someone posts, which is part of the reason while it scaled so shittily. Whats the right way to do this?
▶ No.978231>>978378
>>978223
>Vichan
You sure you're not thinking of infinity next?
>Whats the right way to do this?
Cache the HTML. I'm not sure if it's best to hold it in memory or save it to file or database, but the basic idea is to keep it around and just send it as is. Cloudflare might be able to cache it too but don't quote me on that.
For optimal performance only update the html when it has needs to be modified AND someone requests it.
▶ No.978378>>978384
>>978231
>You sure you're not thinking of infinity next?
Both, actually. It's my understanding that it was a flaw of vichan that Josh carried over to infinity next.
>Cache the HTML. I'm not sure if it's best to hold it in memory or save it to file or database, but the basic idea is to keep it around and just send it as is.
Maybe I'm misunderstanding. The way I understand it, an anon would make a post, then it would get inserted into the database, and all the static html pages would get remade with the new post in the appropriate spot. From what I'm reading that seems to be basically the same as caching static pages. What is my pajeet brain missing? please open bob and show vegana
▶ No.978384>>978388
>>978378
>it would get inserted into the database, and all the static html pages would get remade
No, the second part is wrong. The pages that need to be rebuilt would simply be tagged as "needs_to_be_rebuild". You could pretty easily store that kind of flag in memory so it would take almost no computing effort. They only get rebuilt the first time someone requests the page, and then that version replaces the HTML in the cache until it needs to be rebuilt again.
This way even if there's a 100 people shitposting in each thread, the catalog/index pages don't necessarily get updated at all if nobody is viewing them. Even the threads don't need to update if you have a smarter auto-update mechanic. I think cuckchan uses some JSON string to get the latest posts, if you used something like that, people could auto-update the thread and the HTML wouldn't need to update at all until a new Anon comes in.
▶ No.978388
>>978384
Actually, I think vichan rebuilds all the pages when someone posts. That's the naive caching method, but there's usually much more pageviews than posts so it's probably still beneficial to do that than to rebuild the html every time.
▶ No.978975>>978983 >>978996 >>979005 >>979025
Ok, so what about CAPTCHAs? What's the ideal CAPTCHA system like? Don't say, "none." That's not currently realistic. Should an imageboard use something like Textcaptcha? One of those little math problems? Something like 8chan's captcha? Should 8chan's CAPTCHA be rewritten in C?
▶ No.978983>>978985
>>978975
>Don't say, "none." That's not currently realistic.
Why?
I think it can safely be replaced with spam filters used abundantly in email.
▶ No.978985>>978988
>>978983
>I think it can safely be replaced with spam filters used abundantly in email.
Then you are retarded.
▶ No.978988
▶ No.978996
>>978975
Warped images like 8chan's are the most reliable. It's simple and straightforward, relatively quick to type out, and very hard for bots to interpret.
Unless you use the GPU then warping images is precisely the kind of problem C is best for, since it requires a lot of data crunching to warp the pixels.
▶ No.979005>>979010
>>978975
I am a C hater and I think there woukd be nothing wrong with writing 8chan's captcha system in C, as long as it is well written. The way I see it, the program requires no inputs and always processes the same operations, so it would be hard to exploit it if all you could do with the program was running it to generate an image in a folder.
That said, there are a thousand programming languages that are not C and would be as suitable. Anything that's not PHP and even then, it ain't broken, so whatever
▶ No.979010
>>979005
>PHP isn't broken
▶ No.979025>>979028 >>979602
▶ No.979028>>979030
>>979025
Go on. I'm listening.
▶ No.979030>>979043
>>979028
See: http://410chan.org/b/
There used to be /int/ board, which used flagtpcha, but it closed down due to inactivity.
▶ No.979043>>979602
>>979030
I don't see a faptcha there. Usually it shows a few boobs, butts, etc, and asks you to tell which is which. To make it harder for a machine to learn it could ask you to select flat tits, etc.
▶ No.979108>>980335
Nothing bad with PHP aside from it being legacy (just maintained for really old working websites and they would fucking jump ship if they fucking could), and probably no direction ahead (since it is fucking legacy and meets a lot of problems that are solved by newer langs).
PHP can be super fast - it's not like you have same amount of kikebook users.
Infinity never failed with ugly meme shiny bloated frameworks and many other vectors.
If you're worried about the language be worried first about how the language adapts with severe flaws and performance issues.
File system i/o problems (db nodb), captcha generation (like why would you generate them on the fly, nigger just pre-generate a month's worth).
If you have a big brain you'd do caching gymnastics on how to serve data that are always requested and make everything static for queries so you don't get fucking baph'd in a crappy search textbox (php have shitty workarounds for those exploits but most fail and just implement a slow ass framework to handle all that).
▶ No.979116>>979155
>>977567
do you even know what you're saying
what is language level syntax for string manipulation? here is what python has (python2 syntax for disambiguity):
asciistr[0]
unicodestr[2]
and "\x41SS" and u"nigg\u00e9rfaggot"
that's about it. syntax aside, everyone who programs in languages "that support strings" have no idea what the fuck they're doing
▶ No.979128
Unironically Java. Or some other language with static analysis.
▶ No.979155>>979262 >>979311 >>979722
>>979116
>what is language level syntax for string manipulation
As in you don't need to send strings to functions and create temporary strings for every god damned thing.
Newstring = "Hello" ++ Somestring ++ "ヲルド!" ++ Anotherstring.substring(0, 10) ++ (Somenumber * 50);
if (Newstring.contains("へっろ")) {
Newstring.splice(Newstring.indexOf("へっろ"), "へっろ".length);
}
▶ No.979262
>>979155
<using hiragana for borrowed word
<mispelling the kana version of hello world
Please watch more anime so your Japanese will be better. If you are looking for the proper way to write "hello world", it would be "ハローワールド."
▶ No.979299>>979312
>>977567
>strings in C
>somehow difficult
yes, maybe for you, my pajeet friend
▶ No.979311>>979427 >>979703
>>979155
char Newstring[128];
strcpy(Newstring, "Hello");
strcat(NewString, Somestring);
strcat(NewString, "ヲルド!");
strncat(Newstring, Anotherstring, 10);
sprintf(strchr(Newstring, '\0'), "%d", Somenumber * 50);
char * f;
if((f = strstr(Newstring, "へっろ"))){
memmove(f, f+strlen("へっろ"), strlen(f+strlen("へっろ")));
}
Wow, so difficult. you might actually have to learn the idioms of the language you're using.
For reference, here's some code from dietchan, written in c:
PRINT(S( " <span class='file-size'>"), HK(upload_size(upload)), S("</span>"
"</div>"
"<div class='file-thumbnail'>"
"<a href='"), S(PREFIX), S("/uploads/"), E(upload_file(upload)), S("'>"
"<img class='file-thumbnail-img' "
"src='"), S(PREFIX), S("/uploads/"), S(upload_thumbnail(upload)), S("'>"
"</a>"
"</div>"
"</div>"));
If something is too verbose, write a small library to cover your use case. OpenIB is about 66 megs. dietchan is 147 megs. When you are writing that much code, it pays to spend some of time writing code that makes you write less code.
▶ No.979312
>>979299
It's not difficult. It's tedious and fallible, in which even good programmers can fail after 8 hours of work. Of course you will never experience work fatigue because your NEET ass hasn't had to program anything more complicated than a Fizzbuzz in your life.
>hurr but real programmers make their life as tedious as possible for muh efficiency
Go write it in assembky then, faggot.
▶ No.979427>>979591
>>979311
If you can't see how inconvenient and annoying it is to write all of that shit in comparison, then it's impossible to have this conversation. Plus you made a fixed length array so everything will go to hell if Somestring is longer than 120 or so characters or if you change the other strings or something, you'll have to keep babysitting and analyzing the needs of that stupid array and you'll need to do it constantly all the time everywhere.
I was pretty sure utf8 strings won't work the same way normal strings, but I might've been wrong.
▶ No.979464
The whole string issue is part of the reason I was considering pypy.
▶ No.979591
>>979427
>what if the string is longer than 127 chars
Half the time you know a string will be within a maximum size (eg generated filenames, generated shell commands). If you don't then you need extra code to handle it. Even then, the extra code can be factored pretty easily, so that it only gets written once.
>i was pretty sure utf-8 strings wouldn't work the same as normal strings
Technically you can't slice a utf8 string, its true. The main operations you're allowed are: concatenating strings, looking for and removing ascii chars. If you look at the way imageboards handle user input though, it all fits into these two categories.
>see how annoying that shit is in comparison?
C places a modest burden on the programmer, sure. That burden encourages him to think of more efficient ways to do things. "Do I really need an extra allocation here?", "do I need to create a temporary string, or can I cat it into the buffer directly?", etc. If you want to be less efficient, its quite easy to write inefficient code as well, with similar gains as other languages.
▶ No.979602
>>979025
>>979043
Faptchas fail because they use a small set of images. If you have a clone of *booru then faptchas are a great addition
▶ No.979703>>979788
>>979311
This is a great example of how string handling in C sucks. Your code had to search for 14 nulls and the strchr and memmove obfuscate what's going on. None of that code checks for overflows. Even Somenumber * 50 can cause undefined behavior unless it's unsigned.
> There's nothing wrong with C as it was originally
> designed,
> ...
bullshite.
Since when is it acceptable for a language to
incorporate two entirely diverse concepts such as setf
and cadr into the same operator (=),
...
And what can you say about a language which is largely used
for processing strings (how much time does Unix spend
comparing characters to zero and adding one to pointers?)
but which has no string data type? Can't decide if an array
is an aggregate or an address? Doesn't know if strings are
constants or variables? Allows them as initializers
sometimes but not others?
(I realize this does not really address the original topic,
but who really cares. "There's nothing wrong with C as it
was originally designed" is a dangerously positive sweeping
statement to be found in a message posted to this list.)
▶ No.979715
Crystal. It's about as easy to write effective stuff in as Ruby and has Rails tier frameworks while also being incredibly fast.
▶ No.979722>>980284
>>977668
only a channigger would use kotlin
>Vert.x
wasn't that just Kotlin's clone of node.js?
>>979155
you shouldn't use strings ever when programming anyway. instead your pajeet lazy ass appends a bunch of strings in some retarded way and uses the GC to clean your poo, in a public facing web app (web shotters wont understand the irony)
▶ No.979730>>979738
>>977547 (OP)
I'm shocked nobody has suggested Nim. The only argument against it is that it is not as popular as other languages, which is just an awful excuse not to use something.
▶ No.979738
>>979730
Wait so you're saying Vim is actually the best language ever made? Why have I not been using it all this time!
▶ No.979740
also does that meme shit still compile to a string that you pass into the C compiler?
▶ No.979788>>979827 >>979896 >>980176
>>979703
>This is a great example of how string handling in C sucks
>strchr obfuscates what's going on
Fine, Ill redo it:
asprintf(&Newstring, "%s%s%s%d", "Hello", Somestring, "ヲルド!", Somenumber * 50);
-doesn't search for nulls
-always has a big enough buf
-readable af
>memmove obfuscates what's going on
char * strmove(char * dest, char * src){
char * tmp = strdup(src);
strcpy(dest, tmp);
free(tmp);
return dest;
}
If you care
>Somenumber * 50 can cause undefined behavior unless it's unsigned
>what is -ftrapv
▶ No.979827
>>979788
again ヲルド should be ワールド
▶ No.979896
>>979788
One annoying thing about that is you have to make changes in two places to concat on one other string.
▶ No.980135>>980366
So have we decided that C is the best language to make a shitposting engine?
▶ No.980176>>980179
>>979788
>dat strmove implementation
>malloc, free
For fuck sake.
memmove support intersecting ranges. memmove(dest, src, strlen(str)+1). No fucking allocations. No extra memory write.
▶ No.980179>>980333
>>980176
No fucking explicit allocations. No explicit memory write. Memmove does create extra buffer.
But still 1 line is better than four.
Self fix.
▶ No.980284
>>979722
What's wrong with kotlin? It's better then java and can seamlessly call any java library. Vert.x actually recently added kotlin support. It was focused on java and other JVM languages originally. But yes, it's basically a better node.js that uses real languages and allocates one event loop per core did it scales nicely. It's one of the fastest frameworks available.
▶ No.980333
>>980179
>memmove creates an extra buffer
Not precisely. See linked for (the better part of) gnus implementation. Look for word_copy_bwd_aligned.
https://github.com/lattera/glibc/blob/895ef79e04a953cac1493863bcae29ad85657ee1/string/wordcopy.c
▶ No.980335
>>979108
>PHP is legacy
<replacement is javascript
topkek
▶ No.980366>>980373 >>980375
>>980135
Yep. I spent the weekend translating dietchan, so anyone wanting to host an imageboard can use that:
https://gitgud.io/el1372/dietchan
Should also stay any doubts about Cs feasibility for such a project.
▶ No.980375>>981052
>>980366
>>980373
Don't know why gitgud is so broken. I stuck it on github instead: https://github.com/el1372/dietchan
▶ No.981052
▶ No.981267
Wirthian languages are very underrated
▶ No.981312
>>977661
Autism at its finest. He really fires up when his life's work is questioned. Ask him about using Promises in LynxChan, I dare you. Oh and also you're not allowed to shitpost near him, he'll make War and Peace look like a high school essay with his REEEEEEEing about how it's "cringy".
▶ No.981321>>981322
>>977584
(((StephenLynx)))
▶ No.981322
>>981321
(((Ron Watkins)))
▶ No.981325
▶ No.981328
don't even need all of php, everything can be done in regex
▶ No.981331
>>977655
SOME of that stuff has been fixed in PHP7 and beyond, but yeah I do not recommend writing anything new in PHP. Maintaining existing PHP projects is less horrible these days at least.
▶ No.981872