- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Notes is more than email. Very useful when creating workflow type applications.
Admin
You don't need a @Switch operator.
@If works with multiple conditions (up to 99) without nesting
@If( condition1 ; action1 ; condition2 ; action2 ; ... ; condition99 ; action99 ; else_action )
Admin
ROTFL, have you sent your letter to Santa yet?
Notes is so old, most of you weren't even around yet. And it's a platform, not a programming language. And what you see here is it's oldest programming thingy (note: not language), called formula language, taken straight from Lotus 1-2-3 some 20 years ago and put into Notes (also some 20 years ago). And they kept it in there for compatibility reasons, only they added LotusScript (VB-Clone) and Java a while back. And trust me, the WTF is not the formula lang, it's the so called programmer.
Admin
Don't blame the language...WTF like this could be done in many other languages as this forum has shown time and time again.
Admin
Not any dumber that using braces for that matter.
Look at it that way: everyone indents code. Not indenting code is not only stupid, but annoying.
Indentation is defined via block structures, braces and the like therefore become redundant with indentation.
That's how Guido saw it, and that's how many Pythonistas see it. Now if you don't like it you don't have to use python
God, seriously, not only is converting space to tabs and tabs to space trivial but tools like Pylint or Pychecker can take care of the automated validation of your indentation levels for you...
Uh... right... I realize that it'll probably hurts your feelings but everyone who's used Python for more than a day thinks you're wrong.
yes and? A brace error can change the behavior of the code as well, and an indentation error in whitespace-insignificant languages can very well change the meaning of the code (to the programmer), making debugging a damn pain.
Admin
Only if you mix tabs with spaces. Besides, in Python tabs stops are assumed to be at intervals of 8 spaces, so it's not as if there isn't a right and a wrong setting.
I disagree. Intendation guarantees that block are visibly rectangular: they start and finish on a line break, and the statements within the block start at the same column on a line.
In fact a lot of obfuscated C code takes advantage of the illegibility of brace-delimited blocks.
Just like a simple brace error in languages which rely on braces.
Admin
Ignoring the preprocessor, AFAIK one could write C/C++ program completely in one line
(altough if you're paid by the line this would be rather dumb ...)
Admin
Not true. I like python, but indentation errors are harder than brace errors.
In languages with braces, if there is a brace error your compiler catches it right away, and you add the missing brace and you are good to go.
In Python the same error means you have to go through the entire code to decide what needs to be reindented.
Often I have had code like:
if foo:
bar():
else:
baz()
Then when I realize that the whole thing needs to be in a check, and my re-indent ends up as
if blah:
if foo:
bar()
else:
baz()
Note that else case should have been indented to line up with the if foo, but I didn't do the indent right (every editor I've used will not help here). In complex code this can be a big problem. It gets worse if blah and foo are both expected to be true 99% of the time, when the unit test fails weeks latter I'm not longer sure how to code works so I have to look closely. The deeper you nest things the worse it is. (Though I agree deeply nesting is bad)
The difference is slight, but the advantage is to braces. I have not had this type of problem.
Admin
It's rather difficult (though not impossible) to write a C/C++ program without the preprocessor; and even without the preprocessor,
the // style comments also rely on linefeeds.
Admin
Not at all, most languages use a semi-colon as an end of line marker. This has the advantage of allowing you to have one line of code spanning several lines to prevent it becoming unreadable.
Admin
You both are cracked. Flaming each other over which is better Notes vs. Outlook/Exchange is like say which pile of sh*t tastes better, one with corn kernels or one with peanuts!
Admin
True, but you always have /c comments/
And as for C++, i wouldn't be too surprised if sometime in the near future a language equivalent of #include was introduced to the language.
something like
using "filename.hpp";
Admin
Difference being, having a visible delimiter such as a brace or keyword makes it a little easier (for me, anyway) to find the mismatch by inspection.
As far as Notes goes, I had to womp up a simple script to grab statistics from a defect database using the Formula language thingy. Not an experience I'm anxious to repeat. Of course, Notes in general isn't an experience I'm anxious to repeat. They All Suck, but Notes sucks just a hair worse.
Admin
It's been said already but... NO. In any of the C languages, linefeeds do not impact program logic, except for the // comment. This is one of the reasons I mainly use /* */. I think having whitespace, tabs, or linefeeds control program logic is a very bad idea for any language. Not all operating systems even have the same definition for the end of a line (crlf vs lf). The fact that a tab represents a large space just makes it difficult in a monospace world of code. Python is a great language, but for these reasons I have yet to actually use it. So sue me if I want my code too look like:
Image.ReplaceColors(
((System.Drawing.Color)arguments[0]),
((System.Drawing.Color)arguments[1]),
((System.Drawing.Color)arguments[2]));
Admin
Oh, c'mon. I've used Notes for nearly 10 years now and have never seen or had a problem with most of what you're talking about. Seriously, the people that seem to have an unnatural hatred for all that is Notes seem to have the most bizarre problems that no one else seems to have ever encountered. Most of the problems you seem to have with Notes are usability issues that can be resolved through training. Other items, such as a crash requiring a reboot of Windows (actually, it depends on how and where the app crashed) are annoying but there are tools available to fix the problem without a reboot.
The only complaint I ever had about Notes is that you don't use F5 as the refresh key as every other application known to mankind does. But you know what? Once you get over that, it's really not a big deal.
Admin
<font size="1" style="font-family: verdana;">
<font size="2">Usability issues should be resolved through user interface changes, not training. If it worked as expected, the training wouldn't be necessary, now would it? (Hmm, maybe this is a scheme to keep "Notes consultants", or whatever they're called, employed.)</font>
<font size="2">The "tools" should be the developer's debugger and code editor.</font>
</font>
<font size="1" style="font-family: verdana;">
</font><font size="2" style="font-family: verdana;">If that's your only complaint, then you must have an incredibly high tolerance for pain.
</font>
<font size="2" style="font-family: verdana;">
</font>
Admin
And here I thought Perl was write-only.... damn!
Admin
Yeah, this is one WTF of a script, but judge the language itself in the proper context! Sure, the language looks funny to real programmers, and especially so when you're looking at formulas written before Damien's re-write of the language, and even more especially so when you look at code produced by amateurs -- but it was the amateurs more than the real programmers who were the target audience for the language in the first place.
A little perspective here. This is a language designed in the late 80s to run on 386 machines with 2 MB of RAM running OS/2 and Win16. It was designed to allow very simple scripting in specific contexts, like providing a default value or a selection list for a field on a form, validating input for a field, or writing simple agents for making changes to existing documents (analogous to "records" in most other databases). The original developers (including Ray Ozzie, and unless you've been living under a rock these past few months you know who he is and you know that Bill Gates has considered him one of the top few programmers in the world for a long time) wanted a powerful list processing language, and they got one. They also had some specific ideas in mind that provided ways to simplify the implementation of the lanuage. One idea was that it didn't need sorting in the language, because if you wanted to sort something you built a view (analogous to an "index") that would do the sorting for you and your could would just read the sorted data. Another idea was that it didn't need looping, because there was an implied loop in agents designed to run the same sequence of instructions on "all documents" or "all selected documents". Another idea was that the syntax should look familiar to "power users" (which in those days meant people who wrote their own spreadsheet formulas), instead of looking familiar to programmers. Developers soon proved that these assumptions were short-sighted. There were applications that people wanted to build in Notes that really did need sorting, and really did need looping, and it really needed a scripting language that looked and worked like other languages programmers were used to. And guess what? Lotus added a BASIC-derived language to the product in addition to the macro-style formula language, and smart programmers found ways to do sorting and looping in the formula language anyhow, despite the limits of the language. The sort mechanism based on Notes unique list processing capabilites, though very strange to look at and limited to lists of no more than a few thousand entries, was actually one of the most ingenious pieces of programming I've ever seen. Loops were accomplished, though only in certain circumstances, through indirect (i.e., "ping-pong") recursion. And while developers certainly wanted an imporved language, IBM had some different needs -- like an absolute requirement that maintaining100% backward compatability with code that had to run withiin the constraints of late 80s and early 90s machines as an absolute requirement. For a very long time -- longer than many of today's popular scripting languages have been around at all, IBM just didn't dare try to do the total overhaul of the language's parser and execution engine that was needed to add looping. Not until just a few years ago and Damien went and did it -- adding looping, as well as a construct more coimpact and more intuitive than @Subset() for accessing list elements, along with a wide variety of other language improvements -- and he did it with a top-to-bottom rewrite of the the entire language implementation while still maintaining compatability with a huge installed base of code.
And finally, let me ask you this: how many other application scripting environments exist today that (a) have an installed base of more than 100 million users, and (b) can run scripts that were written more than 15 years ago to run on 386s running OS/2, and get the same results today running on contemporary Windows machines, contemporary Macs, and (real soon now) Linux, too?
Admin
That's a good idea. Next time I need to perform maintenance on one of the bunch of python scripts that are used everuwhere here, I'll just tell my boss to stuff it.
Yeah. So instead of just using whatever text editor you have at hand to modify the script, you have to use a specific tool. Or how to turn a 30 seconds job into a 5 minutes one.
I don't think that my feelings are the one that got hurt there. I just stated an opinion. You have the pretense to know what a large group of people (which does include me) thinks. It may hurt your feelings, but not everyone using python for more than a day is bound to fall in love with it. It is true for any language or technology.
I did use python in various contextx, both professionally and as part of my hobbies, and while I wouldn't qualify myself as having a very long experience of it, I definately did more than skim the surface.
Admin
I think what he meant is that in a functional language loops are not allowed and considered exactly as bad as goto because in fact they are just conditional non-deterministic gotos what makes them probably even worse.
So in languages like Haskell, OCaml and so on you use recursion wich is damn cool if you got it once.
One example woud be:
allNumbersDownFrom val
| val == 0 = []
| otherwise = val : allNumbersDownFrom val-1
here : is "item to front of list" concatenation and the |s are some kind of switch statement, but on a higher level.
"allNumbersDownFrom 6" would return [6,5,4,3,2,1]
You also have syntactic sugar to simplify it most of the time. This for example
fiterAndApplyFunction function list filterFunction = [ function item | item <- list, filterFunction item ]
does filter all "item"s of the "list" by checking if "filterFunction", when called with the value "item" returns true, and then applys function to them, returning a new list.
Admin
What about functional programming languages? Recursion is the goto of functional programming. No loop => No problem.
Admin
Linefeeds are also important in C for the pre-processor. #define lines end with the line, unless you use a \ to continue onto the next line.
Python supports the same thing \ can be used anytime you want to continue a line to the next. Python is also smart enough to recognize ( start a block, and will allow lines to continue as you want inside parentheses. Your code in python would look much the same, except you don't need the explicate casts, or the semicolon.
The following is how your code could look in python.
Image.ReplaceColors(
arguments[0],
arguments[1],
arguments[2])
Though I suspect the code could take a list instead of 3 arguments, so your might have
Image.ReplaceColors(arguments)
Course in C++ you can make arguments a std::vector and get the same thing, and C++ does overloading better.
There are things not to like about python, but the ones you started are not among them.
Admin
AFAIK, you can use braces in Python. Get over it already and complain about something more important.
Admin
While the code shown here is truly horrific, the language isn't actually so bad on the scale of things.
Here's a sample of the PoS language called "Plain English" I have to maintain an ancient legacy app in. The language was developed in 1981 or so for DOS PCs then ported to multi-user Microsoft Xenix (shared ISAM files). It dead ended in about '84 with the death of the company. Nearly identical languages (this one is a rip-off) live on, to my horror, as win32 GUI database-integrated RADs. I have the 1983 implementation of Plain English running in a compatibility kernel personality on SCO OpenServer 5.0.5, which is another horror story in and of its self. The developer wrote the app in 1991 - on a RAD/DB tool EIGHT YEARS DEAD - because he didn't know anything else.
CONVERT DATE is an object verb,
1 Does CUT OBJECT after "."
2 and IF HEAD ^ "@"
do RETURN
3 and CUT OBJECT after 2
4 and COPY HEAD to TEMP DAY
5 and CUT TAIL after 1
6 and CUT TAIL after 2
7 and COPY HEAD to TEMP MONTH
8 and CUT TAIL after 1
9 and COPY TAIL to TEMP YEAR
10 and JOIN TEMP DAY in front of "."
11 and JOIN HEAD in front of TEMP MONTH
12 and JOIN HEAD in front of "."
13 and JOIN HEAD in front of TEMP YEAR
14 and COPY HEAD to OBJECT
15 and CUT OBJECT after "@"
Admin
... is this post editor from hell. Did you guys pick it because it fit in with the theme of the site, or did it just happen to work out that way? For us old-timers, I don't suppose there's any chance of a nice simple HTML edit widget with a preview button?
This site is appreciated, but I suspect it'd be all the more so with a little editor love.
Admin
Hey Craig, right underneath the edit box is a HTML tab widget thingy. Let me post a nice link as an example: porn. I think it messes up code tags, lemme try:
this is code
BTW I love your English program, it's the absolute worst programming language I've ever seen, easily outdoes COBOL multiplied with INTERCAL.
Admin
OK so that was an attempt at a piece of <code>, <pre>, and then <code><pre>.
The preview button had to be killed because it utterly messed up people's posts. You may use the power combo of notepad + your browser as a preview facility ;-)
Admin
Braces are not used for defining blocks in the snaky language.
So yeah, technically, you can use braces.
Admin
Oh ... my ... god! I was going to come to the defense of the @If operator and say, "Oh, that's just the Oracle DECODE operator." But why would it be limited to some set number of conditions? And if it is, why 99 instead of 32, or 256?
*Shudder*
Admin
That doesn't quite look like Ocaml, so I guess it must be Haskell. Unfortunately, the way you've written it, it isn't tail recursive. That's the PITA with languages that use recursion for looping. If you write something nice and cleanly, it isn't fast because it isn't tail recursive so the compiler can't do TCO on it. So then you end up writing:
allNumbersDownFrom val
allNumbersDownFromImpl val []
allNumbersDownFromImpl val list
| val == 0 = list
| otherwise = allNumbersDownFromImpl val-1 (val : list)
Now it's fast, but it isn't so nice and clean any more. *Shrug*
Admin
Last week I had thousands of XML files with different structures to process and format into HTML. There was no DTD. I looked at various ways of doing it (XSL, XMLC, Sitemesh, WebObjects, LotusScript, even Javascript)... It looked like it was going to be a complicated nightmare no matter which option I went with (XML started to seem like an abomination). In the end I decided to look at doing it in the Notes formula language. I'm no @formula guru, but it was easy and fast to do it using @abstract, @right, @left, and @ReplaceSubstring. And that was in R5 without all the additions added in R6. People seem to have really lost sight of the fact that Notes was devised to process text.
Admin
Again, consider this in the context of a macro language rather than as a Turing-complete programming language (although Damien's rewrite brings it there). I have never had occasion to use anything like a "substantial fraction" of the 99 possible conditions. Frankly, I can't imagine a situation where I would have to go anywhere near the limit -- there's almost always a better way to code conditionals in any language than to run a single-layer if/elseif/else with 100 or more forks or a switch with 100 or more hard-coded conditions (prior to optimisation). That kind of code makes me shudder.
As mentioned in the original post, the WTF here is that the whole thing could have been replaced with the fieldname. (The syntax, by the way, would have been: exp_newlocation. No quotes, no =, no @, nothing added.) The Notes Formula Language is deceptively powerful if used with a bit of thought. For instance, to create a set of links on any Domino web page (Notes document in disguise, if you will) to PDFs and only PDFs from an unknown number of file attachments of unknown types:
list := @Trim(@LeftBack(@AttachmentNames;".pdf"));
@If(list = ""; @Return(""); "");
list2 := list + ".pdf";
"<a href=\"/" + @WebDbName + "/0/" + @Text(@DocumentUniqueID) + "/$File/" + list2 + "\" class=\"pdfLink\" title=\"Download Acrobat file " + list2 + "\">" + list2 + "</a>");
No looping required, and the only if is there to prevent an empty link tag from happening if there are no file attachments with the .pdf extension. If there are any PDFs attached, whether one or dozens, an individual link for each will be produced by that one little bit of code.
That's the sort of context in which Formula Language is used. There are other languages for other contexts.
Admin
Dammit -- that last line should have read:
"<a href=\"/" + @WebDbName + "/0/" + @Text(@DocumentUniqueID) + "/$File/" + list2 + "\" class=\"pdfLink\" title=\"Download Acrobat file " + list2 + "\">" + list2 + "</a>"
(Pulled from a longer routine and poorly edited by an idiot during posting.)
Admin
Why buy a product that has is an Apps Server, Email, Web Server, Supports remote working, Easy Access to Relational Database's, 3 fully functional languages (Formula's (a pain to write but for simple stuff is great!), Lotus Script and Java (If Java is so crap why did MS base C# partly on it?) out of the box
- or -
Buy lots of boxes from MS to do the above? (ps: They still havent got a good remote working tool) and of course lots of servers to install all those boxes on to?
A grizzled Lotus Notes, Relational Database, VB.Net, C# and Java developer
Admin
Luckily, in Haskell, the list is contructed lazily, so TCO ends up being much less important than deforestation.
Admin
Nice to see why one can only have 50 rules that actually do something...