A New Release For GNU Octave (lwn.net) 59
Long-time Slashdot reader lee1 shares his recent article from LWN: On November 26, version 6.1 of GNU Octave, a language and environment for numerical computing, was released. There are several new features and enhancements in the new version, including improvements to graphics output, better communication with web services, and over 40 new functions...
In the words of its manual:
GNU Octave is a high-level language primarily intended for numerical computations. It is typically used for such problems as solving linear and nonlinear equations, numerical linear algebra, statistical analysis, and for performing other numerical experiments.
Octave is free software distributed under the GPLv3. The program was first publicly released in 1993; it began as a teaching tool for students in a chemical engineering class. The professors, James B. Rawlings and John G. Ekerdt, tried to have the students use Fortran, but found that they were spending too much time trying to get their programs to compile and run instead of working on the actual substance of their assignments... Octave became part of the GNU project in 1997...
Octave, written in C, C++, and Fortran, soon adopted the goal and policy of being a fully compatible replacement for MATLAB. According to the Octave Wiki, any differences between Octave and MATLAB are considered to be bugs, "in general", and most existing MATLAB scripts will work unmodified when fed to Octave, and vice versa...
When octave is started in the terminal it brings up an interactive prompt. The user can type in expressions, and the results are printed immediately.
In the words of its manual:
GNU Octave is a high-level language primarily intended for numerical computations. It is typically used for such problems as solving linear and nonlinear equations, numerical linear algebra, statistical analysis, and for performing other numerical experiments.
Octave is free software distributed under the GPLv3. The program was first publicly released in 1993; it began as a teaching tool for students in a chemical engineering class. The professors, James B. Rawlings and John G. Ekerdt, tried to have the students use Fortran, but found that they were spending too much time trying to get their programs to compile and run instead of working on the actual substance of their assignments... Octave became part of the GNU project in 1997...
Octave, written in C, C++, and Fortran, soon adopted the goal and policy of being a fully compatible replacement for MATLAB. According to the Octave Wiki, any differences between Octave and MATLAB are considered to be bugs, "in general", and most existing MATLAB scripts will work unmodified when fed to Octave, and vice versa...
When octave is started in the terminal it brings up an interactive prompt. The user can type in expressions, and the results are printed immediately.
Re: Why wouldn't you use numpy? (Score:5, Informative)
Re: Why wouldn't you use numpy? (Score:2, Insightful)
Wow. I did know prejudice against syntax could be built on a form of zealous supremacy.
I mean if you want to pick on syntax why not call our RPG or COBOL? Or even PERL? But nope, gotta hate on one of the most prominent and popular language because white space actually means something. I personally think the design choice was interesting and for anyone who doesn't try to make their code into obfuscated ASCII art, there generally is no problem read or writing python code.
Re: Why wouldn't you use numpy? (Score:2)
*Didn't know. Typo.
Re: Why wouldn't you use numpy? (Score:4, Insightful)
Python is all well and good for classroom examples in CS101 that fit into a single chart. It's not suitable for real code with lots of innate complexity. The way a lot of numerical processing tends to be.
Re: Why wouldn't you use numpy? (Score:3)
I totally agree with your final point. However, my justification would be more about the design nature of python versus a low level language.
Personally the love of my life for languages is C# but I think python gets a lot of flak from bitter veterans in the coding community. It's supremely versatile at empowering non traditional coders to enter our realm. The type of projects covered in Python or Ruby are done by those with a different background and a narrow scope. As things expand, there is always the
Re: (Score:2)
I learned software development on paper.
We did not write BEGIN or END, we skipped that and only indented properly.
It looked exactly as Python looks today.
Python is developed by software developers for software developers, and not for or by hobbyists.
It is an excellent language for scientist, that need readable code to glue together Fortran programs or C++ libraries.
Why the funk would I write a math problem in C++ or Fortran where it take longer to finish than it is worth it?
Re: Why wouldn't you use numpy? (Score:1)
Re: (Score:2)
The math problems I used to implement for energy companies where usually about 30 pages, in words: thirty.
And for that you do not need a God, but only focus. And transform the papers into Code. Actually relatively simply IMHO.
Re: Why wouldn't you use numpy? (Score:1)
Likewise, the issue you mention can be easily handled by a context aware text editor.
In a language like python, it would still be more awkward than typing in a pair of braces and having it indent for you rather than supplying information to tell it how to indent.
And no, the matlab language does not have significant whitespace. Blocks are delimited by "if...end" "for...end" and the like and octave optionally allows "if..endif" and the like to improve readability.
Re: (Score:3)
And no, the matlab language does not have significant whitespace.
Surely it has.
It will not even give you a warning if you provide input like this. Your program will just crash somewhere else when the array size doesn't match or it will produce nonsensical output.
Re: Why wouldn't you use numpy? (Score:1)
Re: (Score:2)
you can indeed do what hankwang posted. the semicolon is recommended but not necessary. screenshot here: https://imgur.com/1Z0VcVJ [imgur.com] or try it yourself on their website: https://www.mathworks.com/help... [mathworks.com] (click "Try this example" and you'll get an interpreter).
Re: (Score:2)
Your example b gives the same in Octave, can you explain what is happening? Is it some sort of parsing issue with the extra space in the first element?
Re: (Score:2)
[1 1] is the same as [1, 1]. +1 is the same as 1. So [1 +1] = [1, 1]. However, spaces on both sides of the plus make it realize it's an expression, not a space-separated list of numbers.
Badly converted code (Score:2)
As things expand, there is always the question of converting the project to something more low level and strongly typed.
Which is, most of the time I've seen this, 1:1 mapped into roughly equivalent high level C++.
Usually by someone who isn't an experienced C/C++ coder, just the somebody who has taken some classes (no pun intened) about the language, often the original python code author.
And that's typically where most of the python "niceties" come to bite you in the arse. Random example:
- Garbage collector, meaning that no single though was done in the original Python. And you end up with C++ code that calls new (or malloc)
Re: (Score:2)
I agree with everything you said. However, this is a crux within the growth of a codebase. At what point should a subject specialist employee a full-time cowboy coder and at what time does a cowboy coder need to be replaced with a more full functioning software development team (CR, QA, etc). I haven't read a lot on this subject in particular besides the mythical man-month but I don't think there is any real clear cut definition to this. Combined with the fact that coding is one of the first places people t
Re: (Score:1)
Re: (Score:2)
I'm not sure what you mean by "a single chart", but in most languages that I've used the guidance is that if a function/method/procedure doesn't fit on a single screen or has more than about three levels of nesting then it's time to refactor and split it up. So if people are programming according to the same guidelines that they use for other languages, Python's whitespace is a non-issue.
Re: (Score:2)
And that rule comes from the time when screens were quite small!!
If I see one who has procedures/methods that are longer than ~30 lines, he is in trouble.
Re: (Score:2)
But you do know about functions or subroutines or however it is called in your favourite language?
Sorry, but if I see you scrolling through code to select a large block of it, you end up in a Umerziehungslager for refactoring quite quickly.
Re: Why wouldn't you use numpy? (Score:1)
Re: (Score:2)
>Function calls are not free. They impose a (tiny) performance penalty in time and in stack space,
One word: inline.
Some languages support it explicitly, some compilers for other languages implement it implicitly, either way it converts the function call to a zero-overhead cosmetic/scoping tool.
And why would you be flipping back and forth to look at different steps? Test your function thoroughly to make sure it does what it's supposed to, and you never have to look inside it again. That's got to be one
Re: Why wouldn't you use numpy? (Score:1)
Re: (Score:2)
In our times function calls cost nearly nothing. And "stack space" is most certainly the least of your problems. Allocating a stack frame is 2 instructions maximum.
And if they are small enough they get inlined, automatically.
And if you have a problem with scrolling: learn how to use an IDE.
Mathlab program are usually not optimized for speed but for finding a certain solution to a problem. And then they get achieved and probably never used again.
Re: (Score:2)
A) Change the conditional to just test for "True"
B) Get a real text editor that lets you quickly select a bunch of text by line number or page scrolling
Python's whitespace rules are a cure for the 75% of programmers that don't give a damn about readability. I'll take that over any minor annoyances.
Re: Why wouldn't you use numpy? (Score:1)
Re: (Score:2)
Where were these people when makefiles were crated?
Re: (Score:1)
Re: Why wouldn't you use numpy? (Score:5, Interesting)
Personally I'm fine with Python's significant whitespace. But I hate, hate, hate 1-based indexing of arrays. Fortran has it, and MATLAB has it, so Octave has it.
I know someone who has used MATLAB for a very long time and gets his work done in it. He juggles the math to calculate array indices without a thought. But I'm still hoping and expecting that SciPy will eventually become The Standard and people will expect math software to be free.
"Pay for MATLAB? What's next, you expect me to pay for a web browser?"
The best thing about MATLAB, and therefore Octave, is that it's set up for matrix math. It's got special operators for matrix-specific stuff.
For example, in MATLAB you can make a 3x2 matrix with this simple expression:
[1 2 3 ; 4 5 6]
The Python is not nearly as nice:
np.array([[1. ,2. ,3.], [4. ,5. ,6.]])
But aside from the special matrix stuff, Python is simply a much better language; and with SciPy Python is now the standard language of science and engineering.
P.S. Comparison of MATLAB features to SciPy:
https://numpy.org/devdocs/user/numpy-for-matlab-users.html [numpy.org]
Re: (Score:1)
it's hilarious people's minds are so bent by the abnormal zero based indexing of arrays only because decades ago some lazy computer weebs arbitrarily chose because they didn't take the effort to have the compiler handle offsets.
Hint, in math, array indexes start at 1. We count things starting at one.
Re: (Score:2)
it's hilarious people's minds are so [blah blah blah...]
Whatever.
Hint, in math, array indexes start at 1. We count things starting at one.
I'm a software developer, and sometimes I do math with indices. It's just easier with 0-based indexing.
Suppose I am writing a binary search and I want to take the current index and find a new index corresponding to half of the current index.
Python:
MATLAB:
If you like the MATLAB version better, please explain to me why. What's
Re: (Score:2)
in MATLAB you can make a 3x2 matrix with this simple expression:
Unfortunately, this easy way of initializing matrices tends to backfire; see my other comment [slashdot.org].
And Matlab's handling of multidimensional arrays gets really awkward if you need to do a linear operation on other dimensions that the default ones. If a and b are 3- and 2-dimensional arrays, you can do this in numpy:
whereas accomplishing the same in Matlab requires crap like this:
Re:Why wouldn't you use numpy? (Score:4, Insightful)
As lovely as python is for prototyping, for specific smaller uses Octave can be faster, even if only slightly.
Take the case of needing to interpolate some data input in csv format, then output to a file.
In python, you read the csv file, feed it to the numpy interpolation function constructor, call the created function with the parameters needed, then output the data.
In octave, you read the csv file, feed the read arrays to the interpolation function complete with the data points needed, then output the data.
I use both, but if something is small and entirely math, octave tends to win out for a simple, functional use. If it is larger or requires integration with other items (in my most common case, connecting to external databases) python is the goto.
Re: (Score:1)
Actually no depending on criteria, Numpy has lower performance.
Re: Why wouldn't you use numpy? (Score:2)
Re: (Score:1)
I do a lot more with matrices than just multiplying them...
Again, numpy is slow in many cases
Re: (Score:2)
I do a lot more with matrices than just multiplying them...
Again, numpy is slow in many cases
Just an example!
Re: (Score:2)
Re: (Score:3)
The biggest selling point of Octave is that it clones MATLAB language. You won't believe how completely computer-illiterate can be people working in technical fields even today. For some, MATLAB can be their first and last programming language. You would be shocked to see even the spaghetti MATLAB code of a lot of well-published tenured professors or even graduate students.
Re: (Score:2)
You would be shocked to see even the spaghetti MATLAB code of a lot of well-published tenured professors or even graduate students.
Why would anyone be shocked?
OK it's not good per-se but software engineering is a discipline in it's own right which takes years even decades to learn well. It's odd that anyone would expect a professional in a different field to also be professional level in a second field. Likewise one wouldn't expect the diagrams to be of the standard produced by a professional illustrator.
Re
Re: (Score:3)
Calling a scientist who is a MATLAB Guru computer-illiterate, is not even an insult, it is so silly it is ridiculous.
You would be shocked to see even the spaghetti MATLAB code of a lot of well-published tenured professors or even graduate students.
Because they do not write software. They solve a problem. When it is done it is done, no need to beautify it.
Re: (Score:2)
Unless you have written maintainable,auditable code, how can you demonstrate that you have solved the problem correctly. Or, if it is demonstrated that you have not solved the problem correctly, how do you fix your code; or do you just start from scratch every time?
Wasn't there a problem within the last two years where some important immunological software was producing incorrect results because it assumed the output from a directory script was sorted by the file names, which were also the dates of the tes
Re: (Score:2)
No idea :D I do not write spaghetti code.
Re: (Score:2)
Apologies; the previous statement was intended with the general you, "some person, some group", not "you, the particular person, specifically".
I know I've written spaghetti code several times; but I like to imagine I at least know that's it's spaghetti code, so once I figure out how to solve the problem, the first thing to do is re-write the code so I solve the problem in the correct fashion.
Re: (Score:2)
Well, my first BASIC programs around 1982 were perhaps a bit Spaghetti. But I soon used an "add on" where you could use named GOSUBs. But around 85 we switched to Pascal. :D
And had only 24 lines big screens, so you automatically started to write "clean code", only problem: variable names where restricted to 8 significant chars (I believe, perhaps I'm wrong), it was UCSD Pascal on Apple ][s perhaps someone remembers more
Re: (Score:2)
matlab shouldn't be used for anything dealing with i/o apart from a standard matrix format or maybe a csv. then you audit the csv generator according to standard practice.
the problems matlab programmers deal with are mathematical and auditing is complete with one-time sufficient coverage of test cases. production matlab code, well, ideally shouldn't exist at all (it's a research and prototyping language) but if it does, it certainly shouldn't be doing ad-hoc database work. that part's your job.
Re: (Score:3)
The biggest selling point of Octave is that it clones MATLAB language.
Speaking as an Octave user, who has never used MATLAB, I dispute that. For me, the value of Octave is in its function libraries, some of which come from MATLAB. I found Octave very useful for signal processing and analysis, because there are library functions for all sorts of specialist stuff I use. It is possible that numpy libraries are available to do the same things, but I have not investigated that.
Re: (Score:1)
The other cool thing is that Octave is open source. I wanted to perform shape-preserving monotonic piecewise cubic interpolation of some data in a program that I intended to publish in C++ under a public domain dedication, and I didn't really know what algorithm to use. I was able to find the fortran routine eventually called by pchip() in Octave's source code and look up the paper referenced in the source code comments.
I ended up using a slightly improved routine from a paper that cited that one, but being
Re: (Score:2)
Because you went to engineering school and they used MATLAB. When you graduated you discovered what MATLAB actually costs, and there was Octave to save you from having to learn anything new.
Honestly, if you're pecking out four liners in Python in a Jupityer notebook or something there isn't much to recommend it over Octave, particularly not if you're used to MATLAB. Python is a much better general purpose language, particularly for writing larger programs, but relatively few people use it that way.
Re:Why wouldn't you use numpy? (Score:5, Insightful)
Because MATLAB had an initial release in 1984 and has been used throughout academia for decades.
Because OCTAVE had an initial release in 1993 when python itself (according to wikipedia) was only 2 years old and no one ever heard of it.
Because NumPy had an initial release in 2006 and MATLAB/OCTAVE had a 22 year head start to build up a base of users. So, your main point about "Python is a widespread and commonly known language already." is actually completely backwards.
MATLAB and therefore OCTAVE is a very commonly known language already.
I'm suspecting you didn't go to university for engineering of any sort and therefore never heard of Matlab or Octave.
heh, Fortran (Score:1)
Fortran still used at that core of many numerical systems. Enjoy your cute python wrapper around Fortran, kid.
Re: (Score:3)
Double that price for the toolboxes. Any practical application of Matlab requires at least a couple of toolboxes. It's still not too expensive considering the quality of software.
Re: (Score:2)
Re: Not really needed (Score:1)
Re: (Score:1)
Are you listening, Mathworks?
Probably not. You pretty much said you wouldn't give them money, so odds are good that their AI filtered out your comment.
Re: (Score:2)
Matlab's killer app is Simulink. If you don't use Simulink then Octave is a pretty good substitute. Something that never gets much love is Scilab, which does have a sort of simulinky thing that I have never got to grips with https://www.scilab.org/softwar... [scilab.org] . Scilab's syntax is subtly different to Matlab/Octave, so I can't program in Scilab and Matlab at the same time, so since I have to use Matlab at work, I use Octave at home.