Home Search First Look Rules Help TheDaddy.org BlogLogin/Register
By bye hackers
The Coders Thread - 1 to 14
Return To Techy Corner

General*
Windows Bob - the best!
Sat 13th Dec '08 11:03PM
4213 Posts
General's Avatar
Member Since
7th Apr '03
In my new job I do quite a bit of software development and I've been wondering what skills I should try to build.

I figured there are a fair few coders and techies on the forum it might be interesting to see what languages forumers have been working with and what they think of them.

The first language I learned was Java which unlike a lot of people I quite like. It's plenty fast enough for most applications and it's nice as a Linux user to be able to write platform independent apps which I can share with my mates,
I ported some C to Java and it made me think maybe I should have spent more time learning low level stuff and get a bit more familiar with the underlying machine.

I spent a while writing C# which I think is definitely the best language for .NET development, but does suffer from being a bit of a mangled amalgam of C++ and Java.

I've also been writing some web apps in PHP. I heard someone say that you can get stuff done quickly with PHP, but you feel a bit dirty when you've finished. I think I'd probably agree with that sentiment.

I've been thinking about getting a bit better with Python and perhaps writing my next game with Pygame. I would be interested to hear from anyone who had spent a lot of time with Python about its strengths and weaknesses.
    

Spanners*
Misses his big brother :(
Mon 15th Dec '08 8:36AM
4597 Posts
Spanners's Avatar
Member Since
7th Apr '03
I've heard good things about python but never used it myself. I work mostly in Ruby on Rails which is the code equivalent of a Thai massage followed by champagne and lobster - beautiful to work with but you end up paying for it in terms of high resource requirements and tricky installation.
I still use PHP for all my personal projects.
    

Amanshu*
Giggity Giggity goo
Mon 15th Dec '08 9:03AM
2708 Posts
Amanshu's Avatar
Member Since
25th Aug '04
I've generally been stuck with Ada at work, which isn't as bad as a lot of people make out - but is still pretty crappy.

I seem to have somehow managed to avoid having to learn C, although not on purpose it's just the way it happened.

For home projects I guess the main languages I've used are either the css/javascript/xul hybrid that most of the Mozilla platforms are based on and a spattering of pretty much every scripting language.

I'm currently playing around with Python. So far it seems pretty damn flexible, if a little bit dense. The documentation is thorough but it doesn't really give a very good overview of basic syntax and structure layout. In the end I went with the finding other code and hacking it route because it saved time...
   

Agentgonzo
There's no pee in catheter!
Mon 15th Dec '08 10:50AM
811 Posts
Agentgonzo's Avatar
Member Since
8th Aug '06
The mainstay of my work (at work and at home) is all done in C++. I've also done quite a bit of raw C and a fair amount of C#. I've done a tiny bit of java. I could rant on for days about the relative strengths and weaknesses of them, but to me C# made some plain stupid design decisions that I can't find a decent reason for (like the lack of static variables in functions).

On the scripting side, I've use bash scripts a lot, have started to have to use batch scripting at work (I can't describe just how hideous batch scripting is) and have done a fair amount of perl and think it is very good, though doesn't lend itself to readability at all. I've looked into python, but never really had a reason to use it in anger, so still remain rather ignorant of it.

Other languages that I've dipped my toe into are BASIC, ML and prolog, but can't really remember much of the latter two.
  

General*
Windows Bob - the best!
Mon 15th Dec '08 1:09PM
4213 Posts
General's Avatar
Member Since
7th Apr '03


Agentgonzo was bold enough to comment:
The mainstay of my work (at work and at home) is all done in C++. I've also done quite a bit of raw C and a fair amount of C#. I've done a tiny bit of java. I could rant on for days about the relative strengths and weaknesses of them, but to me C# made some plain stupid design decisions that I can't find a decent reason for (like the lack of static variables in functions).




I realise that I may be opening a big can of rant, but having done a bit of each myself I would be interested to hear your thoughts?
    

Agentgonzo
There's no pee in catheter!
Mon 15th Dec '08 5:56PM
811 Posts
Agentgonzo's Avatar
Member Since
8th Aug '06
C++ is an ocotopus made by nailing 4 extra legs to a dog. Being a superset of C means that it must support all of C's functionality alongside its own - so you get two forms of cast operators which people mix and match between. It's a general catch-all language that you can do most things in, but it does seem to end up with you thinking "there must be a better way to do this". The STL classes are powerful, but an absolute bitch to work with and templates never worked out quite as well as they were planned as they end up doing stuff at compile-time which means you can't have a truly dynamically typed template as the objects the template operates over need to be defined at compile-time. It suffers from its age and dependency on C and ends up doing a poor job of supporting anything else than single-byte characters (OK, so I suppose this is the library's fault, no the language) for strings as it everything used to assume that all characters were single bytes. It tries hard to be object oriented, but given that it has to support C, it has to support non-object-oriented things which means that it's not really object oriented and you end up with a load of globals floating around the place and many declarations of 'extern' objects.

I have to go home now, but I'll rant some more tomorrow (probably about java and why it's not as good as the fanboys would like to think it is)

Rant continued.

java. I haven't really used it much at all I must admit. C++ advocates normally moan on about the overheads of the java virtual machine, and in the first incarnations of java, this was indeed a problem. The virtual machine was a memory hog and programmes ran noticeably slower than 'native code' languages. However, this is not really true any more and whilst a virtual machine will *always* run code slower than native code - by definition, it has overheads and these will slow it down - the overhead is minimal these days. People who say that virtual machines can (in some cases) run *faster* than native code due to better libraries etc are talking out of their arse as that's due to the implementation in the library and nothing to do with the language at all. Then there are weird peculiarities in java that give me the impression that java was a good idea done badly. I think that integer comparisons are fucked-up in java. If you do 16 == 16, it will treat both integers as primitive types and return true. But if you do similar things with larger integers, you get a result as false because it treats them as non-primitive types and for some reason the comparison fails. I don't know the details, but it's strange. Garbage collection in java is a handy tool and the run-time exceptions for falling off the end of an array is no doubt a handy tool to speed up development and spot errors more easily, but people who tout java as 'more secure' than C/C++ are spouting a new level of bollocks - security holes can be coded in any language, and whilst buffer overflows are one way of attack, they are not the only way and poor protocol design is more of a threat to security than them, so using java because it's 'more secure' can lull people into sloppyness. I like pointers too. I like being able to bounce around memory and for a lot of situations, it's really powerful and very handy. java's references and lack of pointers feels like they've stuck corks over the end of all the forks in the kitchen to stop you from hurting yourself, but it makes eating spaghetti a lot harder. Then there is the major one. 'Java is great because it's multiplatform'. Well, kind of. It was the first language to really start shouting this everywhere it went like a Mormon. C is multiplatform, because you can compile it and run it on any platform. OK, so you need to make sure that you don't use platform-dependent libraries and you may need to compile it with a different compiler to get a different binary for each platform, but it's still platform independant. The java application will run from the same binary on multiple platforms, but that's because it compiles it to java bytecode which won't run anywhere except in its nice cosy little virtual machine. Once the VM loads it up, it still has to interpret it for the native platform, so you can kind of equate the java VM to an emulator that emulates a hypothetical machine. C programmes compiled for 32bit DOS can be thought of as platform independent as long as you run it in a a 32-bit DOS emulator on the target platform. In that way, it satisfies all the platform-independent boxes that java apps do. I don't see how java is magical and great in this respect, apart from it was the first one to shout it very loudly at each and everyone it met, whether they cared about it or were merely on their way to the supermarket to buy some carrots. Sure, every man-and-his-dog operating system has a java virtual machine so you can run java applications anywhere (not that many have 32-bit DOS emulators or aren't that popular for some reason), but that's only because people could be bothered to write them in the first place, and doesn't really have a lot to do with the language itself. You can get java compilers that compile to native binaries that don't run in a virtual machine, kind of pointing out with a really big and pointy stick that the language definition itself means fuck-all about platform independence. You can also get platform-dependent java libraries, which kind of defeats the point in all of that anyway.

C#
Well, C# was conceived because Microsoft didn't own java - Sun did. They moaned and bitched for a few years that it would be best for everyone for java to be not owned by a particular company, but by a consortium which included Microsoft. Basically, it was a mightily big band-wagon and they were the fat kid with braces watching from the sidelines whilst the band members tongued the cheerleaders. So they went off in a huff and re-wrote java so that they could keep control of it (and stopped shouting about languages being owned by a particular company being a bad thing). It's basically a rehash of java, which was itself a rehash of C++, which was itself a merger of Modula 2 and C. It kept the idea of running in a virtual machine that it stole from java, but couldn't be arsed to write a virtual machine for any other platform apart from Windows (well, you wouldn't, would you?) so it's only really been usable on Windows machines (though that's about 75% of the market, so good enough for most people and those linux-hippy-types seem to be writing this fangled 'mono' implementation of it rather than taking baths so that should keep the other 20% happy - Solaris/BSD users are too wrapped up in their own little words and interact with computers through slightly wet tweasers directly to the serial port so they shouldn't have to worry about new fangled languages anyway).

For the most part, C# does a good job of being what java was trying to be. The speed-of-virtual-machines problem was sorted out years ago with java and modern machines have more memory in them than Ziggy did in Quantum leap, and that stored all the newspapers from the last 100 years or so, so memory isn't really a concern. It's pretty much impossible to think of C# without the .NET framework that comes bundled with it, and I must say that for about 98% of the time, the framework is very very good. It's use of properties for everything and simple names really make development a lot easier in a way that only delphi has managed. A hell of a lot easier than the Win32 libraries or MFC. However, if you want to do something that's not standard then it doesn't really make it any easier. In fact sometimes it makes it hard. Because all memory is 'managed' by the virtual machine, you don't get pointers or direct access to memory, which means that you can't use memcpy or functions like that to copy blocks of memory. A lot of the time you don't need to, but if you're using networks and define all your network protocol as structs/classes that you send directly over the network, then you have to jump through the Marshalling class's hoops to get the 'safe' data in your application to the 'unsafe' data as a byte array, then transmit that. Not a major problem, but not as easy as a memcpy from your io buffer to the struct. And while I'm on the subject of networking, whoever thought that the best way to send data across the network was via XML should be shot through the head. Twice. And then once again for luck. Then reversed over with a car. It's daft. There's no good reason for it. It doesn't provide reliability of the network as the IP headers provide error checking and TCP will provide the correction if an error is found. XML is a human-readable format and was made specifically with that in mind, but it's only those BSD people with their wet fingers to the socket that will ever read the network packets, and they're clever enough no to need it to be human-readable. Making it human-readable absolutely bloats the network for no good reason and if you're wanting to use it on a congested network or are a network admin, then you want small packets. Plus, if it's communicating with anything else that's not a .Net application you'll have to parse the XML and do a whole lot of extra effort before dumping the data to your class/struct, rather than just doing it directly. But I digress (and quite some digression it's been), that's more the library rather than the language. C# does some very nice things. The foreach loop is really really handy (I don't know whether java has it, but don't really care - java funds terrorists and gives puppies cancer) and a lot more intuitive than using iterators for lists/hashes etc. That really cuts down on the SLOC count. Properties are nice, but syntactically a bit bloated when you're trying to write a class that fits on one screen. I'm not sure how I'd have done it, but there must have been an easier way to do it to keep the code down. And then you have to declare the variable that the property uses yourself anyway - couldn't they just have interpreted this and automatically put a hidden class variable in there for you that gets used and returned by the get operator (they already have the 'value' keyword, so you could use that to return from the get operator)? It's good (don't get me wrong) but just feels that it could have had just a little more work put into it to make it truly great. Then there are some of their more weird decisions. My main one to bore people stiff with (a free chocolate to anyone who's still reading) is the lack of static variables in methods. So many people have questioned the enlightened ones at Microsoft about this that it's even on the C# FAQ (and it's part of C++.Net and VB.Net - go figure that one out). The reasons they give is that it can be accomplished by other means (class variables), and that "somewhat notorious for causing problems when code is called repeatedly or from multiple threads". Well, point 1: You're an idiot. Lots of things can be accomplished via other means. The point of languages is that it makes it easier for us to do things. Static variables make it easier to do quite a lot of things so why not let us do it? It's not adding more keywords to the language and it's kind of obvious how they'd work so it's not a bad thing. Plus, it fits in exactly with the OO principle of encapsulation - things that don't need it shouldn't have access to it. If a variable is only used in one function, it should only be accessible in that function - the static variable. Having it outside the function in the class opens it up for abuse and can make things go wrong - precisely what they say they are trying to avoid in point 2. Plus, threads are "somewhat notorious for causing problems when code is called repeatedly" as everyone who's ever done a multithreading application will know. Give us our static variables back you bunch of fat herrings! I'll stop ranting now as my fingers are getting tired and I need a pee, but there are a few last things that I'd like to say. Garbage collection is good, but for the love of Elvis, give us a delete operator so that we can tidy up by ourselves so we know when things will get deleted and when the cleanup-code in the destructor will get called. It makes for good programming practises - it's almost as if the fat people who wrote the language had a cleaner who tidied up after them all the time and it didn't even occur to them that someone would want to tidy up after themselves. And all modern languages should start returning tuples. Python does it and it really really is a very good thing. All high level languages should start doing it. It's so much neater than having to pass references/pointers to a function for the return values. I know that you can define structs to encapsulate all the values that you'd want returned from a function, but if you only have one function that returns that struct, then it's quite a lot of faff that can be avoided if you can allow functions to return two or more values when it exits.




C++.Net (or C++/CLI) is just horrible. Imagine the evil cross-breed of Mo Mowlam and the 8-legged-chair-octopus I mentioned above. It's got managed and unmanaged code, but does it in such a nasty way that you end up with two new operators, two delete operators and two pointer and de-reference operators, and you have to look after them all yourself. Stay away. Write stuff in C++ or C# only, not the bastard hybrid that C++.Net is.
  

Epicure_mammon
I'm not crazy cause I take the RIGHT pills :)
Wed 17th Dec '08 9:21AM
140 Posts
Epicure_mammon's Avatar
Member Since
12th Dec '06


C's functionality alongside its own - so you get two forms of cast operators which people mix and match between.



I'm not sure you can criticise a language because people write bad code. I'd hate to think of a language where it was impossible to write bad code - hereby codenamed "The Nanny Language". I guess it would feature things like a compile time error if you didn't wrap a divbyZero exception around every single division
Whilst I'm in no way a C++ advocate, it is its complete encompassing of a procedural language which I quite like. It means that simple routines can be written in a procedural style yet the advantages of object orientation can still be used. That said - writing like that means you have to be very careful about consistency. Ho hum
Whilst I don't code at work - it all gets done, often badly, by people we hire in - I've recently been learning Haskell, mostly because I've got no experience at all of functional programming and wanted to know what all the fuss was about. I was extremely surprised at how differently it makes you think about problems. There are thing which can be done very quickly and easily in Haskell (like calculating the 1 millionth digit of the 1 millionth prime number) which would be a nightmare to code in C or C++. By "easy" I mean maybe 10 lines of code and by "nightmare" i mean about 100 - so its not really that bad to do. Similarly there are things which are much easier to do in C than in a functional language - but I guess that's the entire point!
  

Agentgonzo
There's no pee in catheter!
Wed 17th Dec '08 10:22AM
811 Posts
Agentgonzo's Avatar
Member Since
8th Aug '06




C's functionality alongside its own - so you get two forms of cast operators which people mix and match between.


I'm not sure you can criticise a language because people write bad code.


Well, sometimes yes and sometimes no. You can write bad code in any language, but languages should provide a framework for you to work in to write good code. If you choose to ignore this and still write bad code, then fair enough, but the redundancy of having two different types of cast operators which both implement exactly the same function leads to bad code and (from a non-legacy point of view) there is no need for it and causes worse code than if it was not there.


Stuff about functional languages

I did some ML at uni (a functional language like haskell). Is there any situation where they are useful outside maths/science based functionality (like the example you gave). By their nature they are based around mathematical functions, so I can't really see that it would be easy to write a web browser in one of those languages.
  

General*
Windows Bob - the best!
Wed 17th Dec '08 1:12PM
4213 Posts
General's Avatar
Member Since
7th Apr '03


Agentgonzo was bold enough to comment:

I did some ML at uni (a functional language like haskell). Is there any situation where they are useful outside maths/science based functionality (like the example you gave). By their nature they are based around mathematical functions, so I can't really see that it would be easy to write a web browser in one of those languages.



I have heard that Functional languages are going to become a very bankable skill in the not too distant future as they tend to produce code that runs very well on machines with many cores.
    

Amanshu*
Giggity Giggity goo
Wed 17th Dec '08 5:46PM
2708 Posts
Amanshu's Avatar
Member Since
25th Aug '04
Functional languages are based around the idea of getting one program to do a little job really, really well and then running them altogether to create bigger programs that do things you want them to.

In that sense you could argue that Unix is based around functional programming ideas, using pipes to stitch them altogether...

But yeah, really they're going to be more useful with processors that can do many different operations at the same time, so they'll become more important as processors get more cores.
   

General*
Windows Bob - the best!
Thu 18th Dec '08 9:48PM
4213 Posts
General's Avatar
Member Since
7th Apr '03
Excellent rant there AG however I think religious alagory may sum it up best: http://www.aegisub.net/2008/12/if-programming-languages-were-religions.html
    

Demian*
Oh Lordy, Plegaleggole
Fri 19th Dec '08 5:29PM
4678 Posts
Demian's Avatar
Member Since
7th Apr '03
In the absence of anything useful to add I've been looking up ridiculous languages for you.
The following are 'Hello World' programs.

LOLCODE:


HAI
CAN HAS STDIO?
VISIBLE "HAI WORLD!"
KTHXBYE


Befunge allows you to move the instruction pointer to move around the code any way you like, left right, up or down or randomly:

"dlroW olleH">:v
^,_@


Brainfuck, which has only 8 characters to use:
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.

And my favourite by far, Chef:

Ingredients.
72 g haricot beans
101 eggs
108 g lard
111 cups oil
32 zucchinis
119 ml water
114 g red salmon
100 g dijon mustard
33 potatoes

Method.
Put potatoes into the mixing bowl.
Put dijon mustard into the mixing bowl.
Put lard into the mixing bowl.
Put red salmon into the mixing bowl.
Put oil into the mixing bowl.
Put water into the mixing bowl.
Put zucchinis into the mixing bowl.
Put oil into the mixing bowl.
Put lard into the mixing bowl.
Put lard into the mixing bowl.
Put eggs into the mixing bowl.
Put haricot beans into the mixing bowl.
Liquefy contents of the mixing bowl.
Pour contents of the mixing bowl into the baking dish.

Serves 1.

Yes, that is Hello World, apparently. It is also a 'requirement' that the recipes should be cheap, easy, and delicious when cooked in a real-world environment

Edit: here are the first 100 Fibonacci numbers in caramel sauce.

Ingredients.
100 g flour
250 g butter
1 egg

Method.
Sift the flour. Put flour into mixing bowl. Serve with caramel sauce. Stir for 2 minutes. Remove egg. Rub the flour until sifted. Stir for 2 minutes. Fold the butter into the mixing bowl. Pour contents of the mixing bowl into the baking dish.

Serves 1.

Caramel Sauce.

Ingredients.
1 cup white sugar
1 cup brown sugar
1 vanilla bean

Method.
Fold white sugar into mixing bowl. Put white sugar into mixing bowl. Fold brown sugar into mixing bowl. Clean mixing bowl. Put white sugar into mixing bowl. Remove vanilla bean. Fold white sugar into mixing bowl. Melt white sugar. Put vanilla bean into mixing bowl. Refrigerate. Heat white sugar until melted. Put white sugar into mixing bowl. Remove vanilla bean. Fold white sugar into mixing bowl. Caramelise white sugar. Put vanilla bean into mixing bowl. Refrigerate. Cook white sugar until caramelised. Put white sugar into mixing bowl. Serve with caramel sauce. Fold brown sugar into mixing bowl. Put white sugar into mixing bowl. Add vanilla bean. Serve with caramel sauce. Add brown sugar.
  

Amanshu*
Giggity Giggity goo
Sat 20th Dec '08 11:27AM
2708 Posts
Amanshu's Avatar
Member Since
25th Aug '04


Agentgonzo was bold enough to comment:

(a free chocolate to anyone who's still reading)



I'll have that then...

And I'm sorry Demian, but the best really does have to go to Shakespeare:


The Infamous Hello World Program.

Romeo, a young man with a remarkable patience.
Juliet, a likewise young woman of remarkable grace.
Ophelia, a remarkable woman much in dispute with Hamlet.
Hamlet, the flatterer of Andersen Insulting A/S.


Act I: Hamlet's insults and flattery.

Scene I: The insulting of Romeo.

[Enter Hamlet and Romeo]

Hamlet:
You lying stupid fatherless big smelly half-witted coward!
You are as stupid as the difference between a handsome rich brave
hero and thyself! Speak your mind!

You are as brave as the sum of your fat little stuffed misused dusty
old rotten codpiece and a beautiful fair warm peaceful sunny summer's
day. You are as healthy as the difference between the sum of the
sweetest reddest rose and my father and yourself! Speak your mind!

You are as cowardly as the sum of yourself and the difference
between a big mighty proud kingdom and a horse. Speak your mind.

Speak your mind!

[Exit Romeo]

Scene II: The praising of Juliet.

[Enter Juliet]

Hamlet:
Thou art as sweet as the sum of the sum of Romeo and his horse and his
black cat! Speak thy mind!

[Exit Juliet]

Scene III: The praising of Ophelia.

[Enter Ophelia]

Hamlet:
Thou art as lovely as the product of a large rural town and my amazing
bottomless embroidered purse. Speak thy mind!

Thou art as loving as the product of the bluest clearest sweetest sky
and the sum of a squirrel and a white horse. Thou art as beautiful as
the difference between Juliet and thyself. Speak thy mind!

[Exeunt Ophelia and Hamlet]


Act II: Behind Hamlet's back.

Scene I: Romeo and Juliet's conversation.

[Enter Romeo and Juliet]

Romeo:
Speak your mind. You are as worried as the sum of yourself and the
difference between my small smooth hamster and my nose. Speak your
mind!

Juliet:
Speak YOUR mind! You are as bad as Hamlet! You are as small as the
difference between the square of the difference between my little pony
and your big hairy hound and the cube of your sorry little
codpiece. Speak your mind!

[Exit Romeo]

Scene II: Juliet and Ophelia's conversation.

[Enter Ophelia]

Juliet:
Thou art as good as the quotient between Romeo and the sum of a small
furry animal and a leech. Speak your mind!

Ophelia:
Thou art as disgusting as the quotient between Romeo and twice the
difference between a mistletoe and an oozing infected blister! Speak
your mind!

[Exeunt]


And the prettiest has to go to Piet:

   

Agentgonzo
There's no pee in catheter!
Mon 22nd Dec '08 10:32AM
811 Posts
Agentgonzo's Avatar
Member Since
8th Aug '06
You forgot Whitespace.

I tried to post Hello world in whitespace, but the whitespace-muching properties of HTML zapped it. Here's the source:
http://compsoc.dur.ac.uk/whitespace/hworld.ws
  

Bookmark With: Post to DiggDigg   Post to DeliciousDelicious   Post to RedditReddit   Post to FacebookFacebook   Post to StumbleuponStumbleupon
Return To Techy Corner

Time Zone is Greenwich Mean Time You are Visible
Html Tags are On Smileys are On
Anonymous Posting is Not AllowedMagina is The Daddy