4 ms·
I am currently working on a project that I will be using at home between my laptop and (not so powerful) Raspberry PI. I am well versed in C and this project is
by fredmorcos 11y ago
I am currently working on a project that I will be using at home between my laptop and (not so powerful) Raspberry PI. I am well versed in C and this project is written in it, with very minimal dependencies (currently talloc, libbsd and makeheaders). I am trying to keep resource usage at a bare minimum on the server side (Raspberry PI) for obvious reasons.
I've never worked with Pascal, and I've been looking for an alternative to C that solves some of the issues I'm having without sacrificing too many of its advantages. Since fpc is available for armv6, I am wondering if someone could give me advice on whether moving this project to Pascal would be beneficial, especially compared to the following points:
- A proper module system, without having to keep .h and .c files in sync when the interfaces aren't stable yet. I am currently using makeheaders to make things less annoying for me.
- Compiler warnings, cppcheck and scan-build offer me great feedback. Emacs integration of these tools is priceless.
- The ability to do things like recv() into the middle of a buffer. That is just too efficient to let go of. I think this is something many people overlook when comparing C to other programming languages, many times you can turn O(2n) into O(n) by taking advantage of this. Not theoretically different, but in practice it can pay off.
- Emacs integration and support. Nice to have would be support for auto-completion, static analysis, etc...
- Documentation. Man 2, 3 and 3p are priceless. Emacs man integration is great.
- Number types that are exactly the same across architectures. eg, I've had issues because off_t was ulong on one machine and ulonglong on the other.
- Memory management, error handling and everything you need to do that has nothing to do with the task at hand. It gets old quickly.
- Optionally high-level, I am comfortable working with pointers and addressing memory directly, but sometimes I look for elegance where I know performance is not going to be affected too much (ie, the trade-off is acceptable). This also means that when I'm working with higher-level constructs, I'd like to have easy access to the inner workings so that I can make such a judgement myself (either through documentation or other means).
- I don't care too much about compilation speed.
- Easy semantics and simplicity of things. I really don't think I can put that into words, it's better understood through experience. But this is one of the biggest reasons I stick with C rather than C++ or Rust.
- The availability of a widely approved guide that doesn't go into the very basics of programming to explain the language (maybe some sort of Pascal for C people kind of thing).
- There are probably a few more points I could talk about but can't think of right now. I could write them down some time later if anyone is interested.
Thank you in advance, I would really appreciate if anybody can help me with these points, I'm looking for new adventures :)
- chipsy 11y agoPascal will cover a few of your points and move you sideways on others. For example you do have a required forward declaration but it's all in a single module file. FPC is a good compiler and should cover most concerns around tooling. And it's all been documented in depth at some point, although you might be studying from pretty old sources. But because it remains a pretty simple language, it's not going to have so many nifty time saver features. If you're going for that you might be better served with a "new and hyped" language like D or Nim - those languages aren't as convoluted as C++ but they are still complex.