View Full Version : which programming language should I use for FreeBSD software
mia
June 26th, 2009, 23:34
Hello,
I would like to write simple program for FreeBSD. Which programming language should I use? I am programming in Visual Basic but I think VB is not the best solution for FreeBSD.
Thanks in advance.
graudeejs
June 26th, 2009, 23:46
C or C++
Or
Sh, perl
Later two are scripts (but just because it's script it doesn't mean it's not a programing language).
It all depends on what do you want to write.
There are of course others, but If I wanted to write something I would pick from this list
gnemmi
June 27th, 2009, 00:15
+1 on C++ and Perl, those are the exactly the languages I first think about (although in reverse order) even if BSDs are written in C and Sh.
You still have them all .. so I'd say that you'd be better off by first taking a look at your problem and then picking the language that best suits your need.
my 2 cents
Best Regards and happy coding :)
Lowell
June 27th, 2009, 01:39
Which language to use for software *on* FreeBSD is not a useful question. If you are changing parts of FreeBSD itself, the best approach will almost always be to use the language in which those parts are already implemented. For doing something new, however, pick the appropriate language for your application; it will almost certainly already be supported on FreeBSD.
mwatkins
June 27th, 2009, 02:01
If you are used to VB, and have a goal of writing "simple" programs, I'm inclined to send you to a so-called scripting language like Perl or Python or Ruby.
You can do an awful lot in Python with very little code.
If you define what sort of "simple" programs you are thinking of writing, you'd get more accurately aimed suggestions.
vivek
June 27th, 2009, 04:07
If you used VB and like point and click stuff where you just write code for function, try QT which uses C++. It is used by KDE, Google Earth, Skype, Adobe, Virtualbox, Nokia and many more.
It comes with Qt creator a cross-platform C++ integrated development environment which is part of the Qt SDK. It includes a visual debugger and an integrated GUI layout and forms designer.
Again, lots of things depends upon your requirements. A simple program can be as follows:
#include <QtGui/QApplication>
#include <QtGui/QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel label("Hello, world!");
label.show();
return app.exec();
}
http://www.qtsoftware.com/products
mia
June 27th, 2009, 16:53
guys many many thanks for replies.
I would like to make small "communication" program - it should encrypt text with blowfish and send some encrypted (SSL, for example via stunnel) information to remote server and recieve answer from server. I think it would be better to use C or C++ fo this (but firstly I must learn myself C or C++ :-) So I'm making decision now
iic2
June 28th, 2009, 02:20
Real men code in HEX! But I'm going to write my first FreeBSD program in pure assembler and if something minor get in my way I'll do the remained of it in straight C.
My list for FreeBSD is:
Sh - Required and Quick
Python, Perl - Slow but Resourceful
C++ - Faster but Slow and Insane
C - Faster
ASM - Pure Lighting (easier)
My list for Windows is:
ASM - Pure Lighting (easier)
In the end you'll do them all.
Carpetsmoker
June 28th, 2009, 03:42
I would like to make small "communication" program - it should encrypt text with blowfish and send some encrypted (SSL, for example via stunnel) information to remote server and recieve answer from server. I think it would be better to use C or C++ fo this (but firstly I must learn myself C or C++ So I'm making decision now
You can accomplish this with a scripting language such as Python in less than ~100 lines of code -- It's also possible in C of course, but it will require more work (Especially if you need to learn the language first!).
C is useful for more low level things when you need to be relatively close to the hardware, for many user-land applications scripting languages (Python, Perl. Ruby, Java, etc.) are more suited, they are slower, but on today's hardware the difference is often hardly noticeable.
Brandybuck
June 28th, 2009, 05:50
The two best languages are C++ and Python. C++ is for fast native code and Python for fast and flexible scripting. C is a subset of C++, so it comes for free. Bourne shell is also a good choice, but it's limited to just shell scripts.
vivek
June 28th, 2009, 09:20
C++ - Faster but Slow and Insane
Care to shade some light? I don't think so C++ is slow as compare to C as it is nothing but superset of C. Today compilers are optimized nicely. Ever tried out Intel compiler? In theory only assembly can beat C/C++, but considering the optimizations done by the compiler I don't see anything that can beat C++.
HTH
iic2
June 28th, 2009, 09:50
Even 32bit can be faster than 64bit. It all translate into machine code but (c++) vs ASM on FreeBSD? Examples comes first! I like ia64.
drhowarddrfine
June 28th, 2009, 14:21
You can accomplish this with a scripting language such as Python in less than ~100 lines of code -- It's also possible in C of course, but it will require more work (Especially if you need to learn the language first!).
Absolutely agree.
Carpetsmoker
June 28th, 2009, 18:28
C++ is a horrible language, it has every feature you can think of and then 10 times more, no sane human being can fully understand the language without 10 years of solitary study with the Monks of C++.
anomie
June 28th, 2009, 19:18
Since everyone has an opinion... here is mine. ;)
It seems my opinion jibes pretty closely with Carpetsmoker's in this thread.
When I have the time, patience, (and ability), I prefer to write utilities in C. You have complete control over every byte of data you touch, and of course it is quick.
For most other scenarios I love Python. It is, IMO, everything a high-level (scripting oriented, but also OO) language should be. Easy to learn, pretty to read, terse enough, lots of useful libraries.
I had 20 credit hours of C++ crammed down my throat while doing my CS degree years ago. The language is powerful and all, but IMO it is not designed for humans. (At least not this human.) Steer clear.
iic2
June 28th, 2009, 19:31
C, Python and Perl are most recommended for BSD cause there are many samples and people to help you. C can really be hard to debug if program get too big. They all are just as difficult to learn when first getting started so might as well do ASM and Python or the most recommended C and Python. I love asm but I wish I had learned some C first for the knowledge. It was a hard decision.
graudeejs
June 28th, 2009, 20:17
Guys, do you have opinion on d++
oliverh
June 29th, 2009, 20:31
Care to shade some light? I don't think so C++ is slow as compare to C as it is nothing but superset of C. Today compilers are optimized nicely. Ever tried out Intel compiler? In theory only assembly can beat C/C++, but considering the optimizations done by the compiler I don't see anything that can beat C++.
HTH
Well just read about it: http://www.fefe.de/c++/
http://www.fefe.de/c++/c%2b%2b-talk.pdf
Brandybuck
June 29th, 2009, 23:52
Guys, do you have opinion on d++
I stay away from languages that very few people use. There's just too much pain there. d++ is one of those languages.
iic2
June 30th, 2009, 02:01
I read a line or two about d++ in web development. I think its like a super low-level Python, Ruby, Perl etc, and is very web intensive. I think Microsoft created it in hope to invade, I mean create cross-platform applications for even BSD.
D++ should be the next thing to pure C but don't nobody seem to trust it last I read and it's missing a lot of functionality that even Perl can offer. So why waste your time. Might as well do C if not ASM, including a dash of Perl or Python.
There's just too much pain there. d++ is one of those languages.
Writing for BSD and not Linux or Windows you are in total control. You have no concern about portability so the real choice is, 32bit, 64bit or wait for Quantum (four years to eternity). Don't believe the hype. Just let-em ride. Everyone thinks he/she made the right choice and will do battle if you say difference. C and ASM will live forever.. EVERYTHING else comes down to at lease C or it would have never been invented.
deadguysleeps
June 30th, 2009, 02:34
try reading this:
http://www.python.org/doc/essays/cp4e.html
Eponasoft
July 17th, 2009, 16:50
If you have a background in VB, then gambas might be an interesting choice. I've written a couple of things in it; a few notable differences between the dialects but nothing you can't figure out pretty quickly, despite the total crap documentation. I don't know how well it would work for what you want to do though...it has some pretty severe limitations regarding the GUI.
As for the whole C vs C++ thing...C is not a subset of C++, C++ is a superset of C. C will always have more potential for higher performance, since C++ abstracts a bit too much and is more complex than it needs to be. Potential doesn't mean guarantee though...I've seen programs written in QuickBASIC that run circles around botched x86 assembly programs. When you code in C, you aren't too far off the metal much of the time...the same can't be said for C++. Of course, with modern computers being so fast and compilers being so intelligent, the gap has closed tremendously, but some of us still prefer the knowledge that our C-based programs, even if only 0.1% more efficient, are still going to be that much more efficient. :)
rbelk
July 17th, 2009, 17:35
Shell or C is my choices. This thread kinda reminds me of an old UNIX saying "If you can't do it with a shell script use C" or something like that. I wish I could find out who said that, but searching Google didn't help.
estrabd
July 17th, 2009, 18:41
Guys, do you have opinion on d++
I don't know about d++, but D is pretty interesting to me - much more so than C++ or Java.
http://www.digitalmars.com/d/
SR_Ind
February 5th, 2010, 19:40
If you have a background in VB, then gambas might be an interesting choice. I've written a couple of things in it; a few notable differences between the dialects but nothing you can't figure out pretty quickly, despite the total crap documentation. I don't know how well it would work for what you want to do though...it has some pretty severe limitations regarding the GUI.
As for the whole C vs C++ thing...C is not a subset of C++, C++ is a superset of C. C will always have more potential for higher performance, since C++ abstracts a bit too much and is more complex than it needs to be. Potential doesn't mean guarantee though...I've seen programs written in QuickBASIC that run circles around botched x86 assembly programs. When you code in C, you aren't too far off the metal much of the time...the same can't be said for C++. Of course, with modern computers being so fast and compilers being so intelligent, the gap has closed tremendously, but some of us still prefer the knowledge that our C-based programs, even if only 0.1% more efficient, are still going to be that much more efficient. :)
Few things about C++ incorrect there.
You have started off with the fact that C++ is a superset of C, but not vice-versa. The categorization is irrelevant, given the fact that nowadays any ANSI compliant C++ compiler will compile a well written C program (that leaves out really archaic C language features) with minor warnings.
The speed thing is another FUD propagated by people that never use C++ for large scale industrial grade development.
Is a C++ binary larger (implies slower) than that of a comparable C program? Yes, if you use make use of advanced features like overloading and templates.
Is the difference noticeable? No, not even on elderly 486s.
>>
People tend to forget that a C++ class method after all is good old C function.
If your compiler (and later the loader) doesn't have to muck around deciding whether Foobar() means Foobar@# or Foobar %$ in the current context then the generated opcode for Foobar from a C++ code is similar to a C one...byte by byte.
The moral of the story is C++ doesn't puts a gun on your head to use templates or virtual functions.
They are features that makes your program structure maintainable, extendable and reusable at the fraction of speed penalty.
>>
Does anyone uses inline assembly inside C++ program? Do that and you'll have the benefit of assembly code inside a structured program.
>>
How many of the forumites here maintain product lines that involves system software with LOC running into half a million or so?
I do and I say with authority that a C++ codebase is easier to maintain in an environment that sees occasional handover of code, new staff induction, emergency fixes by relatively junior developers.
A large C++ application enforces certain degree of structural discipline which is important if you let the application to be handled by a people with varying degree of experiences.
>>
If speed is an arguement then one should code in assembly. C is a trade off you need readibility and portability and similarly C++ is a trade off if you need structural integrity in the application.
rockworldmi
January 27th, 2012, 05:23
Has anyone made any application/software with assembly? And with/without GUI?
drhowarddrfine
January 27th, 2012, 06:00
Yes but it's been a long time. I remember my boss drag us kicking and screaming and forcing us to buy "the white book" and learn C. This was around 1987. We would do a little C, then mix in our assembly which eventually wound up as an all assembly routine.
SirDice
January 27th, 2012, 09:12
Has anyone made any application /software with assembly?? and with/without GUI?
Last time I did that was on the Amiga. 68000 assembly is so much easier than x86/x64.
UNIXgod
January 27th, 2012, 09:50
Use posix sh for shell scripting. Here is a cheat sheet to for portable programming:
http://rubyprogrammer.net/~stu/posix/
perl, python, and ruby are great scripting languages.
Ruby is an amazing language and worth checking out. It is inspired from perl which is inspired from sh( i.e. sed/awk) awk is great language to pipe and filter to.
Low level programming as it's been mentioned is done with c. C++ of course could be used for app development.
Of course there are ton of languages that you can use for making programs.
Here is info on the subject in the handbook:
http://www.freebsd.org/doc/en/books/developers-handbook/tools-programming.html
drhowarddrfine
January 27th, 2012, 14:49
68000 assembly is so much easier than x86/x64.
Absolutely! The 68k should have been today's processor of choice.
Uniballer
January 27th, 2012, 15:08
Absolutely! The 68k should have been today's processor of choice.
I used to feel that way, too. I got over it by the mid 90's, though. At that point I didn't care what the underlying machine looked like as long as the target hardware would run compiled C fast enough. And if I had to write a little bit of assembler to fix performance problems (or interrupt handling, whatever) it wasn't like writing a lot of it.
fonz
January 27th, 2012, 21:49
Last time I did that was on the Amiga. 68000 assembly is so much easier than x86/x64.
I liked the MIPS instruction set as seen in e.g. the Silicon Graphics Indy (R4x00). But it doesn't seem to have a whole lot of following anymore these days.
Fonz
fonz
January 27th, 2012, 22:19
More on topic, though: there are lots of programming languages out there, so there's a lot to choose from. Some are easier to learn than others, some are more powerful/rich than others, some have better performance than others, some are more fun than others, some are more widespread than others and some are more portable than other.
Sh is nice for scripting but not really meant for serious applications. Pascal is very well-designed (from a formal language theory point of view) and ideal for teaching programming to people with no prior programming experience (and there's also a reason why it's often used for teaching compiler building) but it's rarely used beyond educational contexts these days. Perl has seen competition from e.g. Python and Ruby but still it can't hurt to learn it. C is still the most common language for systems programming and seems easy enough, but the details are quite subtle and few people are really good at it. C++ is (in my opinion) quite ugly from a linguistic point of view, but it's still quite useful/educational and combines many features found in other languages. Java is portable, very all-round and can be learned in stages but its sheer performance is still questioned. Haskell is extremely cool but based on an entirely different paradigm and therefore (much) more difficult to learn properly. Assembly can be insightful for specialists but is not at all suitable for beginning programmers. C# is for Windows. And even then, there are better options. If your main goal is to write Internet applications quickly, you might want to consider Rebol. It's not very well-known but quite good at what it's meant for. On the downside, it's useless for pretty much everything else.
Fonz
drhowarddrfine
January 27th, 2012, 22:34
I liked the MIPS instruction set as seen in e.g. the Silicon Graphics Indy (R4x00). But it doesn't seem to have a whole lot of following anymore these days.
Fonz
Ooh! I forgot all about Mips and you're right. And I worked for SGI! Sheesh. But I never got to mess with it on that level and my time there was too short.
Mips manufacturer's stock price had a nice runup a little over a year ago. I had a hand in that having owned some briefly. I really haven't kept track of how the cpu chip fairs nowadays but I do see there are people with a lot of interest in it. Just don't recall who.
fonz
January 28th, 2012, 00:38
And I worked for SGI!
Way cool, bastard! Dare I inquire what you did there?
Back in the days (mid to late '90s) SGI hardware was the cat's meow. The university where I was a student at the time had a lab room full of blue pizza boxes and later, when they replaced the individual Indy machines with a central quad-processor Sun beast (the machine was actually hostnamed "beast") and SunRay login card readers, I managed to get my hands on a couple of those Indy things as they were auctioned off. I still have one or two sitting in storage, with grey-marble monitors, Indy-Cams and whatnot. In my opinion MIPS was a very elegantly-designed instruction set but the operating system was a mixed blessing. On the one hand it was standards-compliant enough that many Linux (which was only up and coming in those days) applications could relatively easily be ported to IRIX 5.X (Fvwm(2) sure looked better than 4DWM and I have ported several Linux apps to IRIX) but it was also full of potential buffer overflows and I have actually gotten into trouble with the authorities on more than one occasion because of just that. When they found out that I actually knew what I was doing (rather than blindly deploying some exploit code found on the Internet) it led to some mutual respect and the chief sysadmin at that time is still a good friend of mine nowadays, but still: in my opinion IRIX 5.X was as crappy as swiss cheese.
Fonz
drhowarddrfine
January 28th, 2012, 04:50
I was a systems engineer. I was hired for my video expertise to help out at, then, McDonnell-Douglas and their flight simulators. This was in the early 1990s. I went to SGI from Pixar*.
Even though I was based in St. Louis, I was frequently in California. One of the coolest things was eating lunch and have Jim Clark sit down next to you.
*I worked at Pixar when Pixar made hardware. It was that long ago. They promptly let all of us go shortly after hiring us when they got out of the hardware business.
shitson
January 28th, 2012, 05:07
I'm pretty sure this hasn't been mentioned yet
http://www.freebsd.org/doc/en_US.ISO8859-1/books/developers-handbook/
fonz
January 28th, 2012, 06:37
I was hired for my video expertise to help out at, then, McDonnell-Douglas and their flight simulators.
Or so he casually announced to the aeronautical engineering minor ;)
I wasn't even aware that Silicon Graphics had ventured into that area and it was probably some years before my time, but I sure would have loved to have gotten in on that action. Developing flight simulators for MD? That's way cool! From now on, instead of Doctor I'm going to call you Captain :e
Fonz
drhowarddrfine
January 28th, 2012, 15:09
To show you how stupid things got back then, my boss for the region was in Detroit. He hired me. SGI re-organized and my new boss was based in Dallas. My new boss looked and acted just like J.R Ewing from the TV show "Dallas". He decided he wanted a Fortran programmer and I didn't know Fortran so I was out.
estrabd
January 29th, 2012, 00:00
Real men code in HEX! But I'm going to write my first FreeBSD program in pure assembler and if something minor get in my way I'll do the remained of it in straight C.
My list for FreeBSD is:
Sh - Required and Quick
Python, Perl - Slow but Resourceful
C++ - Faster but Slow and Insane
C - Faster
ASM - Pure Lighting (easier)
My list for Windows is:
ASM - Pure Lighting (easier)
In the end you'll do them all.
You're forgetting about the importance of portability.
All but ASM provide that. It's the reason Unix required the invention of C ;)
xibo
January 29th, 2012, 01:05
Real men code in HEX!
How fortunate there's a lot of women and "fake" men coding, too, for they make the code that is actually maintainable.
C++ - Faster but Slow and Insane
The "Faster but Slow" part seems quite contradictive.
To put things right, C++ is faster to develop applications in, but takes more time to learn and ages in completely mastering it, mostly due to it's over-complicated grammar.
I agree with fonz description.
drhowarddrfine
January 29th, 2012, 01:08
You're forgetting about the importance of portability.
All but ASM provide that.Using libraries, you can make asm just as portable as C.
Carpetsmoker
January 29th, 2012, 01:17
Lately (time permitting) I've been looking at the Scheme programming language, basically, it's a lighter/minimalistic version of Lisp.
I find it interesting because the language is so radically different from anything else I've ever used, and some of the skills and idea's I've picked up from Scheme have been useful in other procedural/OOP languages as well. Specifically it really helped me truly grasp the concept of recursion to the point where it's actually useful in much more scenarios then before.
The little Schemer (http://mitpress.mit.edu/catalog/item/default.asp?sid=86C0EAF5-85CE-41EB-AE2C-828F76F52209&ttype=2&tid=4825) is a great book, although the writing style may not be to everyone's liking. There's also Teach yourelf Scheme in fixnum days (http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme.html) (Free!).
There are a whole bunch of Scheme interpreters available, I use Chicken Scheme (lang/chicken in ports).
I don't know how Scheme/Lisp compares to other functional languages such as Haskell, OCAML, Erlang, etc, but I've found that learning "pure" functional programming is pretty useful even in you spend most of your time in other languages.
estrabd
January 29th, 2012, 05:46
Using libraries, you can make asm just as portable as C.
Not across ISAs, are am I missing something?
estrabd
January 29th, 2012, 05:48
Lately (time permitting) I've been looking at the Scheme programming language, basically, it's a lighter/minimalistic version of Lisp.
I find it interesting because the language is so radically different from anything else I've ever used, and some of the skills and idea's I've picked up from Scheme have been useful in other procedural/OOP languages as well. Specifically it really helped me truly grasp the concept of recursion to the point where it's actually useful in much more scenarios then before.
The little Schemer (http://mitpress.mit.edu/catalog/item/default.asp?sid=86C0EAF5-85CE-41EB-AE2C-828F76F52209&ttype=2&tid=4825) is a great book, although the writing style may not be to everyone's liking. There's also Teach yourelf Scheme in fixnum days (http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme.html) (Free!).
There are a whole bunch of Scheme interpreters available, I use Chicken Scheme (lang/chicken in ports).
I don't know how Scheme/Lisp compares to other functional languages such as Haskell, OCAML, Erlang, etc, but I've found that learning "pure" functional programming is pretty useful even in you spend most of your time in other languages.
I'm looking at Lua, D, and Ada. FWIW, OpenMP enabled GCC compilers (and non-free supporting compilers, too) make for nice interfaces for multi-threaded programming.
aragon
January 29th, 2012, 12:03
Well hopefully the OP figured this out, but I'll just mention it anyway...
If you're writing software for the FreeBSD project, it should be written in C or POSIX-compliant Bourne Shell (if it's a small utility). Except for a handful of exceptions, there are no other languages in FreeBSD's source code.
If you're writing software that must run on FreeBSD, your options are almost endless (http://www.freshports.org/lang). Take your pick. :)
I'm most interested in playing with node.js (http://nodejs.org/) on the V8 engine, and Go (http://golang.org/) in future.
rockworldmi
January 29th, 2012, 12:14
this book is good ...http://www.amazon.com/exec/obidos/tg/detail/-/0470497025/
freethread
January 29th, 2012, 12:36
I'm most interested in playing with node.js (http://nodejs.org/) on the V8 engine
For web server side scripting or system scripting (or both)?
throAU
January 30th, 2012, 02:54
2c.
I would use either
C
Perl
Python
Java
(C, perl and java are available pretty much everywhere)
Work out what other types of workload you may be programming for, any other potential environments you may code for in future, and select a language based on that.
C is going to be faster than the others but it enables the programmer to write code full of buffer overflows and requires the understanding and use of pointers.
I suspect Perl or Python will serve you well - if you prototype in either of those, you can maybe re-write sections of (or your entire) program in C if performance proves to be insufficient.
Diving straight into C from VB for a network daemon is (imho) a recipe for writing exploitable code.
aragon
January 30th, 2012, 20:51
For web server side scripting or system scripting (or both)?
Not scripting. It's an event driven framework, a programming paradigm which isn't really relevant to system scripting.
Interested in server side code, not necessarily web-only.
estrabd
February 5th, 2012, 20:20
I maintain the FreeBSD port lang/qore, and it's a Perl-like interpreted language that supports SMP environments. The interpreter and runtime are written in C++. It has a number of interesting features inspired from a variety of interesting languages (interpreted and compiled).
I created the port for it because, primarily due to its SMP support, has come closest to competing with Perl in my desire to use it.
http://en.wikipedia.org/wiki/Qore_Language
olav
February 6th, 2012, 11:59
Since Mia already knows Visual Basic, what about Gambas (http://gambas.sourceforge.net/en/main.html)?
drhowarddrfine
February 6th, 2012, 15:39
Visual Basic?! Surely you jest.
toongya
February 23rd, 2012, 02:20
If you used VB and like point and click stuff where you just write code for function, try QT which uses C++. It is used by KDE, Google Earth, Skype, Adobe, Virtualbox, Nokia and many more.
It comes with Qt creator a cross-platform C++ integrated development environment which is part of the Qt SDK. It includes a visual debugger and an integrated GUI layout and forms designer.
Again, lots of things depends upon your requirements. A simple program can be as follows:
#include <QtGui/QApplication>
#include <QtGui/QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel label("Hello, world!");
label.show();
return app.exec();
}
http://www.qtsoftware.com/products
Hi vivek,
I am interested in Qt but I can not follow your links. Would you please point a newbies like me to where I can find information about Qt programming?
Thanks vivek in advance.
toongya
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.
0