Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Containers library

Name: Anonymous 2009-12-30 18:03

One question for you /prog/!

Suppose you have a brand new language, which doesn't have any library yet. Which kind of basic containers / data structure would you expect?

Name: Anonymous 2010-01-01 15:36

>>2
Treating arrays as flat memory might be wrong too. It's right for low-level languages like C, but what unless you're designing a low-level language, you might want to consider that an array may be not just a simple indexed buffer, but a more complex structure, for example it could containg a length to be used for bounds checking, a base item type (from which you could find out the size of the item), and so on. It's also questionable if you need built-in operators for pointer arithimethic by default. Some higher-level languages do provide "functions" or "operators" which work directly with the memory, and the compiler would efficiently inline such code, but if the language is high-level enough, you won't need to use pointers except in a few situations:
1)Implement some new data structures from scatch.
Why? If the language was well-thought, you wouldn't have to use those low-level operators except to implement such code.
2) The compiler is rather poor and you want to optimize certain code for more speed.
This may be useful in the case the compiler is lacking or you have some clever optimizations, but most of the code won't need it.
3) You're juggling some foreign data and need to be able to access it using a precise memory layout.
It's possible to make a FFI which abstracts such pointer access, so you might not need to touch the data directly yourself.
4) You're doing something platform-specific.

It's up to you to decide what kind of language you want to make. If you want to make a low-level language like C, then you could give pointer arithimethic their own special syntax as it occurs frequently enough. If you're doinga high-level language, just consider providing some functions/operators which can do pointer arithimethic, and "calls" to which the compiler can optimize very well, however there is no need to add special syntax for it, unless the language is inadequate.

You should take my opinion with a grain of salt, as of the past year, I've become to believe that syntax is very unimportant, and semtantics are truly what matters. S-Expressions or equivlents is just enough for me. Some people claim that they need visual cues to better understand code, but I know that I don't need more visual cues than just indentation and easily readable function names.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List