Search posterous

Search all posts and users. Type a name, type a favorite song title, whatever! See what comes up.
  

More posterous blogs











More recommended blogs »

Here are posterous posts filed under programming...

ajani says...

The following code does not compile:

public class A {
public static void main(String[] args) {
int i = Integer.parseInt(args[0]);
switch (i) {
case X: System.out.println("ONE!"); break;
case Y: System.out.println("TWO!"); break;
default: System.out.println("ZERO!"); break;
}
}
public static final int X = B.getNumber("X");
public static final int Y = B.getNumber("Y");
}

class B {
public static int getNumber(String s) {
if (s.equals("X")) {
return 1;
}
else if (s.equals("Y")) {
return 2;
}
else {
return 0;
}
}
}

The compile error is:

A.java:5: constant expression required
case X: System.out.println("ONE!"); break;
^
A.java:6: constant expression required
case Y: System.out.println("TWO!"); break;
^
2 errors

I think I'll leave explaining why as an exercise for the reader. (Or for a future post. ;-)

Filed under: geek, java, programming

ajani says...

Potion is an object- and mixin-oriented (traits) language.

_why's been working on a new top secret project. Wish I had more time to play with all the neat languages out there. This one seems to have a lot of neat ideas.

Filed under: geek, languages, programming



Mary over at The Coding Pad has a great blog entry titled The Strengths and Pitfalls of Online Tutorials for Beginners. She suggests that beginner programmers should work to develop a strong understanding of fundamentals before diving head first into the plethora of online tutorials out there. She also mentions some great tips on how to do this. But one pitfall she mentioned that really struck a chord with me was "Fragmented Knowledge".

This idea of Fragmented Knowledge (or "fragmentitis") is a huge pitfall for anyone who is looking to learn something new, not just novice programmers. The amount of reference material, how-to books/webcasts, etc. available on the internet is astounding and covers nearly every topic you can imagine. With a few clicks of the keyboard, you could start learning almost anything about any topic you can think of. That's pretty amazing, Star-Trek-esque crap right there. But let me illustrate for you the problem of Fragmented Knowledge. Here are some of the topics I've wanted to learn more about this year:
  • Beginner electronics + circuit-building
  • C# 4.0, WCF, LINQ
  • jQuery, Processing, Javascript
  • Ruby, Python, PHP
  • Linux basics
  • Custom Firefox extensions
Add to this list my experiments with social media + emerging internet services, plus keeping up tabs on RSS feeds and occasional gaming. The result- my limited free time is gone, and I know a little bit about everything on this list but not enough to actually be productive. I can make lights blink on my Arduino device and send http GETs in Ruby, but I haven't learned enough to do anything cool or useful. And I know I'm not the only one in this boat.

Now this is not all bad. I'm a firm believer that society is becoming increasingly disconnected with the technology we reply upon every day, and we all have a duty to understand (at least at a basic level) how the things we use work. But this is clearly a misapplication of my precious free time.

One of the suggestions that Mary makes in her blog is to figure out what you really want to learn and focus your efforts on, then create a learning plan around that. I'll add there is a step in there to "defragment your head"- arrange and weed out the pieces of supporting information you have collected in order to best focus on your learning goals. As an example: for each item in the above list, I have a dizzying number of bits and pieces of info. Links to sites, tutorials, books on Amazon, downloaded videos, PDFs,  whitepapers, page snippets and emails. Not only are they strewn everywhere, but taken together they do not comprise any kind of approach to learning the topic. They distract me, waste time, and worse- could just be plain bad information. So once I have my learning goals in place, I'm going to arrange my data sources + tools accordingly to best maximize my time. Over the next few weeks I'll detail the steps I've taken to defragment my head and focus on actually learning new things.

Filed under: Education, Programming

chewbocka says...

As a postgrad in the late '80s, Neil Bowers made some extra book money by acting as a helper in the computing lab. At the time, undergrads were all working on a grindingly slow VAX-11/780, and Neil and his fellow postgrads were posted there for hands-on help. This tended to be focused at the start of the year, when there were groups discovering Unix and programming for the first time.

One time, an Irish girl asked Neil for some help, saying that she couldn’t understand what was going on: she thought her program looked right, but for some reason, each time she ran it she got partial output, and varying amounts of output each time. The homework assignment she was working on involved writing a program that generated various values and wrote the results in ascii tabular form to a file.

Neil went over to her workstation and had a look at her source code. Everything looked fine. She showed him the file generated by her last run, and indeed, it looked truncated. Hmmm. "Ok," Neil asked, "can you run your program for me, so I can see what happens?".

She typed ./a.out and hit return. Her left hand darted to the keyboard and she hit Control-C. Neil was still mentally processing this when she cat'd the output, and turned to say, "See!" It did indeed contain partial output. Again.

"Um," he paused, "can you just run it again please?" Neil figured that he must have not seen right. But once again she typed ./a.out, hit return, then whap! she hit Control-C. Neil asked her why she hit Control-C every time she ran her program.

"Well," she said confidently, "I discovered that Control-C makes the % prompt come up quicker!"

Filed under: computing, funny, idiot, programming, unix

Brad says...

Filed under: code, macromates, programming, textmate

Steph says...

Amazing twitter visualization from Jer Thorp. Check out his blog and twitter for more programming genious.

This piece looks for tweets containing the phrases 'just landed in...' or 'just arrived in...'. Locations from these tweets are located using MetaCarta's Location Finder API. The home location for the traveling users are scraped from their Twitter pages. The system then plots these voyages over time.

Filed under: Film, Programming, Social Media

jasoncwarner says...

I am a voracious reader. I read tons of books, articles, blogs and magazines. However, that is not the best way for me (or probably anyone) to master a skill such as programming. Even so, I continue to read and don't have as much time to focus my attention on mastering several technologies I really want to master. I've committed to working my way through to "proficient" with the following technologies by this time in '10, which should be a very interesting time for me personally and professionally (I've set personal and professional timers for June 2010...). 

The Technologies in Priority Order

#1 Clojure

I haven't seriously looked at a Lisp since college when I wrote a Baroque chess game for AI class. After that class, Java became the big kid on the block and business programming pretty much consumed me for the next 10 years. Welcome to 2009 and Clojure is already 1.0, runs on the JVM, has some serious people doing some really nice things with it. The world is starting to get hip to the idea that functional can be cool (and useful) and OO isn't all it was cracked up to be. 

A nice side note: Compojure web framework will most likely be used. I tend to write web apps to learn something as that is what I've been doing since college. #2 might change that. 

#2 Erlang

Pure performance. Nine 9's uptime. 20 year history. I need to know more about this or worry that I lose all my technical street cred. 

#3 Flex + Grails + Google App Engine

I already know Grails well enough. I've already launched a web application on google app engine in Python. I "know" Flex theoretically. I want to combine all three of those and launch an app. This will force me to address Grails and Flex integration. Last I looked at it (about 6 months ago), it was rather immature. I hope it being #3 on my list will give it some time to mature before I get there. 

BTW. I really Like Flex in theory. I hope it turns out to be as nice in practice. I've come over to the JQuery camp as much as someone who really hates JavaScript can and I've been pretty pleased with JQuery. I hope Flex really is all its cracked up to be. 

#4 CouchDB and/or Hadoop

In my opinion, the single coolest thing to hit the database market in years. I've always tolerated RDBMSs but I never really liked how "non-agile" they felt. For certain apps, the theory behind schemaless dbs has potential to revolutionize the world. Google did it with BigTable, we have SimpleDB from Amazon and major work has been done by Rapleaf and Yahoo! in Hadoop. My preference is CouchDB as I like the simplicity of it but I owe it to myself to look at Hadoop as well. 

#5 iPhone App Development

I own a Mac, an iPhone...why not. Though I really hate the App Store and the control Apple has over distribution. How can I develop my world changing iPhone app and sell it only to exclusive partners? So far Apple told me I have to distribute to App Store. Haven't figured that one out yet. 

             
Click here to download:
My_Technology_To-Do_List.zip (210 KB)

Filed under: Clojure, CouchDB, Erlang, Flex, Grails, Programming, Technology

jeffmerlet says...

Let's make the web faster

Great initiative with already a good set of tutorials and compilation of tools, and potentially an active community.

Filed under: Design, Development, Performance, Programming, Scalability, Software, Web, Web Design

hboon says...

In one hand, Unicode does not define any implementation: it defines no data representation, only an international unequivocal way to associate a character to a code-point. You could store a list of code-points to represent Unicode data, yes, but doing this forces you to store 4 bytes per character because of the large code-point range. This is rather inefficient, and this is why UTF-* appeared. The whole idea is to map Unicode data to byte strings, choosing yourself the mapping function, so that the resulting representation fits your needs. In a way, you have many different strategies implementing the same interface, depending on your focus

Probably better to sum it up as:

Unicode is a table for mapping characters to a unique ID (code points). Encodings (UTF-8, etc) map the Unicode characters to a byte representation (a string of 0s and 1s).

Filed under: programming

Karthi says...

         
Click here to download:
Programming_cartoons.zip (137 KB)

Filed under: cartoons, email forward, humor, programming