... and that's why I use RoR. 90% of the "anti" opinions here don't get it. It's quick, it has a low entry barrier, and, if you want the Ajax stuff, it's very easy to do simple things. If you want stuff that scales to the moon then you use a technology that will do that - d'oh!
Ruby has also got lots of nice utilities to do SOAP and so on. It just works and it doesn't hurt. Integration with other services (.Net or Java) is a breeze and you can get help really easily from other people in the community. In general there is only one way to do something (because the language is young) and it does what you want. Compare with Java - 25 frameworks with alpine learning curves (XML or properties files - let's have both!) before you can do anything. It *used* to be simple and pretty easy to get things done but the signal to noise ratio is really painful now and getting worse with every "improved" J2EE implementation from the big vendors. Me no want no stinkin' entity beans - they leave a stain on your teeth.
I am a Java certified web developer and wouldn't go back, except for the cash. It used to drive me crazy: make a change, run Ant, deploy the WAR file, waste 20 minutes doing nothing. Get shouted at by PHB for reading El Reg while all this was going on. This is typical if you work on a legacy system.
Now I can just get stuff done, and that's all I want. I'm really keen on the whole JRuby thing, where the Rails app will just run from a WAR file and use all the sexy scalability stuff that the Java people have spent so much time and energy on - but I'll happily use it at one remove, thanks.
Here lies the one that works, not the old one I posted ages ago. It also uses dates instead of timestamp differences and should therefore not break if you ask it to go before the Epoch (some time in 1970 I think):
Also see Adrien's comment left here (he's much cleverer than me!) - it's really trivial:
s is the start date and e is the end date (s is lower than e)
(e.month - s.month) + 12 * (e.year - s.year)
See!
module DateUtils class << self def months_between( date1=Time.now, date2=Time.now ) date1 ||= Time.now date2 ||= Time.now if date1 > date2 recent_date = date1.to_date past_date = date2.to_date else recent_date = date2.to_date past_date = date1.to_date end years_diff = recent_date.year - past_date.year months_diff = recent_date.month - past_date.month if months_diff < 0 months_diff = 12 + months_diff years_diff -= 1 end years_diff*12 + months_diff end end end
Start here to see what this is in response to.
... how many of you go back to the pre-web days? I do - graduated in 1987, I've had to practically start again 3 or 4 times in the last 20 years - Unix before Linux, X-windows, dumb terminal to client-server, pre-javascript web tech, javascript, hand crafting your own stuff in raw html, Java, PHP, Java again, Rails. All I've ever wanted to do was deliver systems that work and meet real-world problems in a usable way. Be able to go home at the end of the day feeling I've achieved something and the people who use the stuff I wrote can do their jobs more effectively and not be dehumanised by it, hence my dislike for techie arrogance, which I see all the time.
2.0 is a Tim O'Reilly marketing thing, because he saw a lot of problems with the current technology and wanted to have some kind of dividing line to help people distinguish between things. But like the man at ucov says: no business model, no idea what people want, groovy idea that recycles some stuff other people have already failed at = failure. I'm with Paul Graham on this one - work on something boring and painful (for the punters) and you will see the rewards. Shiny isn't necessarily good[1]. You seem to have bought the marketing hype.
I applaud people's enthusiasm - I want technology to work and help us get out of the social and cultural ruts we're beginning to die from (a rut is a grave that hasn't had the ends filled in yet). Debate is healthy and really useful. The best "manifesto" is something people find useful and the culture that coheres around it. I'd rather work on that than an essay, any day.
F
[1] for some reason line from "venus in furs" started going through my head when I wrote that, must get new prescription for meds.
Didn't realise that phorm were the timewasting bastards who were behind 121 - spent many a happy hour trying to get rid of their viral nonsense from a machine my then 10 year old son was using (no idea how they got past him not being an administrator).
Can I send them a bill? I think they also managed to hijack firefox a while ago by putting in a bogus (and invisible) add on so I had to trash everybody's settings directory to get rid of it.
DEFINITELY send them a bill, and then a summons through the county court for my time. Anyone else want to join in?
Bloody hell! Although I suppose it might save us from tourists (joke, definitely joke, I hope). Is there any forum you can have a go at them about wasting public money? There's an idea - why not get off your backsides and do your job preventing it? Maybe pay for some police officers with the cash you just threw down the bog?
It's like the "ID cards stop terrorism" argument - how exactly? Unless you are going to start something like the pass laws like they had in South Africa under apartheid? And we all know who will have their movements restricted, don't we? All of the guys on 7/7 were UK citizens and would have had valid ID. No-one suspected anything or they would have done something about it. Gah!
The authorities have to be seen to be doing something so they spend money on paranoid crap like this.
I am a Rails developer who uses a proper IDE (Netbeans for Ruby) and Windows. Installed Cygwin to give me the bash shell and the other tools I need to talk to our Linux server backbones. I started on Unix/Sun workstations, went to client/server stuff then on to web. DHH is a kid, bless him, and hasn't yet lived through the next big change that will make him realise he has to start again. I've done it maybe 5 times in the last 20 years. Experience of one's own ignorance makes one humble. He's on a high now. Losing your job is a great and unwelcome teacher, believe me.
I don't get the Mac thing, either. If you don't want windows Ubuntu is fine, has the sexy desktop thing and runs on more powerful kit that costs a quarter of the price.
Don't get me started about TextMate - it's a word processor with a bunch of arcane key combinations to run a pile of bundled bash shell scripts. I could probably do something similar with Vim or Emacs but don't need to because the nice guys from Sun have written very good free tool. Can't split a view of the same file - just like a word processor all you can see is the few lines around where you are working. http://francis.blog-city.com/debugging_rails_applications.htmFollowing on from the talk I gave on why Java is bad for your brain at Barcamp I thought I'd dig out some of my old blog posts and present them here - try and explain the argument (which is more of a feeling of disquiet than anything else) better.
download mind map here (save as)
I tried to embed the map in an applet - but the downloaded applet doesn't work and locks the site up. There is a Flash reader but I lost the will to live Java, eh?
Defensive programming
http://francis.blog-city.com/what_defensive_programming_is_and_isnt_logging_the_right_t.htm
This one's about 'C':
http://francis.blog-city.com/at_the_feet_of_the_master.htm
Java is the new 'C' parts 1 & 2
http://francis.blog-city.com/at_the_feet_of_the_master_1.htm
http://francis.blog-city.com/at_the_feet_of_the_master_1htm.htm
J2EE is incoherent
http://francis.blog-city.com/cohesive_libraries.htm
Java schools
http://francis.blog-city.com/java_schools.htm
Java as a text processing language - note the comment about merely trying to open a file
http://francis.blog-city.com/java_as_a_text_processing_language.htm
Java and XML
http://francis.blog-city.com/java_finding_nodes_with_xpath_and_how_to_dump_out_xml_dom_as.htm
Create an active record object, retrieve some stuff from a soap service and then get this:
NoMethodError: You have a nil object when you didn't expect it!
The error occurred while evaluating nil.has_key?
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:2172:in `has_attribute?'
If you're having trouble with active record suddenly throwing exceptions it's probably because of a namespace collision with your Soap classes defined in the generated file called default.rb, or YourClassName.rb depending upon what arguments you gave to the wsdl2ruby command.
You need to put the data transfer classes into their own module by adding
--module_path MySoap
to the end of the command line. So you have something like this:
wsdl2ruby.rb --wsdl my.wsdl --type client --classdef My --module_path MySoap
(remember to delete the old files!)
I last fixed this by hand editing the files and adding in the module definition - so this is by far the easier way.
Another problem is you get this:
NameError: uninitialized constant SOAP::Mapping::EncodedRegistry
Just put
gem 'soap4r'
in the mapping registry file
XML - sigh
I read Oracle's early papers on XML DB - "we store the schema and the data separately, with pointers into the data"
Codasyl in disguise. The same with the o-o databases, hierarchical databases - none of this is new at all.
Personally I can write SQL, I understand the syntax and have been using it for over 20 years. Once you realise you're really working with sets it's pretty easy to understand.
RDBMS is now just another commodity. I'm happy to use whatever comes next, I currently develop in Ruby on Rails / MySQL and hardly ever have to see the database directly. Interestingly, the people who designed Active Record made 90% stuff really easy and then allow you to drop into raw SQL for the complex, instead of retrofitting the kitchen sink.
I'll use whatever comes down the pipe, as long as it meets my needs - that's it.
I was doing some hacking with lists of valid phone number codes (3,4,5 digits depending upon various factors). I used hashes that could be walked down because of the key lengths. Now we've decided to do it differently because the data file wasn't up to date ...
This gets the phone number as an array of integers:
code_pieces = code.to_s.split(//).collect(&:to_i) rescue []
(note the Rails &: thing)
This takes a list of keys and a value, pops the value off the beginning of the array and when the array is done then puts the value in with a hash key of -1:
def hash_for_digits(n_array,value)
n = n_array.delete_at(0)
if n
the_hash = {}
the_hash.merge({ n => hash_for_digits(n_array,value) })
else
{ -1 => value}
end
end
This is a merge of a hash of hashes with another - warning - it blows up without the -1 markers from the previous function.
def deep_merge_hash(hash1,hash2)
hash2.each_key do |k1|
if hash1.key?(k1)
deep_merge_hash(hash1[k1],hash2[k1])
else
hash1[k1] = hash2[k1]
end
end
end
Hope others find this some use - I might return to this another day and make it work with arbitrary hashes but now too busy and didn't want to throw the code away ...
The return from the function looked like this:
top_number = get_code_ref[code_pieces[0]][code_pieces[1]][code_pieces[2]] rescue nil
if top_number
ok = top_number[code_pieces[3]][code_pieces[4]][-1] rescue nil
ok = top_number[code_pieces[3]][-1] unless ok rescue nil
ok = top_number[-1] unless ok rescue nil
end
ok
I realised I could probably have speeded things up by having the first 3 as a hash key in their own right but too late now - reimplementation with a different data set on the way ...
Insightful few paragraphs here.
If John and others are right, the climate change folks look like tools, if they are wrong we might be in deep trouble.
That's the problem.
That said, I agree that we can overcome difficulties with technology and ingenuity, and the Green fascist types (who want at least 60% of the human race dead and the rest living on cardboard) tend to see the world as static and unchanging don't get this. But then the whole racist Malthusian project always becomes fashionable when the economy's in trouble. It's quite likely that global warming will become another one of their arguments for sterilising people who happen to have a skin colour they don't like.
I was sent a "reasons to go veggie" leaflet by someone who seemed to think that forcing subsistence farmers to grow and eat what vegetarians think is a good idea is ok. Another complacent fat westerner telling people what to do and what they can and can't eat. It was sickening, and the author of the pamphlet didn't even realise how racist it was. I think the global warming thing is going the same way - there's a lot of anti-Chinese and Indian sub currents when you read the articles. Interesting, eh?
Response to one of the comments left here by Stuart Luscombe
"when I was a teenager a mere 10 years ago there just weren't the kind of problems you keep seeing today. If anything I think school's, parents and the law in general is still too soft on young people who think that because of their age they can get away with anything they like."
I left school in the late 70's with 7 'O' levels and a broken nose. Stuff just didn't get reported then. If anything things are better now because schools at least *try* to deal with bullying, even if they sometimes fail.
My wife is a Guide leader, and I also used do a lot of work helping her and friends who run scouts. Most youngsters are decent, hard working folk just like their parents. They dislike the chav scallywags as much as you obviously do, we're talking about maybe 5% of the population here, but they get the headlines because it suits our lords and masters to demonise them and frighten the rest of us.
Stuff gets into the Daily Mail because it doesn't happen very often - if it were happening all the time then it wouldn't be news, d'oh?
Get a grip.
I was getting this:
undefined method `to_f' for {}:HashWithIndifferentAccess
This was happening in the after_create method. We have a table that lists fields and what validation is needed, we use this to pick out the value in the record so we can apply the validation function to the value if one has been given.
field_value = self.send(field_name) # Error was thrown here
I fixed this by calling self.reload at the beginning of the method that does the field scanning. I think that ActiveRecord doesn't refresh its attributes hash after save and the error came from it expecting the value to be of a particular type... I don't like calling reload, but can't find a method that will refresh the attributes hash.
Bootnote
Discovered that this was the result of sending nils in the hash passed into the create method, as it came over the wire as XML and was then incorporated into the params array, unlike the conventional post method, which puts empty strings in there. I wrote a one-liner to remove the hash elements with nil in them and everything started working. There was also another nasty bug which was putting the HashWithIndifferentAccess thang into any empty strings.
params.delete_if{ |k,v| v.blank? }
Eschew bullet points - they are there to prompt the speaker
Use diagrams and pictures - people think in pictures
Give handouts - That's where screeds of text belongs.
I read a paper that says one of the shuttle disasters was indirectly caused by powerpoint bullet points. A key engineering point about checking for damage was hidden in a 6 point font on a slide about 15 slides in. The engineering company was ruled by salesmen and the only way they could communicate was using it. Instead of producing a proper technical report that everyone could read and discuss at a proper meeting NASA were handed a BS powerpoint full of tiny fonts and missed this - it cost a lot of lives and money. I *hate* bullet points.
Also, the font size should be half the age of your target audience - another reason to use pictures.
Recontacted my Dharma teacher last year after a long time of being unable to practise. It was because I was trying too hard and strained myself. He told me that it's very common for westerners to do this: we're taught by our education system that we have to be perfect and whatnot, instead of aspiring to be like the buddha and working with what we have at hand we think we have to be the buddha right now and either give up because it's impossible or do ourselves an injury.
I'm very happy now, have been meditation regularly again, but this time not trying to sit beyond a reasonable amount. Also studying again. I'm trying very hard to write things down and systemetise them this time using things like mind maps. Ultimately it doesn't matter much, but I think it would be good to be able to remember things like the Four Noble Truths, and the four thoughts that turn the mind to Dharma, without having to get a book out. Memorising some of this stuff is good, it will give me a grounding to understand other things better.
I tend to jump off to the complex shiny stuff (Buddha nature, the madhyamaka etc.) because it's interesting and way beyond the everday view of things. Then details trip me up and I realise the shiny stuff isn't that important. So I'm trying to get a firm grounding in the key concepts and ideas. This should stop me falling off the end of the pier again. The spiritual consequences of leaving Dharma are extremely severe, particularly if you've entered the vajrayana.
Blessings to you all.
I've been using it for a while now, moved because of incompatibility issues.
Perhaps the complete redesign of the interface? Try finding "save as" in Excel - the File menu no longer exists FFS! It is there, but nowhere obvious.
Perhaps the "ribbon" that takes up half your screen if you're on a low-res machine?
Perhaps the redesign of formatting in Word, which was way better than Open Office, to be almost unusable and no longer number headings properly?
I think XP was the terminal release.
I also read that MS have got rid of a lot of their testers and gone in for automated testing of everything - so the whole usability thing they spent billions on has gone out of the door.
Open Office is more compatible with XP than Office 2007 - wtf were they thinking? I recon OO will really take off now.
Thanks, guys, for wasting my time. Can I send you a bill?
I've said that I use netbeans on this blog a few times but never really gone into why.
First, I can park all of the class/project browsers and output windows in the margins of the page and they only pop-up when I click on them.
Second, I can tear off editing windows so I can look at, e.g. Rspec's and the code next to each other. I can also have multiple views of the same file.
Third, it has book marks, which the "poor man's Textmate", 'e', doesn't.
Fourth, ^B will take me to where a function is defined so I can look at the framework and work things out. ^K is a cool key too.
Fifth, I can map everything to key presses if I want.
Sixth, it does indentation properly (which the Eclipse-based Ruby environments don't and it annoys me too much to use them) - it will also re-indent at a key press, which Textmate doesn't seem to do.
Seventh, I can move and copy lines without having to use the mouse: Ctrl-Down copies the current line or selection, Alt-Shift-Up/Down moves the current line or selected lines in the direction you need. This is great. Plus rename of variables inside a method ...
Eighth, you can start mongrel inside the IDE with a keystroke, or start it against the current page.
But best of all, it allows me to debug my Rails apps. You set your break points, start up the debug version of Mongrel and it drops you into a full symbolic debugger. I hadn't realised that lots of people haven't got this facility until I heard a podcast from David HH, the inventor of Rails, when he was saying that debug is back in Rails 2.0. If you use Netbeans it never went away, and you don't have to put breaks in your code.
Plus all the generators and whatnot are visible in the GUI.
The learning curve isn't flat, but not very steep, and it's a good tool that runs on any platform that supports a Java VM.
Enjoy
What follows is an extract from my novel Archive Fragments.
There were great tensions in society back then; tensions that people don’t remember now. They talk about class and ethnicity as if they were new phenomena. But I lived in a country that tolerated Jews in a leery, cautious way. It had been nominally Christian and definitely white for over a thousand years. Some schools were still tied to churches – I even went to one when I was a junior. Many bad things happened there, but that is for another time.
Secondary school there wasn’t a single black face in the place. This might seem strange now, but then it wasn’t. Our government invited people who were citizens of the old empire to come and work, to come and do the low-paid jobs that they couldn’t find people for. They were easy to spot, they were mostly descended from former slaves, they had black skin, and non-UK accents. The unions quietly forgot their internationalist leanings and started to stoke up racism against the threat of lower-paid workers damaging differences in pay. I remember a lot of gibberish about differentials in the news at the time, with my child’s mind, and now look back to see this racist agenda. Of course, scratch and Englishman and you find a racist, because Englishness is defined in terms of who can’t join the exclusive club. I don’t care if that statement annoys you, sorry.
So, it was a little odd when a black child appeared in our school. He was the only one and didn’t have a good time of it. Most of us weren’t against him, most of us didn’t have an opinion, but of course, a large school with several hundred kids in a year and fifty or so teachers had its fair share of dickheads, ignoramuses and out and out bullies.
There was a class distinction between the teachers. There were the arts types, the elite who had gone to a proper university before the blurring of institutions that has happened since, physical education teachers who did a bit and were mostly psychotic ruffians, and the failed engineers who taught technical drawing and metal- or woodwork. This last bunch were old-school and had probably been teenagers at the end of the War.
I have an abiding memory of this poor child standing on one of the woodwork benches, where a bald bastard of a teacher and a slightly older army veteran type were abusing him and using words that you never hear any more. This offended me deeply but I sinned by not taking a stand and getting someone in authority to confront them, if anyone in authority had the balls, which I doubt.
The kid only lasted about a week and I never saw him again. I hope he survived and wish I had been able to do something for him. I’m not sure I even spoke to him; the bullies would have gone for me as well if I had. This shames me.
The next school year it was announced that the bald bastard had died of a heart attack over the summer. I remember the headmaster looking sad, and we were all supposed to be a little sorry. I was glad, it felt like justice, but the older teacher who had egged him on was still there. Of course, he had a family and there was a whole complex web of lives and relationships around him and it was sad, like it always is when someone dies young. But I wasn’t sorry because the thing that defined him for me was that child standing on the bench, bravely holding back his tears.
Now I am an adult I will not tolerate racism or bullying, and I will not be quiet about it either. So hard luck if you stand someone on a table and abuse them – I won’t be sad or sorry when you leave and I will make sure you do...
We migrated a core system to our shiny new cluster on Friday. Colin got everything going apart from a call-out to a 3rd party back-end system that uses SOAP.
Tracking down the problem:
The error message was a method_missing talking about load_file.
I did some google work (googling is apparently not allowed by google because it could undermine their copyright - like I care)
It looked like the call to the SOAP client to add the certificates file wasn't working ... however the permissions on the files were correct.
I had a look on Sunday and found that we were missing the Ruby openssl library. This isn't a gem, but part of the standard install. Found this link explaining how to sort it out. Looks like we're missing zlib and some other stuff too.
Interestingly one leg had readline installed and the other didn't, which meant that the console wouldn't work. I couldn't get it to build on the broken leg and resorted to sftp'ing the file from one machine to the other.
This is because you can't get above Ruby 1.8.3 using the apt-get command so you have to build it from source. No idea why it doesn't install standard stuff - there's probably some magic compile switch that isn't documented.
Have fun.