Page 4 of 4

Re: Which is your favorite programming language?

Posted: Fri Mar 09, 2012 12:02 pm
by Synon
For low-level programming it's got to be C. Otherwise I mostly use C#, C++ or Python. C# is probably my favourite because the .Net framework is so complete and well thought-out (moreso than any other library I've ever used). I also find it easier to conceptualise a project with distinct "pieces" in C#. I tend to write C in a somewhat OOP-like style whereby I'll have a header file with a single structure in it and a set of functions that operate on that structure. I do it like that because I'm against purely imperative languages - having a linear flow of control, though it's intuitive for short programs, seems like a bad idea for anything over a few hundred LOC. I like to write programs in several files where each file has its own primary function, and all the other functions in the file are either related to or helpers for that one function (I'll call them accessory functions). The primary function is at the bottom of the file and the accessory functions are above it; I try to put them into reverse chronological order (so control starts at the bottom of the file and works its way up, although it goes back to the bottom in between function calls). Combined with having that whole file operate on objects of a single struct results in each file being almost like a separate program. All I have to do then is write a main() function to link all the primary functions in different files together. I try to keep functions as short as possible - 3-5 lines is ideal (although in practice they're usually more like 10-20) - and have lots of them, like you would in functional programming (also I'm currently learning Haskell; even though I still don't feel like I know the language very much, it has changed the way I approach programming massively - to that end, lots of the accessory functions don't have any side-effects).

As for webpages, when I do write them (which is almost never), I use HTML, CSS, JavaScript and PHP.

Re: Which is your favorite programming language?

Posted: Fri Apr 20, 2012 10:19 am
by pauldinhqd
Mine are:
  • Intel syntax for assembly
  • C/C++ for application programming
  • Flex/ActionScript for making web embeds
  • PHP for web programming (sometimes I use Perl, but waiting for Perl6)
  • Python for creating server (like chat server etc.)
  • MySQL for database, regardless of what language the code is in

Re: Which is your favorite programming language?

Posted: Fri Apr 20, 2012 10:43 am
by sandras
Synon wrote:I like to write programs in several files where each file has its own primary function, and all the other functions in the file are either related to or helpers for that one function (I'll call them accessory functions).
That's what I'm thinking of doing for my kernel code base. : )

Re: Which is your favorite programming language?

Posted: Fri Apr 20, 2012 12:12 pm
by AndrewAPrice
- Involved applications: C++
- Whipping up something quick: C#
Hobbes wrote:
bubach wrote:Assembly has to be on my list since my OS is 100% assembly. Part of it's beauty is the raw power, which only increases the excitement when developing an OS. ... But for pure personal use or a very specific target use within an architecture - I see no reason to rob myself of the excitement and bare metal feeling that is Assembly.
ACK. Assembler is my favorite for exact the same reason. I do use C quite a lot too, because it's more practical. However, I tend to favor aesthetic over practical.
You make a point that it's less practical. I was excited when I had a university programming class where all of the assignments are in assembly. It is fun, and the ability to control exactly how the CPU functions has a sense of beauty to it. You can utilize CPU features and extensions and get to fiddle with as many bits as you want.

But, I find it is slow to accomplish something in assembly vs something in a higher level language.

The second point is that assembly programming makes you think in a lower level of abstraction. For example, it's common to see comments like:

Code: Select all

// time = fixed_sin(8.30 / PI)
mov eax, 830
div eax, PI
call fixed_sin

// position x + velocity x * time
mov ebx, [velocity_x]
mul ebx, eax
add ebx, [position_x]
mov [position_x], ebx

// position y + velocity y * time
mov ebx, [velocity_y]
mul ebx, eax
add ebx, [position_y]
mov [position_y], ebx

// position z + velocity z * time
mov ebx, [velocity_z]
mul ebx, eax
add ebx, [position_z]
mov [position_z], ebx
Okay, I understand what each small block is doing, but what are we trying to accomplish overall? Where as in C++:

Code: Select all

// update the ship's position
time = fixed_sin(830 / PI); // 8.30 in fixed point
position += velocity * time;
This is just a simple example, but imagine this example extended to some exceedingly complex network protocol or data structure that you're trying to decipher.

Re: Which is your favorite programming language?

Posted: Sun Apr 22, 2012 3:24 pm
by kammce
I love Java because it is my first but I can use any programming languages now, so it just depends on what the project needs.

Re: Which is your favorite programming language?

Posted: Mon Apr 23, 2012 12:37 am
by Combuster
MessiahAndrw wrote:This is just a simple example, but imagine this example extended to some exceedingly complex network protocol or data structure that you're trying to decipher.
I consider that an example of how not to add comments to (assembly) code.

Re: Which is your favorite programming language?

Posted: Mon Apr 23, 2012 12:49 am
by rdos
Assembler, C++ and Java.

Re: Which is your favorite programming language?

Posted: Mon Apr 23, 2012 4:33 pm
by qw
MessiahAndrw wrote:You make a point that it's less practical. I was excited when I had a university programming class where all of the assignments are in assembly. It is fun, and the ability to control exactly how the CPU functions has a sense of beauty to it. You can utilize CPU features and extensions and get to fiddle with as many bits as you want.
I totally agree with that. With "more practical" I mean that you don't have to worry about all the details like what registers are caller- or callee-save, keeping the stack balanced, what instructions may be executed in parallel, etcetera. That's what a high level language compiler does for you. But yes, programming in assembly is exciting.

Re: Which is your favorite programming language?

Posted: Tue Apr 24, 2012 7:35 am
by Yoda
Although I had a practice in dozen assemblers and programming languages I prefer two tools for practical work:
Assembler in NASM sintax. Because it provides good sintax and gives you possibility to turn programming into art. I think that most machine dependent code should be written in assembler in two cases: it requires most dense code or it requires the top performance. The same code written in assembler turns to be several times less in size that in high level programming language. And can save a lot of CPU time also.
C/C++ for architecture programming. Because it provides a high productivity and deeper insight in behavior logic.
Other programming tools seem to be less portable and/or comfortable.

Re: Which is your favorite programming language?

Posted: Tue Apr 24, 2012 5:13 pm
by miker00lz
for most serious projects, C and/or assembly. for putting something together quickly that looks/works nicely and doesn't do anything too CPU intensive, FreeBASIC. (or VB6 if i'm feeling nostalgic)