Linux 2.6.22 Kernel Released
An anonymous reader writes "Linux creator Linus Torvalds announced the official release of the 2.6.22 kernel: 'It's out there now (or at least in the process of mirroring out — if you don't see everything, give it a bit of time).' The previous stable kernel, 2.6.21, was released a little over two months ago. New features in the 2.6.22 kernel include a SLUB allocator which replaces the slab allocator, a new wireless stack, a new Firewire stack, and support for the Blackfin architecture. Source-level changes can be tracked via the gitweb interface to Linus' kernel tree."
Seriously, what the fuck is going on with slashdot?
I've read & reread the linked articles, and not a single mention of the iPhone - and it's been over 48 hours since an iPhone story. Seriously - it's like slashdot's turned into a linux site, instead of an iPhone site.
Let's not forget our roots folks - just because linux is the big hype story today.
There are shills on slashdot. Apparently, I'm one of them.
TFA is /.ed and wikipedia doesn't help me. What's so good about the SLUB allocater?
It's a wee bit offtopic, but try this: http://www.linuxquestions.org/questions/showthread .php?t=462105
Insofar as I'm aware, Linksys ones tend to work ok.
http://xkcd.com/313/
Great improvement! SLUB is obviously better than slab, since it's all uppercase. I get a lot of emails these days using uppercase to distinguish their importance. I think it's a good thing the linux community is catching on to this IT trend.
I got a Hawking USB with an antenna on it. That really helps me to leech, er, acess the web. It is RT73. I had to configure it manually, but works well now. Documentation a little turgid, but it works. The Edi-Max site probably has a slick set up for it by now. Kubuntu.
The USB ones can be exceedingly difficult to get to work. The directional antenna on this one really does work for me.
I think this is just not true (yet). I haven't read anything in the changelogs.
nemesis. Home of an experimental fe code.
have any information on how good the new wireless stack is? That's what I'm most interested in.
For anyone in the dark, disk IO has been broken sometime after 2.6.17 on amd64.
- 450.html
...Or should I be worried that something so utterly fundamental has been lost in the shuffle across so many kernels in the past year? Amid all the eagerness to add new features since then (virtualization for example, and now complete rewrites of firewire?!?!).
I thought I was going crazy, being on 2.6.18 and discovering that any disk activity slows down the whole system, let alone accesses to any other disk.
Then I found a 19-page thread on the gentoo forums that says I'm not alone and it's not unique to a particular chipset:
http://forums.gentoo.org/viewtopic-t-482731-start
(with evidence that the deadline scheduler may alleviate _some_ of the problem but not the root cause)
And more importantly the kernel bug report here:
http://bugzilla.kernel.org/show_bug.cgi?id=7372
So I'm happy people aren't ignoring the problem.
Why can't we have a 2.7 kernel for this stuff?
Linus has repeatedly stated that his code will not be converted to GPLv3. You are either grossly misinformed, or on someone's payroll. If so, they are not getting their money's worth.
The best site out there for only letting you see a small portion of news on other websites, because the site goes down as soon as anything is posted about it.
"sudo rm -rf your-face"
http://kernelnewbies.org.nyud.net:8090/Linux_2_6_2 2#head-650cd139886ede5053ce6b7e1dd080b5378cc521
Some other possibly unnoticed effects of the GPLv3 include:
- You can't use a CPU of the same manufacturer that has previously executed GPLv3 code in the same room as a computer running a Microsoft operating system. If you have exhausted all the alternatives and you still need to run your GPLv3-infected hardware in the same room, you can negate this by drawing a chalk circle around the machines running the MS software and sprinkling a ground-up printed copy of the GPLv3 over and around them. This is all standard as per Section 5.
- In the case the Richard Stallman's or any of his buddies' computer blows up (for any reason - read the license for full details), he's allowed to walk into your house and take your computer right off your desk and keep it, even if it has never run GPLv3 code!
- If left unattended, disks containing copies of the GPLv3 can become corrupted and mutate into GPVv3 (General Public Virus version 3), which will assimilate all carbon and silicon-based matter with in a 3 mile radius into a demonic, electronic, GPLv3 spreading zombie ox (or it might be a buffalo - that part is unclear).
This is why we should all boycott GPLv3. It is just too evil and virusy.
The fact that you were modded up informative really shows that somebody is out here doing a a REAL FUD jobber. Few here, would say that if the kernel did switch to GPL3, that it would not even have a mention in the posting. That means that the modders are deliberate, not just ignorant. Considering that they are modding, shows that most of the time, they do not step off the deep end. That pretty much means that several ppl (30% informative), are most likely on a payroll.
I prefer the "u" in honour as it seems to be missing these days.
I don't understand 70% of the changes listed and don't care about/don't use the rest of them. I know, I know... I must be new here. *sigh*
Cornholio is a prophet.
Ok. You have a major release, it's permission to break all backwards compatibility, to completely change the face of computing.
Given the hardware around. What features should Linux 3.0.0 have?
Deleted
Anyways, I was thinking of adding one of these USB wireless accessories.. could anybody here recommend one that has a good track record of working in linux ?
I would recommend using one of the PCMCIA cards instead. Find one that uses the Anthros chipset. I picked up a D-LINK one that was recognised by Dapper Drake. I didn't need to install NDIS Wrapper of Network Manager. I don't remember the model number of the card, but setting it up was as easy as setting it up in Windows except I didn't need to use the setup CD that came with it. Dapper recognised it as an Unknown Wireless. Properties showed it has an Anthros chipset made by D-Link. From there I gave it a static IP on my LAN and plugged in the WEP key after picking my SSID from a list. I added some DNS listings and put in the gateway address of my router and I was online. There have been some difficulty with configuring many of the USB cards. Check the forums and purchase carefully.
The truth shall set you free!
Whatever happened to the releases being STABLE??
Am I the only one who cringes when someone says they have released a totally new wireless stack in a point release? Does everyone forget the VM switch fiasco already?
I really really regret the switchover to this whole new "accelerated" kernel dev. phase. Since this is just a point release, but has a totally new wireless stack, how do I know that my next OS update won't just break my whole networking setup? Argh.
Specific complaints should be stated as such instead of rubbish about it all being broken. The Gentoo thread quoted above is about people discovering that writing to optical drives is horribly slow and puts a lot of load on the CPU in comparison to dealing with hard disks - looking up ATAPI may have been a good move at that point instead of a lot of speculation.
Off topic, but the point of not using goto is that program structure may suffer because of it (if you've read mr. Dijkstra's paper you would know this- the result was the whole 'structured programming' movement). As long as one is careful about program structure, however, using goto is no problem.
To beginning and average programmers, 'do not use goto' is the best advice to avoid problems.
But kernel hackers are hardly beginning or average programmers. They know very well when they can use goto without problems, and when to avoid it. When used properly, goto will result in better performing, easier to maintain, more elegant, easier to read code.
Visit http://ringbreak.dnd.utwente.nl/~mrjb/growingbettersoftware to download your free copy of the book
To quote from the bottom of the page: [The mm-tree] can crash your machine, eat your data (unlikely but not impossible) or kidnap your family (just because it has never happened it doesn't mean you're safe)
I notice the patches being tested include Reiser 4...suddenly the above warning appears a bit more sinister.
Whoops, forgot to delete that line of code
If this were really happening, what would you think?
See http://kerneltrap.org/node/553/2131 for explanation. In short, Linus has good reasons to use goto.
IMO, goto has been demonized a bit too much.
Yeah, too much of it results in spaghetti code.
But used well, it can compensate for the lack of some things in C. For example, exiting nested loops. In Perl you can say "last NAME", where NAME is the name you gave to the loop, and exit from the outer loop directly.
In C, if you avoid goto what results is a check in every loop to determine whether the inner loop decided that we've got to bail out. This is much uglier than just using goto in the first place, and more error prone too.
Using goto is also handy for error handling: When you're allocating memory, goto allows jumping to the right point in the cleanup process, instead of duplicating bits of code everywhere.
It's my understanding that in kernel programming goto also has advantages in terms of speed over other alternatives.
That's not to say we should use everywhere. But IMO, what to use should be decided on the basis of what is the cleanest and less error prone option -- If goto results in cleaner code, then use it, if it doesn't then don't.
Linux has been crafted from so many hands, some of them now dead, GPL3 looks highly unlikely for Linux. That and Linus' dislike of the GPL3.
This is an implementation of TCP Illinois invented by Shao Liu at University of Illinois. It is a another variant of Reno which adapts the alpha and beta parameters based on RTT. The basic idea is to increase window less rapidly as delay approaches the maximum.
Illinois Congestion control is helpful with network games as that tends to spike my connection.
The purchasing part is hard to do when the same model comes with a different chipset each day, depending on constellations and sunspot activity.
Escher was the first MC and Giger invented the HR department.
Fair enough. The last couple of USB WiFi dongles I used were Linksys, and they were fine. Nonetheless, you're right: they do have a habit of buggering about with the chipset every so often...
http://xkcd.com/313/
In a nutshell, yes. But there is an important exception - goto's are ok when you jump down in the code (similar to a break in the loop), usually to a piece that frees allocated storage and exits function. In the code you cite, dput_and_out commits information and exits the function. In a way it is kinda a replacement for try {} catch {}, but with multiple try {} clauses.
I'd be careful about anything with a Broadcom chip. There is a Broadcom driver for Linux, but it doesn't always work. The alternative is ndiswrapper which can somehow make a Windows driver work under Linux. My experience was that setting up ndiswrapper was not much fun. Not knocking ndiswrapper -- I'm utterly astounded that it works at all
You can't see ANYTHING from a car, You've got to get out of the goddamned contraption and walk...Edward Abbey
Who said there would not be a 3.0 release?
And what's with the need to jump version numbers at the drop of a hat?
And why the need to tell someone else how to name their product, when you don't contribute to it at all?
"If you make people think they're thinking, they'll love you; But if you really make them think, they'll hate you." - DM
We've gone through this over and over. Previous devel branches went too far, taking forever to stabilize in the end, so Linus & co. figured it's better to do more incremental development within the single metastable branch. Really stable releases are up to distro maintainers.
Escher was the first MC and Giger invented the HR department.
Yeah, but does it run Linux?
eeeh, strike that.
Torrent File Here
When thinking about goto, first consider if you're performing a local jump or a non-local jump.
If you're using it for non-local return from inside nested loops and function across compilation units (read: files), why not use setjmp() and longjmp(), especially if you want to unwind the stack?
Mind you, you should keep careful track of memory allocation/deallocation functions when using this kind of chaotic/advanced program flow control, since you might malloc() before the setjmp(), but free() after it, but before the longjmp().
Wanna see nifty goto use? Look at the scanner code generated by lex.
I know this was probably a troll, but ZFS is available through FUSE.
http://www.mhall119.com
The purchasing part is hard to do when the same model comes with a different chipset each day, depending on constellations and sunspot activity.
Either take your laptop in and test drive them (explain it to the salesman, especially if they are on comission.. A fit is a sale.), find a good restocking policy, or spemd little. My D-Link card that worked came from Goodwill. It pays to look.
The truth shall set you free!
but you can always choose to accept the terms of the gplv3 license for any gplv2 licensed software. there you go. :)
Remember that the kernel is C, not C++. The goto here is safe. The deal with GOTO was that it was not supposed to be used to jump from one function to another or to replace functions. (C will not allow you to do this.) That was the point of the "go to considered harmful" paper - That explicit jumps would cause people to avoid writing properly structured code. Inside a function a go-to is entirely legal and sometimes allows you to save clocks by skipping things you don't need. In kernel code, saving clocks is entirely worth it, since your function may possibly be re-entered at a high rate, and your code blocks all other code in the system (you're the kernel). In an application, it's less worth it and the goto is probably unnecessary.
Personally I use whatever the language gives me wherever I can to make things as computationally short as possible. Sacrificing performance for programmer comfort does not make sense. If the code looks ugly, but it works (and works fast!), that's all it needs to do. For every one programmer you have thousands of users, and the users don't care if the source is pretty or not.
Sure, but how many of those 0.001% of the Linux users that this matters to actually read Slashdot? Probably more than you realize.
I, for one, haven't used a distro kernel (discounting LiveCDs) for 4+ years now. I love the discussion on Slashdot whenever a new kernel is released.
*sigh* back to work...
State machines have more or less entirely unstructured control to start with. The goto is a natural expression of this. You can avoid the dreaded "goto" in this situation by using a switch statement in a loop, with the cases representing each state. However, this is slower than the goto, and really no easier to read. For an example of this use of goto, see the code generated by lex.
Handling exceptional conditions inline can get quite ugly, and distracts the reader from the code representing the normal execution flow. It can also case a lot of duplicated code when there are several "exceptions" that need to be handled the same way. Instead, goto's can be used to redirect control to a separate "exception handler". The kernel code you linked appears to be an example of this kind of goto.
Not in the foreseeable future--Linus has decided not to do this. I would have thought you'd heard about this because the decision was made a long time ago and nobody's ever hinted that anyone's mind has changed.
Your question doesn't make sense. 2.6.x is not a "stable branch". You're using old terminology. Linus has decided that 2.6.x is the new development platform. The distros are free to create 2.6.x.y versions that are stable. I would have thought you'd heard about this because the decision was made a long time ago and nobody's ever hinted that anyone's mind has changed.
Linus thought he'd give something new a try. Everyone's working together on the current tree and, if anyone's interested (like, say, a distro), they're free to take a 2.6.x edition and make a 2.6.x.y series of stable kernels. I would have thought you'd heard about this because the decision was made a long time ago and nobody's ever hinted that anyone's mind has changed.
Ian
What did they break?
Unless I missed something, everything they added is an optional replacement to what was already there. Don't use the new stuff if you don't want it.
*sigh* back to work...
You sounded like you knew what you were talking about until I got to this point.
Everybody knows WEP is a waste of time. If you really want your wireless to be secure, just wrap the access point in a HEPA filter, but make sure you cover your laptop with the exact same grade of filter, to ensure compatibility. THAT will keep the undesirables out (assuming they are larger than
Sorry to be spelling Nazi but I think the parent meant Atheros (confirmed by quick google search).... I have that chipset in my laptop, it has a good reputation because it worked in Dapper but my edgy upgrade broke it and each new kernel requires me to set it up again... bummer.
While I use and love Linux, i couldn't agree more with you. This bug has been driving me crazy, as i was looking for the cause in userspace, and it coincided with the move to compiz-fusion. The animations of compiz eyecandy make even the slightest system slowdown noticeable so this bug pretty much killed desktop compositing in the affected platforms until it is solved (it runs but its not fluid). And with that we lose a great tool to generate interest in the Linux OS.
"If God created us in his own image we have more than reciprocated." - Voltaire
See also "Structured programming with go to statements" by Don Knuth. He makes many of the same points that you do. IMGO goto's are the only sensible solution to a switch based on many ordered criteria. Say:
/* and so-on */
... else if ... else if ... statements, but I don't think the code would be clearer, or less bug prone.
if(criterion1||criterion3){
do_something();
goto end_of_cases;
}
if(criterion2){
do_something_else;
goto end_of_cases;
}
if(criterion4){
do something_else again();
goto end_of_cases;
}
end_of_cases:
Now you could do that with a load of if
Athletic Scholarships to universities make as much sense as academic scholarships to sports teams.
I presume you mean "Atheros". I recommend not using those cards. Atheros cards do not have Free Software drivers; they're binary-only. They don't handle suspend well, which is kind of a big issue when you're dealing with a laptop. Ralink or Intel cards are a much better bet.
Please, for the good of Humanity, vote Obama.
I have had lots of trouble with ralink (drivers that wouldn't compile, or when they did compile, didn't work). The two chipsets that have worked the best for me were Atheros and Atmel (though Atheros may need some installation of software (madwifi), and both will need firmware, but both just worked on Ubuntu). The card I just bought with the Atheros chipset is a D-link, but like the parent said, they don't always use the same chipsets. People I've talked to seem to think that linksys often works.
In the future, I'll always buy wireless cards at a mortar and brick store, where I can return them if they don't work. It's not worth my time to fuck with drivers that are unsupported.
A cat can't teach a dog to bark.
Which is hardly worth mentioning. There's a reason we usually put filesystems in the kernel, performance.
Give me Classic Slashdot or give me death!
Your cases are mutually exclusive. The following is indeed clearer, shorter, and less bug prone:
/* and so-on */
if(criterion1||criterion3){
do_something();
} else if(criterion2){
do_something_else;
} else if(criterion4){
do something_else again();
}
There are 0x40000000 types of people: those who understand 32-bit IEEE 754 floating point, and those who don't.
I thought you were onto something until I realized you might not be running Linux over wireless by this statement;
.3 microns).
A &btnG=Google+Search
Everybody knows WEP is a waste of time. If you really want your wireless to be secure, just wrap the access point in a HEPA filter, but make sure you cover your laptop with the exact same grade of filter, to ensure compatibility. THAT will keep the undesirables out (assuming they are larger than
Have you had any luck using WPA on an older distro such as Dapper? I set up to get connected. I live on the end of a road and have brick exterior so signal offsite is wimpy. Not too many wardrivers find me and there are lots of unsecured points nearby so I'm not a high profile target.
It's like being in the jungle with a companion and being attacked by a lion. I don't have to outrun the lion. I just have to run faster than my companion.
Just checking this google page summs it up.
http://www.google.com/search?hl=en&q=Linux+and+WP
I started with the basics to get a working connection. I can try to add WPA later, but enough have had problems.
How did you know I work in a cleanroom?
The truth shall set you free!
I DO use Linux over wireless, only it's WPA2/AES-CCMP. However I am running Kubuntu Feisty. Maybe it's time for an upgrade?
I don't buy the "safe enough" arguments. It's broken. Friends don't let friends use WEP.
Don't forget the Intel chipset. Those work great out of the box. I'm not sure if they've come out with any pci cards, but their internal wireless works like a charm. Sam
There's no tangible performance difference with userspace filesystems. People have even gotten a system to boot off of them. (initrd just has to have the module handy.) The NTFS-ng driver arguably has better performance as a userspace filesystem than NTFS.SYS does on Windows!
grey wolf
LET FORTRAN DIE!
Linus thought he'd give something new a try. Everyone's working together on the current tree and, if anyone's interested (like, say, a distro), they're free to take a 2.6.x edition and make a 2.6.x.y series of stable kernels.
The trouble is "everyone" is "working together on the current tree" therefore there is no one available to make a "stable branch" other than the big money players like RedHat and SuSE.
This plays directly into the hands of other big money like IBM, who can now claim that Linux is "less stable than AIX," and Microsoft, who can now say, "see that free stuff isn't as stable as they claim."
Those of us who can't afford $700 for a RedHat license get to use experimental kernels if we want to keep up with new hardware support.
I'm seriously considering going back to Solaris, which is now Free as in Speech.
Stick Men
JFS is one of the better linux filesystems. And while you can't select it in the installer, you can definitely install the tools to support JFS from universe in Kubuntu, and it's similarly available in the Fedora base repositories. The kernels come with the modules pre-built already, so...
And you can shrink and grow them. And it has nice backup and fsck utilities... Oh, and it supports extended attributes and ACLs and all that good stuff. And it's faster than XFS.
So use it!
THIS THING CAN TURN ON A DIME, MACROSSZERO STYLE ALSO FUCK BETA, ~NYORON
This is getting increasingly Digg-like...
http://www.dieblinkenlights.com
But maybe they'll let you try it out in the store anyway.
Bill Stewart
New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
"It can sneak out the front door with your CD collection in ther middle of the night"
s/can/can not/
http://michaelsmith.id.au
However I am running Kubuntu Feisty. Maybe it's time for an upgrade?
Probably true. I'm running Dapper because I have a life. I spend little time as a noob putzing with it. I'm more of an end user. I settled on Dapper because it is the LTS version so I wouldn't have to be on the 6 month upgrade cycle.
Anyway, in a couple years, I'll upgrade. In the meantime I'll enjoy the sunshine and warm weather, camping, etc. When rainy weather sets in and I have time to blow my install and learn how to recover it, I'll ditz with it.
In the meantime, I have a date with a jetski.
The truth shall set you free!
download them before upgrading?
Semi-automatic amateur armchair Australian philosopher; conjecture ready at any moment...
I think that even though GOTO itself is not necessarily such a bad thing, its current use in C is more of a hack now because C lacks some otherwise common *structured* constructs such as try..catch..finally. But my bigger problem with GOTO is that it's one of those things which completely and utterly destroys the ability to represent a program as a tree structure for possible branches, which keeps us even further from functional-like purity in C code.
GOTO is very rarely used in C++ where the pattern of relying on safe stack destructors (as a sort of 'finally') is wide-spread and well understood. It's downright forbidden in Java, which has solid garbage collection and an explicit 'finally', and therefore very little need for a specific GOTO. These features are much easier to reason about and understand than a GOTO C program which is basically just a self-traversing jump table.
Sam ty sig.
I don't buy the "safe enough" arguments. It's broken. Friends don't let friends use WEP.
Swing by and leach then. Good luck. I use more then 1 router. WEP may be weak on the wireless level.. but it's not the only level of protection.
Notice in my original post the requirement to assign a static IP, manualy assign DNS, gateway, etc. Remember I use more than 1 router. You would need to be pretty dedicated to analise the packets to properly configure a working connection without being noticed. I watch the packets also.
The truth shall set you free!
I've found the upgrade process to be surprisingly painless, from one release to the next. However if you are going to upgrade from Dapper in "a few years" you'll almost certainly be looking at a reload rather than upgrade. It's debatable whether you will have saved much time in the end, and in the meantime you will miss out on things like WPA, for example.
I had planned on running Dapper/LTS on some systems for ease of maintenance but I've since upgraded them to Edgy and Feisty because of features or improvements in the newer releases, and because upgrading is just so easy. In fact I moved to Kubuntu from Gentoo in part to spend less time on system administration and more time actually using the computer or doing outdoor things like you mentioned; and even with occasional upgrades, time spent maintaining my Ubuntu systems is minimal.
Not using DHCP adds a layer of obscurity, not protection.
After cracking WEP and sniffing traffic, all the necessary settings could be trivially obtained. "Pretty dedicated" to run ethereal/wireshark? Not really.
And finally, you still use Dapper and WEP because you have a life. Because you enjoy the sunshine and warm weather, camping, etc. Because you are dating a jetski.
And yet you reserve time for "watching the packets" to see if anyone has pwned your network yet? Wow.
Get Snort, setup WPA, and eat, sleep and be merry. That's my advice.
but I've since upgraded them to Edgy and Feisty
I've heard of several problems with the upgrade from Dapper to Edgy, so I have been avoiding that upgrade. Most of the Forums recommend a new install instead. With a new install, you need to reset most everyting and start over with non-free codecs, MTP Library for the Zen, drivers & apps for the video capture card, configuring Myth, e-mail, Flash 9, Flashblock, etc. For me the re-configure would be times 3.. My laptop, my kids desktop, and my dual boot desktop.
In the meantime, I'm enjoying the sunshine. I'll save that one for a rainy day. I'm not willing to set aside a sunny day just incase the upgrade has problems and requires more time to tweak. As a noob, many of these tasks require quite a bit of time in Google searches.
The truth shall set you free!
And yet you reserve time for "watching the packets" to see if anyone has pwned your network yet? Wow.
It isn't hard. It's mostly automated. If I'm out and there is a burst of traffic, it requires investigating. Some rules when violated send an alert.
Due to a few open unsecured AP's in the neighberhood, I haven't had activity in over a year. It's pretty low maitenence/low risk. It's simply easier to go elsewhere.
Take an old P2 box and install snort between your internet wired router and your wireless router and LAN. Set alerts and check it once in a while if you don't hear from it.
As far as someone pwned the network, remember, I have more than one router. It's not all on the same LAN segment. Wireless mostly goes to a gateway router and a couple networked printers. The rest of the lan is further NAT'ed. Good luck.
The truth shall set you free!
shorter perhaps. I don't see why it would be less bug prone.
And I do think the structure is less easy to parse, and less accurately reflects the logic and structure of the algorithm. I know flow charts are deeply unfashionable, but sometimes they capture exactly what you mean.
Different strokes for different folks.
Athletic Scholarships to universities make as much sense as academic scholarships to sports teams.
I think the GPLv2 is a better license - I'm not against tivoization. They release their changes to the source code, so you can still benefit from that. If they want their box locked down, fine with me. Why is the GPLv2 flawed?
You've got to be kidding! The driver is madwifi It's not yet in the kernel, but it compiles and installs easily. It is easily the most capable hardware/driver combo I have seen for 802.11.
It DOES include a binary-only firmware componant (HAL), but that's mandated by the U.S. FCC (and equivilants in other countries) so you "can't" command the card to violate current regulations. Other wireless cards have that limitation as well and more restrictive licensing on the firmware componant as well. At least the madwifi firmware is freely redistributable.
Edsger Dijkstra thought so and Niklaus Wirth is a true believer, I'm not so sure. The unrestrained use of GOTO in fortran and BASIC is certainly very harmful and needs to go away, ESPECIALLY in BASIC where you can (but shouldn't) GOTO from one subroutine to another.
On the other hand, well considered use of goto is quite another mater. The most common GOOD use of goto is as a way to unwind your state in case of an error. This works quite well in a function that must acquire and release several resources in a naturally nested manner. In that case it's quite natural to release the resources one after the other in order at the end of the function. In that case, the cleanest way to write the code is to have error conditions goto the appropriate nesting level at the end. The result CAN be written as nested if statements, but who wants the meat of the function indented 5 levels with multiple repeated compound conditionals in a while loop?
When goto is TOO pedantically avoided, the program logic can become so contorted to fit that it actually becomes unreadable. It can get especially nasty when the same sort of error handling may be required in several places. That leads to duplicated error handling code. Eventually, one or more cases of that code are missed during an update and you end up with an inconsistant mess.
It *IS* good to think very carefully when tempted to use goto, but it's also worth considering that it MIGHT prove to be the best answer for a particular problem.
In the example you point to, the if statements would get fairly contorted to avoid goto AND not duplicate code (cut 'n paste error handling is very harmful).
Students probably should be smacked for using goto since they probably don't have enough experiance to use them tastefully but never say never. Moderation is a good thing as long as you don't over-do it.
shorter perhaps. I don't see why it would be less bug prone.
Come on now. Maintaining blocks + labels + gotos is clearly more error prone than just maintaining blocks.
And I do think the structure is less easy to parse, and less accurately reflects the logic and structure of the algorithm. I know flow charts are deeply unfashionable, but sometimes they capture exactly what you mean.
The multiple "else if" block is an extremely common idiom that an experienced programmer recognizes immediately. It exactly reflects the logic and structure of an "arbitrary switch". Seriously, you've never seen this before?
There are 0x40000000 types of people: those who understand 32-bit IEEE 754 floating point, and those who don't.
O.K. Now add multiple failure conditions which all require different levels of cleanup handling. That's pretty much most functions in a kernel. Which is why you use goto more: it's actually clearer and reduces code duplication, making it safer.
If you need to break out of the block, fine: add a goto. I'm not claiming that gotos are useless. They're just not called for in this case.
Honestly, if C had exception handling, there would be almost no need for gotos in a kernel.
There are 0x40000000 types of people: those who understand 32-bit IEEE 754 floating point, and those who don't.
... The use of Fortran and BASIC is certainly very harmfulFYP
In all seriousness, the unrestrained use of goto by a novice is much like using a hammer to drive wood screws. It's the wrong tool for the task, and it yields poor results. On the other hand, the master carpenter not only knows to use a screwdriver, he also knows exactly which screwdriver of the dozens in his toolbelt is the correct tool for the job.
It's much the same in C programming - as another poster stated, "continue" and "break" (as well as "if..else") are equivalent to special-purpose goto's. The explicit "goto" is simply more flexible, and when used appropriately, it is not harmful. I can't recall using a goto more than one or two times in my career (outside of BASIC), and it was always for readability/optimization.
Though I haven't touched BASIC in decades (my experience was with AppleSoft BASIC, Commodore BASIC, BASICA and GW-BASIC), I do recall that it was quite impossible to write any kind of non-trivial elegant code in BASIC at that time. I do realize that BASIC has evolved into more structured forms. You can't polish a turd, but I digress.
Dijkstra certainly thought goto was harmful, and I'll not speak ill of the dead. As you say, Wirth is a true believer, a fanatic. At the time when Wirth was developing Pascal, he had a point - the unrestrained use of goto in the BASIC of his day, WAS harmful. For a time around 1982-1985 I drank the kool-aid as well, and embraced Pascal until I realized that Pascal itself should be considered harmful.
It sounds like we have similar experiances in the same timeframe. I used BASIC way back when because it was the usual thing to do on Apple][ and C64. A bit of GW-BASIC thrown in as I got used to the PC. My first Pascal exposure was UCSD for the Apple][. It was a nice learning experiance, but it seemed like it wanted to make me jump through hoops and do it's bidding when I was supposed to be in charge.
Once I got my hands on a C compiler I never looked back.
To be fair to Dijkstra, the goto he was talking about was of the BASIC and Fortran V variety and they are indeed a mess. Wirth's response is not unlike replacing kitchen knives with safety scissors becaause some people manage to cut themselves.
I use goto more frequently, but only in firmware and kernel code. I suppose that's due to the larger complexity of error states and the careful cleanup that must follow.
I picked up an ASUS USB WiFi for a cheap price, works a treat in BackTrack 2, was able to crack our companies wi-fi network in less than 5 minutes of data capture using Kismet and 1 second of cracking with aircrack-ng.
Sometimes I doubt your commitment to Sparkle Motion
Sure, I've seen it a million times. But that doesn't mean its the best. It's certainly elegant if there are 3 or 4 or 5 criteria. But 20 or 30?
I'll take the goto, seriously. I'd certainly recommend using them sparingly, and never, ever use them to jump backwards. In well structured code, there's no more cost in maintaining an occasional label than checking all those braces match where you think they do.
In a subroutine would you really prefer
if(criterion1){
do_something;
} else if(criterion2) {
do_something_else();
} else if(criterion3) {
etc...
}
return;
instead of
if(criterion1){
do_something();
return;
}
if(criterion2){
do_something_else();
return;
}
if(criterion3){
etc...
}
To an experienced programmer they're the same. To an inexperienced/non-programmer, the latter is evidently clearer. Understanding the former code requires the knowledge that the second else only get checked if both the first two if()s are false. That's fairly basic, but it's not clear without that little extra knowledge.
Athletic Scholarships to universities make as much sense as academic scholarships to sports teams.
The (if.. else if.. else if..) idiom is a "generalized switch". When I first encountered it, I recall being confused a bit, so your point is a fair one. I think the expectation is that the elses should somehow create a nested structure. Yet the code does not reflect a nesting in its layout. If C had some sort of generalized switch syntax like
.. etc ..
... would you agree that it's better than goto? If so, then it's really a minor question of syntax. A novice programmer might be confused by the (if..else if..else if) syntax, but there are lots of much harder problems in programming than picking up this idiom.
genswitch
{
case (cond1)
{
firstthing();
}
case (cond2)
{
some = other + stuff;
}
}
As for the multiple returns versus multiple "else if's", I still prefer multiple "else if's". Being familiar with the idiom, I think it's just as clear. (And with any decent compiler, it will compile to the same binary, so you wouldn't get the minor speed gains from reducing the number of jumps.) The benefit of multiple "else if's" is again, maintainability. Many people, myself included, consider having a single return statement within a function to be a best practice. It's not a rule I live by, but I rarely find that multiple points of return are necessary for flow clarity nor speed (though, in those cases, I will use them). This enforces the idea that structure defines flow, a core concept in structured programming. It makes for easier static code analysis, which helps both compiler code optimization and with programmers tracking down logic/flow-related bugs. Of course, this practice is a lot easier to follow in a language that has exception handling, so you don't have to jump through hoops to signal error conditions.
There are 0x40000000 types of people: those who understand 32-bit IEEE 754 floating point, and those who don't.
Athletic Scholarships to universities make as much sense as academic scholarships to sports teams.
I'm not sure if you're being sarcastic.
There are 0x40000000 types of people: those who understand 32-bit IEEE 754 floating point, and those who don't.