Jump to content


Pharap's Content

There have been 194 items by Pharap (Search limited from 30-March 23)


By content type

See this member's


Sort by                Order  

#174073 which programming language's syntax do you like the best?

Posted by Pharap on 17 April 2014 - 10:44 PM in General

View PostDeath, on 15 April 2014 - 05:40 PM, said:

Working on it :P
But, that is a good point - Lua is not really an OOP language, and most people fail to realize that it is up-to-par with speed in other languages. A reason for this is because of how minimalistic it is. If you want to unlock Lua's OOP and other things, prepare for a slightly lower execution time. I will still be working on my version of OOP implementation, however

On topic, my favorite langauge syntax is Lua, as it's the one that got me started. I'm not saying I like Lua as a language, it's still missing a lot of things, but the syntax is one I have come to like.

Part of the problem is Lua's compiler. The compiler is designed to compile quickly (so people can do things like command line calculators and REPL) but sacrifices code optimisation. It also does not support complex datatype construction, it just exposes arrays and tables as is when it could be doing magic behind the scenes to allow people to actually define classes and have them implemented via Lua's arrays, treating the arrays like how C/C++ uses blocks of allocated bytes for creating structs/classes.

On another note regarding Lua's speed, JLua is not as fast as Lua when taken as is, but I believe the JLua JIT compilation eventually makes the code run faster than Lua. There is however a C implementation of Lua that is JIT compiled, which is almost certainly faster still.

Just a few thoughts to mull over. When you know how Lua works under the hood it makes it easier to see where the OO potential lies.

View PostMyrddraall, on 17 April 2014 - 04:25 PM, said:

and very much dislike any language that uses white space as part of the syntax

What about when whitespace is the syntax: [link]



#169001 [mc 1.6.x] Openperipheral

Posted by Pharap on 20 March 2014 - 06:01 PM in Peripherals and Turtle Upgrades

View Posttheoriginalbit, on 19 March 2014 - 10:36 PM, said:


No, nothing will be added to this thread, Mikee isn't active enough.
Fair enough

View Posttheoriginalbit, on 19 March 2014 - 10:36 PM, said:

we simply do not have the time to go through every single possible mod and all its items each time we add a new interface to see if we now support it or not
At no point did I ask you to do that, I have no idea why people are getting the idea that I am asking for other mod's interfaces to be documented.
If there are absolutely no functions that are exposed by all TileEntity-Peripherals then there is nothing to document other than the mod's functionality.

View Posttheoriginalbit, on 19 March 2014 - 10:36 PM, said:

If you want this magical list of everything our open-ended mod supports,

Again, I was never asking for that

View Posttheoriginalbit, on 19 March 2014 - 10:36 PM, said:

View PostPharap, on 19 March 2014 - 08:26 PM, said:

nor am I saying get rid of the mod's internal documentation.

well that's good, 'cause we wouldn't anyway, that documentation is there for us, which has the other effect of being there for you guys through the getAdvancedMethodData function
I shall ignore that comment

View Posttheoriginalbit, on 19 March 2014 - 10:36 PM, said:

also we do have a description on the website

If you mean http://www.openmods.info/, I for one cannot find it.

View Posttheoriginalbit, on 19 March 2014 - 10:36 PM, said:

Chances are by now that if someone doesn't know what this mod does, they won't want to use it
In that case I shall completely forget about this mod.



#168880 [mc 1.6.x] Openperipheral

Posted by Pharap on 19 March 2014 - 08:26 PM in Peripherals and Turtle Upgrades

View PostEngineer, on 19 March 2014 - 04:12 PM, said:

View PostPharap, on 19 March 2014 - 02:19 PM, said:

View Posttheoriginalbit, on 19 March 2014 - 04:57 AM, said:

View PostPharap, on 19 March 2014 - 03:57 AM, said:

Looks like a useful mod, it's a shame the documentation isn't better though.
The problem with documentation is that even we don't know everything our mod does, so its impossible to write an extensive, accurate, and up-to-date online documentation; what we've got is the only way to be able to do this.

Is that because it's just a wrapper for another API or because it uses reflection to investigate other mods or something?

Surely using peripheral.getMethods() would be enough to tell you what methods are exposed and then you can just list them along with what they do and what parameters/returns are involved in calling them.
They check if a tileentity has a certain interface, then they add the registered peripherals which mounts that block. Considering there are tonnes of mod it's undoable to document everything.

Looking at the 'documentation script' all open peripherals are guaranteed to have the getAdvancedMethodsData() function.
Instead of just providing a script that people have to read through to figure out which function(s) all open peripherals expose, it would be nice if there was a list of the functions with their parameters/returns on this thread.
I'm not saying get rid of the script or list all the tile entity exposed functions, nor am I saying get rid of the mod's internal documentation.
What I am saying is that it would be good to have clearer documentation without having to download the mod first or having to sit and watch a 17 minute video.

Also, the first post in the thread doesn't actually say what the mod does (discounting the videos).



#168826 [mc 1.6.x] Openperipheral

Posted by Pharap on 19 March 2014 - 02:19 PM in Peripherals and Turtle Upgrades

View Posttheoriginalbit, on 19 March 2014 - 04:57 AM, said:

View PostPharap, on 19 March 2014 - 03:57 AM, said:

Looks like a useful mod, it's a shame the documentation isn't better though.
The problem with documentation is that even we don't know everything our mod does, so its impossible to write an extensive, accurate, and up-to-date online documentation; what we've got is the only way to be able to do this.

Is that because it's just a wrapper for another API or because it uses reflection to investigate other mods or something?

Surely using peripheral.getMethods() would be enough to tell you what methods are exposed and then you can just list them along with what they do and what parameters/returns are involved in calling them.



#168749 [mc 1.6.x] Openperipheral

Posted by Pharap on 19 March 2014 - 03:57 AM in Peripherals and Turtle Upgrades

Looks like a useful mod, it's a shame the documentation isn't better though.



#168743 [MC 1.6.4/1.7.2/1.7.10] [CC 1.5x/1.6x] Computronics (0.6.0) - Audio tapes...

Posted by Pharap on 19 March 2014 - 02:28 AM in Peripherals and Turtle Upgrades

I like the camera implementation, it's both useful and (for want of a better term) weak enough to not be considered too overpowered.
Kind of reminds me of the old style raycasting engines (http://qt-project.or...asting-demo.png) such as Wolfenstein3D

Note: Haven't tried the mod, just skimmed the docs



#168454 Gamax92's CCLite ComputerCraft Emulator (Updated for CC1.75)

Posted by Pharap on 16 March 2014 - 07:31 PM in General

View Postgamax92, on 13 March 2014 - 01:21 AM, said:

Yes, it is possible to get the source code of luajit, which is what love2d uses. No, I don't want to scan though crap tons of assembly code to fix that. No, I don't want to release a special version of Love2D just to fix that.

However, I would make CCLite use a custom version of Love2D, if I could re enable killing threads on demand. The ability to kill threads on demand would allow me to get past a bug with infinite infinte loops.

If I get time at a later date I'll look into it properly, but after having a quick scan of both Love2D and LuaJit's sources, I expect Love2D is using a configuration of LuaJit that doesn't use doubles for numbers (probably it uses SDL a lot, which doesn't really use doubles much). Finding the issue seems more difficult than fixing it though since the source code for both is quite messy.



#167915 Gamax92's CCLite ComputerCraft Emulator (Updated for CC1.75)

Posted by Pharap on 12 March 2014 - 11:31 PM in General

View Postgamax92, on 23 January 2014 - 05:35 PM, said:

Lua's tonumber locks the output from 0 to 4294967295 (2^32-1), LuaJ doesnt. I've done a patch that enables the output to go from -4294967295 to 4294967295

That's because it's turning them into ints instead of floats.
Can't really get around that without access to the love2D's Lua VM's source code.
If you do have access to it though, it should be easy to fix.



#144084 ZephyrOS (working title) - my first OS

Posted by Pharap on 09 September 2013 - 05:27 AM in Operating Systems

View PostYoYoYonnY, on 28 August 2013 - 02:18 PM, said:

The Picture is a bit small... Mayby use imgur? ( http://www.imgur.com )
Have you tried clicking on the image?
That screenshot is actual size.



#141062 What is you programing / Technical experience ?

Posted by Pharap on 21 August 2013 - 09:27 AM in General

 Encreedem, on 20 August 2013 - 01:19 PM, said:

I started learning how to write programs in school when I was 14. We had to program a 2D hamster which could only make some very basic actions (acually it's almost like the CC Turtle). At that time I already realised that I really like programming and the fact that I'm thinking very logically made it even easier for me. During the past 4 years in school we mostly used C# and sometimes Java for our programs. C# is currently my favorite language by the way. I also made small games (mostly console applications) everytime I learned some new tricks and I usually put lots of time into them regardless of the fact that I was pretty mutch a noob (My first program was a chess game and I didn't even know how to read keys or use multidimensional arrays ^^). Regarding Website developement I also know a bit about HTML, CSS, Javascript and PHP but I don't really do much with that knowledge. In the last two years I learned a lot about SQL and I also started playing around with Lua.
Python, Batch and AutoIt are some languages of which I know the basics.
Right now I'm playing around with Unity, trying to combine my programming skills with my 3D models.
In the near future I plan to learn the languages C++ and Russian.

Hmmm... I feel like I haven't bragged enough in this post. Let's see... Most classmates consider me to be one of the best programmers in my class and I dare to say that I'm generally good in programming. :D

Yay C# :D
If you like Unity you should try XNA or SDL



#136629 How to make and install Lua resource packs

Posted by Pharap on 29 July 2013 - 12:31 AM in Programs

View PostNeverCast, on 21 July 2013 - 10:46 PM, said:

You can symlink in all major operating systems, including Windows.
Mklink or Junction ( Vista+, Windows 2000+ respectively )
Do you happen to know the dll and/or function call required to programatically create symlinks in windows?



#136628 making the beacon a peripheral

Posted by Pharap on 29 July 2013 - 12:28 AM in Suggestions

View PostDex_Luther, on 25 July 2013 - 11:59 AM, said:

View PostPharap, on 25 July 2013 - 08:58 AM, said:

SetRange would be useful if it was a tradeoff between range and fuel.
The problem with the beacon in survival is that it is in a fixed location, thus you can only get the benefits of it whilst in that range.
By making it a turtle upgrade, the beacon would effectively be moveable, thus it doesn't have to stay in one place, it can be taken down into mineshafts then moved back up to the surface as required.

The main point is the moveability.

I like the idea of a beacon peripheral, but not the idea of it being able to move. Movement like that would make it way to over powered. The point of the beacon is for it to be a landmark to help players find important places like spawn or market town in SMP.

Like cranium said, using it as a landmark is one use (though you're supposed to use a compass to find your spawn).
And like I said, the ability to make it moveable in the form of a turtle upgrade would be balanced by fuel increases and/or range decreases.
Also, you have just made me ponder the possibility of the turtle gaining the beacon's beam, which would make locating the turtle easier. In some ways that could be more useful than some of the buffs provided by the beacon.



#135829 making the beacon a peripheral

Posted by Pharap on 25 July 2013 - 08:58 AM in Suggestions

Spoiler

View PostEngineer, on 24 July 2013 - 06:00 PM, said:

In my opinion this idea is so called game breaking. I mean really, whats the point of a .setrange function, which cannot be further than the actual max range, when you actually try to get some profit of that. I mean, whats the point of a beacon with a range of 3? I'd rather have the full effect of the beacon in survival than somebody trolling with some loops to not get some profit of the "hard" wither fight.

SetRange would be useful if it was a tradeoff between range and fuel.
The problem with the beacon in survival is that it is in a fixed location, thus you can only get the benefits of it whilst in that range.
By making it a turtle upgrade, the beacon would effectively be moveable, thus it doesn't have to stay in one place, it can be taken down into mineshafts then moved back up to the surface as required.

The main point is the moveability.



#135427 making the beacon a peripheral

Posted by Pharap on 23 July 2013 - 07:36 PM in Suggestions

View Postimmibis, on 23 July 2013 - 04:25 PM, said:

View PostDex_Luther, on 22 July 2013 - 12:09 AM, said:

I like the idea. It would give server owners the ability to switch the buff given over spawn areas on a timer or by using a command (at least the way I imagine it being implemented), which could be useful. It could also let people set up events or something around the spawnpoint.
They can already do that, they're called pistons.
Piston mechanisms take up an awful amount of space.



#135092 Ubuntu Forums Hacked And Defaced. Usernames, Passwords And Emails Stolen.

Posted by Pharap on 22 July 2013 - 11:16 AM in General

View PostDlcruz129, on 22 July 2013 - 10:29 AM, said:

View PostPharap, on 22 July 2013 - 09:59 AM, said:

It's always amusing when forums get hacked.

It was pretty amusing when he hacked the Yogscast. It was just a banner and some annoying music. But this? Stealing usernames and passwords? I don't know about you, but I use the same password for almost everything (excluding important stuff like bank accounts, etc). He could easily get into people's email accounts, etc. I'm sorry, but I don't find that amusing.

Well firstly, now people know they will have chance to go around changing their passwords before he can get at them.
Secondly with the sheer number of people using the forums it would take a long time to get through them all, and they aren't all going to be signed up to the same sites, so each one will take a bit of searching to find. Generally most people who know about it are safe if they act upon it, it's only the people he's already managed to target and the people who don't know who are in trouble. Aside from which, like you said, most sensible people don't use the same passwords they use for forums for important things like bank accounts and the like, so overall he's likely only going to be able to cause general mischief and trolling, nothing serious. So all in all, yes it's bad, but it could be worse. If anything it's going to cause as much good as bad, because it will make the forums more safety-concious so they'll improve security and thus they'll be less likely to be hacked.

(And out of interest, I have at least 10 different passwords, and their frequency of use generally correspond to how much I care about loosing a particular account. Someone finding out the most used one would cause issues, but I have the advantage of knowing which accounts use what passwords and variations, so if someone stole it, I'd at least be able to salvage the majority. )



#135076 Ubuntu Forums Hacked And Defaced. Usernames, Passwords And Emails Stolen.

Posted by Pharap on 22 July 2013 - 09:59 AM in General

It's always amusing when forums get hacked.



#135074 What Value Does Cc Use For Lua's Fieldsperflush?

Posted by Pharap on 22 July 2013 - 09:50 AM in Ask a Pro

I have the source code for the exact version of LuaJ that CC uses and FieldsPerFlush is clearly defined.
I want an exact answer, whether CC's LuaJ deviates from the original.



#134968 Multiple "ors" don't work?

Posted by Pharap on 21 July 2013 - 06:47 PM in Ask a Pro

View PostMudkipTheEpic, on 21 July 2013 - 04:57 PM, said:

View PostPharap, on 21 July 2013 - 04:51 PM, said:

View PostMudkipTheEpic, on 21 July 2013 - 02:52 PM, said:

View PostCranium, on 19 July 2013 - 06:56 PM, said:

The real fun comes when you start learning ternary operations.
local variable = condition and true_value or false_value
It's really helpful when trying to shorten really long if/else/elseif statements.

That doesn't always work, like if the true_value is nil or false, but that isnt often. :P/>/>/>/>
That's the intended behaviour, that's how ternary operators work.

I get that, just saying that it doesnt always equal to true_value if it is nil or false, that's all.

(i know this is intended behavior, just make sure you account for that before using it as a replacement for if statements)

Condition can be a compound statement, so making it include nil checking would be perfectly viable.
I'm not sure if lua supports nested ternary operations, but if it does that's also a solution. I get the feeling it probably doesn't though since lua is insanely minimalistic and hates symbolic operators.



#134945 Multiple "ors" don't work?

Posted by Pharap on 21 July 2013 - 04:51 PM in Ask a Pro

View PostMudkipTheEpic, on 21 July 2013 - 02:52 PM, said:

View PostCranium, on 19 July 2013 - 06:56 PM, said:

The real fun comes when you start learning ternary operations.
local variable = condition and true_value or false_value
It's really helpful when trying to shorten really long if/else/elseif statements.

That doesn't always work, like if the true_value is nil or false, but that isnt often. :P
That's the intended behaviour, that's how ternary operators work.



#134891 Logo Request

Posted by Pharap on 21 July 2013 - 01:14 PM in General

Dang, too slow.
Oh well, the one I made is close to being too wide anyway



#134875 Eight Good Coding Habits

Posted by Pharap on 21 July 2013 - 12:07 PM in Tutorials

View PostBubba, on 21 July 2013 - 10:53 AM, said:

If by optimized, people mean short, I would have to disagree. To me, optimization is a combination of readability, number of operations, and ease of customization later on. In Lua especially, there is no reason to program only in one block of code for non-repetitive tasks simply because you may at one point want to make the task repetitive and functions make that extremely easy. Also, functions have essentially no effect on speed in CC Lua, and I rather doubt that they have much of effect in a regular Lua environment either.
By optimised I mean goes fast.
Short code does not mean optimised code.
Sometimes 4 really long lines of code can generate faster bytecode than 2 short lines.
How fast functions are depends on their setup, for example a vararg function is slower than an explicit params function, but using a vararg function can be faster than passing a table to a function depending on how much indexing is involved.
Generally functions aren't a problem though, they only start to become a problem when you start giving them upvalues (each upvalue adds about 2 instructions to the function.

JLua is a lot different to CLua, and I believe it does some JIT compiling, in which case it's impossible to say anything other than CLua almost always runs faster.



#134859 Multiple "ors" don't work?

Posted by Pharap on 21 July 2013 - 11:05 AM in Ask a Pro

View PostFreack100, on 19 July 2013 - 03:52 PM, said:

View PostPixelToast, on 19 July 2013 - 03:47 PM, said:

Freack100: that is invalid syntax, actually learn lua before posting please

the problem is here:
if ans ~= answerA or answerB or answerC then
this is how you do it
if ans~=answerA and ans~=answerB and ans~=answerC then
Really?
I've used a snipped like this sometimes in my programs and it works...

You were probably using boolean values.

In any language, or and and on boolean values will follow the basic boolean logic tables.
However, in no known language will a == (b or c) be the same as (a == b or a == c).
In the expression (a == b or a == c), the boolean values of a == b and a == c will be equated first, then those two boolean values will be logically or-ed following the boolean logic table.
In the expression a == (b or c), the or operator is applied to the values of b and c, and the result of that operation is tested with a. Because of the way 'or' gets compiled in lua, that means that if b and c aren't booleans, they are evaluated depending on whether either of the values are nil.
Thus in a == (b or c), if b isn't nil, a is tested with b so the expression boils down to a == b. If b is nil, a is tested with c instead, so the expression is the same as a == c.
Because of this a == (b or c) will give a different result to a == (c or b ) providing b and c aren't booleans.
Thus:
local a = "a";
local b = "b";
local c = "a";
print(a == (b or c)); --prints false
print(a == (c or B)/>/>/>); --prints true
However:
local a = true;
local b = true;
local c = false;
print(a == (b or c)); --prints true
print(a == (c or B)/>/>/>); --prints true

Which is why you have experienced such statements sometimes working.



#134856 What Value Does Cc Use For Lua's Fieldsperflush?

Posted by Pharap on 21 July 2013 - 10:49 AM in Ask a Pro

Does CC use the CLua default of 50, whatever JLua's default FPF is (which I'm assuming is also 50) or does it have a custom value for various reasons (ie save bandwidth etc)?



#134835 LASM - ComputerCraft's First Alternate Programming Language

Posted by Pharap on 21 July 2013 - 07:33 AM in Programs

View PostAutoLocK, on 21 July 2013 - 02:26 AM, said:

View PostKingOfNoobs, on 19 June 2013 - 10:47 AM, said:

View PostAutoLocK, on 19 June 2013 - 03:59 AM, said:

Wow. You made a programming language INSIDE a programming language. Nice work.
That isn't something special. Lua, python and lots of other programming languages are written in other programming languages.
I meant in ComputerCraft. Not in languages outside CC.
Technically it's a programming language assembled in an assembler written in a programming language running on a virtual machine written in a language that runs on a virtual machine which itself is written in another language.
What has (computer) science done?



#134778 Eight Good Coding Habits

Posted by Pharap on 20 July 2013 - 10:58 PM in Tutorials

View PostEngineer, on 20 July 2013 - 06:20 PM, said:

View Poststrayzer, on 20 July 2013 - 02:38 PM, said:

ALWAYS use functions

I very, very disagree. I see where you are coming from with naming them, but really only use functions when you need a piece of code several times. To name it I would do something like:
-- This is the "function's" name
term.write( "This is " )
local s = "doing"
term.write( "what this code is " .. s )

I suppose then you are sometimes doing things like:
local function p()
   local s = "Hi!"
   term.write( s )
end

local function r( name )
   p() -- The one and only call in the whole script
   term.write( name )
end
Of course using some more (complicated) code.
In my opinion it is bad practise, but thats me. I think this is better:
function pr( name )
	local s = "Hi!"
	term.write( s .. name )
end

Seeing this makes me think how sometimes good practise and optimisation are at odds.
Dunno why, just does