News for hackers. Stuff that matters.
Re:Show HN: Bic – a C interpreter and API explorer by wrp on Thursday September 12, 2019 @01:04PM (#20953803)
Interactive C environments were popular for a while. I have collected information on several at the Computer History Museum. I actually have even more stuff that I never got around to uploading.

You unfortunately need to make an account to see the pages. It was heavily attacked at one time and that was the admin's solution.

Interactive C Environments http://www.softwarepreservation.org/projects/interactive_c

Re:Show HN: Bic – a C interpreter and API explorer by sshb on Thursday September 12, 2019 @09:17AM (#20951056)
Reminds me of CERN’s ROOT which has C/C++ interpreter https://root.cern.ch/
Re:Show HN: Bic – a C interpreter and API explorer by kzrdude on Thursday September 12, 2019 @09:44AM (#20951340)
Their new repl is called cling: https://github.com/root-project/cling (They had an old one called C-INT or something like that).
Re:Show HN: Bic – a C interpreter and API explorer by amirmasoudabdol on Thursday September 12, 2019 @11:24AM (#20952528)
One of the biggest problem with these repl for complied languages is that they panic as soon as you rerun a command. `cling` integrates with Jupyter notebook too but as soon as you rerun a declaration of a variable, everything collapse and you have to reset the kernel. Maybe I didn’t dig deep enough and there is a way around this but if not, this is quite painful to deal with and a deal breaker.
Re:Show HN: Bic – a C interpreter and API explorer by sigjuice on Thursday September 12, 2019 @03:10PM (#20955189)
So repeating something like 'int i = 42;' causes problems?
Re:Show HN: Bic – a C interpreter and API explorer by hexagonal-sun on Thursday September 12, 2019 @09:30AM (#20951189)
Huh, I didn't know about that tool. Looking through the docs this looks impressive, especially since it can do C++ too.
Re:Show HN: Bic – a C interpreter and API explorer by jart on Thursday September 12, 2019 @01:04PM (#20953805)
One cool trick for C REPLs is to grep the man page directory to automate those pesky #include lines, e.g. https://gist.github.com/jart/5d0934d26b52f38cad36 Another trick is to build with STABS and use objdump -g.
Re:Show HN: Bic – a C interpreter and API explorer by smhenderson on Thursday September 12, 2019 @10:01AM (#20951515)
This is really cool, nice work. I especially like the bit about putting a REPL statement in a source file to have it drop into bic. Seems like a quick and dirty way to debug without having to fire up gdb and such. Somewhere in between print statements and full on debugging.

Thanks for sharing.

Re:Show HN: Bic – a C interpreter and API explorer by scandox on Thursday September 12, 2019 @09:24AM (#20951133)
I often looked for this and failed to find something that I could easily use. So I'm delighted to see this as a on/off C amateur and learner.
Re:Show HN: Bic – a C interpreter and API explorer by hexagonal-sun on Thursday September 12, 2019 @09:31AM (#20951199)
Thanks! It's still a work in progress but should hopefully help people to get to grips with C.
Re:Show HN: Bic – a C interpreter and API explorer by fortran77 on Thursday September 12, 2019 @12:46PM (#20953580)
In the late 80s there was a product called C-Terp, which I loved!

Here's a link to a brief description:

https://books.google.com/books?id=fHghpJa3va4C&lpg=PA167&ots...

And, yes, I paid the $295 for it.

Re:Show HN: Bic – a C interpreter and API explorer by xvilka on Thursday September 12, 2019 @11:39AM (#20952715)
It lacks the syntax highlight. They could have used tree-sitter[1] for parsing, then the online highlight would be easier to implement.

[1] https://github.com/tree-sitter/tree-sitter

Re:Show HN: Bic – a C interpreter and API explorer by hexagonal-sun on Thursday September 12, 2019 @12:00PM (#20952999)
Agreed, syntax highlighting would be great. I was thinking about something akin to fish's syntax highlighting and completion with the REPL.

I'll take a look at tree-sitter. If I get syntax highlighting for free then I'll take that!

Re:Show HN: Bic – a C interpreter and API explorer by johnisgood on Thursday September 12, 2019 @01:05PM (#20953810)
> Dependency-free so that the runtime library (which is written in pure C) can be embedded in any application

What does dependency-free mean? I mean, it does depend on 128 crates. Do we typically not count those?

By the way, I did `cargo build` and it failed at `#include "utf8proc.c"`. I have `libutf8proc` installed. Changing `.c` to `.h` solved it. It went past that part, only to get:

- error: couldn't read cli/src/../../lib/binding_web/tree-sitter.js: No such file or directory (os error 2)

- error: couldn't read cli/src/../../lib/binding_web/tree-sitter.wasm: No such file or directory (os error 2)

Re:Show HN: Bic – a C interpreter and API explorer by TkTech on Thursday September 12, 2019 @02:47PM (#20954919)
The generator isn't dependency free, the parser it generates is.
Re:Show HN: Bic – a C interpreter and API explorer by israrkhan on Thursday September 12, 2019 @11:46AM (#20952803)
perhaps you meant to include https://github.com/tree-sitter/tree-sitter as reference.
Re:Show HN: Bic – a C interpreter and API explorer by xvilka on Thursday September 12, 2019 @01:27PM (#20954032)
Oh, yes, clipboard mistake, thanks for the correction!
Re:Show HN: Bic – a C interpreter and API explorer by agumonkey on Thursday September 12, 2019 @10:12AM (#20951623)
I love that you have to #include how to exit :)
Re:Show HN: Bic – a C interpreter and API explorer by huhtenberg on Thursday September 12, 2019 @04:26PM (#20956062)
Technically, you should be able to just call exit(1) because of the C's support for "implicit function declarations".

With no prior exit() declaration, the C compiler would assume that "exit" is "int exit()", spit out the code to push whatever arguments are passed to it down the stack and then just call the damn thing. So, magically, it will all just work. Requires an older compiler though, C89 the latest.

Re:Show HN: Bic – a C interpreter and API explorer by jart on Thursday September 12, 2019 @07:00PM (#20957387)
Modern GCC and Clang still support implicit functions. They just complain about it by default. (Mostly for reasons that shouldn't be entirely relevant to modern x86.)
Re:Show HN: Bic – a C interpreter and API explorer by airstrike on Thursday September 12, 2019 @11:33AM (#20952631)
And people think exiting vim is hard!

I suppose you could always quit abruptly, though...

Re:Show HN: Bic – a C interpreter and API explorer by emilfihlman on Thursday September 12, 2019 @10:39AM (#20951960)
Why is fputs returning 1?
Re:Show HN: Bic – a C interpreter and API explorer by fit2rule on Thursday September 12, 2019 @10:44AM (#20952020)
1 is a non-negative number. fputs() return nonnegative numbers on success...
Re:Show HN: Bic – a C interpreter and API explorer by emilfihlman on Thursday September 12, 2019 @11:08AM (#20952322)
Ah yeah true, looked at the wrong part of a man page.
Re:Show HN: Bic – a C interpreter and API explorer by israrkhan on Thursday September 12, 2019 @11:47AM (#20952829)
an integration with jupyter would be nice.
Re:Show HN: Bic – a C interpreter and API explorer by forpace on Thursday September 12, 2019 @08:04PM (#20957778)
One of the biggest problem with these repl for complied languages is that they panic as soon as you rerun a command. `cling` integrates with Jupyter notebook too but as soon as you rerun a declaration of a variable, everything collapse and you have to reset the kernel. Maybe I didn’t dig deep enough and there is a way around this but if not, this is quite painful to deal with and a deal breaker.