چرا برنامهنویسی کپیپیستی بد است؟
https://dzone.com/articles/copy-and-paste-programming
(به همراه مثالهایی از زمانی که این کار مشکلی ندارد)
https://dzone.com/articles/copy-and-paste-programming
(به همراه مثالهایی از زمانی که این کار مشکلی ندارد)
DZone
Is Copy and Paste Programming Really a Problem?
Copy and Paste Programming – taking a copy of existing code in your project and repurposing it – violates coding best practices like Don’t Repeat Yourself...
دستگاه Duff:
تکنیکی برای راحت تر کردن loop unroll وقتی که تعداد چرخش به تعداد unfold کردن بخش پذیر نیست.
کد اولیه:
کد unfold شده معمولی:
کد Duff machine (که هر تعداد n رو ساپورت میکنه)
https://en.wikipedia.org/wiki/Duff%27s_device
تکنیکی برای راحت تر کردن loop unroll وقتی که تعداد چرخش به تعداد unfold کردن بخش پذیر نیست.
کد اولیه:
send(to, from, count)
register short *to, *from;
register count;
{
do { /* count > 0 assumed */
*to = *from++;
} while (--count > 0);
}
کد unfold شده معمولی:
send(to, from, count)
register short *to, *from;
register count;
{
register n = count / 8;
do {
*to = *from++;
*to = *from++;
*to = *from++;
*to = *from++;
*to = *from++;
*to = *from++;
*to = *from++;
*to = *from++;
} while (--n > 0);
}
کد Duff machine (که هر تعداد n رو ساپورت میکنه)
send(to, from, count)
register short *to, *from;
register count;
{
register n = (count + 7) / 8;
switch (count % 8) {
case 0: do { *to = *from++;
case 7: *to = *from++;
case 6: *to = *from++;
case 5: *to = *from++;
case 4: *to = *from++;
case 3: *to = *from++;
case 2: *to = *from++;
case 1: *to = *from++;
} while (--n > 0);
}
}
https://en.wikipedia.org/wiki/Duff%27s_device
Wikipedia
Duff's device
unusual C programming idiom that manually implements loop unrolling using interleaved control structures
نوشتههای ترمینالی
دستگاه Duff: تکنیکی برای راحت تر کردن loop unroll وقتی که تعداد چرخش به تعداد unfold کردن بخش پذیر نیست. کد اولیه: send(to, from, count) register short *to, *from; register count; { do { /* count > 0 assumed */ *to =…
شاید بپرسید چرا اصلا loop باید unroll بشه؟
برای کاهش branch penalty و end of loop test
https://en.wikipedia.org/wiki/Loop_unrolling
برای کاهش branch penalty و end of loop test
https://en.wikipedia.org/wiki/Loop_unrolling
Wikipedia
Loop unrolling
loop transformation technique
این دنیا هی عجیب تر میشه.
یه زبان بوده به اسم Go! قبل از go که مال گوگله.
طرف اسم کتاب اموزشیشم گذاشته let's go
https://www.lulu.com/content/paperback-book/lets-go/641689
حالا گوگل میاد و زبانش رو به اسم go میده (بدون !)
اینم ایشوی خالق Go! روی go که جزو غمگینترین ایشوهایی بود که دیده بودم.
https://github.com/golang/go/issues/9
حالا این وسط کاربرا میگفتن به گوگل که اسم زبانش رو بذاره issue9 (سر اینکه شماره این ایشو، ۹ بوده)
آخرم گوگل کاری نکرد! بعد ۲ سال و ۱۲۰۰ تا دیالوگ توی issue، اون ایشو رو بست و تگ unfortunate زدن بهش.
به جز خود issue میتونید اینجا هم یه سری چیز در مورد داستان بخونید
https://news.ycombinator.com/item?id=935674
یه زبان بوده به اسم Go! قبل از go که مال گوگله.
طرف اسم کتاب اموزشیشم گذاشته let's go
https://www.lulu.com/content/paperback-book/lets-go/641689
حالا گوگل میاد و زبانش رو به اسم go میده (بدون !)
اینم ایشوی خالق Go! روی go که جزو غمگینترین ایشوهایی بود که دیده بودم.
https://github.com/golang/go/issues/9
حالا این وسط کاربرا میگفتن به گوگل که اسم زبانش رو بذاره issue9 (سر اینکه شماره این ایشو، ۹ بوده)
آخرم گوگل کاری نکرد! بعد ۲ سال و ۱۲۰۰ تا دیالوگ توی issue، اون ایشو رو بست و تگ unfortunate زدن بهش.
به جز خود issue میتونید اینجا هم یه سری چیز در مورد داستان بخونید
https://news.ycombinator.com/item?id=935674
Lulu
Lets Go!
Go! is a multi-paradigm language -- it has a strong foundation in object oriented programming, functional programming and procedural programming as well as logic programming. In addition, it is a multi-threaded language with communication capabilities. This…
چرا در cpp نباید مثل جاوا مرتب از new استفاده کرد.
https://stackoverflow.com/a/21735823
https://stackoverflow.com/a/21735823
Stack Overflow
Why should C++ programmers minimize use of 'new'?
I stumbled upon Stack Overflow question Memory leak with std::string when using std::list<std::string>, and one of the comments says this:
Stop using new so much. I can't see any reason you ...
Stop using new so much. I can't see any reason you ...
Forwarded from memealloc
نیم ساعت (یا بیشتر) با تور راسط
https://fasterthanli.me/articles/a-half-hour-to-learn-rust
https://fasterthanli.me/articles/a-half-hour-to-learn-rust
fasterthanli.me
A half-hour to learn Rust
In order to increase fluency in a programming language, one has to read a lot of it.
But how can you read a lot of it if you don’t know what it means?
In this article, instead of focusing on one or...
But how can you read a lot of it if you don’t know what it means?
In this article, instead of focusing on one or...
نوشتههای ترمینالی
برای کامپایل برنامه گو از لینوکس به مقصد ویندوز GOOS=windows GOARCH=amd64 go build (دقت کنید همش تو یه خط باشه) مطالعه بیشتر: https://dave.cheney.net/2015/08/22/cross-compilation-with-go-1-5
برای کامپایل برنامه rust از لینوکس به مقصد ویندوز
مطالعه بیشتر:
https://stackoverflow.com/questions/31492799/cross-compile-a-rust-application-from-linux-to-windows
#one time
rustup target add x86_64-pc-windows-gnu
rustup toolchain install stable-x86_64-pc-windows-gnu
#every time
cargo build --target x86_64-pc-windows-gnu
مطالعه بیشتر:
https://stackoverflow.com/questions/31492799/cross-compile-a-rust-application-from-linux-to-windows
Stack Overflow
Cross-compile a Rust application from Linux to Windows
Basically I'm trying to compile the simplest code to Windows while I am developing on Linux.
fn main() {
println!("Hello, and bye.")
}
I found these commands by searching the internet:
rustc --
fn main() {
println!("Hello, and bye.")
}
I found these commands by searching the internet:
rustc --
ساپورت کرنل لینوکس از binaryها با فرمت غیر طبیعی با
مثلا .class جاوا رو میتونین با
./MyClass.class
اجرا کنید!
https://www.kernel.org/doc/html/latest/admin-guide/binfmt-misc.html
binfmt_misc
مثلا .class جاوا رو میتونین با
./MyClass.class
اجرا کنید!
https://www.kernel.org/doc/html/latest/admin-guide/binfmt-misc.html
کرنل لینوکس و توضیحات/راهحل ها برای باگهای سخت افزاری مثل spectre
https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/index.html
https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/index.html
سختیهای یادگیری rust
(مطلب جذابیه، بخونید به نظرم)
https://fasterthanli.me/articles/frustrated-its-not-you-its-rust
(مطلب جذابیه، بخونید به نظرم)
https://fasterthanli.me/articles/frustrated-its-not-you-its-rust
fasterthanli.me
Frustrated? It's not you, it's Rust
Learning Rust is… an experience. An emotional journey. I’ve rarely been more frustrated than in my first few months of trying to learn Rust.
What makes it worse is that it doesn’t matter how much p...
What makes it worse is that it doesn’t matter how much p...
یادگیری RUST به عنوان برنامهنویس cpp/c#/java
https://fasterthanli.me/articles/i-am-a-java-csharp-c-or-cplusplus-dev-time-to-do-some-rust
https://fasterthanli.me/articles/i-am-a-java-csharp-c-or-cplusplus-dev-time-to-do-some-rust
fasterthanli.me
I am a Java, C#, C or C++ developer, time to do some Rust
As I've said before, I'm working on a book about lifetimes. Or maybe it's just a long series - I haven't decided the specifics yet. Like every one of my series/book things, it's long, and it starts...
چگونه فایل را باز کنیم و بخوانیم؟ از راه سخت
تو این مطلب در مورد زبون های مختلف و سیستم کالهای کرنل و ابزار strace و ... بیشتر یاد میگیریم و بسیار توصیه میشه.
https://fasterthanli.me/series/reading-files-the-hard-way/part-1
خیلی مطلب عمیقیه. البته توی درس سیستم عامل تا حدی پوشش داده میشه. باز توصیه میکنم بخونیدش.
تو این مطلب در مورد زبون های مختلف و سیستم کالهای کرنل و ابزار strace و ... بیشتر یاد میگیریم و بسیار توصیه میشه.
https://fasterthanli.me/series/reading-files-the-hard-way/part-1
خیلی مطلب عمیقیه. البته توی درس سیستم عامل تا حدی پوشش داده میشه. باز توصیه میکنم بخونیدش.
fasterthanli.me
Reading files the hard way - Part 1 (node.js, C, rust, strace)
Everybody knows how to use files. You just open up File Explorer, the Finder, or a File Manager, and bam - it’s chock-full of files. There’s folders and files as far as the eye can see. It’s a genu...
❤3
چرا cpp بلوک فاینالی نداره و کلی سوال و جواب جالب دیگه از سازنده زبان
https://www.stroustrup.com/bs_faq2.html#finally
https://www.stroustrup.com/bs_faq2.html#finally
قواعد کدنویسی cpp از زبان خالق زبان
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md
GitHub
CppCoreGuidelines/CppCoreGuidelines.md at master · isocpp/CppCoreGuidelines
The C++ Core Guidelines are a set of tried-and-true guidelines, rules, and best practices about coding in C++ - isocpp/CppCoreGuidelines
Forwarded from آرچ لینوکس پارسی
برای دیدن فایلهای man به صورت رنگ بندی شده میتوانید از برنامه bat استفاده کنید. برای اینکار بعد از نصب بسته
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
bat
خط زیر را به فایل تنظیمات شل پیش فرض خود (bashrc و غیره) اضافه کنید:export MANPAGER="sh -c 'col -bx | bat -l man -p'"
موتیکس یا دستور اتمیک؟
https://jvns.ca/blog/2014/12/14/fun-with-threads/
https://jvns.ca/blog/2014/12/14/fun-with-threads/
Julia Evans
Diving into concurrency: trying out mutexes and atomics
I hadn’t written any threaded programs before yesterday. I knew sort of abstractly about some concurrency concepts (mutexes! people say compare-and-swap but I don’t totally get it!), but actually understanding a Thing is hard if I’ve never done it. So yesterday…