docs-onboarding/programming-language-recommendations.md

106 lines
11 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Programming language recommendations
## Azure DevOps Pipeline
The following programming languages are included in the comparison:
- [C# (.NET)](https://learn.microsoft.com/dotnet/csharp/)
- Shell Scripting [Bash](https://www.gnu.org/software/bash/) / [Zsh](https://www.zsh.org)
- [Python](https://www.python.org)
- [JavaScript](https://ecma-international.org/publications-and-standards/standards/ecma-262/) / [TypeScript](https://www.typescriptlang.org)
- [Ruby](https://www.ruby-lang.org)
- [Go](https://go.dev)
- [PowerShell](https://learn.microsoft.com/powershell/)
- [Java](https://www.java.com)
### Comparsion of the most important points
Legend for simple scales used below
- Extensions: Limited, Moderate, Extensive
- Simplicity in YAML: Easy, Medium, Complex
- Installation of Dependencies: Easy, Moderate, Complex
- Execution Speed: High, Moderate, Low
- Readability: Easy, Moderate, Hard
| Feature | C# | Shell (Bash/Zsh) | Python | JavaScript / TypeScript | Ruby | Go | PowerShell | Java |
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
| 1. Data processing (PDF) | Extension needed (e. g., [iTextSharp](https://github.com/itext/itextsharp), [PDFSharp](https://github.com/empira/PDFsharp)) | External tool (e. g., [Ghostscript](https://www.ghostscript.com/)) | Extension needed (e. g., [PyPDF2](https://pypi.org/project/PyPDF2/), [ReportLab](https://pypi.org/project/reportlab/)) | Extension needed (e. g., [pdf-lib](https://github.com/Hopding/pdf-lib), [PDFKit](https://github.com/foliojs/pdfkit)) | Extension needed (e. g., [Prawn](https://github.com/prawnpdf/prawn)) | Extension needed (e. g., [go-pdf](https://github.com/signintech/gopdf)) | Extension needed (e. g., same .NET PDF libs invoked from PowerShell) | Extension needed (e. g., [iText7](https://github.com/itext/itext7), [Apache PDFBox](https://pdfbox.apache.org/)) |
| 2. Data processing (AsciiDoc) | Extension needed (e. g., Asciidoctor .NET wrappers) | External tool (e. g., [Asciidoctor](https://asciidoctor.org/)) | Extension needed (e. g., [asciidoc-py3](https://github.com/asciidoc/asciidoc-py3)) | Extension needed (e. g., [@asciidoctor/core](https://www.npmjs.com/package/@asciidoctor/core)) | Extension needed (e. g., [Asciidoctor](https://asciidoctor.org/)) | Extension needed (e. g., use CLI or wrappers for [Asciidoctor](https://asciidoctor.org/)) | External tool ([Asciidoctor](https://asciidoctor.org/)) or .NET-based wrappers | Extension needed (e. g., [AsciidoctorJ](https://github.com/asciidoctor/asciidoctorj)) |
| 3. Data processing (JSON) | Built-in ([System.Text.Json](https://learn.microsoft.com/dotnet/api/system.text.json)) | External tool (e. g., [jq](https://jqlang.github.io/jq/)) | Built-in ([json](https://docs.python.org/3/library/json.html)) | Built-in (`JSON.parse`, `JSON.stringify`; in Node, no extra install needed) | Built-in ([json](https://docs.ruby-lang.org/en//master/JSON.html)) | Built-in (encoding/json) | Built-in (`ConvertFrom-Json`, `ConvertTo-Json` in modern PowerShell) | Extension/library commonly used (e. g., [Jackson](https://github.com/FasterXML/jackson), `org.json`) |
| 4. Data processing (YAML) | Extension needed (e. g., [YamlDotNet](https://github.com/aaubry/YamlDotNet)) | External tool (e. g., [yq](https://github.com/mikefarah/yq)) | Extension needed (e. g., [PyYAML](https://pypi.org/project/PyYAML/)) | Extension needed (e. g., [js-yaml](https://www.npmjs.com/package/js-yaml)) | Built-in ([Psych](https://docs.ruby-lang.org/en//master/Psych.html)) | Extension needed (e. g., gopkg.in/yaml.v3) | Built-in in newer PowerShell versions (`ConvertFrom-Yaml`, `ConvertTo-Yaml`) | Extension needed (e. g., SnakeYAML) |
| 5. Data processing (XML) | Built-in ([System.Xml](https://learn.microsoft.com/dotnet/api/system.xml)) | External tool (e. g., xmlstarlet) | Built-in ([xml](https://docs.python.org/3/library/xml.html)) | Mostly extension (e. g., [xml2js](https://www.npmjs.com/package/xml2js), [fast-xml-parser](https://www.npmjs.com/package/fast-xml-parser)) | Built-in (REXML, Nokogiri) | Built-in (encoding/xml) | Built-in (native `[xml]` type accelerator) | Built-in (javax.xml, org.w3c.dom, plus standard libraries) |
| 6. Extensions (libraries / packages) | Extensive (NuGet) | Extensive (rich set of CLI tools, though not “extensions” in the same sense) | Extensive (PyPI) | Extensive (npm is one of the largest ecosystems) | Extensive (RubyGems) | Extensive (Go Modules) | Moderate (PowerShell Gallery) | Extensive (Maven Central, Gradle plugins) |
| 7. Simplicity in YAML usage | Medium (third-party library but straightforward) | Complex (usually rely on yq or custom scripts) | Easy (with PyYAML) | Medium (need js-yaml, usage is direct in Node/TS) | Easy (built-in Psych) | Medium (import 3rd-party package, usage is simple) | Easy (native cmdlets in newer versions) | Medium (SnakeYAML is straightforward, but an extra lib) |
| 8. Must be compiled? | Yes (C# -> .NET IL) | No (interpreted scripts) | No (interpreted) | JS: No (interpreted), TS: Yes (transpiles to JS) | No (interpreted) | Yes (compiled to native binaries) | No (interpreted on .NET runtime) | Yes (compiled to JVM bytecode) |
| 9. Cross-Platform | Yes (with .NET Core/.NET 5+) | Yes (native to Unix-like, plus Windows via WSL or separate install) | Yes (Windows, macOS, Linux) | Yes (Node.js or browser; TS runs where JS runs) | Yes (Windows, macOS, Linux) | Yes (Windows, macOS, Linux, others) | Yes (PowerShell Core 6+ is cross-platform) | Yes (JVM on Windows, macOS, Linux, etc.) |
| 10. Simple installation of dependencies | Moderate (NuGet + .NET CLI or Visual Studio) | Moderate (install packages/tools via apt, yum, brew, etc.) | Easy (pip, Conda, etc.) | Easy (npm, yarn, etc.) | Easy (RubyGems, Bundler) | Easy (Go modules, go get) | Moderate (PowerShell Gallery + extra config) | Moderate (Maven, Gradle; straightforward but verbose) |
| 11. Licensing | Open-source .NET (MIT for .NET Core); older .NET frameworks under MS licenses | GPL (GNU Bash) | PSF License (Python Software Foundation) | JavaScript is an ECMA standard; TypeScript is Apache 2.0 by Microsoft | Dual License (Ruby License/BSD) | BSD-style (Go is open source under a permissive license) | MIT License (for PowerShell Core; Windows PS is proprietary) | GPL v2 + Classpath (OpenJDK); Oracle JDK has different commercial terms |
| 12. Provider / Owner | Microsoft (language + runtime) | GNU Project (part of GNU utilities) | Python Software Foundation | ECMA standard for JS; Microsoft for TS | Yukihiro “Matz” Matsumoto / community | Google (initially) + open source community | Microsoft (PowerShell) | Oracle + open source community |
| 13. Execution speed | High (JIT on .NET, typically quite fast) | Low (relies on external tools; not optimized for heavy computation) | Moderate (interpreted, can be fast but slower than C#/Go/Java) | Moderate (Nodes V8 engine is JIT-compiled; usually slower than fully compiled languages) | Moderate (CRuby slower; newer versions have partial JIT) | High (compiled to native) | Moderate (.NET-based, typically good performance but overhead in interactive scenarios) | High (JIT-compiled by the JVM; often on par with C#) |
| 14. Code comprehension & readability | Moderate (C-style syntax, can be verbose) | Hard (complex quoting, expansions, and nuances in Bash) | Easy (clean, minimal boilerplate) | Moderate (JS can be flexible/loose; TS adds structure but extra overhead) | Easy (expressive, some “magic” features) | Easy (simple, explicit, fewer features) | Moderate (familiar C#-like syntax + cmdlet conventions) | Moderate (verbose, strongly typed, boilerplate-heavy) |
| 15. Certification available (employee) | Yes (Microsoft .NET/C# certs) | Indirect (part of broader Linux certifications like LPIC, RHCSA) | Yes (e. g., PCAP) | No official (some vendor-specific or full-stack certs may include JS/TS) | No official (third-party training only) | No official (no widely recognized Go cert; some third-party) | Yes (covered in broader MS certs, though not strictly “PowerShell-only”) | Yes (Oracle Certified Professional Java Programmer, etc.) |
| 16. Debugging capabilities | Strong (Visual Studio, VS Code with C# extension) | Limited (VS Code has bash-debug, but fewer features) | Strong (VS Code, PyCharm, pdb, etc.) | Strong (VS Code debugger for JS/TS, Chrome DevTools, Node Debugger) | Moderate (VS Code Ruby extensions, RubyMine) | Strong (VS Code Go extension + Delve) | Strong (VS Code PowerShell extension with integrated debugger) | Strong (VS Code Java extension, IntelliJ, Eclipse) |
| 17. Testing framework | Yes (NUnit, xUnit, MSTest) | Yes (e. g., shUnit2, Bats) | Yes (unittest, pytest, nose, etc.) | Yes (Jest, Mocha, Jasmine, etc. for JS; Mocha/Jest + ts-node for TS) | Yes (RSpec, Minitest) | Yes (testing in stdlib) | Yes (Pester for PowerShell) | Yes (JUnit, TestNG, etc.) |
### Recommended Language: [Python](https://www.python.org)
Python has most features or the best value on scale. The most benefits compared to the other languages:
- **Data Handling**: pull data, parse it, and then format it.
- **Document Generation**: The libraries for data presentation are fast and simple.
- **Dependencies**: are easy handled with requirments.txt.
- **Virtual Environments**: allows different Python versions to be used in the same pipeline.
- **REST APIs**: can be simple used with the Pythons requests library.
### Example Workflows for Python
#### Install Dependencies
Use a pipeline task to install Python (if not already on the agent) and the required libraries.
```yaml
- task: UsePythonVersion@0
inputs:
versionSpec: '3.x'
- script: |
pip install requests python-docx reportlab jinja2
```
#### Fetch Work Items
Write a Python script to call the Azure DevOps REST API to retrieve Work Items.
```python
import requests
# Example: Get Work Items from Azure DevOps
devops_organization_url = "https://dev.azure.com/YOUR_ORG"
project = "YOUR_PROJECT"
api_version = "6.0"
query_id = "YOUR_QUERY_ID"
response = requests.get(
f"{devops_organization_url}/{project}/_apis/wit/wiql/{query_id}?api-version={api_version}",
auth=('PAT_USERNAME', 'PAT_TOKEN') # or use other Auth methods
)
work_items_data = response.json()
```
#### Generate Compliance Documents
Convert the retrieved data into the document format of your choice.
```python
from docx import Document
from docx.shared import Inches
document = Document()
document.add_heading('Compliance Report', level=1)
for item in work_items_data["workItems"]:
document.add_heading(f'Work Item ID: {item["id"]}', level=2)
# Additional data insertion here...
document.save('ComplianceReport.docx')
```