Show HN: Cicada – A scripting language that integrates with C
11–20 of 41 posts
Re: Show HN: Cicada – A scripting language that integrates with C
#12[flagged]
Aliases are strongly-typed which helps avoid some issues. Memory mods come with the territory —- if ‘a’ and ‘b’ point to the same array and ‘a’ resizes that array, then the array behind ‘b’ gets resized too. The one tricky situation is when ‘a’ and ‘b’ each reference range of elements, not the whole array, because a resize of ‘a’ would force a resize of the width of ‘b’. Resizing in this case is usually not allowed.
Garbage collection is indeed done (poorly) by reference counting, and also (very well) by a tracing function that Cicada’s command line script runs after every command.
You’re exactly right, the library is lean because I figure it’s easy to add a C function interface for any capability you want. There’s a bit of personal bias as to what I did include - for example all the basic calculator functions are in, right down to atan(), but no regex. Basic IO (save, load, input, print) is included.
Type marshaling — the Cicada int/float types are defined by cicada.h and can be changed! You just have to use the same types in your C code.
When you run Cicada you pass a list of C functions paired with their Cicada names: { “myCfunction”, &myCfunction }. Then, in Cicada, $myCfunction() runs the callback.
Thanks for the questions! This is exactly the sort of feedback that helps me learn more about the landscape..
Re: Show HN: Cicada – A scripting language that integrates with C
#13Can I call into the interpreter from multiple threads or does it use global state?
Re: Show HN: Cicada – A scripting language that integrates with C
#14I've lost count of projects called Cicada
Re: Show HN: Cicada – A scripting language that integrates with C
#15I've lost count of projects called Cicada
The name came when I was living in Seattle and missed the sounds of east coast summer..
Re: Show HN: Cicada – A scripting language that integrates with C
#16 counter :: int
for counter in (
print(counter)
print(" ")
)
Using backfor to count backwards is an odd choice. Why not overload for? backfor counter in print(counter, " ")
This is confusing to me. Maybe I'm misunderstanding the design principles, but the syntax seems unintuitive.Re: Show HN: Cicada – A scripting language that integrates with C
#17[flagged]
Good questions! The short answer to the first is that the language is interpreted, not compiled, so optimizations are moot. Aliases are strongly-typed which helps avoid some issues. Memory mods come with the territory —- if ‘a’ and ‘b’ point to the same array and ‘a’ resizes that array, then the array behind ‘b’ gets resized too. The one tricky situation is when ‘a’ and ‘b’ each reference range of elements, not the w…
Re: Show HN: Cicada – A scripting language that integrates with C
#18The for loop is odd. Why is the word counter in there twice? counter :: int for counter in ( print(counter) print(" ") ) Using backfor to count backwards is an odd choice. Why not overload for? backfor counter in print(counter, " ") This is confusing to me. Maybe I'm misunderstanding the design principles, but the syntax seems unintuitive.
The example I gave was strange and I’ll have to change it. Not sure what I was trying to show there. The basic syntax is just:
for counter in print(counter)
backfor counter in print(counter)
It’s not overloaded because ‘for’ is basically a macro, expanding to ‘iterate, increment counter, break on counter > 5’ where ‘>’ is hard-coded. If ‘for’ was a fundamental operator then yes, there would be a step option and it would be factored into the exit condition.
You’ve got me thinking, there’s probably a way to overload it even as a macro.. hmmm…
Re: Show HN: Cicada – A scripting language that integrates with C
#19How does it deal with use after free? How does it deal with data races?
Memory safety can't be solved by just eliminating pointer arithmetic, there's more stuff needed to achieve it
Re: Show HN: Cicada – A scripting language that integrates with C
#20Earlier quoted context omitted.
Good questions! The short answer to the first is that the language is interpreted, not compiled, so optimizations are moot. Aliases are strongly-typed which helps avoid some issues. Memory mods come with the territory —- if ‘a’ and ‘b’ point to the same array and ‘a’ resizes that array, then the array behind ‘b’ gets resized too. The one tricky situation is when ‘a’ and ‘b’ each reference range of elements, not the w…
[flagged]
Scripted functions have no set arity, and the same applies to callback C functions. Scripted functions collect their arguments inside an ‘args’ variable. Likewise, each C function has a single ‘argsType’ argument which collects the argument pointers & type info, and there are macros to help unpack them but if you want to do the unpacking manually then the function can be called variadically:
ccInt myCfunction(argsType args)
{ for (int a = 0; a So all functions are automatically variadic.
It’s good to know that these GC/etc. solutions are even used by the big languages..