1. Trouble with the game?
    Try the troubleshooter!

    Dismiss Notice
  2. Issues with the game?
    Check the Known Issues list before reporting!

    Dismiss Notice

Your Personal Micro Blog(s)

Discussion in 'General Discussion' started by tdev, Jan 24, 2015.

  1. SixSixSevenSeven

    SixSixSevenSeven
    Expand Collapse

    Joined:
    Sep 13, 2013
    Messages:
    6,960
    Writing a stack class in languages that dont already support one is often a decent programming exercise. Just so happens to be that an "array" in javascript is actually a list not a true array and natively supports push and pop methods.

    Dunno if the C# list class supports push and pop so I wrote my own fixed size stack for that once. Was limited to storing doubles when I should have used generics though.
     
  2. aljowen

    aljowen
    Expand Collapse

    Joined:
    Oct 21, 2012
    Messages:
    1,677
    Well, due to the school i go to the language that i know best is vb.net, but i do also know a bit about c# since i have played around with it in software such as Unity.

    In vb.net Arrays are actually semi dynamic, you just need to use "ReDim Preserve ArrayName(x)" , that will allow you to make ArrayName become length x while preserving the data that is stored inside it. In the .net framework there are lists, i have never used one but to my knowledge these are dynamic. In C#.net arrays are static, so you would use a .net list instead. I can only assume that C# must have some sort of list system built into it without the need of the .net framework. But i have absolutely no idea about that.
     
  3. SixSixSevenSeven

    SixSixSevenSeven
    Expand Collapse

    Joined:
    Sep 13, 2013
    Messages:
    6,960
    Chances are if its anything like the AQA syllabus its a case of the examiners being scared of new stuff.

    Under AQA I think the language choices were Python, VB.net and I think it was Pascal as the last choice. Many of the examiners are old and from the BASIC era, they have a misguided perception that Visual Basic .NET is simply BASIC compiled for modern machines rather than being a bastard lovechild of C# with BASIC syntax (BASIC being a language notorious for instilling bad practice into novice developers). Python, everybody loves python, except dummiesman but then he's misguidedly glued to lua which is also notorious for instilling bad practice into novice developers. Pascal is just a joke these days and literally only exists for legacy applications, absolutely no use these days.

    When I did AS level, my tutor decided to go with Python as pascal is useless and he hated microsoft so didn't want to pay for visual studio licenses (unaware that as a microsoft partnered school we can get free licenses).
    Python has something that is both an Achilles heel and something I think is good for the newcomer, forced indentation, you quickly get used to indenting your code properly whereas I still see several fellow students at uni with no indentation whatsoever. Python is also very good at forcing getting used to the idea of local vs global variable scope (again dummiesman I recall saying it was impossible to use a global variable in python which made it bad, a - false, it is possible, it just isnt so simple as vb.net or lua (which hideously defaults to global scope), b - global scoped variables are considered very poor practise).

    Our AS tutor actually left mid way through the year. We got a replacement tutor in who had to learn python in order to continue teaching us (the school decided it was unfair for us to switch languages mid way through a term). For the 2nd year he then taught us VB.net as it was still on the exam board and he was a C# developer by trade (although apparently java was his first language he learnt). The school also decided that it was unfair that we sat a coding practical in python when the tutor prior to joining mid term didnt originally know python (although I bumped into him recently, apparently he now uses python quite regularly for quickly trialling ideas), they funded for us to do a resit in VB.net during A2, worked out nicely for me as I went from a high B to an A*, no revision required really as the exam was a may/june one and we'd have an entire year of VB.net behind us plus a years programming experience in python before that. I failed other subjects at A2 and retook my entire A2 year, actually did coursework in C# instead of VB.net (AQA have no language restrictions for coursework). All the VB.net lessons during the resit year I opted to do in C# instead. I much prefer C#



    List class in .NET i have used a few times. It is dynamic in size, not dynamic in datatype though. I just don't think it has a .pop method on it (it has .add for a stack push) so I wrote an actual stack class as an exercise.
     
  4. Goosah

    Goosah
    Expand Collapse
    Global Moderator
    BeamNG Team

    Joined:
    Aug 30, 2013
    Messages:
    790
    I enjoyed the RPN talk. My dad is a math prof and still rocks the same HP 15C(?) that he has had for 20 odd years. That mechanical calculator is awesome too, would be an awesome gift idea for him.
     
  5. aljowen

    aljowen
    Expand Collapse

    Joined:
    Oct 21, 2012
    Messages:
    1,677
    We are allowed to use whatever high level language we like (within reason, it has to be one of the more major ones). We are taught vb.net because that is what our teacher knows, we are allowed to use whatever language we like but we cant receive as much support from the teacher if we use a language that they do not know very well.

    In vb.net a variable is local if it is declared inside a sub and global if it is declared outside a sub. I dont really see the issue there? (especially since we get marks for showing that we can use both global and local variables)

    Its kinda sad that i am making a room booking system that stores passwords and things like that for the school IT department and their list of requirements did not have a single security focused requirement. So the whole database is stored in plain text, usernames, passwords and email addresses, the whole lot (so if anyone uses the same password for the room booking system and email they are screwed). Then to make my life easy and satisfy exam board criteria i am storing the username of the user who is currently logged in both globally and publicly. I also imagine that something like cheat engine would totally be able to grab the users password while the program is using it. The database isn't even password protected, its stored in the same folder as the exe file too. So they wouldnt even need to use any of the above, they just need to double click the database and just read the records, or even export them to a nicely formatted text file for future reference...

    Never mind the thought that keyloggers would also be very effective since the computer that it would be installed on would be easily accessible to anyone.

    At least i wont have to put a security backdoor in the program for the government since they can just walk directly through the front one, just like anyone else, including students :p

    I feel bad whenever i think about the security of this program. There is one IT admin at school who follows all the nsa stuff and is really into security and the need to encrypt things, i can often have a bit of fun mentioning how secure the program is to him.

    The thing is that the school has said that if it works they will use the system since they dont have any room booking systems in place at the moment. Over my dead body is the school using that system unless they implement at least some security measures. Just no, all of the no. Hell no. Its bad.
     
    #105 aljowen, Feb 3, 2015
    Last edited: Feb 3, 2015
  6. SixSixSevenSeven

    SixSixSevenSeven
    Expand Collapse

    Joined:
    Sep 13, 2013
    Messages:
    6,960
    Basically using a global variable is considered poor practise and should be reserved only for where required.

    VB.net scoping is pretty standard. Lua is default to global. Python handles it similarly to VB.net. Only thing that changes in python is the syntax for actually getting a local variable to be global, in a function:
    Code:
    def printName():
        global name
        print name
    name = "Susan"
    printName()
    
    quick and dirty. But global name will retrieve the variable name and bring it into your current scope. According to dummiesman once, impossible to do in python and yet I've just done it.


    However the above is poor practise, the below would be considered far more suitable
    Code:
    def printName(nameToPrint):
        print nameToPrint
    
    name = "Susan"
    printName(name)
    

    Not sure precisely how its done in VB.net but something I will say I have used in C# is passing an object by reference, that should normally be avoided too as it is effectively using a global scope again. In the above python snippet, if nameToPrint in the printName method was a reference (never checked if python supports passing values as references) then nameToPrint within printName would actually be using name as a global instead of a unique local variable. Can be useful at times, but mostly a thing to avoid.

    - - - Updated - - -

    Look up using SQL databases with VB.net, run one remotely with password access. Hash passwords.
     
  7. aljowen

    aljowen
    Expand Collapse

    Joined:
    Oct 21, 2012
    Messages:
    1,677
    But i wouldn't get marks for it since it doesnt contribute towards acheiving the goals of the software. While the software as it is makes me cringe i have had way to many problems with the sql as it is. The sql database stuff should be easy but due to conflicts between everything under the sun it totally isn't. We use Microsoft Access for our databases for the same reason that we use vb.net, note that i do not own Microsoft Access, so i can not add extra fields or tables at home, i would have to do that in school. But i do use a bit of software called MDB viewer which is pretty neat and allows me to get most stuff done.
    But there are compatibility issues between vb.net and Microsoft Access. Meaning that i am having huge problems with storing dates in the database, because of this the program does not behave consistently across different computers. On my computer the whole program is currently imploding because it is trying to retrieve dates in US format. But that only occurs between days 1 and 12 of the month since you cant have a 13th month. So from day 13 onwards of each month it uses UK format when getting data from the database. wtf. why would i ever want it to try and use two separate formats when retrieving the same god damn data. If i then tell it to use US format days 1-12 work but anything after that gives error messages due to the no 13th month thing.

    This is a pain in the ass and i have no idea why it is doing it. My pc is set up to be UK regional, vb is UK regional and Access will apparently use whatever is the local settings (i flipping hope that is a purely visual thing rather than breaking the database when used in America etc) . But my computing teacher says that the program works correctly on his computer, its one of the most irritating things i have ever had to work with.
     
  8. Roadside_Racoon

    Roadside_Racoon
    Expand Collapse

    Joined:
    Nov 1, 2013
    Messages:
    198
    Started playing around with the new "Keep Distance" AI.
    Then drove off a cliff :)
     
  9. aljowen

    aljowen
    Expand Collapse

    Joined:
    Oct 21, 2012
    Messages:
    1,677
    Fixed the storing dates into the database issue. I gave up on storing them as dates and just used a string instead. This does mean that the program may malfunction if it is used in America due to the different date layout but whatever, i doubt the school is going to move to America any time soon. So its fine.

    My program now meets all user requirements with only one of them being partially met, all the others being fully met. But there are still a couple bugs that really need fixing such as error message that appear occasionally, but the program still functions properly, i may just remove the error reporting on that section of the program as a truly awful yet very effective way of fixing them.
     
  10. vmlinuz

    vmlinuz
    Expand Collapse

    Joined:
    Mar 2, 2014
    Messages:
    2,409
    I wrote a while loop in IA-32 assembly:

    Code:
    section .text
    global _start
    
    _start:
    
    xor edx,edx
    jmp loop
    
    loop:
    
    cmp  edx,3
    jge  end
    push edx
    
    mov edx,len
    mov ecx,msg
    mov ebx,1
    mov eax,4
    int 0x80
    
    pop edx
    add edx,1
    jmp loop
    
    end:
    
    mov eax,1
    int 0x80
    
    section .data
    
    msg db 'Hello, world!',0xa
    len equ $ - msg
    All that to say "Hello, world!\n" three times using Linux syscalls. If anyone knows a better way to do this, please tell me. I'm learning assembly so I can write an operating system :cool:
     
    #110 vmlinuz, Feb 5, 2015
    Last edited: Feb 5, 2015
  11. SixSixSevenSeven

    SixSixSevenSeven
    Expand Collapse

    Joined:
    Sep 13, 2013
    Messages:
    6,960
    Code:
    #/usr/bin/python
    print "Hello, world!\nHello, World!\nHello, World!"
    
    Rest my case :p


    I need to have a look at assembly for x86 at some point. My assembly experience so far has only been DCPU16, AVR and also an instruction set of my own design (a simple one at that)
     
  12. aljowen

    aljowen
    Expand Collapse

    Joined:
    Oct 21, 2012
    Messages:
    1,677
    I think that may be cheating...

    Code:
    Sub HelloWorld()
          for IntLoop = 0 to 2 'loop 3 times
                 Console.writeline("Hello world!") 'print hello world to a console window
          next
          Console.readline() 'make sure user can read the output before the console closes
    End Sub
    
    May as well join in i guess.
     
  13. SixSixSevenSeven

    SixSixSevenSeven
    Expand Collapse

    Joined:
    Sep 13, 2013
    Messages:
    6,960
    I use readkey rather than readline for holding the terminal open, closes on any key then rather than just enter.
     
  14. vmlinuz

    vmlinuz
    Expand Collapse

    Joined:
    Mar 2, 2014
    Messages:
    2,409
    x86 assembly (especially on Linux) is much easier than anyone will ever let you believe. It reminds me of programming my old Apple //c in BASIC.
     
  15. SixSixSevenSeven

    SixSixSevenSeven
    Expand Collapse

    Joined:
    Sep 13, 2013
    Messages:
    6,960
    I havent had any issues with assembly on other platforms so far, although most advanced things I have done are a DCPU16 text editor (and a pretty crude one at that) and used an interrupt on Timer2 on an AVR AtMega2560 to display an incrementing pattern on one of its ports.
     
  16. aljowen

    aljowen
    Expand Collapse

    Joined:
    Oct 21, 2012
    Messages:
    1,677
    Only assembly code that i have ever done is in the york LMC. It was ok, didn't particularly like it too much, i understood it but disliked it, but that was 3 years ago, my brain works very differently now. I would love to design and make a really simple CPU some day. It wouldn't be powerful, it would probably be the most inefficient thing under the sun and it would probably feature a two digit seven segment display for output at best (maybe even led's outputting pure binary if i didn't convert it), but it would be totally epic. Maybe some day i may actually know enough to make one. And then make an assembler for it....
     
  17. SixSixSevenSeven

    SixSixSevenSeven
    Expand Collapse

    Joined:
    Sep 13, 2013
    Messages:
    6,960
    Designing an actual hardware CPU is very difficult. However there are 2 alternatives that may interest you.

    First one. FPGA's. Programmable in either VHDL or verilog. Effectively chips that feature masses of reconfigurable logic gates to emulate whatever hardware its programmed to emulate (except its a true logic gate emulation not software).

    Secondly. Simply writing an emulator for the PC in VB.net or whatever, my made up instruction set I emulated in C#. I did start writing a DCPU16 emulator for arduino (would have only worked on the higher end ARM boards as a standard AtMega based arduino just didnt have enough RAM) at one point.


    The original DCPU16 spec (1.1 I think was first published revision) is pretty easy to emulate. Might make a nice exercise. Only gotcha is each "byte" of memory is actually 16 bit rather than the typical 8 bit, this is an oddity my fictional design also shared (and also the reason why an ARM arduino is required, none of the supported AtMega boards have 128kb of RAM + other overheads)
     
  18. aljowen

    aljowen
    Expand Collapse

    Joined:
    Oct 21, 2012
    Messages:
    1,677
    Yeah, that's the problem. I reckon could probably make an ALU at some point in the future. I have never actually used an FPGA before, would like to give it a go someday. My Electronics skills are not all that much higher than GCSE Electronic Products which involved creating circuits with 555/556 timers and Picaxe chips. Ultimately my product did not work because the school computers were unable to write any data onto any the chips. But is still got an A* in that. I would have totally done an A level in electronics if my school offered it.
     
  19. SixSixSevenSeven

    SixSixSevenSeven
    Expand Collapse

    Joined:
    Sep 13, 2013
    Messages:
    6,960
    Pick up an arduino board sometime. Much better supported than picaxe, plus when you want to leave the abstractions the arduino IDE imposes upon you it is alot cheaper to buy an AVR ISP programmer (which will work on all AVR based arduino boards) than it is to buy a PIC programmer for a picaxe chip. Plus arduino IDE can actually use an ISP programmer to flash bare AVR chips missing the Arduino bootloader (either deploying sketch direct via ISP or rewriting the bootloader) so the process of turning an arduino board into an AVR dev board is essentially reversible. A picaxe once flashed as a bare PIC can't be reflashed as a picaxe again, not until rev-ed release the picaxe firmware to the world which they have no intention of doing. AVR C compilers are generally better than PIC ones too (which arent all free either)
     
  20. aljowen

    aljowen
    Expand Collapse

    Joined:
    Oct 21, 2012
    Messages:
    1,677
    Arduino is also something i would like to try out. I dont really have any intentions of going back to using Picaxe chips. I would also like to try standard pic chips some day too. As you can tell there are a lot of things that i would like to try. But currently i have very little free time, no where near enough to have personal projects due to doing A levels. Doing A2 level music tech with AS music tech at the same time requires a ton of time within school. Im doing about 25 hours of music tech a fortnight (not including recording sessions, there are only 8 timetabled music tech lessons every fortnight so the rest i am doing in my own time), which i can only do during school time due to Pro Tools & equipment etc. A2 Computing project takes way more time than i would like to think about. I barely have time to even do any maths outside of lessons and i have an EPQ that the school wants me to have finished by next week. Then i have a mock computing test that i need to resit because i got a grade C which is one grade below my target, which is due to having no time to revise for it. Missing part of the lesson that covered the content because of school buses not turning up due to the snow also didn't help since i was unable to catch up. Then i have teachers moaning because i am not getting everything done on time which makes life oh so much more fun.

    Then add in the concept that i am not a computer and i cant work 24/7 without entertainment or human interaction and that i am going to a university applicant day on Saturday, getting all that done is not really feasible. Last year i studied for 5 AS levels. This year i am doing 3 A2 levels with 2 AS levels, I promised myself after AS Levels to never take on that much work, how the hell did i end up with even more this year. One of the main reasons i am doing 2 AS levels is because the exam board screwed up the exam and they have no consistency in their marking, while they are now under official scrutiny and the exam regulators are commenting about how badly run the course was it still doesn't help me. Cause i have been totally screwed over by them. fml.


    Wow, that got a bit more ranty than i expected. Stress is getting to me i guess :/
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice