- 1
- 2
- 3
Автомобиль-русофоб
https://habr.com/ru/post/572984/
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
Автомобиль-русофоб
https://habr.com/ru/post/572984/
Я нашел статью про Насру (formerly Gologub).
+1
C 5.2s gcc test.c
C++ 1m 25s g++ test.cpp
Zig 10.1s zig build-exe test.zig
Nim 45s nim c test.nim
Rust Stopped after 30 minutes rustc test.rs
Swift Stopped after 30 minutes swiftc test.swift
D Segfault after 6 minutes dmd test.d
Rust and Swift took too long to compile 400k lines, so I tried smaller numbers:
# lines Rust Swift D
2k 3.4s 0.8s
4k 9.0s 1.0s
8k 30.8s 2.3s
20k 3m 52s 11.8s 4.7s
100k - 5m 57s segfault
https://vlang.io/compilation_speed
+2
class S
{
print()
{
print("Hello World");
}
}
interface IPrn
{
print();
}
function run(iface:IPrn)
{
iface.print();
}
function main() {
const s = new S();
let iface = <IPrn>s;
iface.print();
run(s);
}
короче новый говнокод подоспел. Т.к. вы все тут самые умные я не раскажу в чем фича. Сами догадаетесь
+2
// https://github.com/seanbaxter/circle/blob/master/examples/README.md#tldr
// ...
// Circle's primary syntactic element is the @meta keyword, which runs the prefixed statement
// during source translation (or during template instantiation in dependent contexts).
// https://github.com/seanbaxter/circle/blob/master/examples/README.md#same-language-reflection
// duff1.cxx
void duff_copy1(char* dest, const char* source, size_t count) {
const char* end = source + count;
while(size_t count = end - source) {
switch(count % 8) {
case 0: *dest++ = *source++; // Fall-through to case 7
case 7: *dest++ = *source++; // Fall-through to case 6...
case 6: *dest++ = *source++;
case 5: *dest++ = *source++;
case 4: *dest++ = *source++;
case 3: *dest++ = *source++;
case 2: *dest++ = *source++;
case 1: *dest++ = *source++;
break;
}
}
}
// Reproduced above is a simplified version of Duff's device, an infamous memcpy function designed
// to reduce the amount of branching in the operation. (The loop is optimally interleaved with the switch,
// but I'm trying to illustrate some other points and don't want to add to the confusion.) Once we enter the
// switch, perform an assignment and unconditionally progress to the next case statement. This algorithm
// cries out for automation. The case statements have indices that run from 8 down to 1, modulo 8. Can we give it the Circle treatment?
// duff2.cxx
void duff_copy2(char* dest, const char* source, size_t count) {
const char* end = source + count;
while(size_t count = end - source) {
switch(count % 8) {
@meta for(int i = 8; i > 0; --i)
case i % 8: *dest++ = *source++;
break;
}
}
Но гомоиконности таким подкостыливанием вы естественно не добавите!
+2
type int = 1;
function main() {
let result: [value: int, done: boolean];
let v: int | undefined;
v = 1;
result = [v, false];
print(result[0], result[1]);
assert(result[0] == 1);
assert(result[1] == false);
}
опа. новый говнокодец подоспел. а кто знает какая проблема решалась в данном коде?
+1
QSqlQuery& SQLConnect::get()
{
if ( makeConnection() ) {
query = QSqlQuery(mDb);
return query;
}
QSqlQuery empty;
return empty;
}
bool SQLConnect::makeConnection()
{
mDb = SQLConnectPool::Instance().get();
return true;
}
Раньше компилилось и не замечал, а тут на новом компиляторе начал кидать ошибки и решил посмотреть, что же там напроектировали
+2
#!/bin/bash
set -euo pipefail
host() {
echo "n${1}.local"
}
node() {
echo "erl@$(host $1)"
}
build() {
[ "${1}" -eq "1" ] && echo "build: ."
}
container() {
cat <<EOF
worker${1}:
$(build $1)
image: worker
hostname: $(host $1)
networks:
backplane:
aliases:
- $(host $1)
environment:
- "NODE_NAME=$(node $1)"
- ... прочая питушня
EOF
}
main() {
cat <<EOF
version: '3.3'
networks:
backplane:
services:
$(node 1)
$(node 2)
...
EOF
}
main > docker-compose.yml
docker-compose $@
Как тебе такое, Helm?
+3
#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
#define STRING 0
#define INTEGER 1
#define CAT(x,y) x ## _ ## y
#define J(x,y) CAT(x,y)
typedef union
{
char *J(v, STRING);
int J(v,INTEGER);
} Un;
typedef struct
{
uint8_t Obj_t;
Un u;
} Object;
#define IF_INSTOF(var, t, newvar) \
if(var.Obj_t == t) \
{ \
typeof(var.u.J(v,t)) *newvar = &var.u.J(v,t);
int main(void)
{
Object obj1 = {STRING, {.J(v,STRING) = "1"}};
IF_INSTOF(obj1,STRING,str)
printf("String: %s\n", *str);
}
else
{
printf("Not a string\n");
}
Object obj2 = {INTEGER, {.J(v,INTEGER) = 1}};
IF_INSTOF(obj2,INTEGER,i)
printf("Integer: %d\n", *i);
}
else
{
printf("Not an Integer\n");
}
return EXIT_SUCCESS;
}
Вот такие смарткасты через препроцессор.
https://govnokod.ru/27556#comment655527
+2
function foo(arg: any) {
if (typeof arg === "string") {
// We know this is a string now.
print(arg);
}
}
function main() {
foo("Hello");
foo(1);
print("done.");
}
наговнокодил
+1
function foo(arg: any) {
if (typeof arg === "string") {
// We know this is a string now.
print(<string>arg);
}
}
function main() {
foo("Hello");
foo(1);
print("done.");
}
я вам новый говнокодец притарабанил.... вот будете как настоящие жабаскриптеры в нативе