1 Why javascript sucks
• 1.1 Poor construction
• 1.2 Type System
• 1.3 Bad functions
• 1.4 Missing features
• 1.5 DOM
2 Why Lua sucks
3 Why PHP sucks
• 3.1 Fixed in currently supported versions
4 Why Perl 5 sucks
5 Why Python sucks
• 5.1 Fixed in Python 3
6 Why Ruby Sucks
7 Why Flex / ActionScript sucks
8 Why scripting languages suck
9 Why C sucks
10 Why C ++ sucks
11 Why .NET sucks
12 Why C # sucks
13 Why VB.NET sucks
15 Why Objective-C Sucks
16 Why Java sucks
• 16.1 Syntax
• 16.2 Fixed in Java 7 (2011)
• 16.3 Model
• 16.4 Library
• 16.5 Discussion
17 Why Backbase Sucks
18 Why XML Sucks
19 Why sucks XSLT / XPath
20 Why CSS sucks
• 20.1 Fixed in CSS3
21 Why Scala Sucks
22 Why Haskell Sucks
23 Why Closure Sucks
24 Why Go sucks
• 24.1 Basic programming tools (basic language)
• 24.2 Interoperability
• 24.3 Standard Library
• 24.4 Toolkit
• 24.5 Community
25 Why Rust Sucks
• 25.1 Security
• 25.2 Syntax
• 25.3 API design and type system
• 25.4 Community
• 25.5 Toolkit
XMLHttpRequest
HTMLHRElementvar i = 1;
//
i = i + ""; // !
// -
i + 1; // "11"
i - 1; // 0var j = "1";
j++; // j 2
var k = "1";
k += 1; // k "11"
[1,5,20,10].sort() // [1, 10, 20, 5]var args = Array.prototype.slice.call(arguments);0.1 + 0.2 === 0.30000000000000004;typeof NaN === "number"
// , NaN
NaN != NaN
NaN !== NaN
// , "" "NaN".
x !== x
// -
isNaN(x)// "This"
object.property = function foo() {
return this; // "This" , ()
}
// "This"
var functionVariable = function foo() {
return this; // "This"
}
// "This"
function ExampleObject() {
this.someNewProperty = bar; // "This"
this.confusing = true;
}
// "This"
function doSomething(somethingHandler, args) {
somethingHandler.apply(this, args); // "this" , ""
this.foo = bar; // "This" ""
var that = this;
// , "this"
someVar.onEvent = function () {
that.confusing = true;
// "this" someVar
}
}// "This"
return
{
a: 5
};// "This"
return
{
'a': 5
};function bar() {
// -, var,
foo = 5;
}0 == ""
0 == "0"
0 == " \t\r\n "
"0" == false
null == undefined
"" != "0"
false != "false"
false != undefined
false != nullnew Function("x", "y", "return x + y");
new Array(1, 2, 3, 4, 5);
new Object({"a": 5});
new Boolean(true);parseInt("72", 10);with (obj) {
foo = 1;
bar = 2;
}for (var name in object) {
if (object.hasOwnProperty(name)) {
/* ... */
}
}
//
Object.keys(object).forEach(function() { ... });var n = 0;
for (var i in [3, 'hello world', false, 1.5]) {
i = parseInt(i); //
alert(i + n);
}
//
[3, 'hello world', false, 1.5].map(Number).forEach(function() { alert(i + n) });//
const pi = 3.14159265358;
const msg = "Hello World";
//
const bar = {"a": 5, "b": 6};
const foo = [1, 2, 3, 4, 5];
//
const func = function() {
const x = arguments[0], y = arguments[1];
return x + y;
};ES6
x -> x * xMath.pow(7, 2); // 49//
function doNothingWithEvent(event) {
return true;
}
//
function doNothingWithEvent(event) {
alert('screwing everything up');
return true;
}do
local realVar = "foo"
real_var = "bar" -- Oops
end
print(realVar, real_var) -- nil, "bar"local function fn() return "bar", "baz" end
print("foo", fn()) -- foo bar baz
print("foo", fn(), "qux") -- foo bar qux...).break, do while (while (something) do, repeat something until something) goto , continue. .>2+2
stdin:1: unexpected symbol near '2'
>return 2+2
4>("string"):upper()
STRING ()
>({1,2,3}):concat()
stdin:1: attempt to call method 'concat' (a nil value)
>(3.14):floor()
stdin:1: attempt to index a number value'0', 0 0.0 , '0.0' — .• doc- "<<<END" PHP < 5.3.$x = Array();
$y = array();
$x == $y; # is true
$x = 1;
$X = 1;
$x == $X; # is true• , (. func_get_args()).Array() - .• «-» — . - — . :
$arr[2] = 2;
$arr[1] = 1;
$arr[0] = 0;
foreach ($arr as $elem) { echo "$elem "; } // "2 1 0"!!"use strict".error_log("Frobulating $net->ipv4->ip");
Frobulating Object id #5->ip
$foo = $net->ipv4;
error_log("Frobulating $foo->ip");
Frobulating 192.168.1.1error_log("Frobulating {$net->ipv4->ip}");<?php ?>, HTML , .float double.(float).array_diff, array_reverse .. ; , + (- ). ? : $a.diff($b), $a.reverse() .• PHP C Perl, , , -. , .
array_reverse shuffle — .• «needle, haystack», — «haystack, needle».
$$a[1] ${$a[1]} ${$a}[1], $a[1] $aa .• , , . , , , .
$, , — , — , .! , =, — if (!$a = foo()) — «» !<< >> <<= >>=) 32 .and or , && ||, .: endif;, endwhile;, endfor; endforeach .(int) (integer), — (bool) (boolean), — (float), (double) (real).• PHP5 — , , , ( ).
• .
include FALSE .• - , require().function makeyogurt($type = "acidophilus", $flavour)
{
return "Making a bowl of $type $flavour.\n";
}
echo makeyogurt("raspberry"); // " ". .$this) ( self).unserialize(), __PHP_Incomplete_Class, .class A {
public static function who() {
echo __CLASS__;
}
public static function test() {
self::who();
}
}
class B extends A {
public static function who() {
echo __CLASS__;
}
}
B::test(); // A, B!class a {
function nextFoo() {
class b {} //
}
}$var1 = "Example variable";
$var2 = "";
function global_references($use_globals)
{
global $var1, $var2;
if (!$use_globals) {
$var2 =& $var1; //
} else {
$GLOBALS["var2"] =& $var1; //
}
}
global_references(false);
echo "var2 is set to '$var2'\n"; // var2 ''
global_references(true);
echo "var2 is set to '$var2'\n"; // var2 '' "• PHP , .
SplFileObject.SplFileObject SplFileInfo . ? !?in_array("foobar", array(0)) === true• , «foobar» , 0. , in_array strict, , , === == , - .
null, "", 0 0.0 — .0, , 08, 09, 012345678 . , 8 9 : 08 == 0, 08 != 8, 0777 == 07778123456 ( PHP 7).intdiv() PHP 7).[] {} NULL ( PHP 5).class Foo {
function Foo($name) {
// $globalref
global $globalref;
$globalref[] = &$this;
$this->setName($name);
}
function echoName() {
echo "\n", $this->name;
}
function setName($name) {
$this->name = $name;
}
}
$bar1 = new Foo('set in constructor');
$bar1->setName('set from outside');
$bar1->echoName(); // " "
$globalref[0]->echoName(); // " "
// , :
$bar2 =& new Foo('set in constructor');
$bar2->setName('set from outside');
$bar2->echoName(); // " "
$globalref[1]->echoName(); // " "class A
{
function A()
{
echo "Constructor of A\n";
}
function B()
{
echo "Regular function for class A, but constructor for B";
}
}
class B extends A
{
}
$b = new B; // B() $first_element = function_returns_array()[0]; // !!
$first_element = ( function_returns_array() )[0]; // , !!
// :
$a = function_returns_array();
$first_element = $a[0];use strict;
use warnings;my @list = ("a", "b", "c");
print $list[0];sub foo {
my ($a, $b) = @_;
}my $doc = <<"HERE";
But why would you?
HERE
print $doc;if($a==$b) $c=$d ;; :if(something)
if(something_else)
do_this();
else
do_that();• , a.b() «b» «a»; , , a.b() «a» «» ; :
class NoExplicit:
def __init__(self):
self.selfless = lambda: "nocomplain"
def withself(): return "croak" #will throw if calld on an _instance_ of NoExplicit
a = NoExplicit ()
print(a.selfless()) #won't complain
print(a.withself()) #will croak, «». - . , :foo = 1.0 + 2 # Foo is now 3.0
foo = 1,0 + 2 # Foo is now a tuple: (1,2)
foo = 3 # Foo is now 3
foo = 3, # Foo is now a tuple: (3,)(1) == 1 # (1) is just 1
[1] != 1 # [1] is a list
1, == (1,) # 1, is a tuple
(1) + (2) != (1,2) # (1) + (2) is 1 + 2 = 3
[1] + [2] == [1,2] # [1] + [2] is a two-element list
isinstance((), tuple) == True # () is the empty tupledo ... until <condition>", "while not <condition>:""""__main__if __name__ == "__main__":f.write(u'blah blah blah\n')os.path.expanduser os.path.supports_unicode_filenames ( , ).!= <> (. php).(-1)**(0.5), pow(-1, 0.5) 0+1j.String#downcase? «downcase»? — «lower case,» «lowercase» «lower». String#upcase «uppercase» «upper». , , Ruby — . , tw… PHP.@ @@ .nil.to_i «nil» 0, 0 «nil». nil.to_i.nil? #=> false.String#to_i , : "x".to_i == 0.Array#size/Array#length, Array#[]/Array#slice.begin ... rescue ... end if expr. if expr, .unless ( if not) , , .nil, «void» («») (). , , , .`` . .$1, $2,…Array, Hash) , . — . class ThingLikeArray < Array; end."foo" != :foo, , , , HashWithIndifferentAccess.qsort() - . , - .• (, , ) , ; , (nspr, apr, glib...).
• . (API) Berkeley, . , API Microsoft . O (1) API ; (select()poll()O(n)).
•int a = 0; f(a, ++a, ++a);,f(0, 1, 2). .
• , «»:i[++a] = j[a];, , .
• . .
• N intN_t .
•int *float *.memcpy().
• NULL . — !
• ; ( C, ).
•void (*)()int (*)(int, const char *), , ? ! . , , ( ).
• - , ,FILE *double *, . .
• , - C- C++.
std::string s();• : ; , ; , .
• 's' :
std::string s = s(); /* or */ std::string s{};• «», RAII, , C++. , RAII.
• , C, strcat.catch (...) .throw .NULL C++. [ .]mutable , , const , , , .• [=] , .std::string::c_str() std::string char*. operator const char* () const.• , __forceinline .expor , , . C ( C++) .• Pascal (SomeClass, SomeConstantVariable, SomeProperty).
• «extends» «implements» (IInterface).
T plus<T>(T t1, T t2) { return t1+t2; }.lang="text">Dim a As Integer = TextBox1.Text ' ( Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger).On Error Goto On Error Resume Next: — . , Try-Catch-Block ( -).• .
• , ( Strict Off) . . StackOverflow.
• The Microsoft.VisualBasic.HideModuleNameAttribute. - .
Form2.InstanceMethod()Dim Form2Instance As New Form2
Form2Instance.InstanceMethod()MyProject.Forms.Form2.InstanceMethod()Dim myRange As Variant
myRange = Range("A1")
Set myRange = Range("A1")• Objective-C — ; GNUStep Fringe Linux, Windows, … , , .
• Objective-C C++ .
• C++ , , Objective-C.
• C++ Objective-C C++; .
• C++ Objective-C .
• Objective-C , C++, … new.
goto const.a.add(b.multiply(c)), .new T[42], , :class GenSet<E> { Object[] a; E get(int i){return a[i];}}// Java
ClassWithReallyLongNameAndTypeParameter<NamingContextExtPackage> foo = new ClassWithReallyLongNameAndTypeParameter<>();
// C# | :
var foo = new ClassWithReallyLongNameAndTypeParameter<NamingContextExtPackage>();
// Java | :
SomeTypeIHaveToLookUpFirstButIActuallyDontReallyCareAboutIt result = getTransactionResult();Pair «» .int Integer, float Float. - .• , Number.
•java.netURLConnectionHttpURLConnection:UrlConnectionHTTPURLConnectionHttpUrlConnection?
•java.utilZipOutputBufferGZIPOutputBuffer:ZIPOutputBufferGnuZipOutputBufferGzipOutputBufferGZipOutputBuffer?
• , , ; , 3 , , , ..RPGGame,RpgGame,TLSConnection,Starttls.
Cloneable clone ..toString() ( , -) .equals() ( , ).Collections () Arrays ().Stack — , Queue — ?•StackAPI, .Deque()ArrayDeque().
(a|[^d]) StackOverflowException .Serializable RandomAccess, : , , - .Object[] foo = new String[1]; foo[0] = new Integer(42); , .•test=""<xsl:if><xsl:when>.
•<xsl:sort>.
key(), XML, . — ! select="key(...)" . , , «key() » , , « ».select="", value="" match="" , , . ; , - , - . .str:replace ()), (, ), , - . . - ? - , - , , , .[a-zA-Z_][a-zA-Z0-9_]*. , , , . $foo-100, $foo — 100.•$foo-bar.
•$foo - 100.
•$foo+100$foo + 100.
•$foo-100.
<xsl:sort select="count(*)"/>
<!-- sorts like this: 10, 11, 1, 23, 20, 2, 37, 33, 31, 3, 4, 5, 6, 78, 7, 9 -->• , , :
• «4.1.3. » :
« CSS2 ( , ) [A-Za-z0-9] ISO 10646 161 , (-); .»
scala.collection .func randomNumber() *int {
return nil
}
func main() {
a := 1
b := randomNumber()
fmt.Printf("%d\n", a+*b) // - ()
}string []byte. string []byte, Unicode , == > <, + . , , , io.Writer, []byte.utf8.RuneCountInString().break case, break switch. , , switch.slice = append(slice[:n], slice[n+1:]...)if v, err := otherFunc(); err != nil {
return nil, err
} else {
return doSomethingWith(v), nil
}range , / , , :d := loadData()
for i := range d {
// "d" , "i" ,
// "d" , "i"
// "i" //
}
for i, j := range d {
// "d" , !
// , , ,
// , )
// "d" , "i" - , "j" - ( d[i])
// "i" / , "j" d[i]
}func foo1(i int) (r int) {
if i != 0 {
r := 12
fmt.Println(r)
}
return // 0
}
func foo2(i int) (r int) {
if i != 0 {
r = 12
fmt.Println(r)
return // 12
}
return // 0
}
func foo3(i int) (r int) {
if i != 0 {
r := 12
fmt.Println(r)
return // : "r"
}
return
}func dogma() (i int) {
defer func() {
i++
}()
return 2 + 2
}
func main() {
fmt.Println(dogma) // 5
}func returnsError() error {
var p *MyError = nil
if bad() {
p = ErrBad
}
return p // " ".
}select case , , :select {
case <-chan1:
doSomething()
default:
select {
case <-chan1:
doSomething()
case <-chan2:
doSomethingElse()
}
}select 700 . .math/rand crypto/rand.flag, , POSIX- .errors , .. Go , .unsafe , , ; , , .unsafe.unsafe {} ; , , , , sliceable.unsafe_get(index). , , , , .:: ++. / . #[allow(unrooted_must_root)]
pub fn new(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLIFrameElement> {
let element = HTMLIFrameElement::new_inherited(localName, prefix, document);
Node::reflect_node(Box::new(element), document, HTMLIFrameElementBinding::Wrap)
} #[allow(unrooted_must_root)]
pub fn new(localName: Atom,
prefix: Option<DOMString>,
document: &Document) {
let element = HTMLIFrameElement::new_inherited(localName, prefix, document);
Node::reflect_node(Box::new(element), document, HTMLIFrameElementBinding::Wrap);
}impl ().mut , (mutable). &Mutex (mutable), &mut str — (immutable).Vec Cell.str, String). : str, String, CStr, CString, OsStr OsString. OsStr, OsString, CStr, CString (- Windows), CStr, CString, OsStr, OsString String str, .Vec<T>, &[T], , Vec<T> &[T], , .&*some_var ( ) &some_var[..] ( — , Vec<T> &[T] String &str).() , , ).str [T]. , Sized, , ?Sized. , Reddit, , str . Box<str>. Reddit; Reddit, , , -Sized .enum. .Source: https://habr.com/ru/post/315152/
All Articles