Live data from Hacker News

Show HN: Gemini web client in 100 lines of C

github.com

21–30 of 47 posts

Re: Show HN: Gemini web client in 100 lines of C

#21
Nice to see someone else fall upon what I call funnel-based control flow, as opposed to stack-based control flow of most programs using functions. I used the same pattern in nobox: https://github.com/serprex/nobox/blob/master/nobox.c

Idea is that using goto your program can be mostly a loop where you make forward jumps to anywhere in the code & everything converges or jumps back to the start. It ends up making for very terse code since you're no longer passing values back & forth as much through structs/params/returns. You align variables & jump to code. Each label has a kind of ABI where the variables are the registers

Re: Show HN: Gemini web client in 100 lines of C

#22
post #18

It's a nice project, but - I guess as is tradition with the majority of C projects - it has resource leaks and buffer overflows. There is at least one resource leak, namely, `sfd` is not closed when certain `WARN()` invocations jump back to the `start` label; for example, when `gethostbyname()` fails (i.e. try a non-existent domain and observe that the sockets remain open with `lsof`). (It also seems to be leaked in…

This is such a great feedback. Thank you a lot. OFC I will try to correct my mistakes.

Not to make any excuses, just for the context. I'm a beginner in C programming and I wrote only few small programs. My tooling is basically non existent. I will try to improve tho.

Re: Show HN: Gemini web client in 100 lines of C

#23
post #6
post #4

Earlier quoted context omitted.

Yea, you are right. Poor choose of words on my side. One can argue the definition of "web" but it would be much more precise to write "CLI client".

There’s nothing to argue. The "World Wide Web" or "Web" is defined as servers and clients communicating using the HTTP protocol. (Usually, it means that content is using HTML but this is not mandatory). "Gemini" is defined as servers and client communicating using the "Gemini" protocol (and content is usually in the gemtext format). Both are part of the Internet, which is defined as an INTERconnection of NETworks, th…

Meh. I can see why it's unpopular in the Gemini community, but I don't see anything wrong with referring to the "Gemini web".

It's basically the Web but instead of HTTP it uses its own protocol over TCP thus still within the Internet protocol suite. Qualifying it as the "Gemini web" already communicates that just fine and is less less whimsy than Geminiverse or whatever.

I suppose I could see grounds for suggesting OP use the community-preferred vernacular as a personal preference, but that's about all the bite I see in this bark. Maybe that's reason enough to change it so you don't piss off Gemini's 12 users—I can grant that one.

Also, "Gemini web client" does make it sounds like it's a web client for Gemini. I'd just change it to "a client for the Gemini web".

Re: Show HN: Gemini web client in 100 lines of C

#24
post #20

This is the most unreadable code I may have ever seen. Congrats on successfully writing it and getting it to work.

Yea it's very hard to read. I'm surprised that people are actually can follow the flow and can understand dirty tricks.

The most unreadable code would be the code that was intentionally obfuscated. Here I at least try to pretend that it is readable in some parts.

Thanks for kind words.

Re: Show HN: Gemini web client in 100 lines of C

#26
post #25
post #8

Nice, except the dependency on openssl. It would have been a great opportunity to use BearSSL[0]. 0. https://bearssl.org/

Is BearSSL still actively maintained? My approach is abstracting SSL away so the API can be exchanged wit OpenSSL, MbetTLS, etc.

It is a slow-moving project[0], but not dead.

0. https://bearssl.org/gitweb/?p=BearSSL;a=summary

Re: Show HN: Gemini web client in 100 lines of C

#27
post #20

This is the most unreadable code I may have ever seen. Congrats on successfully writing it and getting it to work.

Try the J source code, like https://github.com/jsoftware/jsource/blob/master/jsrc/v.c

  F1(jttable){A z,zz;I r,wr;
   F1PREFIP;ARGCHK1(w);
   // We accept the pristine calculations from ravel
   wr=AR(w); r=(RANKT)jt->ranks; r=wr0),jtravel,z));  // perform ravel on items
   R r?z:IRSIP1(z,0L,0L,jtravel,zz);  // If we are raveling atoms, do it one more time on atoms
  } // ,."r y
Quoting https://corecursive.com/065-competitive-coding-with-conor-ho... :

> Yeah. I started a project a couple months ago. I’m slowly porting that code base, the J source code to C++ 20. And yeah, I think there should be a name for these types of code bases, because it’s not C, it’s like a macro variant of C, where it’s a CDSL, where 80% of your “library” is macros. I did a search, there’s 10,000 macros in the source code, and those macros are used like functions.

Re: Show HN: Gemini web client in 100 lines of C

#28
I remember gplaces, but it doesn't compile under OpenBSD. It needs lots of fixes to be built on systems beside GNU/Linux.

On golang, Bombadillo today supports "images" with Unicode-art and searching inside the "pages" a la ctrl-f in browsers, so it's better than Amfora and one of the best TUI clients ever. Also, it does gopher and https thru external tools like lynx.

Re: Show HN: Gemini web client in 100 lines of C

#29
post #22
post #18

It's a nice project, but - I guess as is tradition with the majority of C projects - it has resource leaks and buffer overflows. There is at least one resource leak, namely, `sfd` is not closed when certain `WARN()` invocations jump back to the `start` label; for example, when `gethostbyname()` fails (i.e. try a non-existent domain and observe that the sockets remain open with `lsof`). (It also seems to be leaked in…

This is such a great feedback. Thank you a lot. OFC I will try to correct my mistakes. Not to make any excuses, just for the context. I'm a beginner in C programming and I wrote only few small programs. My tooling is basically non existent. I will try to improve tho.

Try "valgrind" to check potential memory leaks and also compile your C projects with -Wall and -Wextra, -pedantic it's fine too.

Re: Show HN: Gemini web client in 100 lines of C

#30
post #5

Earlier quoted context omitted.

Web refers to Gemini here, it being a command-line client for the Gemini web. These line-based browsers used to be more common, there were a few ones for the www but also ‘ftp’ has such a mode. As does my little ‘nostt’ Teletext reader.

I've only ever heard it called "Gemini", not "Gemini web". "Gemini web" is a bad name because Gemini's not being part of the web was the main motive in Gemini's creation. "Geminisphere" or "Geminiverse" would be fine with me as a name for the totality of Gemini servers considered collectively.

Gemini being part of the web is pretty baked-in. You can link to http:// pages from gemini, and gemini:// pages from HTTP. And all these links participate in the hyperlinked "Web".

It even supports mime types, you can serve text/gemini from an HTTP server, or a text/html file from a Gemini server.

Post reply on HN