Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
Compare cell phone plans using Wirefly's innovative plan comparison tool ×

Comment Re:Next up O'Google (Score 1) 171

The problem is that they don't bring many jobs and the ones that they do are low-skill, low-pay. For example, Apple runs a call centre and a distribution centre in Ireland. Callcentre employees are just reading through a script, the shipping centre is moving boxes around. They're not bringing the engineering and R&D jobs that come with high salaries that translate to higher income tax revenues and knock-on benefits in the local economies from increased spending.

Comment Re:Moronic Subject for an Article (Score 1) 151

Java isn't a bad language. It's a constrained language, but in general it's constrained in a good way. It may make it difficult to write the best solution, but it makes it impossible to write the ten worst solutions and easiest to write a not-too-bad solution to any given problem. It also strongly encourages modularity and provides tools for reducing privilege for parts of a program so that you don't need to trust all programmers in your address space equally. It's certainly not the best tool for all jobs, but if you have a complex business application that you want to support for a long time with relatively high programmer turnover, it's far from the worst tool.

Comment Re:It's not a popularity contest (Score 1) 151

That's a good reason for providing a C interface, but there's no reason not to use C++ (or Objective-C) inside your library. That said, if you provide a C++ interface that uses smart pointers and conveys explicit ownership semantics, then it's much easier to machine generate interfaces for other languages (even for C) that care about memory management.

Comment Re:problems, lol (Score 4, Informative) 151

The real problem with C is that WG14 sat on its fingers between 1999 and 2011. C11 gave us:

_Generic - Useful for a few things (mostly tgmath.h, which I've rarely seen used in real code because C's type promotion rules make it very dangerous, but it was quite embarrassing that, for 12 years, the C standard mandated a header that could not be implemented in standard C). Existing compilers have all provided a mechanism for doing the same thing (they had to, or they couldn't implement tgmath.h), but it was rarely used in real code. Oh, and the lack of type promotion in _Generic makes it annoyingly verbose: int won't be silently cast to const int, for example, so if you want to handle both then you need to provide int and const int cases, even though it's always safe to use const int where an int is given as the argument.

_Static_assert - useful, but most people had already implemented a similar macro along the lines of:

#define _Static_assert(x) static int _assert_failed_ ## __COUNTER__ [x ? 1 : -1];

This gives a 1 or -1 element array, depending on whether x is true. If x is true, the array is optimised away, if x is false then you get a compile-time failure. _Static_assert in the compiler gives better error diagnostic, but doesn't actually increase the power of the language.

And then we get on to the big contributions: threads and atomics. The threading APIs were bogged down in politics. Microsoft wanted a thin wrapper over what win32 provided, everyone else a thin wrapper over what pthreads provided. Instead, we got an API based on a small company that no one had ever heard of's library, which contains a clusterfuck of bad design. For example, the timeouts assume that the real-time clock is monotonic. Other threading libraries fixed this in the '90s and provide timeouts expressed relative to a monotonic clock.

The atomics were lifted from a draft version of the C++11 spec (and, amusingly, meant that C11 had to issue errata for things that were fixed in the final version of C++11). They were also not very well thought through. For example, it's completely permitted in C11 to write _Atomic(struct foo) x, for any size of struct foo, but the performance characteristics will be wildly different depending on that size. It's also possible to write _Atomic(double) x, and any operation on x must save and restore the floating point environment (something that no compiler actually does, because hardly anyone fully implements the Fortran-envy parts of even C99).

In contrast, let's look at what WG21 gave us in the same time:

Lambdas. C with the blocks extension (from Apple, supported by clang on all platforms that clang supports now) actually gives us more powerful closures, and even that part of blocks that doesn't require a runtime library (purely downward funargs) would have been a useful addition to C. Closures are really just a little bit of syntactic sugar on a struct with a function pointer as a field, if you ignore the memory management issues (which C++ did, requiring you to use smart pointers if you want them to persist longer than the function in which they're created). C++14 made them even nicer, by allowing auto as a parameter type, so you can use a generic lambda called from within the function to replace small copied and pasted fragments.

Atomics, which were provided by the library and not the language in C++11. Efficient implementations use compiler builtins, but it's entirely possible to implement them with inline assembly (or out-of-line assembly) and they can be implemented entirely in terms of a one-bit lock primitive if required for microcontroller applications, all within the library. They scale down to small targets a lot better than the C versions (which require invasive changes to the compiler if you want to do anything different to conventional implementations).

Threads: Unlike the C11 mess, C++11 threads provide useful high-level abstractions. Threads that can be started from a closure (with the thread library being responsible for copying arguments to the heap, so you don't have the dance of passing a pointer to your own stack and then waiting for the callee to tell you that it's copied them to its stack). Futures and promises. Locks that are tied to scopes, so that you don't accidentally forget to unlock (even if you use exceptions).

Smart pointers. C++11 has unique_ptr and shared_ptr, for exclusive and shared ownership semantics. unique_ptr has zero run-time overhead (it compiles away entirely), but enforces unique ownership and turns a whole bunch of difficult-to-debug use-after-free bugs into simple null-pointer-dereferences. shared_ptr is thread safe (ownership in the presence of multithreading is very hard!) and also allows weak references.

C++14 and C++17 both made things even better. I've already mentioned generic lambdas in C++14, C++17 adds structured binding (so you can return a structure from a function and in the caller decompose it into multiple separate return values). It also adds optional (maybe types), any (generic value type) and variant (type-safe union) to the standard library. Variant is going to make a lot of people happy.

With C++11, the language moved from being one I hated and avoided where possible, to my go-to language for new projects. With a rich regular expression library, threads, smart pointers, and lambdas, it's now useable for things that I'd traditionally use a scripting language for as well (and an order of magnitude faster when crunching a load of data). In contrast, C has barely changed since the '80s. It still has no way of doing safe and efficient generic data structures (you either use macros and lose type safety, or you use void* and lose type safety and performance). It still has no way of expressing ownership semantics and reasoning about memory management in multithreaded programs. The standard library still doesn't provide any useful data structures more complex than an array (not even a linked list), whereas C++ provides maps and sets (ordered and unordered), resizable and fixed-size arrays, lists, stacks, queues, and so on.

C11 didn't really address parallelism and definitely didn't address reliability or security. Microsoft Research's Checked-C provides some very nice features, but they initially prototyped them in C++ where they could implement them all purely as library features.

Comment Re:Moronic Subject for an Article (Score 5, Insightful) 151

This really is a moronic article. Programming language choice is not about "popular" or "cool" - it's whatever tool gets the job done.

For a hobby? Sure. Otherwise it's about whatever tool gets the paycheck done. Java sucks today and isn't the best tool for any job, yet it dominates the job market. It was a bad tool 15 years ago, and it will be a bad tool 15 years from now, when it will still dominate the job market. And by then, sadly, $10 computers will run Java easily.

C will always be the kernel guy's tool, and those jobs pay nicely, but there will never be very many of them. C++ has faded (despite being a darn good language with the latest standard, too many burned bridges). C# will go down with the Microsoft ship. Will one of the new fad languages have staying power? Maybe. Likely 1 of them will, if not a current one. But fucking Java just refuses to die.

Comment Re: America in one sentence (Score 1) 482

Knighthood only overlapped with religion in a few times and places - it was really just cavalry. "Chivalry" meant "horsemanship" for most of the time the word was current, and only came to mean "and other things knights should do" towards the end.

Human nature doesn't change, nor does the need to protect civilization from assholes. However, combat robots will fundamentally redefine "arms" in the coming decades, and there's no telling what that looks like.

Comment Re:Drones might have weapons. (Score 1) 482

All who fly them low enough deserve the hate. You don't see many people upset about drones flying high enough that you can't see them, or they're just a dot. It's the assholes who buzz animals, peek into upper story windows, disturb your family in your back yard, that sort of thing.that draws the hate.

Comment Re:Case Backwards (Score 1) 482

In some states, it is perfectly legal to shoot someone on your property as long as you say the magic words "I was in fear for my life". Of course, it would be awkward if your target survived the shot and told a different story, but that problem has a straightforward solution.

True story from Texas: my mother bought a gun after a couple of break-ins. She asked the cops what the rules were. The explained that she should make sure he "falls inside the house *wink*" and that he doesn't survive.

Comment Re:America in one sentence (Score 1) 482

In the early days of America, most of the colonies had a law requiring you to bring your gun to church, at least for men, in case something/someone needed shooting that week. Similar laws predate guns, going back, well, as far as we have written records of laws . Many cultures, perhaps most, have required citizens to keep arms in good condition. Heck, mostly what defined a "knight" from roman times to medieval was that your could brings better weapons to the fight.

Comment Re:FAA fines (Score 2) 482

I wouldn't be worried about his fines, I'd be more worried about the consequences of shooting at an aircraft in federal airspace.

That's a federal crime that could net you up to 20 years in jail.

It depends on the state, but somewhere around 50 feet it stops being "airspace" and starts being "your property". Much like you're still trespassing if you climb a tree.

Comment Re: gotta stay paranoid.. (Score 1) 194

All my data is stored on a CPM machine with no networking capability. I hand code all binaries in Assembly Language. Never had a breach.

For a long time, the GAO ran all its internet-facing servers on Netware. I don't think they had a breach during those years. I've always thought that was a clever strategy, if only because the list of people who could hack on the Netware kernel was so small.

These days I'm not sure if there really is a platform you could make work in production but is so obscure that no one bothers developing exploits for it. Maybe a mainframe OS, now that the financials have left mainframes behind? But then, government-funded attackers can develop expertise in whatever oddball system they need to, so maybe those days have passed.

Comment Re:Yes and no (Score 2) 38

It is vital to keep pace with the changing regulatory and technology landscape to safeguard and advance business objectives. Working backwards by identifying and understanding future risks, predicting risks and acting ahead of competition, can make a company more robust

Wow, buzzword bingo in a single quote. Where's Weird Al when you need him? Right here!

This consultant must have been toning it down though. I would have a expected a "proven methodology" and "commitment to quality" in there somewhere, and maybe a "seamless integration" too.

Slashdot Top Deals

"Pull the wool over your own eyes!" -- J.R. "Bob" Dobbs

Working...