As many web developers are aware, there are a myriad of ways to develop websites and interactive web applications today. On the server side, one typically chooses from one of two technology stacks; the “Open Source” and the Microsoft. Disregarding political and license concerns, they really are very much equal in core capability. The Open Source stack typically consists of A Linux distribution as the Operating System, Apache as the Web Server, MySQL as the database, and PHP as the server-side language. These can also be installed to a Windows machine as well, and Apache has modules that even allow the use of .NET technologies via the Mono runtime. The Microsoft stack consists naturally of Windows as the OS, IIS as the webserver, and ASP as the core server-side script. ASP itself, of course, supports a number of languages; you can use JScript, VBScript, or a .NET language. Both of these platforms provide a myriad of tools at your disposal. LAMP allows you to leverage the wealth of Apache modules and use a large selection of programming languages like Ruby, Python, Perl, and of course PHP. The Microsoft Stack makes use of the very powerful SQL Server, and is particularly scalable to large operations. Of course there are variations of these; obviously MySQL could be swapped out for PostGreSQL, or even a remote SQL Server.
The cheapest hosting plans for most WebHosts use a Linux-based stack. This makes PHP one of the more accessible server-side languages to learn. When I started this sight, I wasn’t really sure how well it would turn out, what I would write about, or how much exposure it would give me or my various programs. After three years, I’m still not entirely sure of that; but at the time, I was working predominantly in Visual Basic 6. I was stagnating, and I didn’t even realize it. When starting the sight, I really had two choices- go with the Linux stack, or the Microsoft stack. My choice of the LAMP stack was done purely for a single reason: it was completely foreign to me. That may seem like an odd reason to choose a technology, but I’m always up to a challenge. I won’t try ot say that learning the “Linux way” of doing things was easy, but it did get easier over time. With the server itself of course I didn’t have full access anyway; just a standard CPanel, and I still do; but understanding Linux, Apache, and MySQL were very helpful in using PHP, which was the language I had to learn to get teh site off the ground beyond a few ugly static webpages.
I basically slogged through learning PHP, in an attempt to create a relatively simple CMS. After getting a basic CMS and some crappy side links started, I decided to redesign the site from scratch. I sketched how I wanted it to look on paper, and then set to work duplicating that appearance using the available web technologies, as well as through the use of Photoshop for the various images I needed. The end result is what you see on the main page; of course I’ve made changes to it since, and added features to the underlying CMS to support new functionality such as listing my youtube videos and different categories of items, but the visual appearance is much the same. I toyed recently with the idea of redesigning it, but decided that it could stay as it is now a little while longer; a redesign is a rather big undertaking, and I like how it looks now.
Since then, I’ve also learned and become quite adept (If I may say so) at C#. This has left me rather- annoyed- when I use PHP, which feels very messy in comparison to what is generally a very clean working environment. Not to mention being relegated to having to debug using echo, which I can’t say I really missed from using GW-BASIC.
I did install a MS Stack locally some time ago, and experiment with it for a short time before deciding to avoid it; I reasoned that if I was to use C# for web development start to avoid working on my PHP site even more. I’ve since changed my mind, however; I’ve decided to install a local IIS-based server and experiment some more with what .NET has to offer on the server-side. I’ve been able to make some pretty fine-looking stuff with WPF and Windows Forms, and I know WebForms as well as the Base-Class Library that is not heavily leveraged on the client side are one of the many areas where my abilities and knowledge can be expanded, so I can’t see why not.
Also, I’ve always thought it a bit weird that my site ran on PHP and I focussed mostly in Windows-based and MS technologies and languages. Though I don’t see a switch over occurring anytime soon.
430 total views, 4 views today
What does C# have that Java doesn’t?
let’s see:
This was excluded from Java because it’s “Dangerous” or some other bullcrap. Just use the BigInteger class to see what a massive cock-up that decision was.
In Java, everything is passed by value. This cannot be changed. The hack to fix this for primitive types is to use one of those stupid boxing classes (Integer for int, Double for double, etc). The justification is that “all functions should only return one type” and that side effects are bad. But programming languages should provide as much capability as possible and sometimes you don’t give a flying fuck if the code is clean, you just want it to work, and having to rewrite some of your codebase because the designers of java decided to take out a few sharp edges is a pain in the ass.
Every method in C# is an object. you call the method if you add brackets and a parameter list; but if you don’t have brackets, you are referring to the MethodInfo object that represents that method. Methods can accept functions as parameters. Example:
Note also that this is using the => syntax to create a function on the fly. the function could have been defined separately:
What is Java’s Solution to this? Anonymous inner classes and interfaces. personally, I got sick of that with Visual Basic 6. Having to write a new interface to define a single callback method was aggravating and polluted the namespace. Java’s “solution” is anonymous inner classes, which is more a band-aid approach. Java apologists typically respond that “but this way it’s easier to add new methods”. But I don’t want a class. I want a bloody function.
Iterators. Heck that’s what I used above. Notice the yield return and IEnumerable<t> return type? that is quite literally impossible to do in Java. You can’t even fake it, certainly not in a transparent way, and not at all with java; you have to either fake it with some sort of goofy threading thing, which completely defeats the purpose of coroutines/iterators to begin with, which is to avoid the overhead of thread locking and kernel scheduling and be as light and fast as possible. Implementing them with full-on threads with tight restrictions gets rid of all the advantages.
A good case and point. In my game, I use an iterator to go through all the game objects. One of the side effects is that nowhere in that code am I “allowed” to change the collection being iterated over. My resolution involves a queue of delegates being stored as needed, and that queue is emptied at the start of each tick. One such usage is to add GameObjects to the list while that list is being processed:
Can you do this in java? Well, you can fake it with inner classes and passing them around; and then giving it a field to hold that local variable, but what if you want to use other local variables? The above uses two locals- gcp and gstate. Local variables that are used in a lambda are closed over in the delegate and you can access them later. Literally this happens long after that method’s stack has been unwound; the variables that are closed over stay alive until the lambda itself is collected. The Java solution would need a new class that has a field for each “local” you want to use, as well as the logic of the function. What in C# takes a few characters of code in Java would take at least one new source file.
Properties. Oh dear gawd properties. Java’s been faking it for over 20 years with getX() and setX() methods, and that is utterly and completely disgusting. C# implements property support directly into the language. Properties can be on interfaces or abstract classes. They cannot be overriden in the latter case, but one can then define a protected set of virtual accessor methods for derived classes to override that the property routines use. Java’s solution is to let things “pretend” that the set/get accessor pattern is a solution. This property stuff get’s quite involved when we move into C# 4.0 along with XAML, where Dependency Properties provide a lot of notification functionality.
Which brings me to another- Events. Events in C# are defined using a name and a delegate that defines the event signature. Class consumers can then subscribe to that event- multiple consumers can in fact- using either methods of the event or operator overloads. The class can invoke the event and all the subscribed consumers will have their event routines called. This is known as a “multicast delegate” since it calls a number of methods on a single invocation. Java doesn’t have this. Again, the best way to fake events is the same way I used to do it with Visual Basic 6, which was to define an interface. that would allow for a Single “event” subscriber to be assigned, probably using some stupid “setEventX()” accessor. What if you want- you know, actual events with multiple subscribers. Well, thanks to Java’s weak generics implementation, you get to rewrite them for every single event, or use slow reflection to do your dirty work. Neither of which are exactly robust.
You want more? Extension methods. Linq uses these extensively over collection classes, providing a myriad of ways to mess about with them. How about the null coalescing operator ??, or the “as” operator for performing conversions between types and giving null rather than a InvalidCastException if it cannot do so?
Platform Invoke is better than JNI or whatever the fuck it’s called now in Java (JNI? J/Direct? damned if I remember). Of course the argument is that you shouldn’t have to use anything other than Java (or C#) to do something. But you do. That’s how the software ecosystem works. You can’t just hid in the Java sandbox and pretend nothing else exists, because then your UI looks like heap of crap and you end up with something whose features pale in comparison to other products and the only advantage is now you can run it on a Solaris without porting it or something.
Even the for(value:collection) foreach syntax in java was something that took years to get added to the language. The Creators hemmed and hawwed about it for years, as if they were making some life altering decision; because they had to make sure it wasn’t dangerous, right? I don’t even know the state of Closures in Java. Personally I gave up on the language after C# passed it with C# 2.0.
Java is a universally weaker language than C# that offers few real advantages, like comparing a companion cube to a edgeless safety cube, the only difference is that the user can’t hurt themselves. But an experienced programmer trying to stack edgeless safety cubes will find it very frustrating for the very reason that there are no corners.
374 total views, no views today
When speaking of browsers, Operating Systems, or various other pieces of technology, people will often speak of “market share”. I’ve always found it somewhat puzzling; the term Market share implies that the various selections are mutually exclusive. The thing is though, that simply isn’t the case
Take Linux “market share” for example. I use windows, as my primary OS, but I also use Linux on my laptop. Where do I fall? Who’s Market share do I increment? I use firefox usually as my browser, but I have Chrome, Opera, and IE installed. Does having them installed count towards market share? And if not, how often do I have to use them before they “count”, and who decides that?
Basically, once people start bleating about market share, they’d lost grip with the facts. There is no “market share” anymore; it’s all about Mind Share.
Anyway that’s a quick post from me. In other news I’ve got some additions to my INIFile.cs class (including a fix) that should make a juicy entry,too.
376 total views, no views today
Most Computer users are familiar with the Sounds that Windows emits when you plug and unplug a USB thumb drive. It’s a useful form of auditory feedback that the drive was in fact detected. However, I’ve found linux to be oddly tacit in this regard. So I set to work writing a python script that uses DBUS to monitor for new USB devices and will play a sound whenever a new Volume is attached.
As can be seen, it’s a tad messy, and even rather hackish. For one thing, it uses DBUS, which to my understanding is deprecated. Unfortunately, the replacement I couldn’t really get a clear answer on. From what I can gather, the proper method for now is libnotify and pynotify, but I couldn’t get libnotify to compile and thus was not able to properly use pynotify, and I didn’t want to have to force people to go through that sort of hell when they tried to use my script, so I stuck to DBUS.
The only limitation I discovered is that on device removal, you can’t really inspect what device was removed. At first I just figured, Just play the sound everytime and let the user figure it out, but for some reason that just assaulted me with constant device removal sounds. So I ended up commenting (and I think removing) that particular segment of code.
Playing Sounds is unnecessarily difficult in Python, or more specifically, Linux. It’s ridiculous. First I found a build in module for python, ossdevsound (or something to that effect), but attempts to use that failed because apparently it uses OSS, which apparently was replaced by ALSA for whatever reason. So I tried pygame, which errored out that I had no mixer device when I tried to initialize the mixer. So I decided to hell with it and just spawned a mplayer process, and redirected it’s stdout to NULL to avoid the nasty business where it barfs all over the console. And amazingly, that seems to work fine for device insertions, which I decided I was content with.
By default I use the Windows insertion and removal sound files. The removal sound isn’t actually used but I kept it in the g-zipped tar because I wanted to. Personally I usually just launch this in a terminal and then tuck it away on another desktop. No doubt one can execute it as a daemon or something instead and get the functionality without the console window baggage to keep around, though.
620 total views, no views today
One feature of windows that I often miss while using My Linux laptop is the ability to eject USB drives from the system tray. With my Linux Mint 10 install (and likely newer versions, and of course other distros) you typically need to minimize everything to get to the desktop (or of course use the shortcut, but you still need to minimize everything) get to the icon, right click it, choose to eject it, etc. With windows, you simply Left-Click on the icon in the Notification area and click the drive to remove.
Thankfully, It turns out there is a very cool and unassuming little program that provides this exact functionality. It is called “ejecter”.
Without dwelling on the fact that it really ought to be called Ejector, the program does exactly what it says on the tin. When you plug in a USB drive, the icon appears on the system tray.
As can probably be guessed, this is exactly the type of functionality I needed. You can see exactly what the product looks like in the image to the left; when you left-click the icon, a little tray pops out (some might call it a menu, I suppose) and lists the connected USB drives that can be “Safely removed”. I rather like how it shows the Volume name as well as the name of the device itself, which helps prevent confusion. Ejecting the device entails clicking the Eject button to the right of the device you want to eject. Two clicks and you’re done!
It’s very simple to install, to- it’s in the repository of most distros; usually it’s a quick sudo apt-get install ejecter or the equivalent command (I remember yum but not the syntax). It works on GNOME, but I’m not sure if it works with KDE, or any other Desktop environment, for that matter.
268 total views, no views today
I don’t have one. It’s impossible to form a opinion on a set of hardware and software that I’ve never used and have no intention on using.
EDIT:
(Thread in question is here : )
(I’m presuming the commenter here is the Mr.Bisquit from there, based on the second comment)
Yeah, You’re scared, especially when it comes that someone needs to search out an answer from you.
Scared of what? I didn’t post in that topic because it quickly devolved into you being a douche to anybody who posted:
7. A line is a set of points. (from the thread)
What is that? You know exactly what he meant, you were just being a giant douche, and the fact is by that point I realized that your question was probably just some sort of loaded trollbait in an attempt to allow yourself to express just how much of an elitist douche you were. Your additional responses that were designed to illicit a response from me “he’s afraid” afraid of what? what the hell is there to be afraid of!? That doesn’t even make any sense.
Actually- I think I know what that is reference to- the fact that I didn’t approve the first comment in the few days since the second was made. Actually, I only noticed the new pending comments today, when I went to write a new blog post. In that context, I do apologize for the delay, and can certainly understand the conclusion you came to (that I was maliciously censoring your comments) I wasn’t though, they are automatically moderated that way. I do have a question- if you ever return-
Why are you so fixated on me, anyways? I mean you posed a question specifically for me on CH and now you’re basically stalking me on my blog…. Why?
This is going to be much more difficult than it was to convince you to use a Linux distribution.
I was using GNU/Linux long before you were a known entity to me. You haven’t really convinced me of a whole lot, except that there is a hell of a lot of polarization and fanaticism on the xxxBSD side of the fence then I had original suspected. I mean, a good portion of Operating System/platform evangelists are self-righteous blowhards, but you have really raised the bar.
>>Makes me wonder about a programmer who mentions assembly
>>and C then clams up when it comes to “new” territory.
clams up? what the hell are you talking about? I didn’t respond to that particular thread because your question was clearly loaded, and second, because, as I noted here, I don’t have a “take” on it because I haven’t used it. I try to make a habit of not forming too strong of an opinion about something if I haven’t used it, but you aren’t making it very easy. I doubly wouldn’t know about running it on the specified hardware because I haven’t USED a PowerPC, nor a SPARC, and have barely even used FreeBSD on x86. I don’t have a powerPC. I don’t have a SPARC, and buying one or both kinds just because you’ve asked my opinion on running a specific OS on them would be pretty silly.
you use freeBSD. Good for you, really, I’m sure it’s a fine OS, clearly it suits your needs. I don’t use FreeBSD. Get over it. I already have it in a VM; I just haven’t done much after the initial install (like doing the appropriate googles to find out how to turn the basic # prompt with a relatively minimal set of commands into a usable desktop environment. But I will do it when I please. Some douchebag being- well, a insistent douchebag throwing not-so-subtle insults and insinuations my way is not going to help, because if that is what I’d be destined to become as a freeBSD user, I want no fucking part of it.
I suppose, as has been said frequently about many things, it’s not Free/OpenBSD I have a problem with, but some of it’s users. Same with Linux; hell, same with windows, or mac. It’s the evangelist assholes who seem to feel they have some sort of inner track to knowledge, that the OS they use is better, despite the fact that their measurement of what was better is using their own predefined yardstick that just happens to only cover the strong points of what they are evangelizing. They also all have a glaring weakness. You tell them a problem with their OS of choice, and they say it’s your fault. This isn’t specific to any OS at all of course. The fact is though, they all have problems. Evangelists of all kinds seem to think that pretending there aren’t any problems- or that those problems are minor- is a good thing. It’s not.
For example, as it stands now- you simply NEED to learn how to use BASH or whatever the included shell is with almost any Linux distro and with all the BSD’s I’ve tried; for the “simpler” Linux’s, like Ubuntu or Mint, people will often still need to use to the console to fix otherwise simple issues- like the package manager somehow getting into some weird inconsistent state and refusing to open; sure, it suggests what command needs to be issued, but in that case there are two problems:
For ages, running that command on my laptop would effectively hang that terminal until I forced it closed. Now this brings me to another point; I ended up just using the –help of the various package management tools (dpkg, apt-get) and found that apt-get had a “check” option, and was able to invoke that and discover that one of my python libraries was corrupt (or, “inconsistent” I guess), I then (using more inference) decided to simply remove, and then reinstall that package, which fixed my package manager issues. hurrah!
I’m not saying that was bad by any stretch, but implying that everybody is willing to go through that to get their computer working properly is utter nonsense. Some people think their computer is broken when the desktop background is wrong and they don’t know how to change it. Yes, they can learn how to change it, but the thing is, a lot of people don’t give a flying fuck about computers. This is something we more nerdy types, regardless of occupation, seem to forget. If Secretaries had the capability to learn about stuff like the command line, they wouldn’t be secretaries.
Basically, the adeptitude that many Linux and FreeBSD versions demand of their users is akin to demanding that everybody learn the specifics of architecture, wiring, roofing, insulation, beam installation, and so forth when they buy a house. Now, it’s true, that a fair number of people that purchase a home do in fact fix it themselves, and no doubt learn in the process; but there are others, who, again- are either too busy or simply don’t give a fuck and hire people to do it. They don’t want to learn about plumbing or wiring or roofing. They just want a house, just as some people don’t want to learn about files, streams, ports, hardware ports and Addresses, IRQs, DMAs, NMI’s, Compilers, command lines, or the details of memory. They just want a computer. Now, some on “the other side of the fence” from them, (including myself) may balk at such a concept “An easy to use computer, how absurd!” After all, in many ways the very “general purpose”-ness of a computer simply doesn’t lend itself to being “easy to use”; but it seems that should be what we are striving for. No Operating System ever created meets this lofty goal of being completely intuitive. My opinion in that context is that Mac Classic (Pre OSX, that is) was the closest to that. And, really, creating a completely intuitive interface is thought impossible; that doesn’t mean we should just give up on it. There are people in this world who aren’t interested in computers ; They don’t want to have to learn arcane commands to get their shit done. They just want to get their shit done. They don’t want to have to learn how to write a script to automate that task. This is not something that should be shrugged off as “well obviously they are an idiot” because get this, Computer’s aren’t the fucking world, even though the world seems to run on computers,and almost any occupation will involving interfacing with computers in some way or another. what we need is some fucking work on making those interfaces easy to use . not just flexible. In that sense, my “Take” on FreeBSD, which you’ve forced out of me through sheer willpower apparently, despite my misgivings that I haven’t even really tried it much, is that it makes absolutely no attempt to be easy to use and trades off at every point better flexibility and security for ease of use. The security concern is understandable, but if you are going to make something flexible, either make it flexible and easy to use, don’t attempt to call it a mainstream OS for everyday people, or don’t bother.
EDIT 2:
Welcome back
Why can’t the GUI application post the command?
1) All options are not available on the GUI but are available on the command line. The GUI is merely a front end to a command.
2) Every person that develops such an application is not aware of all of the options.
3.) Every command is not possible in every situation.
4) It may be assumed by the developer that the individual wants some control.
Specifically, I was speaking for the case of the Synaptic Package manager, which complains when started occasionally and suggests that the user run “dpkg –configure -a” Basically, why does it have to do this- could it not run that command itself? It basically acts as a front end for dpkg, from what I can tell. But, when it is suggesting to run that command- why can’t it do it? The only reason I’ve found for it is that it only fixes the problem 90% of the time, the other 10% of the time you have to figure it out yourself, all the while having the package manager suggest you run that same command each time it doesn’t work. The people developing it are clearly aware of the options they suggest, because they are- well, suggesting it. Response 3 makes sense in the more general case, but I was speaking (specifically) about the dpkg error from the package manager that basically told the user to run a given command to try to fix it- the thing is, the problem can be resolved entirely programmatically without user intervention- just by shelling out and performing two dpkg commands. #4 is a moot point, really- performing the tasks you are using the GUI to do manually defeats the purpose of said GUI. If a user wanted “more control”, they probably wouldn’t be using the GUI tool to begin with.
The choice of shell is up to the individual. In any Unix-like environment, one needs to know the command and its options.
But Why? Why do you need to know commands and their options to use the relevant GUI tool? Isn’t the point of the GUI tool to make it so you don’t have to use the command itself?
Shell programming is useless if you do not understand what you are doing.
Of course it is. I never say anything about shell programming though…
Nobody is fixated on you.
And yet, here you are, again .
A question was asked on one site and the answer was given on another.
The answer was given on another because by the time I saw the thread it had already turned into you saying it was “an open public challenge” or some other nonsense like that. A open challenge to… do what? At that point I felt it was some sort of flamebait or something so I didn’t bother to post there, also, because I didn’t really have an answer since I don’t have any non x86/x64 systems. The idea that asking somebodies opinion on something was a “challenge” still irked me though, so I posted this entry. (because by that time, the thread in question had been locked), if the thread was still open at the time I probably would have put this there instead. (in retrospect I probably could have created yet another thread).
It would have been easier and more direct to give the answer of “It doesn’t interest me at this time,” and have it end at that.
And what obligation am I under to answer any questions at all? None. And the I got from the thread that you seemed to feel I owed you something was another reason I abstained from posting at the time. I may very well have misread you in that instance.
640 total views, 2 views today
No, Not the kissing disease, Infectious mononucleosis, the open-source .NET CLR interpreter and class library.
.NET; I might have ranted about this before, if not on my blog, elsewhere. most of my arguments were against it, being a VB6 using ignorant buffoon. In any case, I’ve found C# to be an awesome language. One of the obvious downsides is that for the most part programs written in C# using Windows forms cannot be run on other systems.
The concept of Mono is to change that; remember, C# isn’t a Microsoft standard, it’s an ECMA specification, and Microsoft holds no copyright over it or anything like that. Mono is a relatively huge undertaking; the creation of something on the scale of a Virtual machine as well as a class library is gargantuan, and of course there is very little hope for 100% success.
On the whole, Mono performs it’s primary goals admirably; there is a GTK# framework that can be used to develop windowed applications… of course then the installation on a windows PC would require the install of the Mono GTK# framework, but I digress. In any case, applications can be developed and the C# code interpreter (for on the fly syntax highlighting) as well as the compiler are top-notch and seem to work well.
My only beefs can of course be in the class library. Of course, re-implementing the class library provided by MS on non-windows systems is not something that can be done in a single afternoon; this stuff takes time. My attempts to create a Mono-compatible project have been stifled, however, by seemingly innocuous issues. AlLlow me to explain.
As many reader may be aware, I have been working on a “upgrade” of sorts to my now ancient “Poing” game, which can be found on my downloads page; the original game was written in Visual Basic 6, and, in it’s earlier incantations didn’t have a single Class; it was all based on User-Defined Types (structures for those privvy to C parlance) and functions; (short explanation: it was made before I understood classes). Later, after I had learned about classes, I refactored everything into classes. This is all rather redundant; in any case, I have since created a new project in C#, in an attempt to learn about GDI+ as well as what appeared to be a different (in some ways) painting model. As one can see by the youtube videos I have posted on it, development has gone well.
The idea occured to me, after Tux2 (of http://www.jrtechsupport.com/) managed to create a Mono-workable, if soundless, version of my earlier C# game, BCDodger that worked in Linux. Sound was unavailable as a result of my choice of sound library, the IRRKLANG library, while truly usable in Linux, doesn’t have a wrapper that works in Linux (or something, I don’t know… it uses DSound or something, I forget). In any case, I have since added the ability for various sound engines to be used, and have added working implementations for Open-Source and Linux-available Sound systems, such as NBass (as well as a broken fmod implementation, let’s ignore that though).
Much obliged, I had decided to try to get it working via Mono as well; this was facilitated by my recent reformatting of my laptop to run a dual boot Windows 7 and Mint 10 system. Installing MonoDevelop and all that, etc.
So, I of course open the project in Monodevelop, quite ready for errors relating to porting.
The version I am using is MonoDevelop (and I assume also Mono) version 2.4, for those following along.
My first hurdle was getting my Appdata files for the program in the right location; on windows systems they are placed in the application data folder; so too they would need to be on a Linux system. Thankfully, a quick C# program run on the Linux machine cured this issue:
using System;
namespace specialfolders
{
class MainClass
{
public static void Main(String [] args)
{
foreach(Environment.SpecialFolder sfolder in
Enum.GetValues(typeof(Environment.SpecialFolder)))
Console.WriteLine(sfolder.ToString() + "=" +
Environment.GetFolderPath(sfolder));
}
}
}
Which gave me, on a Windows system:
Desktop=C:\Users\BC_Programming\Desktop Programs=C:\Users\BC_Programming\AppData\Roaming\Microsoft\Windows\Start Menu\Programs Personal=C:\Users\BC_Programming\Documents Personal=C:\Users\BC_Programming\Documents Favorites=C:\Users\BC_Programming\Favorites Startup=C:\Users\BC_Programming\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup Recent=C:\Users\BC_Programming\AppData\Roaming\Microsoft\Windows\Recent SendTo=C:\Users\BC_Programming\AppData\Roaming\Microsoft\Windows\SendTo StartMenu=C:\Users\BC_Programming\AppData\Roaming\Microsoft\Windows\Start Menu MyMusic=C:\Users\BC_Programming\Music DesktopDirectory=C:\Users\BC_Programming\Desktop MyComputer= Templates=C:\Users\BC_Programming\AppData\Roaming\Microsoft\Windows\Templates ApplicationData=C:\Users\BC_Programming\AppData\Roaming LocalApplicationData=C:\Users\BC_Programming\AppData\Local InternetCache=C:\Users\BC_Programming\AppData\Local\Microsoft\Windows\Temporary Internet Files Cookies=C:\Users\BC_Programming\AppData\Roaming\Microsoft\Windows\Cookies History=C:\Users\BC_Programming\AppData\Local\Microsoft\Windows\History CommonApplicationData=C:\ProgramData System=C:\Windows\system32 ProgramFiles=C:\Program Files MyPictures=C:\Users\BC_Programming\Pictures CommonProgramFiles=C:\Program Files\Common Files
Nothing particularly out of the ordinary there. So, running the program on a Linux machine:
Programs= Personal=/home/bc_programming Personal=/home/bc_programming Favorites= Startup= Recent= SendTo= StartMenu= MyMusic=/home/bc_programming/Music DesktopDirectory=/home/bc_programming/Desktop MyComputer= Templates= ApplicationData=/home/bc_programming/.config LocalApplicationData=/home/bc_programming/.local/share InternetCache= Cookies= History= CommonApplicationData=/usr/share System= ProgramFiles= MyPictures=/home/bc_programming/Pictures CommonProgramFiles=
which gave me what I needed: the appdata folder “BASeBlocks” needed to be copied to /home/bc_programming/.config.
Doing so was easy enough; the file manager on Mint 10 (dolphin) is different from windows explorer but hardly paradigm-breaking.
That copied, I simply threw the source folder as it was on the Visual Studio 2008 projects folder into the MonoDevelop projects folder (well, not really, it was /home/bc_programming/projects/ which I suppose means that any program that uses a projects folder will use it, oh well.)
psyched as I was I ripped into it with MonoDevelop, ready for anything! well, nearly anything.
My first error occured on line 107 of “Block.cs”:
mPowerupChanceSum = Powerupchance.Sum();
Java programmers may be thinking “ew uppercase characters” to them I say be quiet you. Anyways, the problem here was that there was no “Sum()” Extension method defined. Which I found odd. Oh well, though, I simply created my own:
#if MONO
public static class monoextensions
{
public static float Sum(this float [] floats)
{
float accumulator=0;
foreach(float loopfloat in floats)
accumulator+=loopfloat;
return accumulator;
}
}
#endif
this solved the immediate issue of the “Sum()” extension method. (For more info on C# extension methods, see here )
My next hurdle was on line 540 of cBall.cs:
if (wholeref.Blocks.Count((q)=>q.MustDestroy()) == 0)
The error was something to the effect of not being able to pass a delegate or method group to a lambda expression.
oddly enough, the fix was the change the “q” to an x… and after it successfully built I was able to comment out the “new” line (with the x rather then a q) and uncomment the original. very odd.
In either case, now I was confronted with what I knew to be the biggest issue; the fact that I had to now discover how to set it up so that I was able to use the same nBASS library, but so that the nBASS library was “silently” made to use the BASS.so linux library, rather then bass.dll which wouldn’t load either way.
The first step in this process was in finding bass.so. Hoping for the best, I pulled up good ol’ synaptic package manager.
No luck there
so, I went into the depths of the internet….
the BASS for Linux (note the lack of the n prefix; it’s the core BASS library that the nBASS dll is wrapping) can be found here
this topic; or, the original post, to be precise, gives the download location for the Linux source files for BASS 2.4, which can be found at http://www.un4seen.com/stuff/bass24-linux.zip
So, I downloaded the zip file, extracted it to a folder, and am about to attempt to compile it. (there is a libbass.so that I could probably try, but I think I’ll compile it myself instead).
Before I continue, however, I would like to mention something that has most impressed me about Mint 10; the multiple desktops. Now, this is hardly a new feature; programs can be downloaded that do this on windows, and windows itself has built in API support for multiple desktops; however, what impresses me most is that when you activate a window on another screen, it switches to it; what I mean is, for example, in this instance my FF download window was on another desktop (no idea why) and when I went to open the downloads window via Tools->Downloads, it did the fancy compiz box animation (as I have selected in preferences) and switched to it. very cool. But enough if my gushing over the unexpected presense of sanity in the UI design of a Linux desktop environment! back to my attempts to get BaseBlock working on Linux.
my attempts to make the bass project, however, failed:
bc_programming@Satellite ~/Projects/bass $ sudo make make -C 3dtest make [1] : Entering directory `/home/bc_programming/Projects/bass/3dtest' cc -Os -I/home/bc_programming/Projects/bass -L/home/bc_programming/Projects/bass -lbass -Wl,-rpath,/home/bc_programming/Projects/bass `pkg-config gtk+-2.0 --cflags --libs` `pkg-config libglade-2.0 --cflags --libs` -export-dynamic -D'GLADE_PATH="/home/bc_programming/Projects/bass/3dtest/"' 3dtest.c -o 3dtest Package libglade-2.0 was not found in the pkg-config search path. Perhaps you should add the directory containing `libglade-2.0.pc' to the PKG_CONFIG_PATH environment variable No package 'libglade-2.0' found 3dtest.c:7: fatal error: glade/glade.h: No such file or directory compilation terminated. make [1] : *** [3dtest] Error 1 make [1] : Leaving directory `/home/bc_programming/Projects/bass/3dtest' make: *** [3dtest] Error 2 bc_programming@Satellite ~/Projects/bass $
Oh the humanity! now I had to learn about this package nonsense. I first suspected perhaps, as evidence by the fact that it wasn’t found, said package wasn’t installed; so I did a quick sudo apt-get install libglade-2.0 … it reported it was installed already.
after a bit of effort, and installing a few dev packages, I gave up. I was able to resolve the missing dependencies but then it complained about a missing .h file (which was indeed missing and clearly should have been present) so I gave up on that, and am at the time currently trying to simply use the .so file included. An additionally problem that arises here is the obvious fact that I am using a x64 Linux system, working with C# code written on a x64 windows system but targeted towards a x86 system, problem being that to my understanding Linux is not as lenient when it comes to architecture differences; but I suppose I’ll figure that out for myself if it’s the case.
In any case, I am now attempting to get the nBASS library to wrapp around libbass.so rather then bass.dll; from my research if the imports are the same I should have no problem creating a dllmap entry in the appropriate config file. From the documentation it would seem that discovering where that config file goes is left as an exercise for the reader.
Actions:
pasted libbass.so in the “Debug” folder (alongside the dll).
Copied the BASeBlock.config file from the project root to the debug folder; renamed to Bass.Net.config.
opened preceding file in gedit; it now looks like this:
< ?xml version="1.0" encoding="utf-8" ?>
And now, I attempt to run BASeBlock… recall that it now compiles on Linux, so it’s just a matter of making it work. I could, in a worst case scenario, construct a “nullsound” driver that simply stubs out the sound playing interfaces. But that seems like a bit of a cop-out. IN any case, attempts to run it resulted in the same error; clearly either the documentation I was reading was incorrect or I was not interpreting it properly.
I did a few more googles and came upon this page, which, despite being about something completely different addressed the same problem; that is, translating the dllimport(whatever.dll) into imports of functions from Linux .so libraries. namely, it told me where the Mono parameter file was- /etc/mono/config. I quickly opened the feller using gedit:
I tossed in the line:
and crossed my fingers…
It still didn’t work. I guessed maybe mono only loaded that stuff up when it was started? So I restarted monodevelop.
excellent! a little progress. Now I was still getting the error, but it was complaining about libbass.so missing. At least we’re getting somewhere.
It still should have found the file; however, I decided that instead of just throwing it in the app directory (because god knows where Mono is truly looking for it; even putting ./libbass.so in the dllmap failed, so Mono clearly thinks something else is the “current” directory. Instead, I decided to simply cp it somewhere globally accessible;
It still didn’t work.
Anyway, I messed around with the config file and the dllmap attribute and no matter what I put it it refused to find the file; clearly I’m missing something obvious (maybe capitalization? a missing slash? who knows). In either case I decided to defer that work to later on; I’m sure there was more to be fixed afterwards.
So, I created the aforementioned “Null Sound” driver; it worked fine. compiled alright. Encountered a bunch of issues during startup relating to my use of the \ as a path separator, whereas Linux uses /, fixed this with a simple Replace to change all slashes to the slashes of the OS (Environment.PathSeparatorChar).
It still refuses to start; Some gdi plus error. I have no idea how to workaround this, since it seems to be related to the windows forms, and has nothing to do with my own code, but rather with some configuration option. I recall Tux2 working around a similar error in BCDodger but I wasn’t paying very close attention and forget what the fix was, or even if he mentioned it. Either way, at least now BASeBlock compiles on a linux system, and most of the code-related oversights have been resolved.
EDIT:
I’ve managed to solve both issues; not at once of course.
First, the loading issue was fixed; pretty troublesome. In my attempts to resolve the problem I created a number of projects that used the same Image.FromFile() method to load pictures, and they worked fine.
Clearly, the problem then was not in what was not visible; the difference between the two. I realized that the difference was pretty clear: in my test projects, I was loading the images from within the form’s Load event; in BASeBlock, they were being loaded in a static constructor. So I decided to try to load the images elsewhere; I converted the static constructor to a static function, and called that function in the form load; there were a few other changes that I needed to make, mostly in the form of initializers attempting to use values that wouldn’t have been initialized.
The game started and ran fine with the NullSound driver.
Now, to fix the Sound; I opted to try to get nBASS working.
the solution was actually quite simple; merely a dllmap for bass.dll to libbass.so, and placing the x64 libbass.so in usr/lib was enough, and sound worked fine.
Unfortunately, it’s still slow as hell but at least I think that’s Mono’s fault.
678 total views, 16 views today

Categories
Tag Cloud
Blog RSS
Comments RSS
Last 50 Posts
Back
Void « Default
Life
Earth
Wind
Water
Fire
Light 