Answer the question
In order to leave comments, you need to log in
Are there analogues of coffescripta for php?
PHP itself is rather poor after the beauty and elegance of the code in go, pythone, the same coffescripte. But it's such a shame that it remains a favorite in the custom web development arena. Incl. due to the high prevalence of hosting for it.
A quick googling told me snow_php, phpreboot, but they smell like unborn carrion. I just do not follow the development of php, maybe there is an outlet for web developers?
Answer the question
In order to leave comments, you need to log in
Bitwise operations operate on integer type variables.
While Boolean variables compare two variables in their entirety, bitwise variables compare bits.
For example: a = 11 (which is 1011 in binary), and b = 15 (which is 1111). Then a & b will return 11 (1011) (because 1 and 1 = 1, 1 and 0 = 0, 1 and 1 = 1, 1 and 1 = 1). But if a | b will then return 15 (1111) (1 or 1 = 1, 1 or 0 = 1, 1 or 1 = 1, 1 or 1 = 1).
Here everything is very well shown in the pictures.
& is a bitwise operation and works on integers, not bools as you decided.
&& is a logical operation and works with bool.
Similarly with | and ||. Next - Google for the words "% LANGNAME% operators"
The first always checks both conditions for truth, the second can only check the first, for && it is enough that the first is false so as not to check the second, for || - the truth of the first, therefore the second ones are slightly more optimal for the speed of the conditions ( if
).
Operations && || ! :
are used to test the truth of their operands.
Operations & | ^ ~ << >> :
used to manipulate bits in their operands.
If you have flag1, flag2, flag3 variables, you can test them to be true:
if ((flag1 && flag2) || !flag3) {
something;
}
if (states & (0x1 | 0x4)) {
something;
}
if (0x1) {
something;
}
if (0x0) {
something;
}
Everything is quite simple. Basically, this can be easily understood if you use method calls in javascript.
For example:
function a(variant){
console.log("run a");
return variant;
}
function b(variant){
console.log("run b");
return variant;
}
a(false) & b(false); //произведет вызов обеих функций, даже если первый метод вернет false
a(true) | b(true); //Аналогично первому вызовет оба метода даже если первый вернет true
a(true) || b(true); //второй метод не будет вызван, т.к первый уже вернул true
a(false) && b(true);//второй метод не будет вызван, т.к первый вернул false
why the heck write in 1 language to compile in another so that the third one compiles and works.
There are projects like snowscript , but for me it's childish fun. IMHO I don't see any reason why PHP needs a preprocessor. What are you going to cut? Sugar over classes is not needed (in js it is still needed and will appear in ES6), it is possible to shorten the declaration of functions / methods, the ability to write getters / setters a la c #. But apparently no one needs it yet, since IDEs generate the whole thing for you if you know how to use them.
Again, if you don't like the PHP syntax, look into Ruby. Or implement your own preprocessor.
There is also:
mammouth.wamalaka.com
And do you know what will be the disadvantage of such solutions? No IDE knows the syntax of these languages.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question