Ask Slashdot: What Are the Strangest Features of Various Programming Languages? 729
itwbennett writes: Every programming language has its own unique quirks, such as weird syntax, unusual functionality or non-standard implementations -- things that can cause developers new to the language, or even seasoned pros, to scratch their heads in wonder (or throw their hands up in despair). Phil Johnson has rounded up some of the strangest — from the + operator in JavaScript to the trigraphs in C and C++ and indentation level in Python. What programming language oddities cause you the most grief?"
a fucking slideshow? (Score:5, Insightful)
Posting a slideshow on Slashdot? Lame. What, was Buzzfeed not available?
Database Identity (Score:3, Insightful)
Infoworld... pass (Score:3, Insightful)
I envision an add filled slideshow with almost no content, and what content is there to be boring and well known so I’ll skip the article.
To answer the question, most of perl seems to be built around bizarre unintuitive constructs that you just have to kinda know about, so pointing out any of that would seem unfair.
In C, the first time I saw the size of elements of a struct specified (i.e. int something : 3) it threw me (and that’s a hard problem to google). It was being used to essentially overlay a struct onto a chunk of memory being received via an interface and extract values, which was actually kinda a cool use of the feature (though a comment woulda been nice unknown dev!).
Some of the type erasure mechanics of Java can be a bit confusing the first time you hit up against them.
The way javascript does dates, and timezones
I dunno, most languages have their weird bits, but I can’t think of anything that is egregiously terrible.
As far as tools, I'd say pacman (Arch's package manager) and git (yes, I'm an SVN fanboy) have the highest concentration of "the hell were they smoking" flags and usage instructions. Pacman seemed to pick it's arguments randomly, and git seems to go straight off the deep end if you want to do anything non-trivial.
Perl: TMTOWTDI (Score:5, Insightful)
Re:a fucking slideshow? (Score:5, Insightful)
I don't even bother with infoworld links any more. It'll be a bunch of slides with a sentence of text, an unrelated image, and ads everywhere (ads on the slides, ads before the slides, an add in the middle of the slideshow, and an ad at the end). Content wise, usually they find one or two interesting things, then fill the rest of the slots with stupid shit everyone already knows.
Re:a fucking slideshow? (Score:4, Insightful)
And not only that, the slides slides to advertisements WHILE YOU'RE READING THEM!
Closed the tab at that point.
Re:a fucking slideshow? (Score:0, Insightful)
Posting a slideshow on Slashdot? Lame. What, was Buzzfeed not available?
second this. I'm not going to click 12 times for a couple paragraphs worth of information.
Re:a fucking slideshow? (Score:5, Insightful)
That was my experience. I opened the page, clicked Next past the intro slide, saw a picture of apples and oranges, some text talking about "+" in Javascript, clicked Next again, it faded out to show an ad that I blocked, and I closed the page. Bunch of crap.
Re:+ operator for string concat? (Score:5, Insightful)
Re:Powershell (Score:4, Insightful)
- sizeof(string) (I may have got the name of the function wrong) returns the length of a single byte rather than the length of the entire string. Who the hell thought that would be a good idea?
Hey, just because you don't know the language doesn't mean it's necessarily wrong. Documentation for sizeof would have told you that it's for telling you the size in bytes of datatypes on a particular system. It's often paired with malloc to allocate memory for something.
The C specification is remarkably lax on the size of its numeric datatypes, too. To the point where eventually a bunch of bit-specific sizes were introduced because the basic versions weren't. example: uint32 is a 32-bit unsigned integer, where as uint is an unsigned integer that's 16-bits or larger depending on the platform.
For that matter, even pointer size changes depending on systems. For instance, it's 4 bytes for 32-bit Intel systems and 8 bytes for 64-bit Intel systems.
Re:Null Terminated Strings (Score:5, Insightful)
I believe none of you actually programmed in C. A string terminated by \0 can be represented by a single pointer and an have any length. You can also easily let the string keep growing (until the allocated memory is finished.) That is the epitome of KISS. If you use an 8 byte character at the beginning then you are limited to a string length of 255. A structure with a length and a string pointer (or a character array) is much more complex and that would reflect in more complex library functions.
C was invented by exceptionally bright people. For a language that was primarily designed to program kernels its remarkably versatile. If you are seeking a language to write administrative applications then you should look further. COBOL back in the days or Java nowadays would suit you better. And yes, there is a difference in programming prowess between kernel / library programmers and application programmers. The latter "just" have to get the business logic going and are allowed to use every trick in the book. The former must be very concise and consider that their code will be used by a huge amount of other programs.
Re:Powershell (Score:5, Insightful)
You know, I kind of hated Powershell until I was forced to use it.
I still hate it. But then I have to write a bash script, and I run across some specific problem while writing a bash script, and find myself thinking, "This would be easier in Powershell." So that's something.
It's really not like Batch files, though. It really isn't that bad of a scripting language.
Platform lock-in (Score:4, Insightful)