header image
Gtk example
September 26th, 2009 under Devel, OSS, rengolin, Software, Unix/Linux. [ Comments: none ]

Gtk, the graphical interface behind Gnome, is very simple to use. It doesn’t have an all-in-one IDE such as KDevelop, which is very powerful and complete, but it features a simple and functional interface designer called Glade. Once you have the widgets and signals done, filling the blanks is easy.

As an example, I wrote a simple dice throwing application, which took me about an hour from install Glade to publish it on the website. Basically, my route was to apt-get install glade, open it and create a few widgets, assign some callbacks (signals) and generate the C source code.

After that, the file src/callbacks.c contain all the signal handlers to which you have to implement. Adding just a bit of code and browsing this tutorial to get the function names was enough to get it running.

Glade generates all autoconf/automake files, so it was extremely easy to compile and run the mock window right at the beginning. The rest of the code I’ve added was even less code than I would add if doing a console based application to do just the same. Also, because of the code generation, I was afraid it’d replace my already changed callbacks.c when I changed the layout. Luckily, I was really pleased to see that Glade was smart enough not to mess up with my changes.

My example is not particularly good looking (I’m terrible with design), but that wasn’t the intention anyway. It’s been 7 years since the last time I’ve built graphical interfaces myself and I’ve never did anything with Gtk before, so it shows how easy it is to use the library.

Just bear in mind a few concepts of GUI design and you’ll have very little problems:

  1. Widget arrangement is not normally fixed by default (to allow window resize). So workout how tables, frames, boxes and panes work (which is a pain) or use fixed position and disallow window resize (as I did),
  2. Widgets don’t do anything by themselves, you need to assign them callbacks. Most signals have meaningful names (resize, toggle, set focus, etc), so it’s not difficult to find them and create callbacks for them,
  3. Side effects (numbers appearing at the press of a button, for instance) are not easily done without global variables, so don’t be picky on that from start. Work your way towards a global context later on when the interface is stable and working (I didn’t even bother)

If you’re looking for a much better dice rolling program for Linux, consider using rolldice, probably available via your package manager.


Start-ups
September 13th, 2009 under Computers, Corporate, rengolin. [ Comments: 3 ]

To start a new idea and make it profitable is much more of an art than logic. There is no recipe, no fail-proof tactic. The most successful entrepreneurs are either lucky or have a good gut-feeling. Hard work, intelligence and the right idea are seldom useful if they don’t come with luck or a crystal ball. After you have started-up, however, they’re the only things that matter.

I may not know how to start a business and succeed, but I do know how to make them fail miserably. I have done it myself and seen many (many) friends fail for different (but similar) reasons. Yet, I still see other friends trying or the same friends still thinking they could’ve done better next time, so this is my message to all of them.

Do you have a crystal ball?

I really meant it, those that really work they way they’re supposed to. If the answer is no, think twice. Seriously, I’m not joking. The only people that partially succeeded were the ones that had nothing to loose, as they had enough money to get them going for years, but (unfortunately) they’re not filthy rich today. The rest are employees somewhere in the world…

Hard work

One thing they all had in common is the idea that they could do it with hard work and a good idea. How wrong they were… Let’s put it simple: if hard work took you anywhere, the world would be dominated by dockers. If good ideas had any impact, the world would be dominated by scientists. But the world is dominated by bankers… Q.E.D.

Working hard won’t help, you have to work just right. That usually means very little in the beginning, a bit more afterwards and later on and finally hire some hard-workers to do the work for you. Simple, stupid.

Picture this: a salesman comes to your door to sell you a pair of scissors. You have many at home, but he assures you it’s the best pair of scissors in the world, that it has twenty patents and the guys behind the design like to work very hard on their ideas. Would you buy it? No! On the other hand, lots and lots of people go to the supermarket and buy scissors just because they’re cheap (and they assume they lost their own).

Don’t expect people to understand your hard work, they couldn’t care less for how much you do work, they just care for what benefits you can give them. The supermarket scissors give them the benefit of being cheap and “be there”, the salesman is already annoying by definition. No matter how good yours is, they simply won’t buy it.

Ingenious crafts

Now, at this point the friends I mentioned are certainly thinking: “but my product was much better. It was new, there wasn’t any one like that in the market”. The truth is, who cares?!

Novelty doesn’t sell, quality doesn’t sell (at least not yours, anyway). If Apple start selling toothbrushes, people will buy by the millions, if you sell a crystal ball that actually works, they’ll ignore completely. Who are you, anyway? Unless they have some kind of value, and their friends (and other posh people) are doing too, they won’t even bother.

If your product is really good, you have to put a high price for it. Poor people won’t buy it, rich people will buy from the fancy brand. You sell it cheap, poor people won’t buy it (because it’s not fancy nor necessary) and rich people won’t even see you. Poor people only buy superfluous stuff from fancy brands (or fakes) and rich people only buy from the real (sometimes fake too!) brand.

If your item is not an every-day necessity, like food, you are in deep trouble. Being the best is not enough, ordinary products sell more than state-of-the-art ingenious crafts.

Do the right way ™

Some of my failed friends (no hard feelings, ok?), that are now really pissed off, are thinking: “But I didn’t put all that effort, and my product was clearly better than any other, and it was for free! How could it go wrong?”. Capitalism 101: No demand, no production.

Don’t yell just yet, when I say demand, I mean demand by desire. There was always a demand for the internet, but people never desired it before a few decades. There was always a demand for a decent search engine, but no one desired that much after all the failed attempts from Yahoo, AltaVista etc. When there was a desire for instant communication, email was not enough, that ICQ had its chance.

Doing it right is not enough, you need to do it at the right time. The right time is not when there is no other option like yours, this fact is irrelevant. The right time is when many others are failing. This, my friends, is the crucial point. You can have a million of ideas, if none of them coincide with the utter failure of one or more other ideas, it’s worthless.

Don’t trust your brain

The recipe for disaster is simple: trust your brain. Trust that your intelligence will lead you to success. Trust that your ideas are better than others’ and that will lead you to success. Trust that hard work wil lead you to success. People that trust their empire is unbreakable, are already breaking. To trust, is to fail.

The most simple rule for success, as I picture it, is to use other people’s failures for your success. If someone is doing it wrong and people are complaining, there is a high demand by desire for that particular thing. If you can identify it and do what they want, it’s likely that you will succeed.

Again, don’t do more than what they need nor better than you have to. Keep it simple, keep it stupid. Hard work won’t lead you anywhere, remember? You have to be fast, noisy and some times ridiculed. It’s part of the game. Good buzz and bad buzz are both buzz, and buzz is good anyhow.

In a nutshell

  • Minimum work, maximum opportunity: Do as little as possible before the window opens, make connections, prepare demos and mockups of several different projects, multiply your chances.
  • Wait for a major failure: Investigate where others are failing and take action immediately, put anything on the market, no matter how ugly or failing, Beta is always Beta (thanks Google!).
  • Don’t let the window close: After you got your opportunity, work hard as hell, buzz, spam, be ridiculous.
  • Don’t use your brains too much: Good ideas are no better than bad ones, your idea is no better than any other. Failing ideas are important, non-existent ideas are irrelevant.

So, my failed friends, it is very simple: You will fail, unless you step on top of other people’s failures and don’t let them do the same to you. Now you understand why I won’t ever try again… This is absolutely not my style at all! I rather have friends than be rich.

A bit of history

Nothing better than a good bit of history to show us how important is people’s failures in other people’s success…

Microsoft’s success

IBM was dealing with Digital Research to put CP/M on it’s new architecture, the PC. Digital was sloppy, negotiations failed, Microsoft (so far completely irrelevant) got a CP/M clone and called it MS-DOS and gave to IBM. You know the rest…

Microsoft had previously worked on a Unix version for micro-computers, called Xenix which was then sold to SCO who ported to PC, which failed. Unix is, as we all know, the best ever operating system in the world. There was no Unix for micro-computers, it was a perfect market, right?

Wrong. The first move (on top of a failure), and not the second (with a bright idea), is what made Microsoft the number one software company in the world today. For bad or worse, they won big time.

Yahoo vs. Google

In the beginning, the internet was a bunch of Gopher sites. When it turned to HTTP and people started using HTML and the commercial boom came in, it was impossible to find anything decent.

Several people started doing directories of cool websites, but it was Yahoo who consolidated it into one big site. They bought several other companies, most notably for their directory contents and search engines. No matter how hard they tried it was still too bad. In 2000 they were to close a search deal with Google. For a short time, Google actually provided search results for Yahoo, but the pride was bigger and they bought Inktomy (who?) and dropped Google’s techology, which obviously brought no value at all to their users.

The search was still no better than Google’s, which saw Yahoo’s pride as their biggest mistake. Google started low, using basically the word of mouth as buzz and making really cool (but stupid, simple and easy to implement) features. Even their search engine was not novelty, as others had done similar in the past and they spent their college time doing it.

Yahoo’s mistake was Google’s take. They now have more than half of the internet passing through them, left Yahoo with second (or third) class, outdated products. The company is now finally destroyed.

To make things even more interesting, Microsoft tried to compete with them, but failed miserably. Their products were even worse than Yahoo’s and, to cement once and for all Yahoo’s mistake, they’re now using Microsoft’s technology as their search platform.

There are obviously many more stories of failures and successes, but I let this as an exercise to the reader. My final and most important point is: commercial success has nothing to do with quality, only with timing and a good deal of bad behaviour.


SLC 0.2.0
September 12th, 2009 under Algorithms, Devel, OSS, rengolin. [ Comments: none ]

My pet compiler is now sufficiently stable for me to advertise it as a product. It should deal well with the most common cases if you follow the syntax, as there are some tests to assure minimum functionality.

The language is very simple, called “State Language“. This language has only global variables and static states. The first state is executed first, all the rest only if you call goto state;. If you exit a state without branching, the program quits. This behaviour is consistent with the State Pattern and that’s why implemented this way. You can solve any computer problem using state machines, therefore this new language should be able to tackle them all.

The expressions are very simple, only binary operations, no precedence. Grouping is done with brackets and only the four basic arithmetic operations can be used. This is intentional, as I don’t want the expression evaluator to be so complex that the code will be difficult to understand.

As every code I write on my spare time, this one has an educational purpose. I learn by writing and hopefully teach by providing the source, comments and posts, and by letting it available on the internet so people can find it through search engines.

It should work on any platform you can compile to (currently only Linux and Mac binaries provided), but the binary is still huge (several megabytes) because they contain all LLVM libraries statically linked to it.

I’m still working on it and will update the status here at every .0 release. I hope to have binary operations for if statements, print string and all PHI calculated for the next release.


 


License
Creative Commons License
We Support

WWF

EFF

National Autistic Society

Royal Society for the Prevention of Cruelty to Animals

DefectiveByDesign.org

End Software Patents

See Also
Disclaimer

The information in this weblog is provided “AS IS” with no warranties, and confers no rights.

This weblog does not represent the thoughts, intentions, plans or strategies of our employers. It is solely our opinion.

Feel free to challenge and disagree, and do not take any of it personally. It is not intended to harm or offend.

We will easily back down on our strong opinions by presentation of facts and proofs, not beliefs or myths. Be sensible.

Recent Posts