Live data from Hacker News

PicoC: a very small C interpreter for scripting

code.google.com

31–40 of 47 posts

Re: PicoC: a very small C interpreter for scripting

#31

Language interpreters are great for experimenting with new or buggy pieces of code - just experiment at the prompt and copy what works into a file for posterity. I've started looking through the parsing code for PicoC, and its all nice and readable. But I'm surprised this was used in an actual system, embedded or not. C is an absolutely miserable language whose saving graces are executable size and speed. It lacks re…

As you suggested, it offers the possibility to switch from interpreted to compiled code at no extra effort.

Re: PicoC: a very small C interpreter for scripting

#33
post #13

Would this be allowed in an iPhone application, since it's all C?

AFAIK no programs are allowed which interpret code.

Actually, Apple allows interpreted code under certain circumstances. Link provides more details. I'm not sure how helpful it would be in this case, though. My understanding is that the main motivation for having scripted languages as a small part of an app, as this rule allows, is for game engines which have high-performance graphics stuff in C, and some of the application logic in a language like Lua. The use of a scripting language can reduce development time, but if you were using C, you might as well compile it.

http://arstechnica.com/apple/news/2010/06/devs-cautiously-op...

Re: PicoC: a very small C interpreter for scripting

#36
post #32

Personally I would use Forth for this. PicoC looks interesting but if I were to weigh my options (i.e. PicoC vs Forth in his example app UAV-onboard system, I would definitely go Forth).

Care to explain your reasoning behind this?

As I understand, the main appeal of using C as a scripting language is the fact that you use the same language in compiled and interpreted part of your application.

Drawbacks of using C interpreter for scripting could include large footprint and external dependencies, but as far as I can understand, they are not the case here.

So what is your reasoning for Forth?

Re: PicoC: a very small C interpreter for scripting

#37

Earlier quoted context omitted.

Yeah. Why reuse something when you can write it yourself!

I was wondering if you really meant that, given that this is intended to be useful in embedded applications. To try to get a feel for the sort of programming you do and the sort of opinions you hold, I checked your profile - Bang - there's the answer right there: > I'm not trolling: > I actually think that. Is it really the case that you don't see the point in writing a minimal, small, clean, self-contained system th…

Just curious: Is it trolling, if I write out a strong opinion, that I don't necessarily believe, but that sounds reasonable to me, on a topic I'm trying to figure out what to believe, and then, when my sentiments get refuted, I say to myself, "Okay, now there's a reasonable way to think."

Re: PicoC: a very small C interpreter for scripting

#39

How refreshing to see something that only has 'readline' as a dependency and otherwise just requires a working C compiler and 'make'.

Yeah. Why reuse something when you can write it yourself!

Because:

- each dependecy makes it harder to build your project

- and makes it more brittle (libraries goes obsolete, changes versions, occasionaly have non-backward-compatibile changes, on different systems different versions of libraries are available, etc)

- most of the time you use only small fraction of each library, it is also common (at least in static typing world) that libraries enforces data structures on you, so sometimes it's easier to reinvent wheel, than to integrate your app with some library

- when you need to add some feature to library you often have to go throught hoops (inherit some class, make some wrappers and use it instead of what you'd use normally) - it is much easier to keep things simple, when you have controll over interfaces and can just change what you want, also architecture is simpler without proxies, wrappers and delegates

- static binaries on linux don't work after a few years

- dynamic linked binaries works as long as somebody worries about dependency problems - and this means you

- you can keep all dependencies in VCS together with your project, but often it's not legal (LGPL)

- not really important for most apps - dependencies bloats your app

Dependencies in programming are like moving parts in enginering - there should be as few of them as possible.

Re: PicoC: a very small C interpreter for scripting

#40
post #31

Language interpreters are great for experimenting with new or buggy pieces of code - just experiment at the prompt and copy what works into a file for posterity. I've started looking through the parsing code for PicoC, and its all nice and readable. But I'm surprised this was used in an actual system, embedded or not. C is an absolutely miserable language whose saving graces are executable size and speed. It lacks re…

As you suggested, it offers the possibility to switch from interpreted to compiled code at no extra effort.

[deleted]
Post reply on HN