Python? Java? Rust? Qual a Diferença? | Discutindo Linguagens

Python? Java? Rust? Qual a Diferença? | Discutindo Linguagens

New Section

In this section, Fabio Akita introduces the topic of discussing popular programming languages, emphasizing a different perspective on viewers' favorite languages.

Exploring Different Perspectives on Programming Languages

  • Fabio aims to provide insights into viewers' favorite languages without comparing them or showing bias.
  • He encourages beginners to broaden their knowledge by introducing new concepts and terms.
  • Python's popularity has surged due to projects like Jupyter Notebooks and its relevance in data science and machine learning.
  • Perl's historical significance in Linux scripting and web development is highlighted, especially its role in regular expressions (Regex).

Python's Evolution and Influence

This section delves into Perl's impact on dynamic languages like Python, focusing on regular expressions and text processing.

Legacy of Perl in Dynamic Languages

  • Perl's development stagnation led to Python's rise with modern syntax and object-oriented features.
  • Perl influenced subsequent scripting languages like Ruby, PHP, and Python, particularly in handling variables and regular expressions.

Understanding Syntax and Language Configurations

In this section, the speaker discusses how different programming languages configure syntax for regular expressions. They explore examples like "verbatim string literal" in C# and the use of ICU syntax in languages such as Java, C++, Swift, and PHP.

Syntax Variations in Programming Languages

  • The speaker mentions that each language can configure the details of syntax differently. For instance, C# offers the option of using "verbatim string literal" for writing regex without escaping special characters.
  • Some languages opt for ICU syntax over Perl style for regular expressions. Examples include java.util.regex in Java, icu::RegexPattern in C++, and NSRegularExpression in Swift.
  • Personal preference towards Perl syntax is highlighted by the speaker, who faced challenges with ICU syntax while programming mobile applications in Swift or Objective-C.

Challenges with Date and Time Formatting

This part delves into discrepancies between date and time formatting conventions across different programming languages. The speaker contrasts strftime function usage in C with DateFormatter class methods in Objective-C and Swift.

Date and Time Formatting Differences

  • The speaker reflects on challenges faced when adapting from Linux's Time library to Objective-C/Swift's DateFormatter class for date/time formatting.
  • While strftime function uses a specific template format like "%d/%m/%Y %H:%M:%S" in C, DateFormatter class requires a different template format like "dd/MM/yyyy HH:mm:ss" in Objective-C/Swift due to ICU standards.
  • The discussion emphasizes how various languages adopt either ICU or Unix/Linux-derived formats for date/time formatting, showcasing differences between popular languages like C++, Python, Ruby (C-based) versus Swift, Java, C#, PHP (ICU-based).

Influence of Underlying Languages on Scripting Languages

This segment explores how scripting languages inherit functionalities from underlying platforms like C. It highlights examples from JavaScript, Python, Ruby, emphasizing their reliance on libraries written in C.

Influence of Underlying Platforms

  • The speaker illustrates that many features of scripting languages are implemented using libraries written in lower-level languages like C.
  • Compilers of certain languages such as Rust and Go are written in the same language itself to streamline development processes.
  • Noteworthy mention is made about popular scripting languages inheriting characteristics from their platform origins; contrasting them with self-contained languages like Java or Go.

Integration of Libraries Written in Different Languages

This part focuses on popular Python projects like Pandas that integrate essential libraries written partially in other languages such as C to enhance functionality.

Integration of Libraries

  • Pandas project exemplifies modern Python projects incorporating dependencies like numpy and scipy which contain significant portions of code written in C.
  • Numpy plays a crucial role by providing multidimensional arrays and mathematical functions through seamless integration with C libraries.

Fortran and Compilers in Python Projects

In this section, the speaker discusses the importance of Fortran and compilers like MSVC for generating packages in Python projects.

Fortran and Compiler Dependencies

  • Fortran is essential for generating packages on Mac, as indicated in the wiki script. Windows requires MSVC, the C and C++ compiler package from Microsoft.
  • Projects like SciPy rely heavily on Fortran, C, and C++. SciPy utilizes numpy arrays for various scientific modules such as statistics, optimization, linear algebra, signal processing, and image processing.

Python Projects Utilizing Fortran and Compilers

This section delves into how Python projects heavily depend on languages like Fortran, C, and C++ despite being primarily written in Python.

Dependency on Non-Python Languages

  • Numpy and SciPy are crucial for data science projects but are predominantly composed of Fortran, C, and C++ code segments.
  • TensorFlow relies significantly on C++, with over half of its codebase written in this language. PyTorch also contains a substantial portion of code in C++ to accelerate GPU operations.

Performance Requirements Beyond Python

The discussion shifts towards performance requirements beyond Python in projects involving machine learning and GPU acceleration.

Performance Demands

  • Understanding neural networks' functioning necessitates knowledge of languages like C++ for GPU acceleration rather than solely relying on Python.
  • JavaScript's Tensorflow.js leverages TypeScript alongside JavaScript for performance-demanding tasks while interacting with hardware components directly through languages like C++.

System Dependencies Impacting Language Usage

System dependencies play a crucial role in determining the compatibility of programming languages across different operating systems.

System Influence on Language Functionality

  • Interpreted languages like Python rely heavily on system libraries such as LibC. Discrepancies across operating systems impact language functionality.
  • Operating system variations necessitate distinct coding approaches within repositories like CPython to cater to specific platforms such as Windows or Linux.

Differences Across Operating Systems

The speaker highlights how programming languages exhibit variations across different operating systems due to system-specific dependencies.

OS-Specific Coding Variances

  • Code discrepancies within repositories like CPython showcase platform-specific adaptations through conditional compilation directives tailored for distinct operating systems.

Understanding System Operations and Programming Languages

In this section, the speaker delves into the importance of system operations and programming languages in enabling various functionalities within different operating systems.

The Role of libuv in Node.js Development

  • Different operating systems implement asynchronous I/O differently: Linux uses epoll, UNIX BSD utilizes Kqueue, and Windows employs IOCP for I/O Completion.
  • The libuv library acts as a shell in C++ to abstract diverse asynchronous I/O methods, facilitating Node.js's operation across multiple operating systems.

Comparison Between Deno and Node.js

  • Deno, considered by some as superior to Node.js, has over 60% of its codebase written in Rust.
  • Despite the language differences, both Deno and Node.js import functions from libuv, indicating similar event loop functionalities.

Insights on Programming Languages and System Components

This segment explores the utilization of C++ in various programming languages and system components to enhance functionality and efficiency.

Utilization of C++ Across Programming Languages

  • Java, despite its "Write Once, Run Anywhere" motto, incorporates 13% C++ code within OpenJDK for components like HotSpot JIT Compiler.
  • Numerous programming languages such as Ruby, PHP, DotNet rely significantly on C and C++, leveraging libraries like LibC and OpenSSL for enhanced performance.

Exploring Database Systems Composition

The discussion shifts towards database systems composition with a focus on the prevalence of C and C++ usage in popular databases.

Database System Composition Analysis

  • Postgres comprises over 85% C codebase while MySQL (MariaDB) consists of approximately half C++ code along with significant portions of C.
  • Modern databases like MongoDB predominantly utilize C++, emphasizing the continued relevance of these languages in database development.

Significance of Language Choice in Distributed Systems

Delving into distributed systems architecture reveals how language selection impacts system efficiency and productivity.

Impact of Language Selection on Distributed Systems

  • Java and Erlang excel in constructing distributed systems efficiently compared to traditional languages like C or C++, with platforms like RabbitMQ showcasing Erlang's prowess.

Understanding Low-Level Programming Languages

In this section, the speaker discusses the necessity of low-level programming languages for kernel-level operations and device drivers.

The Role of Low-Level Languages

  • Low-level languages like C are essential for creating device drivers that interact directly with the kernel.
  • These languages must generate binaries compatible with C's Application Binary Interface (ABI) to ensure seamless integration at a binary level.
  • Distinction between compiled languages (e.g., C, Rust) and technically interpreted languages (e.g., Python, JavaScript), highlighting the importance of ABI compatibility for direct data type usage across different languages.

Binary Compatibility and Memory Management

This section delves into the significance of binary compatibility in reducing memory duplication and efficient memory management.

Binary Compatibility Insights

  • Explanation of serialization, deserialization, marshalling, and unmarshalling processes to facilitate communication between different data formats.
  • Illustration of memory duplication issues when converting data formats, emphasizing the need for binary compatibility to avoid redundant memory usage.

Memory Duplication Challenges in Software Development

Discusses how memory duplication occurs in various scenarios like web servers and scripting languages.

Memory Duplication Scenarios

  • Example involving date formatting functions showcasing how integration between different language types leads to memory duplication.
  • Explores the impact of duplicating structures like Strings when integrating with external libraries or remote APIs on resource consumption.

Optimizing Memory Usage Through Language Integration

Emphasizes optimizing memory usage through language choices and integration methods.

Optimizing Memory Usage Strategies

Understanding Python, C, and Rust Interactions

In this section, the speaker delves into examples in Python, C, and Rust to illustrate how these languages interact and handle data structures like strings differently.

Python Interaction with C

  • In Python, a function in C is called through an intermediary code written in Cython for marshalling and unmarshalling data.
  • Marshalling involves converting Python string objects to arrays of characters in C to prevent memory conflicts between garbage collectors of both languages.

Rust Interaction with C

  • Rust interacts with C by directly working with C strings using CString from the "std::ffi" module for conversion.
  • Unlike Python, Rust allows direct manipulation of C strings without converting them into native Rust objects but requires writing syntax similar to C in Rust.

Language Selection for System Programming

  • For system programming tasks like device drivers or infrastructure components, languages like C, C++, Rust, Nim, or D are recommended due to their low-level capabilities.

Detailed Overview of Systems Development and Programming Languages

In this section, the speaker discusses systems development, focusing on distributed systems and programming languages like Java, C++, and Erlang. The evolution of these languages in the context of building complex distributed systems is explored.

Apache Ecosystem and Distributed Systems

  • Apache ecosystem includes tools like Hadoop, Solr, Spark, Kafka, Cassandra developed in Java.
  • ZooKeeper facilitates consensus among nodes in distributed systems.
  • Benefits of Cassandra include scalability by adding new servers to the cluster and fault tolerance mechanisms.

Evolution of Programming Languages

  • Java was a predominant choice due to familiarity and productivity compared to C++ for developing massive software systems.
  • Erlang's advanced features were ahead of its time for distributed services but lacked adoption early on.

Language Choices for Distributed Systems

  • Comparison between JVM-based solutions like Java with Erlang's native support for distributed services.
  • Speculation on using modern languages like Elixir or Go for increased productivity but acknowledging the maturity of existing Java-based solutions.

Application Development Frameworks

  • Discussion on the need for infrastructure development before creating equivalent frameworks in newer languages like Go.
  • Preference towards utilizing established Java ecosystem for distributed systems over newer language frameworks.

Challenges in Web Application Development

This segment delves into challenges faced during web application development compared to system-level programming. The focus is on balancing stability with rapid feature deployment.

Stability vs. Feature Deployment

  • Emphasis on minimal changes in core software components such as databases for stability.
  • Web applications require frequent feature updates to stay competitive while ensuring quick bug fixes deployment.

Productivity vs. Performance Trade-off

  • Balancing efficiency with ease of training developers; preference towards Python or JavaScript despite limitations in certain functionalities.

Mobile App Development Frameworks

Developing Efficient Components for Mobile Development

In this segment, the speaker discusses the importance of creating efficient components for mobile development to differentiate and optimize performance.

Creating Differentiated Components

  • Emphasizes the need to develop more efficient components for mobile apps.
  • Suggests building low-level components in Swift for iOS or Kotlin for Android to stand out and enhance value as a professional.
  • Highlights the significance of understanding low-level programming for career advancement and increased earning potential.

Leveraging Hardware for Data Science and Machine Learning

This part delves into maximizing hardware capabilities, particularly vector instruction sets like AVX, SSE, CUDA, and OpenCL, essential for data science, machine learning, and artificial intelligence tasks.

Hardware Optimization

  • Stresses the importance of leveraging hardware features such as AVX, SSE, CUDA, and OpenCL for optimal performance in data science and machine learning.
  • States that accessing parallel computing components is crucial rather than focusing solely on programming languages.
  • Mentions that while advanced models like GPT3 are costly to create, simpler machine learning models with TensorFlow can still be highly beneficial for practical applications.

Practical Applications of Machine Learning Algorithms

This section explores how seemingly simple algorithms like statistical classification can have significant real-world applications in areas such as e-commerce recommendations and search relevance.

Real-world Utility

  • Discusses the practicality of using basic machine learning algorithms like statistical classification for tasks such as personalized product recommendations in e-commerce.
  • Highlights the utilization of algorithms like Elastic or Solr in various systems from e-commerce platforms to social networks.

Importance of Maturity over Novelty in Technology Choices

The speaker emphasizes the significance of maturity over novelty when selecting technologies, underlining that each language has its place based on historical context rather than being inherently superior.

Technology Selection Criteria

  • Advocates prioritizing maturity over novelty when choosing technologies.
Video description

Finalmente vou falar sobre linguagens que você goste ou use, mas vou fazer isso do meu jeito: escovando bits e explicando como muita coisa funciona por baixo de Python, Javascript e outras linguagens que talvez você não sabia antes de concluir na segunda metade onde discuto onde cada linguagem pode ser melhor aproveitada e porque. ## Errata Eu falei que o Deno usa libuv, mas eu me confundi, ele na realidade usa o próprio Tokio de Rust por baixo mesmo. ## Capítulos 00:00 - Intro 01:36 - Cap 1 - Perl e Regex | Anos 90 06:18 - Cap 2 - Estilo C e ICU | strftime 10:25 - Cap 3 - Tudo de Python é em C! | Linguagem "Grude" 17:54 - Cap 4 - Tudo de Node.js é em C! | LibUV 22:31 - Cap 5 - Compilado vs Interpretado | ABI de C 28:21 - Cap 6 - Interoperabilidade: Marshalling/Unmarshalling | FFI 36:21 - Cap 7 - Onde cada Linguagem é mais Forte? | Rust 38:09 - Cap 8 - Sistemas Distribuídos | Apache Java 42:41 - Cap 9 - Produtividade > Performance? | Apps Comerciais 48:31 - Bloopers ## Links * Palestra de Elixir: https://youtu.be/8Ng6TfAj7Sk * https://github.com/python/cpython/search?p=2&q=ifdef+MS_WINDOWS * https://github.com/python/cpython/blob/a87c46eab3c306b1c5b8a072b7b30ac2c50651c0/Modules/_ssl.c * https://github.com/pandas-dev/pandas/blob/main/requirements-dev.txt * https://github.com/numpy/numpy/wiki/Building-with-MSVC * https://github.com/scipy/scipy * https://github.com/jupyter/notebook * https://github.com/openjdk/jdk/search?l=c%2B%2B&p=99 * https://github.com/libuv/libuv * https://github.com/tensorflow/tensorflow * https://github.com/tensorflow/tfjs * https://github.com/pytorch/pytorch * https://github.com/nodejs/node/search?q=libuv * https://www.npmjs.com/package/async-await-retry * https://stackoverflow.com/questions/11996988/how-good-is-oniguruma-compared-to-other-cross-platform-regexp-libraries * https://www.baeldung.com/jni * https://www.elastic.co/blog/found-zookeeper-king-of-coordination * https://github.com/akitaonrails/ObjC_Rubyfication * https://zaiste.net/posts/shell-commands-rust/# * Podcast: https://anchor.fm/akitando/episodes/Akitando-136---Python--Java--Rust--Qual-a-Diferena---Discutindo-Linguagens-e1spbvb * Transcript: https://www.akitaonrails.com/2023/01/23/akitando-136-python-java-rust-qual-a-diferenca-discutindo-linguagens