Which is your favorite programming language?
Re: Which is your favorite programming language?
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.
As for webpages, when I do write them (which is almost never), I use HTML, CSS, JavaScript and PHP.
- pauldinhqd
- Member
- Posts: 37
- Joined: Tue Jul 12, 2011 9:14 am
- Location: Hanoi
- Contact:
Re: Which is your favorite programming language?
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
AMD Sempron 140
nVidia GTS 450
Transcend DDR2 2x1
LG Flatron L1742SE
nVidia GTS 450
Transcend DDR2 2x1
LG Flatron L1742SE
Re: Which is your favorite programming language?
That's what I'm thinking of doing for my kernel code base. : )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).
- AndrewAPrice
- Member
- Posts: 2299
- Joined: Mon Jun 05, 2006 11:00 pm
- Location: USA (and Australia)
Re: Which is your favorite programming language?
- Involved applications: C++
- Whipping up something quick: C#
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:
Okay, I understand what each small block is doing, but what are we trying to accomplish overall? Where as in C++:
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.
- Whipping up something quick: C#
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.Hobbes wrote: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.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.
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
Code: Select all
// update the ship's position
time = fixed_sin(830 / PI); // 8.30 in fixed point
position += velocity * time;
My OS is Perception.
Re: Which is your favorite programming language?
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.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Which is your favorite programming language?
I consider that an example of how not to add comments to (assembly) code.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.
Re: Which is your favorite programming language?
Assembler, C++ and Java.
Re: Which is your favorite programming language?
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.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.
Re: Which is your favorite programming language?
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.
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?
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)