Page 6 of 7

Re: Programming Experience

Posted: Mon Mar 27, 2017 12:10 am
by Dinosawer
Well those velociraptor attacks are annoying Image More seriously, it makes your program hard to read for other people (or yourself a few months later) and you can do everything without them more clearly

Re: Programming Experience

Posted: Mon Mar 27, 2017 12:20 am
by Flatfingers
That's true for modern high-level languages; GOTO just isn't necessary. Having a way to branch to one of three labels on -1, 0, or 1 was just a neat little feature of FORTRAN.

Throwing hate at the GOTO is a little silly, though, since it's still a required feature of machine code and assembly language. This of course was the worst offender in that area. (And oh, look, there's Niklaus Wirth again.... :ghost: )

Re: Programming Experience

Posted: Mon Mar 27, 2017 12:26 am
by Dinosawer
Yeah, I don't hate it but it makes me even less fond of my predecessor when I find it in C++ in a function of a couple thousand lines :ghost:

Re: Programming Experience

Posted: Mon Mar 27, 2017 1:37 am
by JanB1
Graf wrote:My school's entire freshman engineering program is dedicated to MATLAB.
Gotta love MATLAB. You can do some cool shit with it. :thumbup:

Flatfingers wrote:That's true for modern high-level languages; GOTO just isn't necessary. Having a way to branch to one of three labels on -1, 0, or 1 was just a neat little feature of FORTRAN.

Throwing hate at the GOTO is a little silly, though, since it's still a required feature of machine code and assembly language. This of course was the worst offender in that area. (And oh, look, there's Niklaus Wirth again.... :ghost: )
Totally agree on this one. I remember my batch-coding days where I had to use GOTO EVERYWHERE.

And in PLC programming jumps are still regularly used.

Re: Programming Experience

Posted: Mon Mar 27, 2017 9:01 am
by Scytale
Also a remark, Fortran used to be exceptionally fast for numerical purposes, possibly the fastest. My understanding is only recently did C++ 'catch up' in this area. But IANACS

Re: Programming Experience

Posted: Mon Mar 27, 2017 1:02 pm
by Graf
JanB1 wrote: Gotta love MATLAB. You can do some cool shit with it. :thumbup:
It is pretty cool, but now I always have to stop myself from starting my array indecies at 1 instead of zero, as well as dealing with the occasional weirdness of going out of bounds by 1 while I am programming in C or C++. It can be pretty annoying.

Re: Programming Experience

Posted: Mon Mar 27, 2017 1:52 pm
by JanB1
Graf wrote:
JanB1 wrote: Gotta love MATLAB. You can do some cool shit with it. :thumbup:
It is pretty cool, but now I always have to stop myself from starting my array indecies at 1 instead of zero, as well as dealing with the occasional weirdness of going out of bounds by 1 while I am programming in C or C++. It can be pretty annoying.
Well, the cool thing is when you can define the starting and end point of your array freely. So, the array starts at 11 and goes up to 35 for example. THAT is a real mess up. Oh, and UDTs (user-defined types, so you can define a data type by yourself) of course too. :D

Re: Programming Experience

Posted: Mon Mar 27, 2017 3:25 pm
by Graf
JanB1 wrote: Well, the cool thing is when you can define the starting and end point of your array freely. So, the array starts at 11 and goes up to 35 for example. THAT is a real mess up. Oh, and UDTs (user-defined types, so you can define a data type by yourself) of course too. :D
That does actually sound pretty cool! I don't really know much about all the stuff you can do with MATLAB, as all I have been told is that it is 'useful'.

Unfortunately, my professors aren't programmers, so most MATLAB assignments are akin to "Write a 'For' loop and an 'If' statement to solve this contrived problem." It would be much better if they had a dedicated MATLAB class that freshman are required to take, rather than inconsistently ham fisting MATLAB into the regular courses. Several of my friends have their professor only teach MATLAB instead of the drone project that is supposed to be the focus of the curriculum. Some of my other friends have professors who haven't mentioned the language once. Most of my fellows in CpE, EE, and CS hate MATLAB, as all they have done with it are the basic assignments that do not demonstrate what MATLAB is good at, and instead often demonstrate what MATLAB's weaknesses are instead. :|

Re: Programming Experience

Posted: Tue Mar 28, 2017 12:23 am
by JanB1
Graf wrote:
JanB1 wrote: Well, the cool thing is when you can define the starting and end point of your array freely. So, the array starts at 11 and goes up to 35 for example. THAT is a real mess up. Oh, and UDTs (user-defined types, so you can define a data type by yourself) of course too. :D
That does actually sound pretty cool! I don't really know much about all the stuff you can do with MATLAB, as all I have been told is that it is 'useful'.

Unfortunately, my professors aren't programmers, so most MATLAB assignments are akin to "Write a 'For' loop and an 'If' statement to solve this contrived problem." It would be much better if they had a dedicated MATLAB class that freshman are required to take, rather than inconsistently ham fisting MATLAB into the regular courses. Several of my friends have their professor only teach MATLAB instead of the drone project that is supposed to be the focus of the curriculum. Some of my other friends have professors who haven't mentioned the language once. Most of my fellows in CpE, EE, and CS hate MATLAB, as all they have done with it are the basic assignments that do not demonstrate what MATLAB is good at, and instead often demonstrate what MATLAB's weaknesses are instead. :|
Yeah, it's called a "struct" and is pretty common in PLC programming. It's really useful. You can, for example, define a struct for a specific purpose that contains floats, ints, bools and arrays. So you can feed that struct to a function, and within the function read the values of different sub-variables (inside the struct) via dot-notation.

We used MATLAB for control unit simulation in our control engineering courses. That was really cool. We did everything, tested the effects of the proportional, integral and derivative part of controllers and tested different variants of controllers. Some worked really well (PI-Controller) and some were absolutely useless (PD-controller). In the end, we tested PID-controllers and figured out how to calculate the different configuration values for them. And in the end we did some Fuzzy-logik and experimented with the extremely fast Fuzzy-Controller. THAT was interesting.

Re: Programming Experience

Posted: Tue Mar 28, 2017 12:25 am
by Dinosawer
JanB1 wrote:
Yeah, it's called a "struct" and is pretty common in PLC programming. It's really useful. You can, for example, define a struct for a specific purpose that contains floats, ints, bools and arrays. So you can feed that struct to a function, and within the function read the values of different sub-variables (inside the struct) via dot-notation.
That's a thing in quite literally any modern programming language since C :ghost:
And in object-oriented languages you can even define "structs" (which are called objects and classes) that have their own functions. :)

Re: Programming Experience

Posted: Tue Mar 28, 2017 12:27 am
by JanB1
Dinosawer wrote:
JanB1 wrote:
Yeah, it's called a "struct" and is pretty common in PLC programming. It's really useful. You can, for example, define a struct for a specific purpose that contains floats, ints, bools and arrays. So you can feed that struct to a function, and within the function read the values of different sub-variables (inside the struct) via dot-notation.
That's a thing in quite literally any modern programming language since C :ghost:
And in object-oriented languages, you can even define "structs" (which are called objects and classes) that have their own functions. :)
Yeah, I knew about the objects and classes and how you define them. And that you can add different variables and even functions to them. But I always had the feeling the UDT in PLC programming were easier to handle and make.

Re: Programming Experience

Posted: Tue Mar 28, 2017 2:06 am
by 0111narwhalz
I poked around for a few seconds, and I don't really see how MATLAB's user-defined types are any easier to use than, say, C#'s.

Code: Select all

//Defining and using a class in C#
class Example
{
 //Instance variable
 byte a;
 //Static variable
 static uint b = 0;
 
 //Constructor (but you could just as easily put any other function here)
 public static Example(byte c)
 {
  a = c;
  b ++;
 }
}

class Driver
{
 public static void main()
 {
  Example e = new Example(2);
 }
}
:eh:

Re: Programming Experience

Posted: Tue Mar 28, 2017 3:20 am
by JanB1
0111narwhalz wrote:I poked around for a few seconds, and I don't really see how MATLAB's user-defined types are any easier to use than, say, C#'s.

Code: Select all

//Defining and using a class in C#
class Example
{
 //Instance variable
 byte a;
 //Static variable
 static uint b = 0;
 
 //Constructor (but you could just as easily put any other function here)
 public static Example(byte c)
 {
  a = c;
  b ++;
 }
}

class Driver
{
 public static void main()
 {
  Example e = new Example(2);
 }
}
:eh:
Nah, not in MATLAB. In MATLAB they are difficult to define. But PLC programming is not MATLAB. It's...PLC programming. :lol:

But yeah, you're right. It's easier than I remember to define structs in other languages. Should have looked it up again. I apologize. It was a stupid point, when I think about it, it should have been clear that you can define your own data types in other languages as well, I'm not unfamiliar to OOP, but never really used it in other languages, because I always got told it is easier and more compact, but slower for my uses...

Re: Programming Experience

Posted: Tue Mar 28, 2017 8:07 am
by JanB1
Just gotta...drop this here. Because I thought it was really funny and fitting.

https://imgur.com/gallery/9bp5R

Re: Programming Experience

Posted: Tue Mar 28, 2017 8:14 am
by Talvieno
Fake and old, but funny, yes. :P